1

In my Vulkan code, I use spir-v reflection (spirv-reflect) to construct a compatible VkPipeline object for a combination of shader modules (VkShaderModule).

Once a VkPipeline object is created for a specific combination, it is cached so it won't have to be recreated once the same combination is requested.

Given a list of shader blobs, I can deduce the descriptor sets used and their bindings to construct an appropriate VkDecriptorSetLayout. However, given that I already created many pipelines with similar shaders before, I probably already created a compatible VkDecriptorSetLayout, which I can potentially reuse.

  • Generally speaking, is it a beneficial to reuse VkDecriptorSetLayout objects across multiple VkPipeline objects?
  • If it is beneficial, is there a mechanism which will allow me to identify compatible sets? (for instance, a set 'tag' attribute in hlsl / glsl) which can be used for caching.
Elad Maimoni
  • 3,703
  • 3
  • 20
  • 37
  • "*I use spir-v reflection (spirv-reflect) to construct a compatible VkPipeline object for a combination of shader modules (VkShaderModule).*" That is generally not a good idea. – Nicol Bolas Jul 22 '22 at 19:44
  • @NicolBolas please explain? – Elad Maimoni Jul 22 '22 at 20:09
  • One thing is that it means that two shaders basically cannot share descriptor set layouts unless they both define every component of that descriptor set, even the parts that they don't actually use. – Nicol Bolas Jul 22 '22 at 20:12
  • @NicolBolas when loading a shader combination, I concatenate their bindings to a single descriptor set layout. So if both use set 0, but different bindings, it will result in a single set. make sense? – Elad Maimoni Jul 22 '22 at 20:17
  • I'm talking about sharing sets between separate pipelines. Like they could conceptually share set 0 but have different set 1s. Your system doesn't really allow for that; if you change pipelines, you're also changing descriptor sets. And if you need to update some descriptor, you have to change it in each pipeline's descriptor set even if they are conceptually the same thing. – Nicol Bolas Jul 22 '22 at 20:20
  • I understand. So I must share the set layout between pipelines. So assuming 2 shaders that share a set *do* define the whole set (via common include file), is there a way to identify that they share the same set? – Elad Maimoni Jul 22 '22 at 20:32

0 Answers0