Open NikolayKanchevski opened 1 year ago
In the second commit, I made push constant fields' names to be their actual GLSL in-shader member names (not their type names, which what they were populated with before). See this link.
Hello, I don't want to intrude, but what's the main difference of this pr from mine #154 aside from having yaml output but no 64 bit and evaluation?
Hello, @shangjiaxuan, it seems I have glossed over your PR, as I had not seen it before. I wish I had - this would have made my life much simpler! Anyway, I see they are very similar now, so if you want to, I could close this PR. You can by the way take the YAML output bit and put it in yours, as it is the original one.
@NikichaTV I'm sorry I didn't have a good description in the pr until yesterday. I didn't implement YAML because I'm not quite familiar with YAML, and because the tests currently tests YAML by string comparison against set result (Adding will fail tests. I also added a few to test my added features, and failing early on will mean it may not test my cases). I hope you can leave this open so that when maintainers decide to merge or integrate this feature, they can be merged together.
As commit name states, I added support for specialization constants. All the code written follows the already-established style of the SPIRV-Reflect codebase, and I have provided all the needed functions/fields, that such a feature would make sense to have.
Additions:
Two new fields within
SpvReflectShaderModule
:uint32_t specialization_constant_count;
SpvReflectSpecializationConstant* specialization_constants;
As you can see, a new type
SpvReflectSpecializationConstant
has also been added. It includes the following members:const char* name;
uint32_t spirv_id;
uint32_t constant_id;
uint32_t size;
SpvReflectSpecializationConstantType constant_type;
where all possible types are:SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL
SPV_REFLECT_SPECIALIZATION_CONSTANT_INT
SPV_REFLECT_SPECIALIZATION_CONSTANT_FLOAT
union { float float_value; uint32_t uint_bool_value } default_value;
These fields can freely be accessed in
SpvReflectShaderModule
, just as all other types (push_constant_blocks
,descriptor_bindings
, etc.) are.Two new enumerating methods:
spvReflectEnumerateSpecializationConstants(p_module, p_count, pp_constants)
- a static method inspirv-reflect.h
, which works like any otherspvReflectEnumerate...
method.ShaderModule::EnumerateSpecializationConstants(p_count, pp_constants)
- a public member method of theShaderModule
class. Just like the rest ofShaderModule
's member enumerating functions, it relies on its static counterpart inspirv-reflect.h
under the hood (in this case -spvReflectEnumerateSpecializationConstants()
).Last but not least,
SpvReflectToYaml
(aka theyamlizer
) also picks up specialization constants and displays them same way all other members are shown. Example:Note that all the new additions are properly documented, once again, following the general styling of SPIRV-Reflect's documentation within the code.