diff options
| author | DadaCap <167002618+DadaCap@users.noreply.github.com> | 2026-11-28 12:41:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-28 12:41:59 +0100 |
| commit | feaaa13a66528a6525ff6bc4f0d8a8bef6442e25 (patch) | |
| tree | 78245010e0f7bfb99dcef9b27f9ad021d2321cea /docs | |
| parent | 23ccf1486e16dcabe35a80d4cfe7346d3d1624a2 (diff) | |
| parent | 7c2de8a936897b2322caf574c991746dfe732b01 (diff) | |
Merge pull request #1423 from GTAVIB4GTAVI/feat/library-code-base-pairs
pso_code_base_pairs: count PSOs by code-base stage (SHADER-CODEBASE-PAIRS)
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/boot.md | 2 | ||||
| -rw-r--r-- | docs/d3d12_vulkan.md | 24 | ||||
| -rw-r--r-- | docs/shader_library.md | 8 |
3 files changed, 26 insertions, 8 deletions
diff --git a/docs/boot.md b/docs/boot.md index bc11a2185..ecd0ddc37 100644 --- a/docs/boot.md +++ b/docs/boot.md | |||
| @@ -264,7 +264,7 @@ order. It maps each question to the event to look for; it does not answer them. | |||
| 264 | | 11 | `CheckFeatureSupport` answers | the call's `ok`/`failed` and the `[rt]` feature-id line; the answer itself is not logged yet | | 264 | | 11 | `CheckFeatureSupport` answers | the call's `ok`/`failed` and the `[rt]` feature-id line; the answer itself is not logged yet | |
| 265 | | 12 | Async compute / copy queues | queue creation and cross-queue fences | | 265 | | 12 | Async compute / copy queues | queue creation and cross-queue fences | |
| 266 | | 13 | 144-byte push constants | device creation `[rt]` line; `push_constants_need_fallback` when the device reports fewer | | 266 | | 13 | 144-byte push constants | device creation `[rt]` line; `push_constants_need_fallback` when the device reports fewer | |
| 267 | | 14 | Two code-base stages in one PSO | PSO creation log; the index metadata (`uses_code_base`) | | 267 | | 14 | Two code-base stages in one PSO | answered without a trace: the pipeline library pairs the stages, and `tools/pso_code_base_pairs.py` counts 0 of 25,471 (`uses_code_base` per stage comes from the index metadata) | |
| 268 | | 15 | `ExecuteIndirect` signatures | `CreateCommandSignature` and `ExecuteIndirect` calls | | 268 | | 15 | `ExecuteIndirect` signatures | `CreateCommandSignature` and `ExecuteIndirect` calls | |
| 269 | | 16 | UAV counters and typed buffer formats | UAV descs and V# format logs; formats outside `Gen.FORMATS` read 0 | | 269 | | 16 | UAV counters and typed buffer formats | UAV descs and V# format logs; formats outside `Gen.FORMATS` read 0 | |
| 270 | | 17 | Upload/readback resources reaching shaders | `CreateCommittedResource` heap types and the VB/IB/descriptor that points at one | | 270 | | 17 | Upload/readback resources reaching shaders | `CreateCommittedResource` heap types and the VB/IB/descriptor that points at one | |
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 85bee426b..3084bf06b 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md | |||
| @@ -5120,20 +5120,32 @@ contract, not a runtime bug: | |||
| 5120 | block is still under the 256-byte limit of common desktop GPUs, but above Vulkan's 128-byte minimum; the device | 5120 | block is still under the 256-byte limit of common desktop GPUs, but above Vulkan's 128-byte minimum; the device |
| 5121 | requirement must be checked. | 5121 | requirement must be checked. |
| 5122 | - A second option is a per-stage uniform/storage buffer for the code base, patched in at pipeline creation. That | 5122 | - A second option is a per-stage uniform/storage buffer for the code base, patched in at pipeline creation. That |
| 5123 | adds a descriptor binding and a load per `s_getpc`, but avoids growing push constants. Decide after measuring | 5123 | adds a descriptor binding and a load per `s_getpc`, but avoids growing push constants. Not needed for the 1.0.2.1 |
| 5124 | how many real PSOs have two code-base stages. | 5124 | package: measured over whole PSOs, none has two code-base stages (below). |
| 5125 | 5125 | ||
| 5126 | Measured per stage (all 26,503, `tools/feature_scan.py`): `s_getpc_b64` is kept to read code-embedded data in 54 | 5126 | Measured per stage (all 26,503, `tools/feature_scan.py`): `s_getpc_b64` is kept to read code-embedded data in 54 |
| 5127 | VS, 93 PS, 266 MS and 263 CS (0 GS); the 147 VS/PS match the translator's own note. Both stages of a VS+PS or | 5127 | VS, 93 PS, 266 MS and 263 CS (0 GS); the 147 VS/PS match the translator's own note. Both stages of a VS+PS or |
| 5128 | MS+PS pipeline can therefore need a code base. | 5128 | MS+PS pipeline can therefore need a code base. |
| 5129 | 5129 | ||
| 5130 | Measured per PSO (all 25,471 graphics records of the 1.0.2.1 pipeline library, `tools/pso_code_base_pairs.py`): | ||
| 5131 | **no PSO has two code-base stages.** The pipeline library names a program per stage slot, and a stage's | ||
| 5132 | resource-layout blob ends with the digest of the container its code came from, which is how a record's stage joins to | ||
| 5133 | that program's `uses_code_base` in the translation index ([shader_library.md](shader_library.md) §3). 25,027 records | ||
| 5134 | have no code-base stage and 444 have exactly one — 343 in MS, 60 in PS, 41 in VS — in a corpus whose slots are 13,383 | ||
| 5135 | VS+PS, 10,726 MS+PS, 1,336 MS, 24 VS and 2 VS+PS+slot 6. The 21 records left unknown (19 VS+PS, 2 with slot 6) have a | ||
| 5136 | stage whose program is not in the carve output, so its code base is unknown rather than absent. The per-stage library | ||
| 5137 | program counts there (38 VS, 46 PS, 260 MS, 263 CS) are lower than the corpus counts above: the library holds a | ||
| 5138 | second compiled form of 6,522 carved shaders, and a program can serve two stage slots. | ||
| 5139 | |||
| 5130 | **Measured:** across the GPU test fleet (Issue #166), desktop NVIDIA (Turing, Ampere, Ada, Blackwell: 256 bytes), desktop AMD (RDNA2: 256 bytes) and Apple Silicon (MoltenVK: 4096 bytes) all satisfy the 144-byte contract natively (`maxPushConstantsSize >= 144`). Intel Arc is not uniform: the earlier fleet entries report the 128-byte specification minimum (`maxPushConstantsSize == 128`) for Arc, but an Arc B580 (Battlemage) on Windows 11, driver 32.0.101.9175, reports 256 bytes (#166, @rtrexmass), so there D3D-14's fallback never engages. The 128 figure may be specific to another OS or driver (Mesa ANV on Linux is the guess; no Arc run on Linux that records the OS is cited here, and an ANV result would settle it). So does an integrated AMD RDNA2 GPU, a Radeon 680M on the Windows driver 22.40.84.06, so the minimum is not Intel-only. That figure follows the driver as well: a Radeon 610M reports 128 on 24.10.16.14 and 256 on 26.11.2 (#166). 128 bytes cannot fit the 16-byte tail (dwords 32–35: heap base and code base) inside push constants. The runtime detects `maxPushConstantsSize < 144` at device creation (`d3d12_vulkan_device.cpp`) and flags `push_constants_need_fallback` for the uniform-buffer fallback. | 5140 | **Measured:** across the GPU test fleet (Issue #166), desktop NVIDIA (Turing, Ampere, Ada, Blackwell: 256 bytes), desktop AMD (RDNA2: 256 bytes) and Apple Silicon (MoltenVK: 4096 bytes) all satisfy the 144-byte contract natively (`maxPushConstantsSize >= 144`). Intel Arc is not uniform: the earlier fleet entries report the 128-byte specification minimum (`maxPushConstantsSize == 128`) for Arc, but an Arc B580 (Battlemage) on Windows 11, driver 32.0.101.9175, reports 256 bytes (#166, @rtrexmass), so there D3D-14's fallback never engages. The 128 figure may be specific to another OS or driver (Mesa ANV on Linux is the guess; no Arc run on Linux that records the OS is cited here, and an ANV result would settle it). So does an integrated AMD RDNA2 GPU, a Radeon 680M on the Windows driver 22.40.84.06, so the minimum is not Intel-only. That figure follows the driver as well: a Radeon 610M reports 128 on 24.10.16.14 and 256 on 26.11.2 (#166). 128 bytes cannot fit the 16-byte tail (dwords 32–35: heap base and code base) inside push constants. The runtime detects `maxPushConstantsSize < 144` at device creation (`d3d12_vulkan_device.cpp`) and flags `push_constants_need_fallback` for the uniform-buffer fallback. |
| 5131 | **Open:** the exact count of such PSOs (the pairing is in the executable), and the minimum `maxPushConstantsSize` across target GPUs. If a GPU only | 5141 | **Open:** the minimum `maxPushConstantsSize` across target GPUs. The pair count above is measured, and zero, so the |
| 5142 | 168-byte block is not needed for this package. If a GPU only | ||
| 5132 | supports 128 bytes, the current 144-byte contract already fails; the layer needs a fallback (uniform buffer for the | 5143 | supports 128 bytes, the current 144-byte contract already fails; the layer needs a fallback (uniform buffer for the |
| 5133 | tail) regardless. | 5144 | tail) regardless. |
| 5134 | 5145 | ||
| 5135 | At run time, `CreateGraphicsPipelineState` refuses a pair where both stages read their code base, with a log, so | 5146 | At run time, `CreateGraphicsPipelineState` refuses a pair where both stages read their code base, with a log, so a |
| 5136 | the first boot measures the pair count. A device whose `maxPushConstantsSize` is below 144 has every PSO refused, | 5147 | pair the measurement missed still shows up on the first boot. A device whose `maxPushConstantsSize` is below 144 |
| 5148 | has every PSO refused, | ||
| 5137 | with the limit in the log, until the uniform-buffer tail exists. | 5149 | with the limit in the log, until the uniform-buffer tail exists. |
| 5138 | 5150 | ||
| 5139 | ### 5.3 Descriptor T#/S# parsing | 5151 | ### 5.3 Descriptor T#/S# parsing |
| @@ -5352,7 +5364,7 @@ nothing is copied from their trees. | |||
| 5352 | | 11 | What should `CheckFeatureSupport` answer for UMA, resource binding tier, mesh tier, RT tier? | **Implemented** (D3D-11). Reports truthful host architecture (discrete desktop GPU: non-UMA), ResourceBindingTier 3 (descriptor indexing / bindless support), 48-bit GPU virtual address support matching the arena, and maps `D3D12_FEATURE_FORMAT_SUPPORT` to Vulkan format properties plus multisample render-target/resolve support and one quality level per supported sample count. | | 5364 | | 11 | What should `CheckFeatureSupport` answer for UMA, resource binding tier, mesh tier, RT tier? | **Implemented** (D3D-11). Reports truthful host architecture (discrete desktop GPU: non-UMA), ResourceBindingTier 3 (descriptor indexing / bindless support), 48-bit GPU virtual address support matching the arena, and maps `D3D12_FEATURE_FORMAT_SUPPORT` to Vulkan format properties plus multisample render-target/resolve support and one quality level per supported sample count. | |
| 5353 | | 12 | Does the game rely on async compute or copy queues for correctness? | Trace queue creation and cross-queue fences. If only performance, serialize on one queue for boot. | | 5365 | | 12 | Does the game rely on async compute or copy queues for correctness? | Trace queue creation and cross-queue fences. If only performance, serialize on one queue for boot. | |
| 5354 | | 13 | Is 144 bytes of push constants available on all target GPUs? | **Resolved / Measured** (D3D-14). Checked at device creation in `runtime/shims/d3d12_vulkan_device.cpp`. Measured across the test fleet (#166): NVIDIA (256 B), desktop AMD (256 B), and Apple M1/MoltenVK (4096 B) satisfy 144 B natively. A Radeon 680M on the Windows driver 22.40.84.06 and the earlier Intel Arc entries expose only the core minimum 128 B (`maxPushConstantsSize == 128`), but an Arc B580 on Windows 11 (driver 32.0.101.9175) reports 256 B (#166), so the 128 B figure for Arc depends on the OS or driver; an Arc result on Linux (Mesa ANV) would settle which side it is. `d3d12_vulkan_device_test` accepts either answer and checks that the fallback flag matches it. Below 144 B, the device logs a warning and marks `push_constants_need_fallback`, routing the 16-byte tail (dwords 32..35: heap base and code base) to a uniform-buffer fallback. | | 5366 | | 13 | Is 144 bytes of push constants available on all target GPUs? | **Resolved / Measured** (D3D-14). Checked at device creation in `runtime/shims/d3d12_vulkan_device.cpp`. Measured across the test fleet (#166): NVIDIA (256 B), desktop AMD (256 B), and Apple M1/MoltenVK (4096 B) satisfy 144 B natively. A Radeon 680M on the Windows driver 22.40.84.06 and the earlier Intel Arc entries expose only the core minimum 128 B (`maxPushConstantsSize == 128`), but an Arc B580 on Windows 11 (driver 32.0.101.9175) reports 256 B (#166), so the 128 B figure for Arc depends on the OS or driver; an Arc result on Linux (Mesa ANV) would settle which side it is. `d3d12_vulkan_device_test` accepts either answer and checks that the fallback flag matches it. Below 144 B, the device logs a warning and marks `push_constants_need_fallback`, routing the 16-byte tail (dwords 32..35: heap base and code base) to a uniform-buffer fallback. | |
| 5355 | | 14 | Are there PSOs with two code-base stages? | Count from the PSO/shader hash table and the index metadata. If yes, implement per-stage code-base slots (section 5.2). **Per stage, measured** (`tools/feature_scan.py`, `s_getpc_b64` kept for data rather than a far branch): 54 VS, 93 PS, 266 MS, 263 CS, 0 GS; the translator's `uses_code_base` gives the same counts (with LLVM 23 that needs #223, without which these 1,471 shaders are rejected). So VS+PS and MS+PS pipelines with two code-base stages are possible; whether any exists depends on which shaders a PSO pairs, which is in the executable, not in `shaders.rpf`. | | 5367 | | 14 | Are there PSOs with two code-base stages? | **No: 0 of 25,471**, measured per PSO (`tools/pso_code_base_pairs.py`, section 5.2). Per stage (`tools/feature_scan.py`, `s_getpc_b64` kept for data rather than a far branch): 54 VS, 93 PS, 266 MS, 263 CS, 0 GS; the translator's `uses_code_base` gives the same counts (with LLVM 23 that needs #223, without which these 1,471 shaders are rejected). The pairing is in `shaders.rpf` after all, in the pipeline library ([shader_library.md](shader_library.md) §3): each graphics record names a program per stage slot and a stage's resource-layout blob carries the digest of the container its code came from, which joins to the translation index. So one 144-byte block with one code base at dwords 34–35 is enough for this package; the per-stage slot stays a fallback, and the runtime's refusal of a PSO whose two stages both read the code base (section 3.2) can stand. | |
| 5356 | | 15 | Is `ExecuteIndirect` used with signatures Vulkan cannot express directly? | Trace `CreateCommandSignature` and `ExecuteIndirect`; implement simple signatures first, expand the complex ones with compute. The simple signatures are D3D-17 (#313). | | 5368 | | 15 | Is `ExecuteIndirect` used with signatures Vulkan cannot express directly? | Trace `CreateCommandSignature` and `ExecuteIndirect`; implement simple signatures first, expand the complex ones with compute. The simple signatures are D3D-17 (#313). | |
| 5357 | | 16 | Does the game use append/consume UAV counters or typed buffer formats the translator does not model? | **Shaders: answered** by `tools/feature_scan.py` over all 26,503 (1.0.2.1, disassembled with LLVM 21.1.8 for gfx1013; SHADER-65). **No append/consume counters:** none of the 445,394 PSV0 binding records is a structured UAV with a counter, and there is no `ds_append`/`ds_consume`/GDS instruction. Typed buffers are declared in 5,359 shaders as SRVs (17,328 records) and in 2,177 as UAVs (4,005). **MTBUF** (format in the instruction): 52,890 loads in 10,278 shaders, all in five formats the translator decodes (`16_16_SNORM` 24,881, `8_8_8_8_UNORM` 19,835, `8_8_8_8_UINT` 5,099, `2_10_10_10_UNORM` 2,648, `16_16_16_16_UINT` 427), and no MTBUF store. **MUBUF** `buffer_*_format_*` (format from V# word 3): 90,316 accesses (84,908 loads, 5,408 stores) in 11,591 shaders; word 3 comes from a scalar load in 88,924 of them, is computed in 1,390, and is a literal in 2 (FORMAT 0, INVALID, which reads 0 on the hardware and in the translator). So the shaders fix no MUBUF format: the descriptors the executable writes decide it. Still open: which formats those descriptors carry; the runtime can log a V# format outside `Gen.FORMATS` (those read 0 today) when the descriptor is created or copied. Trace UAV descs and shader `buffer_*` ops; extend the translator/runtime together. **Runtime side done, console side open:** the layer writes typed buffer V#s and a counter V# (a hypothesis for where the shader finds it, section 3.4 "Buffer UAVs"); whether the game uses either is for the trace. | | 5369 | | 16 | Does the game use append/consume UAV counters or typed buffer formats the translator does not model? | **Shaders: answered** by `tools/feature_scan.py` over all 26,503 (1.0.2.1, disassembled with LLVM 21.1.8 for gfx1013; SHADER-65). **No append/consume counters:** none of the 445,394 PSV0 binding records is a structured UAV with a counter, and there is no `ds_append`/`ds_consume`/GDS instruction. Typed buffers are declared in 5,359 shaders as SRVs (17,328 records) and in 2,177 as UAVs (4,005). **MTBUF** (format in the instruction): 52,890 loads in 10,278 shaders, all in five formats the translator decodes (`16_16_SNORM` 24,881, `8_8_8_8_UNORM` 19,835, `8_8_8_8_UINT` 5,099, `2_10_10_10_UNORM` 2,648, `16_16_16_16_UINT` 427), and no MTBUF store. **MUBUF** `buffer_*_format_*` (format from V# word 3): 90,316 accesses (84,908 loads, 5,408 stores) in 11,591 shaders; word 3 comes from a scalar load in 88,924 of them, is computed in 1,390, and is a literal in 2 (FORMAT 0, INVALID, which reads 0 on the hardware and in the translator). So the shaders fix no MUBUF format: the descriptors the executable writes decide it. Still open: which formats those descriptors carry; the runtime can log a V# format outside `Gen.FORMATS` (those read 0 today) when the descriptor is created or copied. Trace UAV descs and shader `buffer_*` ops; extend the translator/runtime together. **Runtime side done, console side open:** the layer writes typed buffer V#s and a counter V# (a hypothesis for where the shader finds it, section 3.4 "Buffer UAVs"); whether the game uses either is for the trace. | |
| 5358 | | 17 | Do upload/readback resources ever reach shaders (as vertex/index buffers or descriptors), and does the `-heap_base` bias work for them? | Trace `CreateCommittedResource` heap types and every VB/IB/descriptor that points at an upload resource; test the bias with a synthetic draw. | | 5370 | | 17 | Do upload/readback resources ever reach shaders (as vertex/index buffers or descriptors), and does the `-heap_base` bias work for them? | Trace `CreateCommittedResource` heap types and every VB/IB/descriptor that points at an upload resource; test the bias with a synthetic draw. | |
diff --git a/docs/shader_library.md b/docs/shader_library.md index 140fe9a71..19b45e5ed 100644 --- a/docs/shader_library.md +++ b/docs/shader_library.md | |||
| @@ -167,6 +167,9 @@ python -I tools/rdna2spirv.py <work>/library/disasm --out <work>/library/spirv | |||
| 167 | * `--stages` limits the output to some stages. | 167 | * `--stages` limits the output to some stages. |
| 168 | * `--compute-hashes FILE` instead writes only the compute programs whose code has one of the SHA-256 digests listed | 168 | * `--compute-hashes FILE` instead writes only the compute programs whose code has one of the SHA-256 digests listed |
| 169 | in `FILE` (`fspx_code_sha256`), with every state they are used with. A digest no compute program has is an error. | 169 | in `FILE` (`fspx_code_sha256`), with every state they are used with. A digest no compute program has is an error. |
| 170 | * `tools/pso_code_base_pairs.py` reads the same library, in either form, and joins each graphics record's stage to | ||
| 171 | the translation index through that stage's source digest (§3). It counts whole PSOs by the `uses_code_base` of | ||
| 172 | their stages: counts only, no name or code. §6 and [d3d12_vulkan.md](d3d12_vulkan.md) §5.2 report what it says. | ||
| 170 | 173 | ||
| 171 | The output is game data and must stay in your work folder. `tests/test_shader_library.py` builds libraries and | 174 | The output is game data and must stay in your work folder. `tests/test_shader_library.py` builds libraries and |
| 172 | archives by hand and covers the header, both tables, the size checks, the search in an archive and the digest | 175 | archives by hand and covers the header, both tables, the size checks, the search in an archive and the digest |
| @@ -265,7 +268,10 @@ None of the programs has been run on a GPU. | |||
| 265 | 268 | ||
| 266 | * **Pipeline pairing is in the package.** [d3d12_vulkan.md](d3d12_vulkan.md) question 14 asks whether a PSO pairs | 269 | * **Pipeline pairing is in the package.** [d3d12_vulkan.md](d3d12_vulkan.md) question 14 asks whether a PSO pairs |
| 267 | two code-base stages, and says the pairing is in the executable. The graphics records give it for 25,471 | 270 | two code-base stages, and says the pairing is in the executable. The graphics records give it for 25,471 |
| 268 | pipelines: each names its VS or MS and its PS. Each source can be found through §3. | 271 | pipelines: each names its VS or MS and its PS, and each source can be found through §3. `tools/pso_code_base_pairs.py` |
| 272 | joins that to the FSSM translation index and counts the result: **no PSO in 1.0.2.1 has two code-base stages**. | ||
| 273 | 25,027 have none, 444 exactly one (343 MS, 60 PS, 41 VS), and 21 stay unknown because a stage's program is not in | ||
| 274 | the carve output. So the one code base in the 144-byte push-constant block is enough for this package. | ||
| 269 | * **A second compiled form of 6,522 shaders.** The pipeline builds differ from the FSSM code. Which form the game | 275 | * **A second compiled form of 6,522 shaders.** The pipeline builds differ from the FSSM code. Which form the game |
| 270 | runs for a pipeline is not measured here (that needs the executable). Either way, a translated pipeline build can | 276 | runs for a pipeline is not measured here (that needs the executable). Either way, a translated pipeline build can |
| 271 | be compared with the translated FSSM shader of the same pipeline. | 277 | be compared with the translated FSSM shader of the same pipeline. |