Vulkan: Push constants #104880

Merged
Jeroen Bakker merged 73 commits from Jeroen-Bakker/blender:vulkan-push-constants into main 2023-03-06 12:29:06 +01:00
2 changed files with 15 additions and 7 deletions
Showing only changes of commit 2765552504 - Show all commits

View File

@ -205,8 +205,6 @@ class VKPushConstants : NonCopyable {
*
* TODO: this function still needs to convert the input_data layout to that
* what the storage type is expected.
* TODO: Current implementation has a work around for missing implementation
* of builtin uniforms. Builtin uniforms should eventually also be supported.
*/
template<typename T>
void push_constant_set(int32_t location,
@ -216,11 +214,7 @@ class VKPushConstants : NonCopyable {
{
const VKPushConstantsLayout::PushConstantLayout *push_constant_layout = layout_->find(
location);
if (push_constant_layout == nullptr) {
/* TODO: Currently the builtin uniforms are set using a predefined location each time a
* shader is bound. This needs to be fixed in the VKShaderInterface.*/
return;
}
BLI_assert(push_constant_layout);
BLI_assert_msg(push_constant_layout->offset + comp_len * array_size * sizeof(T) <=
layout_->size_in_bytes(),
"Tried to write outside the push constant allocated memory.");

View File

@ -116,6 +116,20 @@ void VKShaderInterface::init(const shader::ShaderCreateInfo &info)
sort_inputs();
/* Builtin Uniforms */
for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORMS; u_int++) {
GPUUniformBuiltin u = static_cast<GPUUniformBuiltin>(u_int);
const ShaderInput *uni = this->uniform_get(builtin_uniform_name(u));
builtins_[u] = (uni != nullptr) ? uni->location : -1;
}
/* Builtin Uniforms Blocks */
for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORM_BLOCKS; u_int++) {
GPUUniformBlockBuiltin u = static_cast<GPUUniformBlockBuiltin>(u_int);
const ShaderInput *block = this->ubo_get(builtin_uniform_block_name(u));
builtin_blocks_[u] = (block != nullptr) ? block->binding : -1;
}
/* Determine the descriptor set locations after the inputs have been sorted.*/
descriptor_set_locations_ = Array<VKDescriptorSet::Location>(input_tot_len);
uint32_t descriptor_set_location = 0;