upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authoriFeyz <62035583+iFeyz@users.noreply.github.com>2026-11-24 16:45:13 +0100
committeriFeyz <62035583+iFeyz@users.noreply.github.com>2026-11-24 16:50:49 +0100
commit5fdd6abbc07a0b2e4120944b4e624e3a70ddb76e (patch)
tree22a6ccd466c4e735b5d78e1912d55d3c0a2e8a2a /runtime/src
parent1504c1af63aeab49fb451ee42d3d051b29d4c976 (diff)
D3D-448-GRAPHICS: graphics root arguments in the console layout, mesh shaders through a window
The graphics bind point laid root arguments out with pack() (from s0, two dwords per table), while the console starts them at s8 for VS/PS/GS with one dword per table (the corpus census, and the retail frame loop reading its tables at s8..s10). Compute already took the console layout (D3D-448); graphics waited because a mesh shader (s16) and a pixel shader (s8) share one push-constant block. - translator: user_data_dword() - a mesh shader loads s16..s31 from push dwords 8..23, s8..s15 as 0, s0..s7 unchanged, so root dword k is push dword 8 + k for every graphics stage; index.json records the window as "root_window" on mesh shaders. VS/PS/GS/CS are unchanged. - runtime: CreateRootSignature lays graphics out with pack_stage(Stage::Vertex) and checks Stage::Mesh (mesh_ok); a table is one dword at both bind points; DispatchMesh with a signature past the 16-dword mesh window invalidates the list; a mesh PSO whose mesh shader has no root_window (translated before) is refused with a log line. - fixtures: the GLSL stand-ins read the root arguments at push dword 8 + k; the M1.5/M2/M3 asm read their tables as one dword from s8. - tests: tests/semantic/test_ms_root_window.py (MeshEXT and --mesh-compute on the CPU interpreter), graphics-window cases in root_signature_test, the two refusals in d3d12_mesh_test. - docs: d3d12_vulkan.md 3.5, design.md user-data row.
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/root_signature.h7
-rw-r--r--runtime/src/shader_library.h9
2 files changed, 14 insertions, 2 deletions
diff --git a/runtime/src/root_signature.h b/runtime/src/root_signature.h
index 376962940..d1b8e38b4 100644
--- a/runtime/src/root_signature.h
+++ b/runtime/src/root_signature.h
@@ -129,8 +129,11 @@ constexpr uint32_t kMaxD3d12Cost = 64;
129// in this layout equals the program's RSRC2 USER_SGPR count in 29 of 29, and the programs read the tables and 129// in this layout equals the program's RSRC2 USER_SGPR count in 29 of 29, and the programs read the tables and
130// root CBVs at exactly these SGPRs (tools/rootsig_census.py --disasm). The game's compute census agrees (lowest 130// root CBVs at exactly these SGPRs (tools/rootsig_census.py --disasm). The game's compute census agrees (lowest
131// pointer s4, one-dword tables). 131// pointer s4, one-dword tables).
132// - vertex/pixel/geometry s8 and mesh s16: a hypothesis from the corpus census only (lowest pointer SGPR per stage); 132// - vertex/pixel/geometry s8 and mesh s16: from the corpus census (lowest pointer SGPR per stage) and one live
133// no signature confirms them, and visibility is not modelled (every parameter takes its place in every stage). 133// retail frame (a VS and PS reading their tables at s8, s9, s10; issue #14, comment 7131556366); no serialized
134// signature confirms them yet, and visibility is not modelled (every parameter takes its place in every stage).
135// The graphics bind point uses Stage::Vertex; a mesh shader reads the same dwords through its translator-side
136// window (docs/d3d12_vulkan.md section 3.5).
134// A parameter that does not fit goes to the console's spill array behind s[0:1] (compute, section 7) together with 137// A parameter that does not fit goes to the console's spill array behind s[0:1] (compute, section 7) together with
135// every parameter after it; that array is not modelled, so such a signature is refused, never truncated. 138// every parameter after it; that array is not modelled, so such a signature is refused, never truncated.
136enum class Stage : uint32_t { Vertex = 0, Pixel = 1, Geometry = 2, Compute = 3, Mesh = 4 }; 139enum class Stage : uint32_t { Vertex = 0, Pixel = 1, Geometry = 2, Compute = 3, Mesh = 4 };
diff --git a/runtime/src/shader_library.h b/runtime/src/shader_library.h
index 9f752317e..9cfb902ef 100644
--- a/runtime/src/shader_library.h
+++ b/runtime/src/shader_library.h
@@ -827,6 +827,9 @@ struct ShaderEntry {
827 // subgroup size. Empty for a native translation. 827 // subgroup size. Empty for a native translation.
828 std::string wave64_exchange; 828 std::string wave64_exchange;
829 bool emulated() const { return wave64_exchange == "workgroup"; } 829 bool emulated() const { return wave64_exchange == "workgroup"; }
830 // Mesh shaders: the index's "root_window" is {"sgpr": 16, "dword": 8}, so the module reads its root arguments
831 // from the graphics window (push dword 8 = root dword 0, D3D-448 follow-up). False for one translated before it.
832 bool graphics_root_window = false;
830 std::vector<SignatureElement> input_signature; // vertex shaders: what the input layout must feed 833 std::vector<SignatureElement> input_signature; // vertex shaders: what the input layout must feed
831 std::vector<std::uint32_t> inputs; // pixel shaders: input locations declared 834 std::vector<std::uint32_t> inputs; // pixel shaders: input locations declared
832 std::vector<std::uint32_t> outputs; // pixel/vertex shaders: output locations written 835 std::vector<std::uint32_t> outputs; // pixel/vertex shaders: output locations written
@@ -1026,6 +1029,12 @@ private:
1026 e.subgroup_size = u32(g); 1029 e.subgroup_size = u32(g);
1027 if (const Json* x = meta.find("wave64_exchange"); x && x->kind == Json::Kind::string) 1030 if (const Json* x = meta.find("wave64_exchange"); x && x->kind == Json::Kind::string)
1028 e.wave64_exchange = x->string; 1031 e.wave64_exchange = x->string;
1032 if (const Json* r = meta.find("root_window"); r && r->kind == Json::Kind::object) {
1033 const Json* sgpr = r->find("sgpr");
1034 const Json* dword = r->find("dword");
1035 e.graphics_root_window = sgpr && dword && sgpr->kind == Json::Kind::number &&
1036 dword->kind == Json::Kind::number && u32(sgpr) == 16 && u32(dword) == 8;
1037 }
1029 if (const Json* s = meta.find("input_signature"); s && s->kind == Json::Kind::array) { 1038 if (const Json* s = meta.find("input_signature"); s && s->kind == Json::Kind::array) {
1030 for (const Json& item : s->array) { 1039 for (const Json& item : s->array) {
1031 SignatureElement element; 1040 SignatureElement element;