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
4 changed files with 7 additions and 10 deletions
Showing only changes of commit 8a591a7845 - Show all commits

View File

@ -82,7 +82,7 @@ void VKBackend::compute_dispatch(int groups_x_len, int groups_y_len, int groups_
case VKPushConstants::StorageType::UNIFORM_BUFFER:
push_constants.update_uniform_buffer();
descriptor_set.bind(push_constants.uniform_buffer_get(),
push_constants.layout_get().storage_buffer_binding_get());
push_constants.layout_get().descriptor_set_location_get());
break;
}
descriptor_set.update(context.device_get());

View File

@ -80,7 +80,7 @@ void VKPushConstants::Layout::init(const shader::ShaderCreateInfo &info,
size_in_bytes_ = 0;
if (storage_type == StorageType::UNIFORM_BUFFER) {
storage_buffer_binding_ = location;
descriptor_set_location_ = location;
init_struct<Std140>(info, interface, push_constants, &size_in_bytes_);
}
else {

View File

@ -82,7 +82,7 @@ class VKPushConstants : NonCopyable {
/**
* Binding index in the descriptor set when the push constants use an uniform buffer.
*/
VKDescriptorSet::Location storage_buffer_binding_;
VKDescriptorSet::Location descriptor_set_location_;
public:
/**
@ -127,9 +127,9 @@ class VKPushConstants : NonCopyable {
*
* Only valid when storage_type=StorageType::UNIFORM_BUFFER.
*/
VKDescriptorSet::Location storage_buffer_binding_get() const
VKDescriptorSet::Location descriptor_set_location_get() const
{
return storage_buffer_binding_;
return descriptor_set_location_;
}
/**
@ -204,9 +204,6 @@ class VKPushConstants : NonCopyable {
* 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.
*
* TODO: this function still needs to convert the input_data layout to that
* what the storage type is expected.
*/
template<typename T>
void push_constant_set(int32_t location,

View File

@ -890,7 +890,7 @@ static VkDescriptorSetLayoutBinding create_descriptor_set_layout_binding(
BLI_assert(push_constants_layout.storage_type_get() ==
VKPushConstants::StorageType::UNIFORM_BUFFER);
VkDescriptorSetLayoutBinding binding = {};
binding.binding = push_constants_layout.storage_buffer_binding_get();
binding.binding = push_constants_layout.descriptor_set_location_get();
binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
binding.descriptorCount = 1;
binding.stageFlags = VK_SHADER_STAGE_ALL;
@ -1045,7 +1045,7 @@ std::string VKShader::resources_declare(const shader::ShaderCreateInfo &info) co
ss << "layout(push_constant) uniform constants\n";
}
else if (push_constants_storage == VKPushConstants::StorageType::UNIFORM_BUFFER) {
ss << "layout(binding = " << push_constants_layout.storage_buffer_binding_get()
ss << "layout(binding = " << push_constants_layout.descriptor_set_location_get()
<< ", std140) uniform constants\n";
}
ss << "{\n";