GPUState: Encapsulate glFlush and glFinish inside the GLContext

Part of the Vulkan task T68990

Isolate the few remaining gl functions.
This commit is contained in:
2020-09-08 00:10:37 +02:00
parent f23400490e
commit 77f60a0931
4 changed files with 28 additions and 2 deletions

View File

@@ -76,6 +76,12 @@ struct GPUContext {
virtual void activate(void) = 0; virtual void activate(void) = 0;
virtual void deactivate(void) = 0; virtual void deactivate(void) = 0;
/* Will push all pending commands to the GPU. */
virtual void flush(void) = 0;
/* Will wait until the GPU has finished executing all command. */
virtual void finish(void) = 0;
virtual void memory_statistics_get(int *total_mem, int *free_mem) = 0; virtual void memory_statistics_get(int *total_mem, int *free_mem) = 0;
bool is_active_on_thread(void); bool is_active_on_thread(void);

View File

@@ -295,12 +295,12 @@ bool GPU_mipmap_enabled(void)
void GPU_flush(void) void GPU_flush(void)
{ {
glFlush(); GPU_context_active_get()->flush();
} }
void GPU_finish(void) void GPU_finish(void)
{ {
glFinish(); GPU_context_active_get()->finish();
} }
void GPU_unpack_row_length_set(uint len) void GPU_unpack_row_length_set(uint len)

View File

@@ -160,6 +160,22 @@ void GLContext::deactivate(void)
/** \} */ /** \} */
/* -------------------------------------------------------------------- */
/** \name Flush, Finish & sync
* \{ */
void GLContext::flush(void)
{
glFlush();
}
void GLContext::finish(void)
{
glFinish();
}
/** \} */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/** \name Safe object deletion /** \name Safe object deletion
* *

View File

@@ -97,6 +97,10 @@ class GLContext : public GPUContext {
void activate(void) override; void activate(void) override;
void deactivate(void) override; void deactivate(void) override;
void flush(void);
void finish(void);
void memory_statistics_get(int *total_mem, int *free_mem) override; void memory_statistics_get(int *total_mem, int *free_mem) override;
static inline GLStateManager *state_manager_active_get() static inline GLStateManager *state_manager_active_get()