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

#include <draw_manager.hh>

Classes

struct  SubmitDebugOutput
struct  DataDebugOutput
struct  DeferredTexture

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 (ResourceHandleRange handle, const ObjectRef &ref, const GPUMaterial *material)
void extract_object_attributes (ResourceHandleRange handle, const ObjectRef &ref, Span< GPUMaterial * > materials)
void extract_all_object_attributes (ResourceHandleRange handle, const ObjectRef &ref)
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 hold_texture (gpu::Texture *texture)
DeferredTexture & add_texture_deferred (blender::Image *image, blender::ImageUser *image_user, const bool use_tile_mapping)
bool has_deferred_textures () const
uint resource_handle_count () const
void begin_sync (Object *object_active=nullptr)
void end_sync ()
void load_deferred_textures ()
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, GPULayerAttr > layer_attributes
LayerAttributeBuf layer_attributes_buf
Vector< gpu::Texture * > acquired_textures

Detailed Description

Definition at line 56 of file draw_manager.hh.

Constructor & Destructor Documentation

◆ Manager()

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

Definition at line 143 of file draw_manager.hh.

◆ ~Manager()

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

Definition at line 35 of file draw_manager.cc.

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

Member Function Documentation

◆ add_texture_deferred()

DeferredTexture & blender::draw::Manager::add_texture_deferred ( blender::Image * image,
blender::ImageUser * image_user,
const bool use_tile_mapping )
inline

◆ 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 238 of file draw_manager.cc.

References blender::draw::View::bind(), BLI_assert_msg, bounds_buf, blender::draw::View::compute_visibility(), blender::View3D::debug_flag, blender::drw_get(), infos_buf, blender::draw::View::manager_fingerprint_, blender::U, USER_DEVELOPER_TOOL_TEST, blender::DRWContext::v3d, and blender::V3D_DEBUG_FREEZE_CULLING.

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 456 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 253 of file draw_manager.cc.

References compute_visibility(), and blender::draw::View::manager_fingerprint_.

Referenced by blender::draw::overlay::Instance::draw().

◆ extract_all_object_attributes()

◆ extract_object_attributes() [1/2]

void blender::draw::Manager::extract_object_attributes ( ResourceHandleRange handle,
const ObjectRef & ref,
const GPUMaterial * material )
inline

◆ extract_object_attributes() [2/2]

◆ generate_commands() [1/3]

◆ generate_commands() [2/3]

◆ generate_commands() [3/3]

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

◆ has_deferred_textures()

bool blender::draw::Manager::has_deferred_textures ( ) const
inline

Return true if there are textures pending deferred loading this frame.

Definition at line 337 of file draw_manager.hh.

Referenced by blender::eevee::Instance::end_sync().

◆ hold_texture()

◆ load_deferred_textures()

void blender::draw::Manager::load_deferred_textures ( )

Definition at line 122 of file draw_manager.cc.

References blender::GPU_debug_group_begin(), and blender::threading::parallel_for().

Referenced by end_sync().

◆ register_layer_attributes()

void blender::draw::Manager::register_layer_attributes ( GPUMaterial * material)
inline

Collect necessary View Layer attributes.

Definition at line 578 of file draw_manager.hh.

References blender::GPU_material_layer_attributes(), and layer_attributes.

◆ 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 448 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 456 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

◆ 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 345 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

◆ 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 412 of file draw_manager.cc.

References blender::draw::View::bind(), debug_bind(), blender::draw::detail::PassBase< DrawCommandBufType >::is_empty(), blender::draw::View::is_inverted(), and submit().

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(), blender::draw::TestDefrag::TestDefrag(), and blender::draw::GSplatModule::update().

◆ 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_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 483 of file draw_manager.hh.

References bounds_buf, blender::draw::ResourceHandle::index(), and blender::draw::ObjectRef::object.

◆ 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 307 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 119 of file draw_manager.hh.

Referenced by begin_sync(), hold_texture(), 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 103 of file draw_manager.hh.

Referenced by begin_sync(), end_sync(), extract_all_object_attributes(), 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 108 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 113 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: