Class VertexSemanticMapper
- Namespace
- ShadowDusk.Core.Reflection
- Assembly
- ShadowDusk.Core.dll
Maps an HLSL vertex-input semantic name to MonoGame's VertexElementUsage byte plus
its semantic index. Shared by every backend that builds a per-shader vertex attribute table
(SPIR-V for Vulkan, DXIL for DirectX12) so the mapping cannot drift between them.
public static class VertexSemanticMapper
- Inheritance
-
VertexSemanticMapper
- Inherited Members
Methods
Map(string)
Semantic → (VertexElementUsage byte, semantic index). The usage values are
MonoGame's VertexElementUsage enum: Position=0, Color=1, TextureCoordinate=2,
Normal=3, Binormal=4, Tangent=5, BlendIndices=6, BlendWeight=7, Depth=8, Fog=9,
PointSize=10, Sample=11, TessellateFactor=12.
An unrecognised semantic falls back to TextureCoordinate, the same default
mgfxc applies — and, like mgfxc, ShadowDusk warns when it defaults: use the
Map(string, out bool) overload and turn a false result into
UnrecognizedSemanticWarning(string, int, string) (SD0104). The value is never
gated by the warning; the fallback attribute is emitted either way.
public static (byte Usage, int Index) Map(string semantic)
Parameters
semanticstring
Returns
Map(string, out bool)
The same mapping as Map(string), additionally reporting whether the
semantic was actually recognised. The returned usage/index are identical in both
overloads — recognized only says whether they came from the
table or from the TextureCoordinate fallback, so a caller can raise the
mgfxc-parity SD0104 warning without changing a single emitted byte.
public static (byte Usage, int Index) Map(string semantic, out bool recognized)
Parameters
semanticstringThe HLSL vertex-input semantic, with or without its numeric index.
recognizedbooltruewhensemanticmatched a known semantic (a name in the table followed by an optional, parseable numeric index);falsewhen the TextureCoordinate default was applied — including for a table name carrying a numeric suffix too large to parse (e.g.TEXCOORDfollowed by 40 digits), which also takes the fallback path.
Returns
UnrecognizedSemanticWarning(string, int, string)
The SD0104 warning for a vertex-input semantic that fell through to the
TextureCoordinate default — mgfxc prints one in exactly this situation, so a
drop-in replacement has to as well. It is a WARNING, never an error: mgfxc accepts
and defaults, and the effect bytes are emitted unchanged either way. The point is
that a typo (TEXCORD0 for TEXCOORD0) otherwise silently mints a
phantom TextureCoordinate attribute the consumer's vertex declaration must then
supply, and the only symptom is a failed draw far from the shader.
public static ShaderError UnrecognizedSemanticWarning(string semantic, int index, string file = "")
Parameters
semanticstringThe unrecognised semantic exactly as it appeared in the shader.
indexintThe semantic index the fallback attribute was written with.
filestringThe source file to attribute the warning to; empty when unknown.