Closed FunMiles closed 3 years ago
I've taken a first pass at this. I've added an extra argument to PipelineMaker::shader()
. I've got a demo in the teapot example. However the current version only supports 32bit integer type constants and the syntax is, maybe, a bit awkward, particularly if there is only one specialization constant. For example, to set variable 12 to 3 use:
pm.shader(vk::ShaderStageFlagBits::eVertex, final_vert, { {12,3} });
See https://github.com/FunMiles/Vookoo/tree/shader_specialization
After using the resize equipped version from PR #28 I had to come back to this. I am going to make a PR. Maybe that will get a discussion about the syntax started.
This issue is closed, following the merge of commit c25c3addf9502e05ca47b84b608bdfb14c27fdc4
I'm going to start feeling like I'm nagging. 😃 As I'm replacing my own homegrown library with Vookoo in my own project, I am discovering a few features I had implemented and are not available.
One of them are shader specialization constants. I understand that not many people use them, but for me they allow me to write mini-uber-shaders to handle many of my cases (in scientific visualization, I may have a variable number of attributes and rather than writing one shader per case, the constant specialization allows me to write a single shader handling all cases).
In my own library, I had attached the specialization constants to the shader. In Vookoo, the role of that object is the
ShaderModule
right now. Thevku::ShaderModule
contains a vk::UniqueShaderModule. Thus it seems a bit inappropriate to try to attach the specialization directly to the vku::ShaderModule. Since the sameUniqueShaderModule
can be used with various values of the specialization constants. The specialization variable values need to be given when the pipeline is built. So I see taking one of two approaches:PipelineMaker::shader()
methodUniqueShaderModule
in ShaderModule with astd::shared_ptr<UniqueShaderModule>
and using aspecialize
method to create a lightweightSpecializedShaderModule
that is passed toPipelineMaker::shader()
Any comments/suggestions?