|
Blender V5.0
|
#include <draw_manager.hh>
Classes | |
| struct | SubmitDebugOutput |
| struct | DataDebugOutput |
Public Attributes | |
| SwapChain< ObjectMatricesBuf, 2 > | matrix_buf |
| SwapChain< ObjectBoundsBuf, 2 > | bounds_buf |
| SwapChain< ObjectInfosBuf, 2 > | infos_buf |
| ObjectAttributeBuf | attributes_buf |
| Map< uint32_t, GPULayerAttr > | layer_attributes |
| LayerAttributeBuf | layer_attributes_buf |
| Vector< gpu::Texture * > | acquired_textures |
Definition at line 45 of file draw_manager.hh.
|
inline |
Definition at line 119 of file draw_manager.hh.
| blender::draw::Manager::~Manager | ( | ) |
Definition at line 28 of file draw_manager.cc.
References acquired_textures, GPU_texture_free(), and texture().
|
inline |
Will acquire the texture using ref counting and release it after drawing. To be used for texture coming from blender Image.
Definition at line 286 of file draw_manager.hh.
References acquired_textures, GPU_texture_ref(), and texture().
Referenced by blender::draw::detail::PassBase< DrawCommandBufType >::material_set().
TODO(fclem): The following should become private at some point.
Definition at line 36 of file draw_manager.cc.
References acquired_textures, attributes_buf, bounds_buf, GPU_texture_free(), blender::MatBase< float, 4, 4 >::identity(), infos_buf, layer_attributes, matrix_buf, resource_handle(), and texture().
Referenced by blender::draw::gpencil::render_frame(), blender::draw::test_draw_manager_sync(), blender::draw::test_draw_resource_id_gen(), blender::draw::test_draw_submit_only(), blender::draw::test_draw_visibility(), blender::draw::test_eevee_shadow_tag_update(), and workbench_render_to_image().
| void blender::draw::Manager::compute_visibility | ( | View & | view | ) |
Compute <-> Graphic queue transition is quite slow on some backend. To avoid unnecessary switching, it is better to dispatch all visibility computation as soon as possible before any graphic work.
Grouping the calls to compute_visibility() together is also beneficial for PSO switching overhead. Same thing applies to generate_commands().
IMPORTANT: Generated commands are stored inside PassMain and overrides commands generated for a previous view.
Before:
After:
Compute visibility of ResourceHandle for the given View. The commands needs to be regenerated for any change inside the Manager or in the View. Avoids just in time computation of visibility.
Definition at line 190 of file draw_manager.cc.
References BLI_assert_msg, bounds_buf, View3D::debug_flag, drw_get(), infos_buf, U, USER_DEVELOPER_TOOL_TEST, DRWContext::v3d, V3D_DEBUG_FREEZE_CULLING, and view.
Referenced by ensure_visibility(), submit(), and blender::draw::test_draw_submit_only().
| Manager::DataDebugOutput blender::draw::Manager::data_debug | ( | ) |
Check data buffers of the draw manager. Only to be used after end_sync().
Definition at line 408 of file draw_manager.cc.
References bounds_buf, infos_buf, matrix_buf, and output.
Referenced by blender::draw::test_draw_manager_sync().
| void blender::draw::Manager::debug_bind | ( | ) |
Definition at line 148 of file draw_manager.cc.
References DRW_DEBUG_DRAW_SLOT, blender::draw::DebugDraw::get(), GPU_BARRIER_SHADER_STORAGE, blender::draw::DebugDraw::gpu_draw_buf_get(), GPU_memory_barrier(), and GPU_storagebuf_bind().
Referenced by submit(), submit(), and submit_only().
| void blender::draw::Manager::end_sync | ( | ) |
Definition at line 114 of file draw_manager.cc.
References attributes_buf, bounds_buf, divide_ceil_u(), DRW_FINALIZE_GROUP_SIZE, DRW_shader_draw_resource_finalize_get(), DRW_submission_end(), DRW_submission_start(), GPU_BARRIER_SHADER_STORAGE, GPU_compute_dispatch(), GPU_debug_group_begin(), GPU_debug_group_end(), GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_get_ssbo_binding(), GPU_shader_uniform_1i(), GPU_storagebuf_bind(), infos_buf, layer_attributes_buf, and matrix_buf.
Referenced by blender::draw::gpencil::render_frame(), blender::draw::test_draw_manager_sync(), blender::draw::test_draw_resource_id_gen(), blender::draw::test_draw_submit_only(), blender::draw::test_draw_visibility(), blender::draw::test_eevee_shadow_tag_update(), and workbench_render_to_image().
| void blender::draw::Manager::ensure_visibility | ( | View & | view | ) |
Same as compute_visibility but only do it if needed.
Definition at line 205 of file draw_manager.cc.
References compute_visibility(), and view.
Referenced by blender::draw::overlay::Instance::draw().
|
inline |
Populate additional per resource data on demand. IMPORTANT: Should be called only once per object.
Definition at line 434 of file draw_manager.hh.
References attributes_buf, GPU_material_uniform_attributes(), infos_buf, GPUUniformAttrList::list, LISTBASE_FOREACH, ObjectInfos::object_attrs_len, ObjectInfos::object_attrs_offset, and blender::draw::ResourceHandle::resource_index().
|
inline |
WATCH: Linear Search. Avoid duplicate attributes across materials.
Definition at line 454 of file draw_manager.hh.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), attributes_buf, blender::Span< T >::first(), blender::Vector< T, InlineBufferCapacity, Allocator >::first_index_of_try(), GPU_material_uniform_attributes(), infos_buf, GPUUniformAttrList::list, LISTBASE_FOREACH, ObjectInfos::object_attrs_len, ObjectInfos::object_attrs_offset, and blender::draw::ResourceHandle::resource_index().
Generate commands for ResourceHandle for the given View and PassMain. The commands needs to be regenerated for any change inside the Manager, the PassMain or in the View. Avoids just in time command generation.
IMPORTANT: Generated commands are stored inside PassMain and overrides commands previously generated for a previous view.
Definition at line 212 of file draw_manager.cc.
References BLI_assert_msg, blender::draw::detail::PassBase< DrawCommandBufType >::commands_, blender::draw::detail::PassBase< DrawCommandBufType >::draw_commands_buf_, blender::draw::detail::PassBase< DrawCommandBufType >::headers_, blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), blender::draw::detail::PassBase< DrawCommandBufType >::manager_fingerprint_, blender::draw::detail::PassBase< DrawCommandBufType >::use_custom_ids, view, and blender::draw::detail::PassBase< DrawCommandBufType >::view_fingerprint_.
Referenced by generate_commands(), submit(), submit(), and blender::draw::test_draw_submit_only().
| void blender::draw::Manager::generate_commands | ( | PassSimple & | pass | ) |
Generate commands on CPU. Doesn't have the GPU compute dispatch overhead.
Definition at line 246 of file draw_manager.cc.
References BLI_assert_msg, blender::draw::detail::PassBase< DrawCommandBufType >::commands_, blender::draw::detail::PassBase< DrawCommandBufType >::draw_commands_buf_, blender::draw::detail::PassBase< DrawCommandBufType >::headers_, blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), blender::draw::detail::PassBase< DrawCommandBufType >::manager_fingerprint_, and blender::draw::detail::PassBase< DrawCommandBufType >::sub_passes_.
| void blender::draw::Manager::generate_commands | ( | PassSortable & | pass, |
| View & | view ) |
Definition at line 236 of file draw_manager.cc.
References generate_commands(), blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), blender::draw::PassSortable::sort(), and view.
|
inline |
Collect necessary View Layer attributes.
Since layer attributes are global to the whole render pass, this only collects a table of their names.
Definition at line 485 of file draw_manager.hh.
References GPU_material_layer_attributes(), layer_attributes, and LISTBASE_FOREACH.
| void blender::draw::Manager::resource_bind | ( | ) |
Definition at line 161 of file draw_manager.cc.
References attributes_buf, DRW_LAYER_ATTR_UBO_SLOT, DRW_OBJ_ATTR_SLOT, DRW_OBJ_INFOS_SLOT, DRW_OBJ_MAT_SLOT, GPU_storagebuf_bind(), GPU_uniformbuf_bind(), infos_buf, layer_attributes_buf, and matrix_buf.
Referenced by submit(), and submit_only().
|
inline |
Get resource id for a loose matrix. The draw-calls for this resource handle won't be culled and there won't be any associated object info / bounds. Assumes correct handedness / winding.
Definition at line 392 of file draw_manager.hh.
References bounds_buf, infos_buf, and matrix_buf.
|
inline |
Get resource id for a loose matrix with bounds. The draw-calls for this resource handle will be culled but there won't be any associated object info / bounds. Assumes correct handedness / winding.
Definition at line 400 of file draw_manager.hh.
References bounds_buf, infos_buf, and matrix_buf.
|
inline |
Create a new resource handle for the given object, but optionally override model matrix and bounds.
Definition at line 363 of file draw_manager.hh.
References BLI_assert, bounds_buf, DRW_object_is_in_edit_mode(), ELEM, infos_buf, blender::draw::ObjectRef::is_active(), matrix_buf, Object::mode, OB_MODE_SCULPT, OB_MODE_TEXTURE_PAINT, OB_NEG_SCALE, blender::draw::ObjectRef::object, and Object::transflag.
|
inline |
Create a new resource handle for the given object.
Definition at line 324 of file draw_manager.hh.
References bounds_buf, DRW_object_is_in_edit_mode(), ELEM, float, infos_buf, blender::draw::ObjectRef::is_active(), DupliObject::mat, matrix_buf, Object::mode, OB_MODE_SCULPT, OB_MODE_TEXTURE_PAINT, OB_NEG_SCALE, blender::draw::ObjectRef::object, ObjectInfos::random, DupliObject::random_id, ObjectBounds::sync(), ObjectInfos::sync(), and Object::transflag.
Referenced by begin_sync(), blender::draw::test_draw_manager_sync(), blender::draw::test_draw_resource_id_gen(), blender::draw::test_draw_visibility(), blender::draw::test_eevee_shadow_tag_update(), unique_handle(), and unique_handle_for_sculpt().
|
inline |
Return the number of resource handles allocated.
Definition at line 295 of file draw_manager.hh.
Referenced by blender::eevee::IrradianceBake::surfels_create().
|
inline |
Get resource id for particle system. The draw-calls for this resource won't be culled. The associated object info will contain the info from its parent object.
Definition at line 410 of file draw_manager.hh.
References BLI_assert, bounds_buf, DRW_object_is_in_edit_mode(), ELEM, infos_buf, blender::draw::ObjectRef::is_active(), matrix_buf, Object::mode, OB_MODE_SCULPT, OB_MODE_TEXTURE_PAINT, OB_NEG_SCALE, blender::draw::ObjectRef::object, and Object::transflag.
Referenced by blender::workbench::Instance::hair_sync(), blender::draw::external::Prepass::particle_sync(), and blender::draw::overlay::Prepass::particle_sync().
Definition at line 310 of file draw_manager.cc.
References compute_visibility(), generate_commands(), blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), blender::draw::detail::PassBase< DrawCommandBufType >::manager_fingerprint_, submit_only(), view, and blender::draw::detail::PassBase< DrawCommandBufType >::view_fingerprint_.
| void blender::draw::Manager::submit | ( | PassSimple & | pass, |
| bool | inverted_view = false ) |
Variant without any view. Must not contain any shader using draw_view create info.
Definition at line 340 of file draw_manager.cc.
References debug_bind(), blender::draw::detail::PassBase< DrawCommandBufType >::draw_commands_buf_, generate_commands(), blender::draw::detail::PassBase< DrawCommandBufType >::has_generated_commands(), blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), resource_bind(), state, and blender::draw::detail::PassBase< DrawCommandBufType >::submit().
| void blender::draw::Manager::submit | ( | PassSimple & | pass, |
| View & | view ) |
Submit a pass for drawing. All resource reference will be dereferenced and commands will be sent to GPU. Visibility and command generation are run JIT if needed.
Definition at line 364 of file draw_manager.cc.
References debug_bind(), blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), submit(), and view.
Referenced by blender::draw::gpencil::Instance::antialiasing_accumulate(), blender::eevee::Film::cryptomatte_sort(), blender::eevee::DeferredPipeline::debug_draw(), blender::eevee::Film::display(), blender::workbench::AntiAliasingPass::draw(), blender::workbench::DofPass::draw(), blender::workbench::OpaquePass::draw(), blender::workbench::OutlinePass::draw(), blender::workbench::ShadowPass::draw(), blender::workbench::TransparentDepthPass::draw(), blender::workbench::TransparentPass::draw(), blender::workbench::VolumePass::draw(), blender::draw::overlay::Outline::draw_line_only_ex(), blender::draw::overlay::Background::draw_vignette(), blender::draw::DRW_curves_update(), blender::eevee::Precompute::Precompute(), blender::eevee::DepthOfField::render(), blender::draw::external::Prepass::submit(), submit(), submit(), submit_debug(), submit_debug(), blender::draw::test_draw_curves_interpolate_attributes(), blender::draw::test_draw_curves_interpolate_position(), blender::draw::test_draw_curves_lib(), blender::draw::test_draw_curves_topology(), blender::draw::test_draw_submit_only(), 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::draw::TestAlloc::TestAlloc(), and blender::draw::TestDefrag::TestDefrag().
| void blender::draw::Manager::submit | ( | PassSortable & | pass, |
| View & | view ) |
Definition at line 329 of file draw_manager.cc.
References blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), blender::draw::PassSortable::sort(), submit(), and view.
| Manager::SubmitDebugOutput blender::draw::Manager::submit_debug | ( | PassMain & | pass, |
| View & | view ) |
Definition at line 391 of file draw_manager.cc.
References divide_ceil_u(), blender::draw::detail::PassBase< DrawCommandBufType >::draw_commands_buf_, GPU_BARRIER_BUFFER_UPDATE, GPU_memory_barrier(), output, submit(), and view.
| Manager::SubmitDebugOutput blender::draw::Manager::submit_debug | ( | PassSimple & | pass, |
| View & | view ) |
Submit a pass for drawing but read back all data buffers for inspection.
Definition at line 377 of file draw_manager.cc.
References blender::draw::detail::PassBase< DrawCommandBufType >::draw_commands_buf_, output, submit(), and view.
Referenced by blender::draw::test_draw_resource_id_gen(), and blender::draw::test_draw_visibility().
Submit a pass for drawing. All resource reference will be dereferenced and commands will be sent to GPU. Visibility and command generation must have already been done explicitly using compute_visibility and generate_commands.
Definition at line 277 of file draw_manager.cc.
References BLI_assert_msg, debug_bind(), blender::draw::detail::PassBase< DrawCommandBufType >::draw_commands_buf_, blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), blender::draw::detail::PassBase< DrawCommandBufType >::manager_fingerprint_, resource_bind(), state, blender::draw::detail::PassBase< DrawCommandBufType >::submit(), view, and blender::draw::detail::PassBase< DrawCommandBufType >::view_fingerprint_.
Referenced by blender::draw::overlay::Cameras::draw_background_images(), blender::draw::overlay::Empties::draw_background_images(), blender::draw::overlay::Empties::draw_images(), blender::draw::overlay::Cameras::draw_in_front(), blender::draw::overlay::Empties::draw_in_front_images(), blender::draw::overlay::Outline::draw_line_only_ex(), blender::draw::overlay::Cameras::draw_scene_background_images(), submit(), and blender::draw::test_draw_submit_only().
|
inline |
Create a unique resource handle for the given object. Returns the existing handle if it exists.
Definition at line 315 of file draw_manager.hh.
References blender::draw::ResourceHandleRange::is_valid(), and resource_handle().
Referenced by blender::draw::overlay::Sculpts::curves_sync(), blender::workbench::Instance::curves_sync(), blender::draw::overlay::Curves::edit_object_sync_legacy(), blender::draw::overlay::Sculpts::mesh_sync(), blender::draw::external::Prepass::object_sync(), blender::draw::gpencil::Instance::object_sync(), blender::draw::overlay::Fade::object_sync(), blender::workbench::Instance::object_sync(), blender::draw::overlay::Wireframe::object_sync_ex(), and blender::workbench::Instance::pointcloud_sync().
| ResourceHandleRange blender::draw::Manager::unique_handle_for_sculpt | ( | const ObjectRef & | ref | ) |
Definition at line 175 of file draw_manager.cc.
References blender::bke::pbvh::bounds_get(), blender::draw::ResourceHandleRange::is_valid(), blender::math::midpoint(), blender::draw::ObjectRef::object, blender::bke::object::pbvh_get(), and resource_handle().
Referenced by blender::draw::overlay::Sculpts::mesh_sync(), blender::draw::overlay::Fade::object_sync(), blender::workbench::Instance::object_sync(), blender::draw::external::Prepass::sculpt_sync(), and blender::draw::overlay::Prepass::sculpt_sync().
|
inline |
Update the bounds of an already created handle.
Definition at line 427 of file draw_manager.hh.
References bounds_buf, blender::draw::ObjectRef::object, and blender::draw::ResourceHandle::resource_index().
| void blender::draw::Manager::warm_shader_specialization | ( | PassMain & | pass | ) |
Make sure the shader specialization constants are already compiled. This avoid stalling the real submission call because of specialization.
Definition at line 259 of file draw_manager.cc.
References blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), state, and blender::draw::detail::PassBase< DrawCommandBufType >::warm_shader_specialization().
| void blender::draw::Manager::warm_shader_specialization | ( | PassSimple & | pass | ) |
Definition at line 268 of file draw_manager.cc.
References blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), state, and blender::draw::detail::PassBase< DrawCommandBufType >::warm_shader_specialization().
| Vector<gpu::Texture *> blender::draw::Manager::acquired_textures |
List of textures coming from Image data-blocks. They need to be reference-counted in order to avoid being freed in another thread.
Definition at line 102 of file draw_manager.hh.
Referenced by acquire_texture(), begin_sync(), and ~Manager().
| ObjectAttributeBuf blender::draw::Manager::attributes_buf |
Object Attributes are reference by indirection data inside ObjectInfos. This is because attribute list is arbitrary.
Definition at line 86 of file draw_manager.hh.
Referenced by begin_sync(), end_sync(), extract_object_attributes(), extract_object_attributes(), and resource_bind().
| SwapChain<ObjectBoundsBuf, 2> blender::draw::Manager::bounds_buf |
Definition at line 79 of file draw_manager.hh.
Referenced by begin_sync(), blender::eevee::ShadowModule::begin_sync(), compute_visibility(), data_debug(), end_sync(), blender::eevee::ShadowModule::end_sync(), resource_handle(), resource_handle(), resource_handle(), resource_handle(), resource_handle_for_psys(), blender::eevee::IrradianceBake::surfels_create(), blender::draw::test_eevee_shadow_tag_update(), and update_handle_bounds().
| SwapChain<ObjectInfosBuf, 2> blender::draw::Manager::infos_buf |
Definition at line 80 of file draw_manager.hh.
Referenced by begin_sync(), compute_visibility(), data_debug(), end_sync(), extract_object_attributes(), extract_object_attributes(), resource_bind(), resource_handle(), resource_handle(), resource_handle(), resource_handle(), and resource_handle_for_psys().
| Map<uint32_t, GPULayerAttr> blender::draw::Manager::layer_attributes |
Table of all View Layer attributes required by shaders, used to populate the buffer below.
Definition at line 91 of file draw_manager.hh.
Referenced by begin_sync(), and register_layer_attributes().
| LayerAttributeBuf blender::draw::Manager::layer_attributes_buf |
Buffer of layer attribute values, indexed and sorted by the hash.
Definition at line 96 of file draw_manager.hh.
Referenced by end_sync(), and resource_bind().
| SwapChain<ObjectMatricesBuf, 2> blender::draw::Manager::matrix_buf |
Buffers containing all object data. Referenced by resource index. Exposed as public members for shader access after sync.
Definition at line 78 of file draw_manager.hh.
Referenced by begin_sync(), blender::draw::overlay::GreasePencil::compute_depth_planes(), data_debug(), end_sync(), blender::draw::overlay::FlatObjectRef::if_flat_axis_orthogonal_to_view(), resource_bind(), resource_handle(), resource_handle(), resource_handle(), resource_handle(), and resource_handle_for_psys().