diff options
| author | YaBulochka <157796093+YaBulochka@users.noreply.github.com> | 2026-11-23 05:43:31 +0300 |
|---|---|---|
| committer | YaBulochka <157796093+YaBulochka@users.noreply.github.com> | 2026-11-23 05:43:31 +0300 |
| commit | 16dc3fb7a08e0e900d0ce4de6fe539e9c9afe0e0 (patch) | |
| tree | 1dbfe6149eee6f611574ca445ec6c8ccc4833ef3 /docs/pso_cache.md | |
| parent | bb360f84d924df9759cd1eefa80c272c80118717 (diff) | |
Add a graphics user-signature describer
tools/psocache_usersig.py resolves a graphics PSO to the chunk records its
stage record names, decodes each 0x41 entry (kind, offset, key, count,
space/base/size) and each 0x42 slot word (SS, II, RR), and computes the
32-dword cost as constants + 2 tables and as constants + 1 table. --limit N
summarises the first N graphics PSOs, --entry N prints one, --json dumps the
same report. It reuses the cache parser from psocache_inspect and never
prints a hash.
docs/pso_cache.md maps the graphics records to descriptor tables, ranges and
32-bit constants with a confidence per claim, gives the measured fit numbers
and sketches how a CreateGraphicsPipelineState path would consume them.
tests/test_psocache_usersig.py builds a two-PSO cache that covers SRV, UAV,
CBV, Sampler, constants, a record that does not fit 32 dwords and extra
slots, and checks the summary, the entry listing, --limit, --json and the
error paths.
Diffstat (limited to 'docs/pso_cache.md')
| -rw-r--r-- | docs/pso_cache.md | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/docs/pso_cache.md b/docs/pso_cache.md index 43cadf906..1d3d448c5 100644 --- a/docs/pso_cache.md +++ b/docs/pso_cache.md | |||
| @@ -137,11 +137,14 @@ zero key and w4=0, with (SS,II) mostly (14,3), (2,0) or (10,0). They are not dec | |||
| 137 | 137 | ||
| 138 | ### Relation to the 32 user-data dwords | 138 | ### Relation to the 32 user-data dwords |
| 139 | 139 | ||
| 140 | A 1:1 packing into the 32-dword root-argument block is not supported by the counts. A compute PSO's chunk | 140 | Within one record the cost is small: a graphics chunk record carries 11 constant dwords and one or two tables, |
| 141 | record has a median of 17 slots (max 281), and 0x41 offsets reach 0x820 (2,080 bytes); 199,074 of 402,328 | 141 | 15 dwords under two dwords per table. The 32-dword block is therefore the union of the tables and constants, |
| 142 | offsets (49.5%) fit inside 128 bytes, but only 5,581 of 20,318 records have all of theirs inside. The record | 142 | not one dword per 0x41 entry (medium). The 0x41 offsets also exceed 128 bytes for half the entries (range |
| 143 | therefore describes a larger layout than the 32 dwords, and at most half of the 0x41 entries can be part of | 143 | 0..0x820, 49.5% at or below 0x78), which fits a per-table descriptor index better than a dword offset. The |
| 144 | that block (medium). No mapping from a slot to a user-SGPR index was confirmed. | 144 | records that do not fit are elsewhere: 4,519 of the 20,318 chunk records exceed 32 dwords under two dwords per |
| 145 | table (4,202 under one), and none of them is on the graphics path. Of those 4,519, 1,017 are named by a compute | ||
| 146 | PSO and the other 3,502 are not named by the graphics or compute records measured here. The extreme record has | ||
| 147 | 231 constant dwords; the largest slot count is 281. No mapping from a slot to a user-SGPR index was confirmed. | ||
| 145 | 148 | ||
| 146 | ### Which PSOs reference which records | 149 | ### Which PSOs reference which records |
| 147 | 150 | ||
| @@ -153,6 +156,41 @@ that block (medium). No mapping from a slot to a user-SGPR index was confirmed. | |||
| 153 | - A compute PSO's +8 and +0xC name 20- and 28-byte hash records, +0x10 a mixed record and +0x14 a chunk record | 156 | - A compute PSO's +8 and +0xC name 20- and 28-byte hash records, +0x10 a mixed record and +0x14 a chunk record |
| 154 | (2,693 references, 2,684 distinct records). | 157 | (2,693 references, 2,684 distinct records). |
| 155 | 158 | ||
| 159 | ## Graphics user signature | ||
| 160 | |||
| 161 | `tools/psocache_usersig.py` resolves a graphics PSO to its user data and prints, per chunk, the kind, register | ||
| 162 | space, base register, count, element size and the slot bytes. A PSO uses 3 to 5 distinct chunk records after | ||
| 163 | duplicates are removed (four on 23,625 of 25,471 PSOs); the eight layouts are shared across the corpus. | ||
| 164 | |||
| 165 | | Chunk or field | Reading | Confidence | | ||
| 166 | |---|---|---| | ||
| 167 | | 0x300 / 0x302 / 0x303 | descriptor entries | high that they are descriptors, medium for the SRV/CBV/UAV names | | ||
| 168 | | 0x002 | sampler entry, no slot | medium-high; none of the eight graphics records carries one | | ||
| 169 | | 0x401 | 32-bit constants, `a` = count | medium | | ||
| 170 | | 0x100 | unknown, not consumed | low | | ||
| 171 | | 0x41 offset (w2) | descriptor index inside the table, 8-byte granular | medium | | ||
| 172 | | 0x41 `b` | register space | medium | | ||
| 173 | | 0x41 `a` | base register for descriptors | medium | | ||
| 174 | | 0x41 size | element size 2, 4 or 8 | high | | ||
| 175 | | 0x41 key (w3) | unknown | low | | ||
| 176 | | 0x41 count (w4) | descriptor count | low | | ||
| 177 | | 0x42 SS | descriptor-table / root-parameter index | medium-high | | ||
| 178 | | 0x42 II | range type: 0 SRV, 1 UAV, 2 CBV, 3 sampler | medium-high | | ||
| 179 | | 0x42 RR | width, 1 normally and 2 on extra slots | low | | ||
| 180 | |||
| 181 | The kind-to-range-type correspondence is exact in the positional pairing: 23,047 of 23,049 0x300 entries sit on | ||
| 182 | II=0, 4,144 of 4,146 0x303 on II=1 and all 6,100 0x302 on II=2. One distinct SS is read as one | ||
| 183 | `D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE`, each (SS, II) pair as one `D3D12_DESCRIPTOR_RANGE`, and each 0x401 | ||
| 184 | as one `D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS`. That mapping is one-to-one for the measured graphics | ||
| 185 | records, but it is an inference: SS could be a register space and `b` the table index instead, and the cache | ||
| 186 | does not say whether a table costs one or two user-data dwords. | ||
| 187 | |||
| 188 | Under both table models all 25,471 graphics PSOs fit 32 dwords (15 dwords with two per table). A later | ||
| 189 | `CreateGraphicsPipelineState` path would group the slots by SS into tables, take II as the range type and the | ||
| 190 | 0x41 entries as the range contents, take each 0x401 as a constants parameter, and pack them in root-parameter | ||
| 191 | order. The record does not carry that order, so it would have to come from SS or from the shader's reads, which | ||
| 192 | is not measured. | ||
| 193 | |||
| 156 | ## What remains unknown | 194 | ## What remains unknown |
| 157 | 195 | ||
| 158 | - The meaning of the two header strings, the 0x48 value and the six 0x41 second-dword values. The SRV/CBV/UAV/sampler | 196 | - The meaning of the two header strings, the 0x48 value and the six 0x41 second-dword values. The SRV/CBV/UAV/sampler |
| @@ -192,3 +230,13 @@ described above, `--entry N` lists one meta index entry and `--limit N` bounds h | |||
| 192 | prints offsets, sizes and counts, names every field that does not fit instead of stopping, and exits 0 when the | 230 | prints offsets, sizes and counts, names every field that does not fit instead of stopping, and exits 0 when the |
| 193 | regions add up to the file size, 1 on a disagreement and 2 when the file is not a cache. `--json` prints the same | 231 | regions add up to the file size, 1 on a disagreement and 2 when the file is not a cache. `--json` prints the same |
| 194 | report as JSON. It does not decode a chunk payload, disassemble the code or verify a hash. | 232 | report as JSON. It does not decode a chunk payload, disassemble the code or verify a hash. |
| 233 | |||
| 234 | `tools/psocache_usersig.py` turns one or more graphics PSOs into the per-record user signature and the 32-dword | ||
| 235 | fit described above: | ||
| 236 | |||
| 237 | ``` | ||
| 238 | python -I tools/psocache_usersig.py <cache> [--entry N] [--limit N] [--json] | ||
| 239 | ``` | ||
| 240 | |||
| 241 | It reuses the parser from `tools/psocache_inspect.py`, prints the aggregate over the first `--limit` graphics PSOs | ||
| 242 | (all by default) or one PSO with `--entry N`, and never prints a hash. | ||