Vulkan: Add read dependency for push constants fallback

When a shader uses push constants fallback the push constants are
stored inside a uniform buffer. The uniform buffer needs to be guarded
with a read barrier.

Pull Request: https://projects.blender.org/blender/blender/pulls/123777
This commit is contained in:
Jeroen Bakker 2024-06-26 14:38:08 +02:00
parent af71cb6485
commit 02a45fb60d
2 changed files with 11 additions and 0 deletions

@ -255,6 +255,15 @@ void VKContext::update_pipeline_data(VKShader &vk_shader,
r_pipeline_data.push_constants_data = vk_shader.push_constants.data();
}
/* When using the push constant fallback we need to add a read access dependency to the uniform
* buffer after the buffer has been updated.
* NOTE: this alters the context instance variable `access_info_` which isn't clear from the API.
*/
if (push_constants_layout.storage_type_get() == VKPushConstants::StorageType::UNIFORM_BUFFER) {
access_info_.buffers.append(
{vk_shader.push_constants.uniform_buffer_get()->vk_handle(), VK_ACCESS_UNIFORM_READ_BIT});
}
/* Update descriptor set. */
r_pipeline_data.vk_descriptor_set = VK_NULL_HANDLE;
if (vk_shader.has_descriptor_set()) {

@ -46,6 +46,8 @@ class VKDevice;
* data.
*/
class VKPushConstants : VKResourceTracker<VKUniformBuffer> {
friend class VKContext;
public:
/** Different methods to store push constants. */
enum class StorageType {