Cleanup: rename GPU context in RenderEngine for consistency with other code
This commit is contained in:
parent
b29d2c607d
commit
9705f4cc56
|
@ -162,7 +162,7 @@ typedef struct RenderEngine {
|
|||
void *update_render_passes_data;
|
||||
|
||||
/* GPU context. */
|
||||
void *wm_blender_gpu_context; /* WindowManager GPU context -> GHOSTContext. */
|
||||
void *system_gpu_context; /* WindowManager GPU context -> GHOSTContext. */
|
||||
ThreadMutex blender_gpu_context_mutex;
|
||||
bool use_drw_render_context;
|
||||
struct GPUContext *blender_gpu_context;
|
||||
|
|
|
@ -1287,17 +1287,17 @@ bool RE_engine_gpu_context_create(RenderEngine *engine)
|
|||
BLI_assert(BLI_thread_is_main());
|
||||
|
||||
const bool drw_state = DRW_gpu_context_release();
|
||||
engine->wm_blender_gpu_context = WM_system_gpu_context_create();
|
||||
engine->system_gpu_context = WM_system_gpu_context_create();
|
||||
|
||||
if (engine->wm_blender_gpu_context) {
|
||||
if (engine->system_gpu_context) {
|
||||
/* Activate new GPU Context for GPUContext creation. */
|
||||
WM_system_gpu_context_activate(engine->wm_blender_gpu_context);
|
||||
WM_system_gpu_context_activate(engine->system_gpu_context);
|
||||
/* Requires GPUContext for usage of GPU Module for displaying results. */
|
||||
engine->blender_gpu_context = GPU_context_create(nullptr, engine->wm_blender_gpu_context);
|
||||
engine->blender_gpu_context = GPU_context_create(nullptr, engine->system_gpu_context);
|
||||
GPU_context_active_set(nullptr);
|
||||
/* Deactivate newly created GPU Context, as it is not needed until
|
||||
* `RE_engine_gpu_context_enable` is called. */
|
||||
WM_system_gpu_context_release(engine->wm_blender_gpu_context);
|
||||
WM_system_gpu_context_release(engine->system_gpu_context);
|
||||
}
|
||||
else {
|
||||
engine->blender_gpu_context = nullptr;
|
||||
|
@ -1305,18 +1305,18 @@ bool RE_engine_gpu_context_create(RenderEngine *engine)
|
|||
|
||||
DRW_gpu_context_activate(drw_state);
|
||||
|
||||
return engine->wm_blender_gpu_context != nullptr;
|
||||
return engine->system_gpu_context != nullptr;
|
||||
}
|
||||
|
||||
void RE_engine_gpu_context_destroy(RenderEngine *engine)
|
||||
{
|
||||
if (!engine->wm_blender_gpu_context) {
|
||||
if (!engine->system_gpu_context) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool drw_state = DRW_gpu_context_release();
|
||||
|
||||
WM_system_gpu_context_activate(engine->wm_blender_gpu_context);
|
||||
WM_system_gpu_context_activate(engine->system_gpu_context);
|
||||
if (engine->blender_gpu_context) {
|
||||
GPUContext *restore_context = GPU_context_active_get();
|
||||
GPU_context_active_set(engine->blender_gpu_context);
|
||||
|
@ -1326,8 +1326,8 @@ void RE_engine_gpu_context_destroy(RenderEngine *engine)
|
|||
}
|
||||
engine->blender_gpu_context = nullptr;
|
||||
}
|
||||
WM_system_gpu_context_dispose(engine->wm_blender_gpu_context);
|
||||
engine->wm_blender_gpu_context = nullptr;
|
||||
WM_system_gpu_context_dispose(engine->system_gpu_context);
|
||||
engine->system_gpu_context = nullptr;
|
||||
|
||||
DRW_gpu_context_activate(drw_state);
|
||||
}
|
||||
|
@ -1339,14 +1339,14 @@ bool RE_engine_gpu_context_enable(RenderEngine *engine)
|
|||
DRW_render_context_enable(engine->re);
|
||||
return true;
|
||||
}
|
||||
if (engine->wm_blender_gpu_context) {
|
||||
if (engine->system_gpu_context) {
|
||||
BLI_mutex_lock(&engine->blender_gpu_context_mutex);
|
||||
/* If a previous GPU/GPUContext was active (DST.blender_gpu_context), we should later
|
||||
* restore this when disabling the RenderEngine context. */
|
||||
engine->gpu_restore_context = DRW_gpu_context_release();
|
||||
|
||||
/* Activate RenderEngine System and Blender GPU Context. */
|
||||
WM_system_gpu_context_activate(engine->wm_blender_gpu_context);
|
||||
WM_system_gpu_context_activate(engine->system_gpu_context);
|
||||
if (engine->blender_gpu_context) {
|
||||
GPU_context_active_set(engine->blender_gpu_context);
|
||||
GPU_render_begin();
|
||||
|
@ -1362,12 +1362,12 @@ void RE_engine_gpu_context_disable(RenderEngine *engine)
|
|||
DRW_render_context_disable(engine->re);
|
||||
}
|
||||
else {
|
||||
if (engine->wm_blender_gpu_context) {
|
||||
if (engine->system_gpu_context) {
|
||||
if (engine->blender_gpu_context) {
|
||||
GPU_render_end();
|
||||
GPU_context_active_set(nullptr);
|
||||
}
|
||||
WM_system_gpu_context_release(engine->wm_blender_gpu_context);
|
||||
WM_system_gpu_context_release(engine->system_gpu_context);
|
||||
/* Restore DRW state context if previously active. */
|
||||
DRW_gpu_context_activate(engine->gpu_restore_context);
|
||||
BLI_mutex_unlock(&engine->blender_gpu_context_mutex);
|
||||
|
@ -1381,7 +1381,7 @@ void RE_engine_gpu_context_lock(RenderEngine *engine)
|
|||
/* Locking already handled by the draw manager. */
|
||||
}
|
||||
else {
|
||||
if (engine->wm_blender_gpu_context) {
|
||||
if (engine->system_gpu_context) {
|
||||
BLI_mutex_lock(&engine->blender_gpu_context_mutex);
|
||||
}
|
||||
}
|
||||
|
@ -1393,7 +1393,7 @@ void RE_engine_gpu_context_unlock(RenderEngine *engine)
|
|||
/* Locking already handled by the draw manager. */
|
||||
}
|
||||
else {
|
||||
if (engine->wm_blender_gpu_context) {
|
||||
if (engine->system_gpu_context) {
|
||||
BLI_mutex_unlock(&engine->blender_gpu_context_mutex);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue