|
Blender V5.0
|
#include "BKE_global.hh"#include "GPU_capabilities.hh"#include "GPU_context.hh"#include "GPU_state.hh"#include "RE_engine.h"#include "RE_pipeline.h"#include "DRW_engine.hh"#include "DRW_render.hh"#include "WM_api.hh"#include "wm_window.hh"Go to the source code of this file.
Classes | |
| class | ContextShared |
Functions | |
Draw GPU Context | |
| void | DRW_gpu_context_enable_ex (bool) |
| void | DRW_gpu_context_disable_ex (bool restore) |
| static void | drw_gpu_preview_context_enable () |
| static void | drw_gpu_preview_context_disable () |
| void | DRW_gpu_context_enable () |
| bool | DRW_gpu_context_try_enable () |
| bool | DRW_gpu_context_is_enabled () |
| void | DRW_gpu_context_disable () |
| void | DRW_system_gpu_render_context_enable (void *re_system_gpu_context) |
| void | DRW_system_gpu_render_context_disable (void *re_system_gpu_context) |
| void | DRW_blender_gpu_render_context_enable (void *re_gpu_context) |
| void | DRW_blender_gpu_render_context_disable (void *) |
| void | DRW_render_context_enable (Render *render) |
| void | DRW_render_context_disable (Render *render) |
Draw manager context release/activation | |
These functions are used in cases when an GPU context creation is needed during the draw. This happens, for example, when an external engine needs to create its own GPU context from the engine initialization. Example of context creation: const bool drw_state = DRW_gpu_context_release(); viewport_system_gpu_context = WM_system_gpu_context_create(); DRW_gpu_context_activate(drw_state); Example of context destruction: const bool drw_state = DRW_gpu_context_release(); WM_system_gpu_context_activate(viewport_system_gpu_context); WM_system_gpu_context_dispose(viewport_system_gpu_context); DRW_gpu_context_activate(drw_state); NOTE: Will only perform context modification when on main thread. This way these functions can be used in an engine without check on whether it is a draw manager which manages GPU context on the current thread. The downside of this is that if the engine performs GPU creation from a non-main thread, that thread is supposed to not have GPU context ever bound by Blender. | |
| bool | DRW_gpu_context_release () |
| void | DRW_gpu_context_activate (bool drw_state) |
Submission critical section | |
The usage of gpu::Shader objects is currently not thread safe. Since they are shared resources between render engine instances, we cannot allow pass submissions in a concurrent manner. | |
| static TicketMutex * | draw_mutex = nullptr |
| static TicketMutex * | submission_mutex = nullptr |
| void | DRW_mutexes_init () |
| void | DRW_mutexes_exit () |
| void | DRW_lock_start () |
| void | DRW_lock_end () |
| void | DRW_submission_start () |
| void | DRW_submission_end () |
GPU & System Context | |
A global GPUContext is used for rendering every viewports (even on different windows). This is because some resources cannot be shared between contexts (GPUFramebuffers, GPUBatch). | |
| static ContextShared * | viewport_context = nullptr |
| static ContextShared * | preview_context = nullptr |
| void | DRW_gpu_context_create () |
| void | DRW_gpu_context_destroy () |
| void DRW_blender_gpu_render_context_disable | ( | void * | re_gpu_context | ) |
Definition at line 280 of file draw_gpu_context.cc.
References GPU_context_active_set(), and GPU_flush().
Referenced by DRW_render_context_disable().
| void DRW_blender_gpu_render_context_enable | ( | void * | re_gpu_context | ) |
Definition at line 272 of file draw_gpu_context.cc.
References BLI_assert, BLI_thread_is_main(), and GPU_context_active_set().
Referenced by DRW_render_context_enable().
| void DRW_gpu_context_activate | ( | bool | drw_state | ) |
Definition at line 436 of file draw_gpu_context.cc.
References BLI_thread_is_main(), GPU_context_active_set(), viewport_context, WM_system_gpu_context_activate(), and wm_window_reset_drawable().
Referenced by RE_engine_gpu_context_create(), RE_engine_gpu_context_destroy(), and RE_engine_gpu_context_disable().
| void DRW_gpu_context_create | ( | ) |
Definition at line 166 of file draw_gpu_context.cc.
References BLI_assert, DRW_mutexes_init(), preview_context, and viewport_context.
Referenced by WM_init_gpu().
| void DRW_gpu_context_destroy | ( | ) |
Definition at line 178 of file draw_gpu_context.cc.
References BLI_assert, BLI_thread_is_main(), DRW_mutexes_exit(), preview_context, and viewport_context.
Referenced by WM_exit_ex().
| void DRW_gpu_context_disable | ( | ) |
Definition at line 252 of file draw_gpu_context.cc.
References DRW_gpu_context_disable_ex().
Referenced by DRW_render_context_disable(), DRW_select_buffer_read(), ED_view3d_draw_offscreen_imbuf(), engine_depsgraph_free(), blender::render::Compositor::execute(), GPU_viewport_unbind(), RE_engines_exit(), screen_opengl_render_doit(), screen_opengl_render_end(), screen_opengl_render_init(), view3d_gpu_select_ex(), and blender::render::Compositor::~Compositor().
| void DRW_gpu_context_disable_ex | ( | bool | restore | ) |
Definition at line 204 of file draw_gpu_context.cc.
References viewport_context.
Referenced by DRW_engine_external_free(), DRW_gpu_context_disable(), WM_exit_ex(), and WM_init_gpu().
| void DRW_gpu_context_enable | ( | ) |
Binds the draw GPU context to the active thread. In background mode, this will create the draw GPU context on first call.
Definition at line 228 of file draw_gpu_context.cc.
References DRW_gpu_context_enable_ex(), G, viewport_context, and WM_init_gpu().
Referenced by DRW_render_context_enable(), DRW_select_buffer_read(), ED_view3d_draw_offscreen_imbuf(), engine_depsgraph_free(), blender::render::Compositor::execute(), GPU_viewport_bind(), screen_opengl_render_doit(), screen_opengl_render_end(), screen_opengl_render_init(), view3d_gpu_select_ex(), and blender::render::Compositor::~Compositor().
| void DRW_gpu_context_enable_ex | ( | bool | restore | ) |
Never use this. Only for closing blender.
Definition at line 196 of file draw_gpu_context.cc.
References viewport_context.
Referenced by DRW_engine_external_free(), DRW_gpu_context_enable(), DRW_gpu_context_try_enable(), and WM_exit_ex().
| bool DRW_gpu_context_is_enabled | ( | ) |
Returns true if the DRW_gpu_context is enabled on the calling thread.
Definition at line 247 of file draw_gpu_context.cc.
References viewport_context.
Referenced by DRW_engine_external_free().
| bool DRW_gpu_context_release | ( | ) |
Definition at line 417 of file draw_gpu_context.cc.
References BLI_thread_is_main(), GPU_context_active_get(), GPU_context_active_set(), viewport_context, and WM_system_gpu_context_release().
Referenced by RE_engine_gpu_context_create(), RE_engine_gpu_context_destroy(), and RE_engine_gpu_context_enable().
| bool DRW_gpu_context_try_enable | ( | ) |
Tries to bind the draw GPU context to the active thread. Returns true on success, false if the draw GPU context does not exists.
Definition at line 238 of file draw_gpu_context.cc.
References DRW_gpu_context_enable_ex(), and viewport_context.
Referenced by RE_engines_exit().
|
static |
Definition at line 220 of file draw_gpu_context.cc.
References preview_context.
Referenced by DRW_render_context_disable().
|
static |
Definition at line 212 of file draw_gpu_context.cc.
References preview_context.
Referenced by DRW_render_context_enable().
| void DRW_lock_end | ( | ) |
Definition at line 53 of file draw_gpu_context.cc.
References BLI_ticket_mutex_unlock(), and draw_mutex.
Referenced by ContextShared::disable(), and DRW_system_gpu_render_context_disable().
| void DRW_lock_start | ( | ) |
Definition at line 46 of file draw_gpu_context.cc.
References BLI_assert, BLI_ticket_mutex_lock_check_recursive(), draw_mutex, and UNUSED_VARS_NDEBUG.
Referenced by DRW_system_gpu_render_context_enable(), and ContextShared::enable().
| void DRW_mutexes_exit | ( | ) |
Definition at line 40 of file draw_gpu_context.cc.
References BLI_ticket_mutex_free(), draw_mutex, and submission_mutex.
Referenced by DRW_gpu_context_destroy().
| void DRW_mutexes_init | ( | ) |
Definition at line 34 of file draw_gpu_context.cc.
References BLI_ticket_mutex_alloc(), draw_mutex, and submission_mutex.
Referenced by DRW_gpu_context_create().
| void DRW_render_context_disable | ( | Render * | render | ) |
Definition at line 314 of file draw_gpu_context.cc.
References DRW_blender_gpu_render_context_disable(), DRW_gpu_context_disable(), drw_gpu_preview_context_disable(), DRW_system_gpu_render_context_disable(), GPU_context_main_unlock(), GPU_render_end(), GPU_use_main_context_workaround(), RE_blender_gpu_context_ensure(), and RE_system_gpu_context_get().
Referenced by DRW_render_gpencil(), engine_depsgraph_free(), engine_depsgraph_init(), engine_render_view_layer(), RE_engine_gpu_context_disable(), blender::eevee::Instance::render_frame(), and blender::render::Compositor::~Compositor().
| void DRW_render_context_enable | ( | Render * | render | ) |
Definition at line 286 of file draw_gpu_context.cc.
References DRW_blender_gpu_render_context_enable(), DRW_gpu_context_enable(), drw_gpu_preview_context_enable(), DRW_system_gpu_render_context_enable(), G, GPU_context_main_lock(), GPU_render_begin(), GPU_use_main_context_workaround(), RE_blender_gpu_context_ensure(), RE_system_gpu_context_get(), viewport_context, and WM_init_gpu().
Referenced by DRW_render_gpencil(), engine_depsgraph_free(), engine_depsgraph_init(), engine_render_view_layer(), RE_engine_gpu_context_enable(), blender::eevee::Instance::render_frame(), and blender::render::Compositor::~Compositor().
| void DRW_submission_end | ( | ) |
Definition at line 66 of file draw_gpu_context.cc.
References BLI_ticket_mutex_unlock(), GPU_render_end(), and submission_mutex.
Referenced by blender::draw::compositor_engine::Instance::draw(), blender::draw::edit_select::Instance::draw(), blender::draw::gpencil::Instance::draw(), blender::draw::overlay::Instance::draw(), blender::image_engine::Instance::draw(), blender::workbench::Instance::draw(), drw_callbacks_post_scene(), drw_callbacks_post_scene_2D(), drw_callbacks_pre_scene(), drw_callbacks_pre_scene_2D(), blender::draw::DRW_curves_update(), blender::draw::Manager::end_sync(), blender::eevee::VelocityModule::geometry_steps_fill(), blender::eevee::Instance::light_bake_irradiance(), and workbench_render_to_image().
| void DRW_submission_start | ( | ) |
Definition at line 58 of file draw_gpu_context.cc.
References BLI_assert, BLI_ticket_mutex_lock_check_recursive(), GPU_render_begin(), submission_mutex, and UNUSED_VARS_NDEBUG.
Referenced by blender::draw::compositor_engine::Instance::draw(), blender::draw::edit_select::Instance::draw(), blender::draw::gpencil::Instance::draw(), blender::draw::overlay::Instance::draw(), blender::image_engine::Instance::draw(), blender::workbench::Instance::draw(), drw_callbacks_post_scene(), drw_callbacks_post_scene_2D(), drw_callbacks_pre_scene(), drw_callbacks_pre_scene_2D(), blender::draw::DRW_curves_update(), blender::draw::Manager::end_sync(), blender::eevee::VelocityModule::geometry_steps_fill(), blender::eevee::Instance::light_bake_irradiance(), and workbench_render_to_image().
| void DRW_system_gpu_render_context_disable | ( | void * | re_system_gpu_context | ) |
Definition at line 266 of file draw_gpu_context.cc.
References DRW_lock_end(), and WM_system_gpu_context_release().
Referenced by DRW_render_context_disable().
| void DRW_system_gpu_render_context_enable | ( | void * | re_system_gpu_context | ) |
Definition at line 257 of file draw_gpu_context.cc.
References BLI_assert, BLI_thread_is_main(), DRW_lock_start(), and WM_system_gpu_context_activate().
Referenced by DRW_render_context_enable().
|
static |
Definition at line 31 of file draw_gpu_context.cc.
Referenced by DRW_lock_end(), DRW_lock_start(), DRW_mutexes_exit(), and DRW_mutexes_init().
|
static |
Unique context used by Preview jobs.
Definition at line 164 of file draw_gpu_context.cc.
Referenced by DRW_gpu_context_create(), DRW_gpu_context_destroy(), drw_gpu_preview_context_disable(), and drw_gpu_preview_context_enable().
|
static |
Definition at line 32 of file draw_gpu_context.cc.
Referenced by DRW_mutexes_exit(), DRW_mutexes_init(), DRW_submission_end(), and DRW_submission_start().
|
static |
Unique context used by Viewports.
Definition at line 162 of file draw_gpu_context.cc.
Referenced by DRW_gpu_context_activate(), DRW_gpu_context_create(), DRW_gpu_context_destroy(), DRW_gpu_context_disable_ex(), DRW_gpu_context_enable(), DRW_gpu_context_enable_ex(), DRW_gpu_context_is_enabled(), DRW_gpu_context_release(), DRW_gpu_context_try_enable(), and DRW_render_context_enable().