Blender V4.5
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 resource_handle (const ObjectRef &ref, float inflate_bounds=0.0f)
ResourceHandle 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)
ResourceHandleRange resource_handle_for_sculpt (const ObjectRef &ref)
void update_handle_bounds (ResourceHandle handle, const ObjectRef &ref, float inflate_bounds=0.0f)
void update_handle_bounds (ResourceHandle handle, const float3 &bounds_center, const float3 &bounds_half_extent)
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 (GPUTexture *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< GPUTexture * > 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 ( GPUTexture * 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 289 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 185 of file draw_manager.cc.

References BLI_assert_msg, bounds_buf, View3D::debug_flag, drw_get(), infos_buf, this, U, USER_EXPERIMENTAL_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 403 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 200 of file draw_manager.cc.

References compute_visibility(), this, 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 418 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 469 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 370 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 378 of file draw_manager.hh.

References bounds_buf, infos_buf, and matrix_buf.

◆ resource_handle() [3/4]

ResourceHandle blender::draw::Manager::resource_handle ( const ObjectRef & ref,
const float4x4 * model_matrix,
const float3 * bounds_center,
const float3 * bounds_half_extent )
inline

◆ 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 298 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 388 of file draw_manager.hh.

References bounds_buf, DRW_object_is_in_edit_mode(), blender::draw::ObjectRef::dupli_object, blender::draw::ObjectRef::dupli_parent, ELEM, infos_buf, matrix_buf, Object::mode, OB_MODE_SCULPT, OB_MODE_TEXTURE_PAINT, OB_NEG_SCALE, blender::draw::ObjectRef::object, and Object::transflag.

Referenced by blender::draw::external::Prepass::particle_sync(), and blender::draw::overlay::Prepass::particle_sync().

◆ resource_handle_for_sculpt()

◆ 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 359 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::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_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 372 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()

◆ update_handle_bounds() [1/2]

void blender::draw::Manager::update_handle_bounds ( ResourceHandle handle,
const float3 & bounds_center,
const float3 & bounds_half_extent )
inline

Update the bounds of an already created handle.

Definition at line 411 of file draw_manager.hh.

References bounds_buf, and blender::draw::ResourceHandle::resource_index().

◆ update_handle_bounds() [2/2]

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 404 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 254 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<GPUTexture *> 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: