.. _stdlib_spirv_reflect: ================================================================================================= SPIR-V shader reflection (dasSpirv): API-neutral descriptor + push-constant layout, host-consumed ================================================================================================= .. das:module:: spirv_reflect Shader reflection for the dasSpirv SPIR-V backend: an API-neutral description of a shader's descriptor bindings and push-constant ranges, emitted alongside the SPIR-V blob and consumed by the host (e.g. dasVulkan) to auto-build descriptor-set and pipeline layouts. The same per-global classification that emits the SPIR-V fills the reflection, so the host never re-declares set/binding/type by hand. Serialized to an ``array`` (riding the same module-global-capture rail as the blob) and decoded once at layout-build time; the wire form is versioned so producer/consumer drift fails loudly. ++++++++++++ Type aliases ++++++++++++ .. _alias-SpirvStageFlags: .. das:attribute:: bitfield SpirvStageFlags :Fields: * **vertex** (0x1) - < used in the vertex stage * **fragment** (0x2) - < used in the fragment stage * **compute** (0x4) - < used in the compute stage +++++++++ Constants +++++++++ .. _global-spirv_reflect-REFLECTION_MAGIC: .. das:attribute:: REFLECTION_MAGIC = 0x52464c32 REFLECTION_MAGIC:uint const ++++++++++++ Enumerations ++++++++++++ .. _enum-spirv_reflect-SpirvDescriptorKind: .. das:attribute:: SpirvDescriptorKind :Values: * **uniform_buffer** = 0 - < a `@uniform` block (UBO) * **storage_buffer** = 1 - < an `@ssbo` (SSBO) * **combined_image_sampler** = 2 - < a `sampler2D`/`3D`/`Cube`/`2DArray` (image + sampler in one descriptor) * **storage_image** = 3 - < an `image2D` (read-write storage image) * **sampled_image** = 4 - < a standalone `texture2D` (separate-image model) * **sampler** = 5 - < a standalone `sampler` (separate-sampler model) ++++++++++ Structures ++++++++++ .. _struct-spirv_reflect-SpirvDescriptorBinding: .. das:attribute:: SpirvDescriptorBinding :Fields: * **set** : int - < descriptor-set index (`@set`) * **binding** : int - < binding index within the set (`@binding`) * **kind** : :ref:`SpirvDescriptorKind ` - < what kind of descriptor this is * **count** : int - < array size; 1 for a non-array binding * **stages** : :ref:`SpirvStageFlags ` - < stages this binding is used in .. _struct-spirv_reflect-SpirvPushConstantRange: .. das:attribute:: SpirvPushConstantRange :Fields: * **offset** : int - < byte offset of the range (4-aligned) * **size** : int - < byte size of the range (4-aligned) * **stages** : :ref:`SpirvStageFlags ` - < stages this range is used in .. _struct-spirv_reflect-SpirvReflection: .. das:attribute:: SpirvReflection :Fields: * **stage** : :ref:`SpirvStageFlags ` - < which stage this reflection describes * **entry_point** : string - < entry-point name; always "main" (invariant, not serialized — decode restores it) * **local_size** : int3 - < compute workgroup size; (1,1,1) for graphics stages * **bindings** : array< :ref:`SpirvDescriptorBinding `> - < descriptor bindings (UBO / SSBO / image / sampler) * **push_constants** : array< :ref:`SpirvPushConstantRange `> - < push-constant ranges +++++++++++++ Serialization +++++++++++++ * :ref:`decode_reflection (words: array\) : SpirvReflection ` * :ref:`encode_reflection (refl: SpirvReflection) : array\ ` .. _function-spirv_reflect_decode_reflection_array_ls_uint_gr_: .. das:function:: decode_reflection(words: array) : SpirvReflection def decode_reflection (words: array) : SpirvReflection :Arguments: * **words** : array .. _function-spirv_reflect_encode_reflection_SpirvReflection: .. das:function:: encode_reflection(refl: SpirvReflection) : array def encode_reflection (refl: SpirvReflection) : array :Arguments: * **refl** : :ref:`SpirvReflection `