GTA VI mesh shaders: the root signature is inside FSSM (no RTS0 needed), format + validation #54

Closed
opened 2026-11-26 06:08:36 +00:00 by github-bot · 1 comment
Owner

@⁠bymsec on GitHub · 2026-11-21 21:36 UTC · original

Your notes say the 8,765 GTA VI mesh programs stop at the first resource load because there is no RTS0 chunk, so the user-SGPR resources (s16+) cannot be bound. We hit the same wall in a separate GTA VI tooling project and found that the root-signature layout is embedded in the FSSM blob itself. Sharing it in case it unblocks you.

All offsets are in the FSSM blob (the zlib stream inside XDAT/XBCH, starting with "FSSM"), measured on the Xbox Series 1.0.2.1 build.

Header fields

  • 0xD6 (u8): user SGPR count. It is fixed per root signature, not per shader; even a resource-free PS has 17.
  • 0xF8 (u32): number of root-signature entries n.
  • 0xF0: points 4 bytes into the LAST entry, so the first entry starts at [0xF0] - 4 - 20*(n-1).
  • 0xE8 = 0xDEADBEEF when there is no table.
  • 0xD4 bit 5: wave32 (1) / wave64 (0).

Entry = 5 dwords: kind, offset (in dwords), count, register, loc, with loc = (rootParam << 8) | userSgpr.

kind meaning
0 root constants (b-register, count dwords)
1 root descriptor: 64-bit GPU address in 2 SGPRs; the code builds the V# itself as [lo, hi | 0x10000, 0xFFFFFFFF, 0x11014FAC]
3 descriptor in a table: T# (8 dwords) at table + offset*4
4 static sampler: the S# is a literal in the code, not in memory
5 ResourceDescriptorHeap base (bindless)
6 SamplerDescriptorHeap base

Bindless images are read as heap[index << 5] (32-byte stride).

Merged/NGG stages (mesh, geometry, some VS): user data starts at s8; s0–s7 are system. So "s16 and up" in a mesh shader is root parameter data at user SGPR index 8+.

Validation

  • We traced every s_load / s_buffer_load / buffer_load / image op back to its user SGPR plus offset over all 26,502 shaders.
  • Every traced table access hits exactly one entry: 0 ambiguous, 0 missing.
  • About 93% of resource operands were traced statically.

End-to-end check

  • MS_VS_TransformTerrainNormalTint and MST_DS_TerrainTransform (the real terrain path) were translated to compute and run on D3D12 with the bound resources.
  • Output positions and topology match a CPU decode of the same terrain tile exactly: 24,035 / 24,035 triangles, max distance 0.
  • MS ABI notes that agree with yours: v5 = workgroup*128 + thread (every MS starts with readfirstlane(v5) >> 7), s3[27:24] = wave id, s_sendmsg 9 with m0 = verts | prims << 12.

Happy to share code or answer questions. In return: if anyone finds anything about the BCPack bitstream (TTPF pool chunk codec 1–7 = BC1–BC7, 8 = zlib), we would love to hear it.

**@⁠bymsec** on GitHub · 2026-11-21 21:36 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/54) Your notes say the 8,765 GTA VI mesh programs stop at the first resource load because there is no RTS0 chunk, so the user-SGPR resources (s16+) cannot be bound. We hit the same wall in a separate GTA VI tooling project and found that the root-signature layout is embedded in the FSSM blob itself. Sharing it in case it unblocks you. All offsets are in the FSSM blob (the zlib stream inside XDAT/XBCH, starting with "FSSM"), measured on the Xbox Series 1.0.2.1 build. **Header fields** - `0xD6` (u8): user SGPR count. It is fixed per root signature, not per shader; even a resource-free PS has 17. - `0xF8` (u32): number of root-signature entries `n`. - `0xF0`: points 4 bytes into the LAST entry, so the first entry starts at `[0xF0] - 4 - 20*(n-1)`. - `0xE8` = `0xDEADBEEF` when there is no table. - `0xD4` bit 5: wave32 (1) / wave64 (0). **Entry = 5 dwords:** `kind, offset (in dwords), count, register, loc`, with `loc = (rootParam << 8) | userSgpr`. | kind | meaning | |---|---| | 0 | root constants (b-register, `count` dwords) | | 1 | root descriptor: 64-bit GPU address in 2 SGPRs; the code builds the V# itself as `[lo, hi \| 0x10000, 0xFFFFFFFF, 0x11014FAC]` | | 3 | descriptor in a table: T# (8 dwords) at `table + offset*4` | | 4 | static sampler: the S# is a literal in the code, not in memory | | 5 | ResourceDescriptorHeap base (bindless) | | 6 | SamplerDescriptorHeap base | Bindless images are read as `heap[index << 5]` (32-byte stride). **Merged/NGG stages (mesh, geometry, some VS):** user data starts at **s8**; s0–s7 are system. So "s16 and up" in a mesh shader is root parameter data at user SGPR index 8+. **Validation** - We traced every s_load / s_buffer_load / buffer_load / image op back to its user SGPR plus offset over all 26,502 shaders. - Every traced table access hits exactly one entry: 0 ambiguous, 0 missing. - About 93% of resource operands were traced statically. **End-to-end check** - MS_VS_TransformTerrainNormalTint and MST_DS_TerrainTransform (the real terrain path) were translated to compute and run on D3D12 with the bound resources. - Output positions and topology match a CPU decode of the same terrain tile exactly: 24,035 / 24,035 triangles, max distance 0. - MS ABI notes that agree with yours: v5 = workgroup*128 + thread (every MS starts with readfirstlane(v5) >> 7), s3[27:24] = wave id, s_sendmsg 9 with m0 = verts | prims << 12. Happy to share code or answer questions. In return: if anyone finds anything about the BCPack bitstream (TTPF pool chunk codec 1–7 = BC1–BC7, 8 = zlib), we would love to hear it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:08:36 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 13:35 UTC · original

Thanks for sharing this! Title-specific formats like GTA VI's FSSM layout are out of scope for this repo, so I'm closing this.

**@⁠omonkeyz** on GitHub · 2026-11-22 13:35 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/54#issuecomment-7079923101) Thanks for sharing this! Title-specific formats like GTA VI's FSSM layout are out of scope for this repo, so I'm closing this.
This discussion has been locked. Commenting is limited to contributors.
No description provided.