Reported by @Silliana in #1891 for PS_DeferredTextured and
checked here across all 2,989 *Deferred* pixel shaders (and all 1,703 six-target pixel shaders) in the
1.0.2.1 shaders.rpf corpus. Counts, target masks, numeric constants and format requirements only; no shader text or
disassembly.
Every DXBC container in shaders.rpf carries an OSG1 (and PSV0) output signature table with {register, semantic_index, component_type, mask, min_precision} per SV_TargetN output, and the unpacked FSSM header records the
exported target count as u32 at +0x0FC.
Across the 2,989 pixel shaders with Deferred in their container name (including 807 PS_DeferredTextured
variants: 380 five-target, 371 six-target and 56 three-target):
Targets declared (+0x0FC / OSG1) |
*Deferred* PS count |
PS_DeferredTextured count |
Corpus-wide PS count | OSG1 component type on all colour targets |
Per-target OSG1 write masks (SV_Target0..N-1) |
|---|---|---|---|---|---|
6 (SV_Target0..5) |
953 | 371 | 955 | float32 (ctype = 3, prec = 0) |
0xF, 0xF, 0xF, 0xF, 0x3, 0xF (mrt4 is 2-component RG) |
6 (SV_Target0..5) |
737 | 0 | 747 | float32 (ctype = 3, prec = 0) |
0xF, 0xF, 0xF, 0xF, 0xF, 0xF (all six RGBA) |
5 (SV_Target0..4) |
1,160 | 380 | 1,168 | float32 (ctype = 3, prec = 0) |
0xF, 0xF, 0xF, 0xF, 0x3 (mrt4 is 2-component RG) |
5 (SV_Target0..4) |
2 | 0 | 20 | float32 (ctype = 3, prec = 0) |
0xF, 0xF, 0xF, 0xF, 0xF |
3 (SV_Target0..2) |
125 | 56 | 248 | float32 (ctype = 3, prec = 0) |
0xF, 0xF, 0x3 (mrt2 is 2-component RG) |
other (0, 1, 2, 4 or 5 + SV_Depth) |
12 | 0 | — | float32 (3 single-target uint32) |
depth-only, discard, or reduced passes |
In the compiled RDNA2 code of every 5-target and 6-target PS_DeferredTextured variant, all exported targets
(mrt0..mrt4 or mrt0..mrt5) pack their outgoing register pairs with v_cvt_pkrtz_f16_f32 and export them with
exp mrtN, ... compr (EXP_FORMAT_FP16_ABGR).
Confirming #1891 against the 5-target (mrt0..mrt4) and 6-target (mrt0..mrt5) PS_DeferredTextured programs:
| Target | OSG1 mask |
Expected RTV format class | Channel layout and encoding in PS_DeferredTextured |
|---|---|---|---|
mrt0 (SV_Target0) |
0xF (RGBA) |
R8G8B8A8_UNORM |
Albedo + alpha/material byte: rgb holds base colour/albedo; in 6-target variants a packs a byte extracted from an integer register and scaled by 1.0 / 255.0 (0x3b808081). |
mrt1 (SV_Target1) |
0xF (RGBA) |
R8G8B8A8_UNORM |
Scalar in r + 24-bit octahedral world normal split across g, b, a: see section 3 below. |
mrt2 (SV_Target2) |
0xF (RGBA) |
R8G8B8A8_UNORM |
Square-root encoded material/specular channels: rgb values pass through hardware square root (sqrt(x), or sqrt(1.0 - sqrt(x)) on 6-target variants) before export so the deferred lighting pass squares them back; a holds an unencoded [0, 1] scalar (0.5 or a conditional select). |
mrt3 (SV_Target3) |
0xF (RGBA) |
R8G8B8A8_UNORM |
Flags + byte IDs: x and y carry clamped [0, 1] material/shading flags biased by a dither term (scale = 2.0 / 255.0 = 0x3c008081, offset = -1.0 / 255.0 = 0xbb808081); z and w carry two 8-bit integer IDs extracted with byte-to-float conversion (ubyte0, ubyte1) and multiplied by 1.0 / 255.0 (0x3b808081). |
mrt4 (SV_Target4) |
0x3 (RG, 2,113 deferred PS) or 0xF (RGBA, 739 deferred PS) |
Float format (e.g. R16G16_FLOAT) |
Motion vectors: unscaled signed float screen-space motion offset (xy, with zw disabled as off, off on the 2,113 mask = 0x3 variants). |
mrt5 (SV_Target5) |
0xF (RGBA, 1,690 deferred PS) |
R8G8B8A8_UNORM |
Sixth deferred target on the 6-target permutations (rgb material terms + clamped alpha). |
PS_DeferredTextured does not store a 3-channel (nx, ny, nz) normal in mrt1. Instead:
- The unit world normal
(nx, ny, nz)is divided by its$L_1$ norm$|nx| + |ny| + |nz|$ and octahedral-folded across the$nz \le 0$ hemisphere into$(u, v) \in [-1, 1]^2$ . - Both coordinates are quantized to 12-bit unsigned integers
$q_u, q_v \in [0, 4095]$ with the scale constant2047.5(0x44fff000):$$q_u = \operatorname{uint32}(u \cdot 2047.5 + 2047.5), \qquad q_v = \operatorname{uint32}(v \cdot 2047.5 + 2047.5)$$ - The two 12-bit integers are combined into one 24-bit word
$q = (q_v \ll 12) \mid q_u$ (q_uin bits[11:0],q_vin bits[23:12]). - The three bytes of
$q$ (ubyte0 = q[7:0],ubyte1 = q[15:8],ubyte2 = q[23:16]) are converted tof32, multiplied by1.0 / 255.0(0x3b808081), rounded toward zero tof16(v_cvt_pkrtz_f16_f32), and exported tomrt1.g,mrt1.b, andmrt1.a.
-
Declared signatures do not separate
UNORM8fromFLOAT16: becauseOSG1andPSV0declarefloat32on all sixSV_Target0..5outputs and the RDNA2 code usesexp mrtN ... compr(EXP_FORMAT_FP16_ABGR) for all of them, neither the DXBC signature nor the FSSM export opcode indicates thatmrt0..mrt3(andmrt5) areR8G8B8A8_UNORMwhilemrt4is a float motion target. -
Why binding
R16G16B16A16_FLOATtomrt1ormrt3corrupts the packed bytes:v_cvt_pkrtz_f16_f32roundsbyte * (1.0 / 255.0)toward zero (RTZ), producing anf16value slightly belowbyte / 255.0for most byte values1..254. Whenmrt1is bound asR8G8B8A8_UNORM, the render-target output stage quantizes with$\lfloor x \cdot 255.0 + 0.5 \rfloor$ and restores the exact byte0..255. Whenmrt1is bound as anf16float target and the lighting pass reconstructs the bytes by multiplying by255.0, the RTZ truncation drops 1 LSB onubyte1(bits[15:8], which straddles the 12-bit split between$q_u$ and$q_v$ ) andubyte2(bits[23:16]), shifting the reconstructed normal by whole octahedral steps and producing speckled lighting (#1891). - The runtime must always bind the PSO's declared
RTVFormats[](R8G8B8A8_UNORMfor the byte-packed G-buffer targets and a float format formrt4) and must never inferR16G16B16A16_FLOATfor all G-buffer attachments fromOSG1orexp ... compr.