MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ calculate_dispatch_size()

std::array< uint32_t, 3 > MayaFlux::Buffers::ShaderProcessor::calculate_dispatch_size ( const std::shared_ptr< VKBuffer > &  buffer)
protectedvirtual

Calculate dispatch size from buffer.

Parameters
bufferBuffer to process
Returns
{group_count_x, group_count_y, group_count_z}

Override for custom dispatch calculation logic. Default implementation uses m_config.dispatch settings.

Definition at line 347 of file ShaderProcessor.cpp.

348{
349 using DispatchMode = ShaderDispatchConfig::DispatchMode;
350
351 switch (m_config.dispatch.mode) {
352 case DispatchMode::MANUAL:
354
355 case DispatchMode::ELEMENT_COUNT: {
356 uint64_t element_count = 0;
357 const auto& dimensions = buffer->get_dimensions();
358
359 if (!dimensions.empty()) {
360 element_count = dimensions[0].size;
361 } else {
362 element_count = buffer->get_size_bytes() / sizeof(float);
363 }
364
365 auto groups_x = static_cast<uint32_t>(
366 (element_count + m_config.dispatch.workgroup_x - 1) / m_config.dispatch.workgroup_x);
367 return { groups_x, 1, 1 };
368 }
369
370 case DispatchMode::BUFFER_SIZE: {
371 uint64_t size_bytes = buffer->get_size_bytes();
372 auto groups_x = static_cast<uint32_t>(
374 return { groups_x, 1, 1 };
375 }
376
377 case DispatchMode::CUSTOM:
379 return m_config.dispatch.custom_calculator(buffer);
380 }
381 return { 1, 1, 1 };
382
383 default:
384 return { 1, 1, 1 };
385 }
386}
enum MayaFlux::Buffers::ShaderDispatchConfig::DispatchMode mode
std::function< std::array< uint32_t, 3 >(const std::shared_ptr< VKBuffer > &)> custom_calculator
uint32_t workgroup_x
Workgroup size X (should match shader)

References MayaFlux::Buffers::ShaderDispatchConfig::custom_calculator, MayaFlux::Buffers::ShaderProcessorConfig::dispatch, MayaFlux::Buffers::ShaderDispatchConfig::group_count_x, MayaFlux::Buffers::ShaderDispatchConfig::group_count_y, MayaFlux::Buffers::ShaderDispatchConfig::group_count_z, m_config, MayaFlux::Buffers::ShaderDispatchConfig::mode, and MayaFlux::Buffers::ShaderDispatchConfig::workgroup_x.

Referenced by execute_dispatch().

+ Here is the caller graph for this function: