Table of Contents

Class SpirvVertexInputReflector

Namespace
ShadowDusk.Core.Reflection
Assembly
ShadowDusk.Core.dll

Builds the .mgfx per-shader vertex ATTRIBUTE TABLE from a vertex shader's SPIR-V, mirroring real mgfxc's Vulkan writer (ShaderProfile.Vulkan.CreateShader): the inputs are ordered by Location, each semantic maps to a MonoGame VertexElementUsage byte plus its semantic index, and an input that spans several locations (a matrix, an array) contributes one entry per location with a running index.

This table IS load-bearing on the new native backend (correction, Phase 54 follow-up, 2026-07-23). An earlier version of this remark claimed MonoGame's native backends build their vertex input layout positionally and never read this table — that is false. The shared managed VertexInputLayout.GenerateInputElements (used by every native backend, including DirectX12) iterates this exact table to match declared vertex-buffer elements against the shader's required inputs; an empty table silently yields a zero-element input layout (its "missing input" check only runs inside the per-attribute loop, so it never fires when the table itself is empty), which then fails DirectX12's CreateGraphicsPipelineState — called lazily right before the first Draw — with E_INVALIDARG. Confirmed by reading MonoGame's real v3.8.5 source directly (VertexInputLayout.Native.cs, Shader.Native.cs). Always populate this table for a native-backend vertex shader; never assume it is decorative.

The Name and Location fields are written as "" / 0 — exactly what mgfxc emits for a Vulkan shader (its GL profile is the one that populates them); Usage/Index are what GenerateInputElements actually matches on.

public static class SpirvVertexInputReflector
Inheritance
SpirvVertexInputReflector
Inherited Members

Methods

Read(ReadOnlyMemory<byte>)

Reads the vertex attribute table from spirvBlob. Unparseable SPIR-V or a reflection failure is a compile-time ERROR (bug-hunt 2026-07-27 M11): the previous empty-table fallback shipped a .mgfx whose zero-element input layout failed at the consumer's first Draw with an unattributed E_INVALIDARG (see class remarks). A module that genuinely declares no located inputs still returns an empty table — a zero-element layout is valid when the shader consumes nothing.

public static Result<IReadOnlyList<MgfxVertexAttributeInfo>, ShaderError> Read(ReadOnlyMemory<byte> spirvBlob)

Parameters

spirvBlob ReadOnlyMemory<byte>

Returns

Result<IReadOnlyList<MgfxVertexAttributeInfo>, ShaderError>

Read(ReadOnlyMemory<byte>, out IReadOnlyList<ShaderError>)

The same read as Read(ReadOnlyMemory<byte>), additionally reporting the non-fatal SD0104 warnings for input semantics that fell through to the TextureCoordinate default (bug-hunt 2026-07-27 N5 — mgfxc warns when it defaults, so a drop-in replacement must too). The attribute table is byte-for-byte what the warning-free overload produces: warnings never gate output.

public static Result<IReadOnlyList<MgfxVertexAttributeInfo>, ShaderError> Read(ReadOnlyMemory<byte> spirvBlob, out IReadOnlyList<ShaderError> warnings)

Parameters

spirvBlob ReadOnlyMemory<byte>
warnings IReadOnlyList<ShaderError>

Returns

Result<IReadOnlyList<MgfxVertexAttributeInfo>, ShaderError>