|
Blender V4.5
|
#include "BKE_global.hh"#include "BLI_assert.h"#include "BLI_threads.h"#include "BLI_vector_set.hh"#include "DNA_userdef_types.h"#include "GHOST_C-api.h"#include "GHOST_Types.h"#include "GPU_context.hh"#include "GPU_batch.hh"#include "GPU_pass.hh"#include "gpu_backend.hh"#include "gpu_context_private.hh"#include "gpu_matrix_private.hh"#include "gpu_private.hh"#include "gpu_shader_private.hh"#include "dummy_backend.hh"#include "draw_debug.hh"#include <mutex>Go to the source code of this file.
Namespaces | |
| namespace | blender |
| namespace | blender::gpu |
Functions | |
| GPUContext * | GPU_context_create (void *ghost_window, void *ghost_context) |
| void | GPU_context_discard (GPUContext *ctx_) |
| void | GPU_context_active_set (GPUContext *ctx_) |
| GPUContext * | GPU_context_active_get () |
| void | GPU_context_begin_frame (GPUContext *ctx) |
| void | GPU_context_end_frame (GPUContext *ctx) |
GPU Begin/end work blocks | |
Used to explicitly define a per-frame block within which GPU work will happen. Used for global autoreleasepool flushing in Metal | |
| void | GPU_render_begin () |
| void | GPU_render_end () |
| void | GPU_render_step (bool force_resource_release) |
GPUSecondaryContext | |
| static GHOST_TDrawingContextType | ghost_context_type () |
Variables | |
| static Context * | active_ctx = nullptr |
| static blender::Mutex | backend_users_mutex |
| static int | num_backend_users = 0 |
Main context global mutex | |
Used to avoid crash on some old drivers. | |
| static blender::Mutex | main_context_mutex |
| void | GPU_context_main_lock () |
| void | GPU_context_main_unlock () |
Backend selection | |
| static eGPUBackendType | g_backend_type = GPU_BACKEND_OPENGL |
| static std::optional< eGPUBackendType > | g_backend_type_override = std::nullopt |
| static std::optional< bool > | g_backend_type_supported = std::nullopt |
| static GPUBackend * | g_backend = nullptr |
| static GHOST_SystemHandle | g_ghost_system = nullptr |
| static void | gpu_backend_create () |
| static void | gpu_backend_discard () |
| void | GPU_backend_ghost_system_set (void *ghost_system_handle) |
| void * | GPU_backend_ghost_system_get () |
| void | GPU_backend_type_selection_set (const eGPUBackendType backend) |
| eGPUBackendType | GPU_backend_type_selection_get () |
| void | GPU_backend_type_selection_set_override (const eGPUBackendType backend_type) |
| bool | GPU_backend_type_selection_is_overridden () |
| bool | GPU_backend_type_selection_detect () |
| static bool | gpu_backend_supported () |
| bool | GPU_backend_supported () |
| void | gpu_backend_init_resources () |
| void | gpu_backend_delete_resources () |
| eGPUBackendType | GPU_backend_get_type () |
Manage GL vertex array IDs in a thread-safe way Use these instead of glGenBuffers & its friends
Definition in file gpu_context.cc.
|
static |
Definition at line 533 of file gpu_context.cc.
References BLI_assert_unreachable, GHOST_kDrawingContextTypeNone, GPU_BACKEND_METAL, GPU_BACKEND_OPENGL, GPU_backend_type_selection_get(), and GPU_BACKEND_VULKAN.
Referenced by blender::gpu::GPUSecondaryContext::GPUSecondaryContext().
|
static |
Definition at line 449 of file gpu_context.cc.
References BLI_assert, g_backend, g_backend_type, GPU_BACKEND_METAL, GPU_BACKEND_NONE, GPU_BACKEND_OPENGL, GPU_backend_supported(), and GPU_BACKEND_VULKAN.
Referenced by GPU_context_create().
| void gpu_backend_delete_resources | ( | ) |
Definition at line 485 of file gpu_context.cc.
References BLI_assert, and g_backend.
Referenced by GPU_exit().
|
static |
Definition at line 491 of file gpu_context.cc.
References g_backend.
Referenced by GPU_context_discard().
| eGPUBackendType GPU_backend_get_type | ( | ) |
Definition at line 498 of file gpu_context.cc.
References g_backend, GPU_BACKEND_METAL, GPU_BACKEND_NONE, GPU_BACKEND_OPENGL, and GPU_BACKEND_VULKAN.
Referenced by blender::render::hydra::GPURenderTaskDelegate::bind(), BPyInit_bgl(), buffer_from_list_inputs_sort(), blender::draw::calc_final_indices(), blender::opensubdiv::compile_eval_patches_shader(), blender::opensubdiv::compile_eval_stencil_shader(), blender::opensubdiv::GPUVertexBuffer::Create(), blender::draw::compositor_engine::Instance::draw(), blender::workbench::Instance::draw_image_render(), blender::eevee::Instance::draw_viewport(), DRW_custom_pipeline_end(), blender::render::hydra::Engine::Engine(), get_padded_gpu_type(), GPU_pass_should_optimize(), gpu_shader_create_info_compile(), BlenderDisplayDriver::graphics_interop_get_device(), BlenderDisplayDriver::graphics_interop_update_buffer(), immDrawPixelsTexTiled_scaling_clipping(), blender::eevee::ShadowModule::init(), is_subdivision_evaluation_possible_on_gpu(), playanim_toscreen_ex(), pygpu_platform_backend_type_get(), pygpu_shader__tp_new(), RE_PreviewRender(), blender::eevee::Instance::render_frame(), screen_opengl_render_doit(), blender::eevee::ShadowModule::set_view(), standard_defines(), blender::gpu::tests::test_texture_1d(), blender::gpu::tests::test_texture_1d_array(), blender::gpu::tests::test_texture_1d_array_upload(), blender::gpu::tests::test_texture_roundtrip__GPU_DATA_2_10_10_10_REV__GPU_RGB10_A2UI(), blender::gpu::tests::test_texture_roundtrip__GPU_DATA_FLOAT__GPU_DEPTH24_STENCIL8(), blender::gpu::tests::test_texture_roundtrip__GPU_DATA_FLOAT__GPU_DEPTH32F_STENCIL8(), WM_platform_support_perform_checks(), and wm_xr_init().
| void * GPU_backend_ghost_system_get | ( | ) |
Definition at line 358 of file gpu_context.cc.
References g_ghost_system.
Referenced by blender::gpu::GPUSecondaryContext::GPUSecondaryContext(), and blender::gpu::GPUSecondaryContext::~GPUSecondaryContext().
| void GPU_backend_ghost_system_set | ( | void * | ghost_system_handle | ) |
For when we need access to a system context in order to create a GPU context.
Definition at line 353 of file gpu_context.cc.
References g_ghost_system.
Referenced by multitestapp_new(), blender::gpu::GPUTest::SetUpTestSuite(), wm_ghost_init(), wm_ghost_init_background(), and wm_main_playanim_intern().
| void gpu_backend_init_resources | ( | ) |
Definition at line 479 of file gpu_context.cc.
References BLI_assert, and g_backend.
Referenced by GPU_init().
| bool GPU_backend_supported | ( | ) |
Definition at line 441 of file gpu_context.cc.
References g_backend_type_supported, and gpu_backend_supported().
Referenced by gpu_backend_create(), GPU_backend_type_selection_detect(), RE_engine_render(), blender::gpu::GPUTest::SetUpTestSuite(), and WM_init_gpu().
|
static |
Definition at line 412 of file gpu_context.cc.
References BLI_assert, g_backend_type, GPU_BACKEND_METAL, GPU_BACKEND_NONE, GPU_BACKEND_OPENGL, GPU_BACKEND_VULKAN, blender::gpu::VKBackend::is_supported(), and blender::gpu::MTLBackend::metal_is_supported().
Referenced by GPU_backend_supported().
| bool GPU_backend_type_selection_detect | ( | ) |
Detect the most suited eGPUBackendType.
Returns true when detection found a supported backend, otherwise returns false. When no supported backend is found GPU_backend_type_selection_set is called with GPU_BACKEND_NONE.
Definition at line 384 of file gpu_context.cc.
References blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), G, g_backend_type_override, G_FLAG_GPU_BACKEND_FALLBACK, GPU_BACKEND_METAL, GPU_BACKEND_NONE, GPU_BACKEND_OPENGL, GPU_backend_supported(), GPU_backend_type_selection_set(), and GPU_BACKEND_VULKAN.
Referenced by wm_init_userdef(), and wm_main_playanim_intern().
| eGPUBackendType GPU_backend_type_selection_get | ( | ) |
Definition at line 369 of file gpu_context.cc.
References g_backend_type.
Referenced by ghost_context_type(), playanim_window_open(), WM_system_gpu_context_create(), and wm_window_ghostwindow_add().
| bool GPU_backend_type_selection_is_overridden | ( | ) |
Check if the GPU_backend_type_selection_detect is overridden to only test a specific backend.
Definition at line 379 of file gpu_context.cc.
References g_backend_type_override.
Referenced by wm_gpu_backend_override_from_userdef().
| void GPU_backend_type_selection_set | ( | const eGPUBackendType | backend | ) |
Definition at line 363 of file gpu_context.cc.
References g_backend_type, and g_backend_type_supported.
Referenced by GPU_backend_type_selection_detect(), and blender::gpu::GPUTest::SetUpTestSuite().
| void GPU_backend_type_selection_set_override | ( | eGPUBackendType | backend_type | ) |
Alter the GPU_backend_type_selection_detect to only test a specific backend
Definition at line 374 of file gpu_context.cc.
References g_backend_type_override.
Referenced by arg_handle_gpu_backend_set(), and wm_gpu_backend_override_from_userdef().
| GPUContext * GPU_context_active_get | ( | ) |
Definition at line 260 of file gpu_context.cc.
References blender::gpu::Context::get(), and blender::gpu::wrap().
Referenced by DRWContext::acquire_data(), DRW_gpu_context_release(), blender::gpu::TexturePool::get(), blender::gpu::GPUSecondaryContext::GPUSecondaryContext(), playanim_toscreen_ex(), pygpu_framebuffer__tp_new(), pygpu_offscreen__tp_new(), pygpu_texture__tp_new(), pygpu_uniformbuffer__tp_new(), RE_engine_gpu_context_destroy(), DRWContext::release_data(), WM_init(), and wm_main_playanim_intern().
| void GPU_context_active_set | ( | GPUContext * | ctx_ | ) |
#GPUContext can be null.
Definition at line 237 of file gpu_context.cc.
References blender::gpu::Context::activate(), active_ctx, GPU_shader_unbind(), blender::gpu::Context::shader_builtin_srgb_is_dirty, and blender::gpu::unwrap().
Referenced by blender::gpu::GPUSecondaryContext::activate(), ContextShared::disable(), DRW_blender_gpu_render_context_disable(), DRW_blender_gpu_render_context_enable(), DRW_gpu_context_activate(), DRW_gpu_context_create(), DRW_gpu_context_release(), ContextShared::enable(), blender::render::Compositor::execute(), extrawindow_do_draw(), extrawindow_do_reshape(), GPU_context_create(), blender::gpu::GPUSecondaryContext::GPUSecondaryContext(), loggerwindow_do_draw(), loggerwindow_do_reshape(), mainwindow_do_draw(), mainwindow_do_reshape(), playanim_toscreen_ex(), RE_blender_gpu_context_free(), RE_engine_gpu_context_create(), RE_engine_gpu_context_destroy(), RE_engine_gpu_context_disable(), RE_engine_gpu_context_enable(), RE_system_gpu_context_free(), wm_ghostwindow_destroy(), wm_main_playanim_intern(), wm_surface_clear_drawable(), wm_surface_set_drawable(), WM_window_pixels_read_from_frontbuffer(), WM_window_pixels_read_sample_from_frontbuffer(), wm_window_set_drawable(), and ContextShared::~ContextShared().
| void GPU_context_begin_frame | ( | GPUContext * | ctx | ) |
Begin and end frame are used to mark the singular boundary representing the lifetime of a whole frame. This also acts as a divisor for ensuring workload submission and flushing, especially for background rendering when there is no call to present. This is required by explicit-API's where there is no implicit workload flushing.
Definition at line 265 of file gpu_context.cc.
References blender::gpu::Context::begin_frame(), and blender::gpu::unwrap().
Referenced by ContextShared::enable(), playanim_toscreen_ex(), blender::gpu::GPUTest::SetUpTestSuite(), wm_draw_surface(), wm_draw_window(), and WM_init().
| GPUContext * GPU_context_create | ( | void * | ghost_window, |
| void * | ghost_context ) |
Definition at line 190 of file gpu_context.cc.
References blender::draw::DebugDraw::acquire(), backend_users_mutex, blender::gpu::GPUBackend::context_alloc(), blender::draw::DebugDraw::get(), blender::gpu::GPUBackend::get(), gpu_backend_create(), GPU_context_active_set(), lock, num_backend_users, and blender::gpu::wrap().
Referenced by ContextShared::ContextShared(), extrawindow_new(), blender::gpu::GPUSecondaryContext::GPUSecondaryContext(), loggerwindow_new(), mainwindow_new(), RE_blender_gpu_context_ensure(), RE_engine_gpu_context_create(), blender::gpu::GPUTest::SetUpTestSuite(), wm_main_playanim_intern(), and wm_window_ghostwindow_add().
| void GPU_context_discard | ( | GPUContext * | ctx_ | ) |
To be called after #GPU_context_active_set(ctx_to_destroy).
Definition at line 210 of file gpu_context.cc.
References active_ctx, backend_users_mutex, BLI_assert, blender::draw::DebugDraw::get(), blender::gpu::GPUBackend::get(), gpu_backend_discard(), lock, num_backend_users, blender::gpu::printf_end(), blender::draw::DebugDraw::release(), blender::gpu::GPUBackend::render_begin(), blender::gpu::GPUBackend::render_end(), and blender::gpu::unwrap().
Referenced by RE_blender_gpu_context_free(), RE_engine_gpu_context_destroy(), RE_system_gpu_context_free(), blender::gpu::GPUTest::TearDownTestSuite(), wm_ghostwindow_destroy(), wm_main_playanim_intern(), ContextShared::~ContextShared(), and blender::gpu::GPUSecondaryContext::~GPUSecondaryContext().
| void GPU_context_end_frame | ( | GPUContext * | ctx | ) |
Definition at line 273 of file gpu_context.cc.
References blender::gpu::Context::end_frame(), and blender::gpu::unwrap().
Referenced by ContextShared::disable(), playanim_toscreen_ex(), blender::gpu::GPUTest::TearDownTestSuite(), wm_draw_surface(), wm_draw_window(), and WM_init().
| void GPU_context_main_lock | ( | ) |
Legacy GPU (Intel HD4000 series) do not support sharing GPU objects between GPU contexts. EEVEE/Workbench can create different contexts for image/preview rendering, baking or compiling. When a legacy GPU is detected (GPU_use_main_context_workaround()) any worker threads should use the draw manager opengl context and make sure that they are the only one using it by locking the main context using these two functions.
Definition at line 289 of file gpu_context.cc.
References main_context_mutex.
Referenced by DRW_render_context_enable(), and wm_draw_update().
| void GPU_context_main_unlock | ( | ) |
Definition at line 294 of file gpu_context.cc.
References main_context_mutex.
Referenced by DRW_render_context_disable(), and wm_draw_update().
| void GPU_render_begin | ( | ) |
GPU Begin/end work blocks
Definition at line 308 of file gpu_context.cc.
References active_ctx, BLI_assert, blender::gpu::GPUBackend::get(), blender::gpu::printf_begin(), and blender::gpu::GPUBackend::render_begin().
Referenced by DRW_render_context_enable(), DRW_render_to_image(), DRW_submission_start(), ContextShared::enable(), blender::render::Compositor::execute(), blender::gpu::tests::gpu_shader_lib_test(), playanim_toscreen_ex(), RE_engine_gpu_context_enable(), RE_PreviewRender(), blender::gpu::GPUTest::SetUpTestSuite(), blender::gpu::tests::ShaderSpecializationConst::ShaderSpecializationConst(), blender::draw::test_draw_resource_id_gen(), blender::draw::test_draw_visibility(), blender::draw::test_eevee_lut_gen(), blender::draw::test_eevee_shadow_finalize(), blender::draw::test_eevee_shadow_free(), blender::draw::test_eevee_shadow_page_mask_ex(), blender::draw::test_eevee_shadow_shift(), blender::draw::test_eevee_shadow_shift_clear(), blender::draw::test_eevee_shadow_tag_update(), blender::draw::test_eevee_shadow_tilemap_amend(), blender::draw::test_eevee_surfel_list(), blender::gpu::tests::test_framebuffer_cube(), blender::gpu::tests::test_framebuffer_multi_viewport(), blender::gpu::tests::test_framebuffer_subpass_input(), blender::gpu::tests::test_texture_1d(), blender::gpu::tests::test_texture_1d_array(), blender::gpu::tests::test_texture_1d_array_upload(), blender::gpu::tests::test_texture_2d_array(), blender::gpu::tests::test_texture_2d_array_upload(), blender::gpu::tests::test_texture_3d(), blender::gpu::tests::test_texture_copy(), blender::gpu::tests::test_texture_cube(), blender::gpu::tests::test_texture_cube_array(), blender::gpu::tests::test_texture_read(), blender::draw::TestAlloc::TestAlloc(), wm_draw_update(), wm_event_do_handlers(), wm_event_do_notifiers(), WM_init(), wm_main_playanim_intern(), wm_window_events_process(), and wm_window_ghostwindow_add().
| void GPU_render_end | ( | ) |
Definition at line 319 of file gpu_context.cc.
References active_ctx, BLI_assert, blender::gpu::GPUBackend::get(), blender::gpu::printf_end(), and blender::gpu::GPUBackend::render_end().
Referenced by ContextShared::disable(), DRW_render_context_disable(), DRW_render_to_image(), DRW_submission_end(), blender::render::Compositor::execute(), blender::gpu::tests::gpu_shader_lib_test(), playanim_toscreen_ex(), RE_engine_gpu_context_disable(), RE_PreviewRender(), blender::gpu::tests::ShaderSpecializationConst::ShaderSpecializationConst(), blender::gpu::GPUTest::TearDownTestSuite(), blender::draw::test_draw_resource_id_gen(), blender::draw::test_draw_visibility(), blender::draw::test_eevee_lut_gen(), blender::draw::test_eevee_shadow_finalize(), blender::draw::test_eevee_shadow_free(), blender::draw::test_eevee_shadow_page_mask_ex(), blender::draw::test_eevee_shadow_shift(), blender::draw::test_eevee_shadow_shift_clear(), blender::draw::test_eevee_shadow_tag_update(), blender::draw::test_eevee_shadow_tilemap_amend(), blender::draw::test_eevee_surfel_list(), blender::gpu::tests::test_framebuffer_cube(), blender::gpu::tests::test_framebuffer_multi_viewport(), blender::gpu::tests::test_framebuffer_subpass_input(), blender::gpu::tests::test_texture_1d(), blender::gpu::tests::test_texture_1d_array(), blender::gpu::tests::test_texture_1d_array_upload(), blender::gpu::tests::test_texture_2d_array(), blender::gpu::tests::test_texture_2d_array_upload(), blender::gpu::tests::test_texture_3d(), blender::gpu::tests::test_texture_copy(), blender::gpu::tests::test_texture_cube(), blender::gpu::tests::test_texture_cube_array(), blender::gpu::tests::test_texture_read(), blender::draw::TestAlloc::TestAlloc(), wm_draw_update(), wm_event_do_handlers(), wm_event_do_notifiers(), WM_init(), wm_main_playanim_intern(), wm_window_events_process(), and wm_window_ghostwindow_add().
| void GPU_render_step | ( | bool | force_resource_release = false | ) |
For operations which need to run exactly once per frame – even if there are no render updates.
Definition at line 328 of file gpu_context.cc.
References active_ctx, BLI_assert, blender::gpu::GPUBackend::get(), GPU_pass_cache_update(), blender::gpu::printf_begin(), blender::gpu::printf_end(), and blender::gpu::GPUBackend::render_step().
Referenced by blender::workbench::Instance::draw_image_render(), playanim_toscreen_ex(), blender::eevee::Instance::render_frame(), screen_opengl_render_doit(), wm_draw_update(), and wm_main_playanim_intern().
Definition at line 55 of file gpu_context.cc.
Referenced by blender::gpu::Context::get(), GPU_context_active_set(), GPU_context_discard(), GPU_render_begin(), GPU_render_end(), GPU_render_step(), and blender::gpu::Context::is_active_on_thread().
|
static |
Definition at line 57 of file gpu_context.cc.
Referenced by GPU_context_create(), and GPU_context_discard().
|
static |
Definition at line 350 of file gpu_context.cc.
Referenced by blender::gpu::GPUBackend::get(), gpu_backend_create(), gpu_backend_delete_resources(), gpu_backend_discard(), GPU_backend_get_type(), and gpu_backend_init_resources().
|
static |
Definition at line 347 of file gpu_context.cc.
Referenced by gpu_backend_create(), gpu_backend_supported(), GPU_backend_type_selection_get(), and GPU_backend_type_selection_set().
|
static |
Definition at line 348 of file gpu_context.cc.
Referenced by GPU_backend_type_selection_detect(), GPU_backend_type_selection_is_overridden(), and GPU_backend_type_selection_set_override().
|
static |
Definition at line 349 of file gpu_context.cc.
Referenced by GPU_backend_supported(), and GPU_backend_type_selection_set().
|
static |
Definition at line 351 of file gpu_context.cc.
Referenced by GPU_backend_ghost_system_get(), and GPU_backend_ghost_system_set().
|
static |
Definition at line 287 of file gpu_context.cc.
Referenced by GPU_context_main_lock(), and GPU_context_main_unlock().
|
static |
Definition at line 58 of file gpu_context.cc.
Referenced by GPU_context_create(), and GPU_context_discard().