Blender V5.0
blender::draw::Manager Class Reference

#include <draw_manager.hh>

Classes

struct  SubmitDebugOutput
struct  DataDebugOutput

Public Member Functions

 Manager ()
 ~Manager ()
ResourceHandleRange unique_handle (const ObjectRef &ref)
ResourceHandleRange unique_handle_for_sculpt (const ObjectRef &ref)
ResourceHandleRange resource_handle (const ObjectRef &ref, float inflate_bounds=0.0f)
ResourceHandleRange resource_handle (const ObjectRef &ref, const float4x4 *model_matrix, const float3 *bounds_center, const float3 *bounds_half_extent)
ResourceHandle resource_handle (const float4x4 &model_matrix)
ResourceHandle resource_handle (const float4x4 &model_matrix, const float3 &bounds_center, const float3 &bounds_half_extent)
ResourceHandle resource_handle_for_psys (const ObjectRef &ref, const float4x4 &model_matrix)
void update_handle_bounds (ResourceHandle handle, const ObjectRef &ref, float inflate_bounds=0.0f)
void extract_object_attributes (ResourceHandle handle, const ObjectRef &ref, const GPUMaterial *material)
void extract_object_attributes (ResourceHandle handle, const ObjectRef &ref, Span< GPUMaterial * > materials)
void register_layer_attributes (GPUMaterial *material)
void compute_visibility (View &view)
void ensure_visibility (View &view)
void generate_commands (PassMain &pass, View &view)
void generate_commands (PassSortable &pass, View &view)
void generate_commands (PassSimple &pass)
void warm_shader_specialization (PassMain &pass)
void warm_shader_specialization (PassSimple &pass)
void submit_only (PassMain &pass, View &view)
void submit (PassSimple &pass, View &view)
void submit (PassMain &pass, View &view)
void submit (PassSortable &pass, View &view)
void submit (PassSimple &pass, bool inverted_view=false)
SubmitDebugOutput submit_debug (PassSimple &pass, View &view)
SubmitDebugOutput submit_debug (PassMain &pass, View &view)
DataDebugOutput data_debug ()
void acquire_texture (gpu::Texture *texture)
uint resource_handle_count () const
void begin_sync (Object *object_active=nullptr)
void end_sync ()
void debug_bind ()
void resource_bind ()

Public Attributes

SwapChain< ObjectMatricesBuf, 2 > matrix_buf
SwapChain< ObjectBoundsBuf, 2 > bounds_buf
SwapChain< ObjectInfosBuf, 2 > infos_buf
ObjectAttributeBuf attributes_buf
Map< uint32_t, GPULayerAttrlayer_attributes
LayerAttributeBuf layer_attributes_buf
Vector< gpu::Texture * > acquired_textures

Detailed Description

Definition at line 45 of file draw_manager.hh.

Constructor & Destructor Documentation

◆ Manager()

blender::draw::Manager::Manager ( )
inline

Definition at line 119 of file draw_manager.hh.

◆ ~Manager()

blender::draw::Manager::~Manager ( )

Definition at line 28 of file draw_manager.cc.

References acquired_textures, GPU_texture_free(), and texture().

Member Function Documentation

◆ acquire_texture()

void blender::draw::Manager::acquire_texture ( gpu::Texture * 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().

◆ begin_sync()

◆ compute_visibility()

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:

manager.submit(pass1, view1);
manager.submit(pass2, view1);
manager.submit(pass1, view2);
manager.submit(pass2, view2);

After:

manager.compute_visibility(view1);
manager.compute_visibility(view2);
manager.generate_commands(pass1, view1);
manager.generate_commands(pass2, view1);
manager.submit(pass1, view1);
manager.submit(pass2, view1);
manager.generate_commands(pass1, view2);
manager.generate_commands(pass2, view2);
manager.submit(pass1, view2);
manager.submit(pass2, view2);

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().

◆ data_debug()

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().

◆ debug_bind()

◆ end_sync()

◆ ensure_visibility()

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().

◆ extract_object_attributes() [1/2]

void blender::draw::Manager::extract_object_attributes ( ResourceHandle handle,
const ObjectRef & ref,
const GPUMaterial * material )
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().

◆ extract_object_attributes() [2/2]

◆ generate_commands() [1/3]

void blender::draw::Manager::generate_commands ( PassMain & pass,
View & view )

◆ generate_commands() [2/3]

◆ generate_commands() [3/3]

void blender::draw::Manager::generate_commands ( PassSortable & pass,
View & view )

◆ register_layer_attributes()

void blender::draw::Manager::register_layer_attributes ( GPUMaterial * material)
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.

◆ resource_bind()

◆ resource_handle() [1/4]

ResourceHandle blender::draw::Manager::resource_handle ( const float4x4 & model_matrix)
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.

◆ resource_handle() [2/4]

ResourceHandle blender::draw::Manager::resource_handle ( const float4x4 & model_matrix,
const float3 & bounds_center,
const float3 & bounds_half_extent )
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.

◆ resource_handle() [3/4]

ResourceHandleRange blender::draw::Manager::resource_handle ( const ObjectRef & ref,
const float4x4 * model_matrix,
const float3 * bounds_center,
const float3 * bounds_half_extent )
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.

◆ resource_handle() [4/4]

◆ resource_handle_count()

uint blender::draw::Manager::resource_handle_count ( ) const
inline

Return the number of resource handles allocated.

Definition at line 295 of file draw_manager.hh.

Referenced by blender::eevee::IrradianceBake::surfels_create().

◆ resource_handle_for_psys()

ResourceHandle blender::draw::Manager::resource_handle_for_psys ( const ObjectRef & ref,
const float4x4 & model_matrix )
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().

◆ submit() [1/4]

◆ submit() [2/4]

◆ submit() [3/4]

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().

◆ submit() [4/4]

void blender::draw::Manager::submit ( PassSortable & pass,
View & view )

◆ submit_debug() [1/2]

◆ submit_debug() [2/2]

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_only()

◆ unique_handle()

◆ unique_handle_for_sculpt()

◆ update_handle_bounds()

void blender::draw::Manager::update_handle_bounds ( ResourceHandle handle,
const ObjectRef & ref,
float inflate_bounds = 0.0f )
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().

◆ warm_shader_specialization() [1/2]

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().

◆ warm_shader_specialization() [2/2]

Member Data Documentation

◆ acquired_textures

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().

◆ attributes_buf

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().

◆ bounds_buf

◆ infos_buf

◆ layer_attributes

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().

◆ layer_attributes_buf

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().

◆ matrix_buf

SwapChain<ObjectMatricesBuf, 2> blender::draw::Manager::matrix_buf

The documentation for this class was generated from the following files: