Added support for specialization constants. They are now automaticall… #197
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.