Class ResourceArrayBindings
- Namespace
- ShadowDusk.Core.Reflection
- Assembly
- ShadowDusk.Core.dll
Collapses the per-element resource bindings a Shader Model 5 RDEF carries for an ARRAY
of textures or samplers into the one binding per array that Shader Model 4 reflection reports,
which is the view real mgfxc builds its DirectX_11 parameter table from (issue #339).
Measured 2026-10-02 with d3dcompiler_47 (/Gec /O3, mgfxc's own flags) on
Texture2D Tex[2] : register(t0) sampled as Tex[0] and Tex[1]:
ps_4_0(andps_4_0_level_9_3): ONE bindingTex, BindPoint 0, BindCount 2. The BindPoint is the array's base register and the BindCount its declared size whichever elements are used:Tex[1]alone still reflectsText0 count 2, andTex[0] + Tex[3]of a 4-array reflectsText0 count 4. An array declared atregister(t1)reflectsText1 count 2 after the texture at t0.ps_5_0: one binding PER ELEMENT, named with the index, each BindCount 1:Tex[0]t0,Tex[1]t1 (andTex[1]t1 alone when only element 1 is read). vkd3d-shader's DXBC follows the same convention, andD3DReflectreports these records as they are stored.
mgfxc compiles a DirectX_11 shader at the model the author wrote (ps_4_0 in
every MonoGame template), walks the texture bindings and makes one sampler record per binding
whose parameter is named by the binding, so a texture array is ONE effect parameter
(Tex) with ONE record at the array's base slot (3.8.4.1 and 3.8.5 alike). ShadowDusk
compiles DirectX 11 at Shader Model 5 (Vkd3dShaderCompiler / D3DCompileRequest),
so its RDEF has the per-element records; before this collapse they became parameters
Tex[0], Tex[1], ... that no author ever names (effect.Parameters["Tex"]
was null). The collapse reproduces the Shader Model 4 view from the Shader Model 5 records:
the base name, the base slot (slot - index, the same for every element), and the
element count as ArrayLength. Non-array bindings pass through untouched, so no byte of
an array-free effect moves. The DXIL reflector (DirectX 12) already reports an array this way
(BindCount), so the two DirectX extractors now agree.
public static class ResourceArrayBindings
- Inheritance
-
ResourceArrayBindings
- Inherited Members
Methods
Collapse(ReflectedEffect)
Returns effect with every run of per-element texture and sampler
bindings collapsed into one binding per array; the same instance when it has none.
public static ReflectedEffect Collapse(ReflectedEffect effect)
Parameters
effectReflectedEffectA reflected shader stage (typically RdefReader output).
Returns
IsElement(string)
True when name is spelled as an array element (Name[i]).
public static bool IsElement(string name)
Parameters
namestring