upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorubiquitarianism <283527159+ubiquitarianism@users.noreply.github.com>2026-11-23 21:27:26 -0500
committerGitHub <noreply@github.com>2026-11-23 21:27:26 -0500
commite6ca5cb29ede877fa0b2bb6666ae1e3f10e3b2df (patch)
tree3683df0d08f1ea45200a16550bfe0b5c9ed51222 /docs
parent091aa263359e5c05d148dd18af35cda6226ee384 (diff)
parent642880a217f4fbed23b4de2746e27ab9834e3a0b (diff)
Merge pull request #19 from moffington/contrib/pipeline-library-upstream
Add slot-67 pipeline-library shader build and runtime loading
Diffstat (limited to 'docs')
-rw-r--r--docs/fspx.md15
-rw-r--r--docs/shader_library.md19
2 files changed, 29 insertions, 5 deletions
diff --git a/docs/fspx.md b/docs/fspx.md
index 7550a2cc8..a603545e9 100644
--- a/docs/fspx.md
+++ b/docs/fspx.md
@@ -183,9 +183,18 @@ The step is redone as a whole when the DLL, the unpacking or translating tools,
183flags change (`fspx_build.json`, written last); it never makes the game's shaders translate again. A package without 183flags change (`fspx_build.json`, written last); it never makes the game's shaders translate again. A package without
184the DLL skips it. 184the DLL skips it.
185 185
186**Run time.** `ShaderLibrary::load(dir)` (`runtime/src/shader_library.h`) reads `<dir>/index.json` and then, when it 186The executable calls slot 67 itself, for the compute pipelines of the pipeline library in `shaders.rpf`
187is there, `<dir>/fspx/index.json`, whose entries are named `fspx/<name>`. A missing or unreadable `fspx/index.json` 187([shader_library.md](shader_library.md)): a compute record's state blob, blob, program and layout blob have the sizes
188leaves the main index loaded. Entries are found by `fssm_sha256` or by `fspx_code_sha256`, in two separate tables. 188and shapes of kinds 0, 1, 6 and 7. The next step of the same stage, `library_shaders`, unpacks those programs with
189`tools/shader_library.py --stages cs` (which writes each one's `.code` and its record's state as `.state`) and
190translates them into `<work>/shaders/spirv/library/`, with the same keys, the same clash check and its own
191`library_build.json`.
192
193**Run time.** `ShaderLibrary::load(dir)` (`runtime/src/shader_library.h`) reads `<dir>/index.json` and then, when they
194are there, `<dir>/fspx/index.json`, `<dir>/bvh/index.json` ([embedded_shaders.md](embedded_shaders.md)), and
195`<dir>/library/index.json`, whose entries are named `fspx/<name>`, `bvh/<name>`, and `library/<name>`. A missing or
196unreadable one leaves the others loaded. Entries are found by `fssm_sha256` or by `fspx_code_sha256`, in two separate
197tables.
189`compute_program()` decides what a compute PSO's bytecode is looked up by: 198`compute_program()` decides what a compute PSO's bytecode is looked up by:
190 199
191| Bytecode | Key | Who passes it | 200| Bytecode | Key | Who passes it |
diff --git a/docs/shader_library.md b/docs/shader_library.md
index 891a740c1..09a1997a9 100644
--- a/docs/shader_library.md
+++ b/docs/shader_library.md
@@ -117,7 +117,10 @@ python -I tools/rdna2spirv.py <work>/library/disasm --out <work>/library/spirv
117``` 117```
118 118
119* It writes `fspx/<name>.code` and `fspx/<name>.json`, the layout `fspx_unpack.py` writes and `rdna2spirv.py` 119* It writes `fspx/<name>.code` and `fspx/<name>.json`, the layout `fspx_unpack.py` writes and `rdna2spirv.py`
120 reads (`native_blob`, `cs_dispatch_state`). It also writes `index.json` with each program's stage, and 120 reads (`native_blob`, `cs_dispatch_state`). A compute program also gets `fspx/<name>.state`, its record's state
121 blob (FSPX kind 0) as it is, whose SHA-256 is the index's `fspx_state_sha256`; in the 1.0.2.1 `shaders.rpf` library,
122 every compute program has one distinct state-blob index across `library.json`'s `compute` table (2,684 programs,
123 2,693 records). It also writes `index.json` with each program's stage, and
121 `library.json` with the header and both pipeline tables, stage to program name. Programs are named 124 `library.json` with the header and both pipeline tables, stage to program name. Programs are named
122 `lib_<stage>_<index>`. 125 `lib_<stage>_<index>`.
123* `--disasm` writes `disasm/<name>.s` for the code after the prologue, as `fspx_unpack.py --disasm` does. 126* `--disasm` writes `disasm/<name>.s` for the code after the prologue, as `fspx_unpack.py --disasm` does.
@@ -129,7 +132,19 @@ python -I tools/rdna2spirv.py <work>/library/disasm --out <work>/library/spirv
129 132
130The output is game data and must stay in your work folder. `tests/test_shader_library.py` builds libraries and 133The output is game data and must stay in your work folder. `tests/test_shader_library.py` builds libraries and
131archives by hand and covers the header, both tables, the size checks, the search in an archive and the digest 134archives by hand and covers the header, both tables, the size checks, the search in an archive and the digest
132walk. It also checks the `--carve` copy and the translator's reads of the compute sidecar. 135walk. It also checks the `--carve` copy, the translator's reads of the compute sidecar and the compute `.state`.
136
137**In the build.** `make_game.py`'s `shaders` stage runs this for the compute stage after the BVH step
138(`library_shaders`): `--stages cs --disasm --carve` into `<work>/shaders/library`, then `translate()` shards
139`rdna2spirv.py` across `--jobs` and merges into `<work>/shaders/spirv/library` with the stage's `--wave64-emulate`
140and fallback flags. The runtime's shader library
141reads that index next to `fspx/` and finds its entries by `fspx_code_sha256` and `fspx_state_sha256`
142([fspx.md](fspx.md), "Build and run-time lookup"). That is how the executable creates these pipelines: it reads the
143library through DirectStorage zlib requests and passes each compute record's four parts to Xbox device slot 67,
144`DeserializeComputePipelineStateX`, as kinds 0, 1, 6 and 7, so the code key is the program's bytes as the table gives
145them and the state key is the record's state blob. The step is redone as a whole when `shaders.rpf`, the tools,
146`llvm-mc`, the wave64 mode or the flags change (`library_build.json`, written last), and a clash of both keys between
147different modules fails it, as for the FSPX step. Graphics pipelines are not translated by the build.
133 148
134## 5. Translation 149## 5. Translation
135 150