Blender V4.3
blender::gpu::VKPushConstants Class Reference

#include <vk_push_constants.hh>

Inherits blender::gpu::VKResourceTracker< VKUniformBuffer >.

Classes

struct  Layout
 

Public Types

enum class  StorageType { NONE , PUSH_CONSTANTS , UNIFORM_BUFFER }
 

Public Member Functions

 VKPushConstants ()
 
 VKPushConstants (const Layout *layout)
 
 VKPushConstants (VKPushConstants &&other)
 
virtual ~VKPushConstants ()
 
VKPushConstantsoperator= (VKPushConstants &&other)
 
size_t offset () const
 
const Layoutlayout_get () const
 
std::unique_ptr< VKUniformBuffercreate_resource (VKContext &context) override
 
const void * data () const
 
template<typename T >
void push_constant_set (int32_t location, int32_t comp_len, int32_t array_size, const T *input_data)
 
void update_uniform_buffer ()
 
std::unique_ptr< VKUniformBuffer > & uniform_buffer_get ()
 

Friends

class VKContext
 

Detailed Description

Container to store push constants in a buffer.

Can handle buffers with different memory layouts (std140/std430) Which memory layout is used is based on the storage type.

VKPushConstantsLayout only describes the buffer, an instance of this class can handle setting/modifying/duplicating push constants.

It should also keep track of the submissions in order to reuse the allocated data.

Definition at line 48 of file vk_push_constants.hh.

Member Enumeration Documentation

◆ StorageType

Different methods to store push constants.

Enumerator
NONE 

Push constants aren't in use.

PUSH_CONSTANTS 

Store push constants as regular vulkan push constants.

UNIFORM_BUFFER 

Fallback when push constants doesn't meet the device requirements.

Definition at line 53 of file vk_push_constants.hh.

Constructor & Destructor Documentation

◆ VKPushConstants() [1/3]

blender::gpu::VKPushConstants::VKPushConstants ( )
default

◆ VKPushConstants() [2/3]

blender::gpu::VKPushConstants::VKPushConstants ( const Layout * layout)

◆ VKPushConstants() [3/3]

blender::gpu::VKPushConstants::VKPushConstants ( VKPushConstants && other)

Definition at line 124 of file vk_push_constants.cc.

◆ ~VKPushConstants()

blender::gpu::VKPushConstants::~VKPushConstants ( )
virtual

Definition at line 130 of file vk_push_constants.cc.

References MEM_freeN().

Member Function Documentation

◆ create_resource()

std::unique_ptr< VKUniformBuffer > blender::gpu::VKPushConstants::create_resource ( VKContext & context)
overridevirtual

Part of Resource Tracking API is called when new resource is needed.

Implements blender::gpu::VKResourceTracker< VKUniformBuffer >.

Definition at line 164 of file vk_push_constants.cc.

References blender::gpu::VKPushConstants::Layout::size_in_bytes().

◆ data()

const void * blender::gpu::VKPushConstants::data ( ) const
inline

Get the reference to the active data.

Data can get inactive when push constants are modified, after being added to the command queue. We still keep track of the old data for reuse and make sure we don't overwrite data that is still not on the GPU.

Definition at line 192 of file vk_push_constants.hh.

◆ layout_get()

const Layout & blender::gpu::VKPushConstants::layout_get ( ) const
inline

Definition at line 175 of file vk_push_constants.hh.

◆ offset()

size_t blender::gpu::VKPushConstants::offset ( ) const
inline

Definition at line 170 of file vk_push_constants.hh.

◆ operator=()

VKPushConstants & blender::gpu::VKPushConstants::operator= ( VKPushConstants && other)

Definition at line 138 of file vk_push_constants.cc.

◆ push_constant_set()

template<typename T >
void blender::gpu::VKPushConstants::push_constant_set ( int32_t location,
int32_t comp_len,
int32_t array_size,
const T * input_data )
inline

Modify a push constant.

location: ShaderInput.location of the push constant to update. comp_len: number of components has the data type that is being updated. array_size: number of elements when an array to update. (0=no array) input_data: packed source data to use.

Definition at line 206 of file vk_push_constants.hh.

References blender::gpu::VKPushConstants::Layout::PushConstant::array_size, BLI_assert, BLI_assert_msg, blender::gpu::VKPushConstants::Layout::PushConstant::inner_row_padding, max_ii(), blender::gpu::VKPushConstants::Layout::PushConstant::offset, PUSH_CONSTANTS, T, and UNUSED_VARS.

Referenced by blender::gpu::VKShader::uniform_float(), and blender::gpu::VKShader::uniform_int().

◆ uniform_buffer_get()

std::unique_ptr< VKUniformBuffer > & blender::gpu::VKPushConstants::uniform_buffer_get ( )

◆ update_uniform_buffer()

void blender::gpu::VKPushConstants::update_uniform_buffer ( )

When storage type = StorageType::UNIFORM_BUFFER use this method to update the uniform buffer.

It must be called just before adding a draw/compute command to the command queue.

Definition at line 148 of file vk_push_constants.cc.

References BLI_assert, blender::gpu::VKContext::get(), blender::gpu::VKPushConstants::Layout::storage_type_get(), blender::gpu::VKResourceTracker< VKUniformBuffer >::tracked_resource_for(), and UNIFORM_BUFFER.

Friends And Related Symbol Documentation

◆ VKContext

friend class VKContext
friend

Definition at line 49 of file vk_push_constants.hh.


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