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

Closed
opened 2026-11-21 21:36:15 +00:00 by bymsec · 1 comment
bymsec commented 2026-11-21 21:36:15 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by bymsec on 2026-11-21T21:36:15Z.


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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6534686371 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/issues/54). Originally posted by [bymsec](https://github.com/bymsec) on 2026-11-21T21:36:15Z. --- 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.
omonkeyz commented 2026-11-22 13:35:46 +00:00 (Migrated from github.com)
Author

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-22T13:35:46Z.


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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7079923101 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/issues/54#issuecomment-7079923101). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-22T13:35:46Z. --- 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.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
omonkeyz/xbox-emulator#54
No description provided.