upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/test
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 22:03:46 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 22:03:51 -0500
commitd4f3e0bbc63bbd47c7b0afa762f0f22fed5a5a2e (patch)
tree0725672e4c136fc0f2f5bf6650ba473f42ef221a /runtime/test
parent9f82f136f68a84bafa745ff61eb6eebb01128654 (diff)
parentb07b9ecb09b47fa6496f01ad9d8fe87d205bd5d8 (diff)
Merge main (b07b9ecb0) into radv-import-pins
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test')
-rw-r--r--runtime/test/d3d12_mesh_test.cpp73
-rw-r--r--runtime/test/glsl/ms_draw.mesh5
-rw-r--r--runtime/test/glsl/ps_draw.frag2
-rw-r--r--runtime/test/glsl/ps_image_atomic.frag2
-rw-r--r--runtime/test/root_signature_test.cpp42
-rw-r--r--runtime/test/subgroup_size_test.cpp27
6 files changed, 141 insertions, 10 deletions
diff --git a/runtime/test/d3d12_mesh_test.cpp b/runtime/test/d3d12_mesh_test.cpp
index 2108cb1b7..e59414a01 100644
--- a/runtime/test/d3d12_mesh_test.cpp
+++ b/runtime/test/d3d12_mesh_test.cpp
@@ -113,16 +113,21 @@ int main(int argc, char** argv) {
113 EXPECT(device_status == vktest::DeviceStatus::ready); 113 EXPECT(device_status == vktest::DeviceStatus::ready);
114 114
115 const auto ms_program = fssm_program({0x4d530001, 0xbf810000}); 115 const auto ms_program = fssm_program({0x4d530001, 0xbf810000});
116 // The same mesh shader listed without "root_window": one translated before the graphics root window (D3D-448).
117 const auto ms_old_program = fssm_program({0x4d530002, 0xbf810000});
116 const auto ps_program = fssm_program({0x50530001, 0xbf810000}); 118 const auto ps_program = fssm_program({0x50530001, 0xbf810000});
117 const auto vs_program = fssm_program({0x56530002, 0xbf810000}); 119 const auto vs_program = fssm_program({0x56530002, 0xbf810000});
118 auto ms_container = shader_container(ms_program); 120 auto ms_container = shader_container(ms_program);
121 auto ms_old_container = shader_container(ms_old_program);
119 const auto ps_container = shader_container(ps_program); 122 const auto ps_container = shader_container(ps_program);
120 // The synthetic container has one part at 36, followed by its eight-byte header. 123 // The synthetic container has one part at 36, followed by its eight-byte header.
121 ms_container[36 + 8 + 2] = 13; // DXIL mesh shader kind 124 ms_container[36 + 8 + 2] = 13; // DXIL mesh shader kind
125 ms_old_container[36 + 8 + 2] = 13;
122 const auto vs_container = shader_container(vs_program); 126 const auto vs_container = shader_container(vs_program);
123 const auto library = std::filesystem::temp_directory_path() / "leonida_mesh_test"; 127 const auto library = std::filesystem::temp_directory_path() / "leonida_mesh_test";
124 std::filesystem::create_directories(library); 128 std::filesystem::create_directories(library);
125 std::filesystem::copy_file(LEONIDA_TEST_MS_SPV, library / "ms_draw.spv", std::filesystem::copy_options::overwrite_existing); 129 std::filesystem::copy_file(LEONIDA_TEST_MS_SPV, library / "ms_draw.spv", std::filesystem::copy_options::overwrite_existing);
130 std::filesystem::copy_file(LEONIDA_TEST_MS_SPV, library / "ms_old.spv", std::filesystem::copy_options::overwrite_existing);
126 std::filesystem::copy_file(LEONIDA_TEST_PS_SPV, library / "ps_draw.spv", std::filesystem::copy_options::overwrite_existing); 131 std::filesystem::copy_file(LEONIDA_TEST_PS_SPV, library / "ps_draw.spv", std::filesystem::copy_options::overwrite_existing);
127 std::filesystem::copy_file(LEONIDA_TEST_VS_FULLSCREEN_SPV, library / "vs_fullscreen.spv", 132 std::filesystem::copy_file(LEONIDA_TEST_VS_FULLSCREEN_SPV, library / "vs_fullscreen.spv",
128 std::filesystem::copy_options::overwrite_existing); 133 std::filesystem::copy_options::overwrite_existing);
@@ -130,6 +135,9 @@ int main(int argc, char** argv) {
130 std::ofstream index(library / "index.json", std::ios::binary); 135 std::ofstream index(library / "index.json", std::ios::binary);
131 index << "{\"ms_draw\": {\"stage\": \"ms\", \"fssm_sha256\": \"" << leonida::sha256_hex(ms_program) 136 index << "{\"ms_draw\": {\"stage\": \"ms\", \"fssm_sha256\": \"" << leonida::sha256_hex(ms_program)
132 << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"local_size\": [32, 1, 1], " 137 << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"local_size\": [32, 1, 1], "
138 "\"max_vertices\": 4, \"max_primitives\": 2, \"root_window\": {\"sgpr\": 16, \"dword\": 8}},\n"
139 " \"ms_old\": {\"stage\": \"ms\", \"fssm_sha256\": \"" << leonida::sha256_hex(ms_old_program)
140 << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"local_size\": [32, 1, 1], "
133 "\"max_vertices\": 4, \"max_primitives\": 2},\n" 141 "\"max_vertices\": 4, \"max_primitives\": 2},\n"
134 " \"vs_fullscreen\": {\"stage\": \"vs\", \"fssm_sha256\": \"" << leonida::sha256_hex(vs_program) 142 " \"vs_fullscreen\": {\"stage\": \"vs\", \"fssm_sha256\": \"" << leonida::sha256_hex(vs_program)
135 << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"input_signature\": []},\n" 143 << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"input_signature\": []},\n"
@@ -164,23 +172,35 @@ int main(int argc, char** argv) {
164 return true; 172 return true;
165 }; 173 };
166 const auto root_signature = [&](ID3D12Device* device, Ref<ID3D12RootSignature>& root) { 174 const auto root_signature = [&](ID3D12Device* device, Ref<ID3D12RootSignature>& root) {
167 // The mesh fixture reads s0:s1 (offset) and the colour fixture, built as ps_draw_s0.spv, s2:s3 (tint VA). 175 // [0] two constants (push dwords 8, 9: offset), [1] a root CBV (10, 11: tint), as in d3d12_draw_test. The
168 // Select the runtime's packed s0 layout by declaring 25 words: one more than fits above s8. 176 // mesh shader reads them as s16..s19 and the pixel shader as s8..s11 (the graphics root window, D3D-448).
169 D3D12_ROOT_PARAMETER params[3] = {}; 177 D3D12_ROOT_PARAMETER params[2] = {};
170 params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; 178 params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
171 params[0].Constants = {0, 0, 2}; 179 params[0].Constants = {0, 0, 2};
172 params[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; 180 params[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
173 params[1].Descriptor = {1, 0}; 181 params[1].Descriptor = {1, 0};
174 params[2].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
175 params[2].Constants = {2, 0, 21};
176 D3D12_VERSIONED_ROOT_SIGNATURE_DESC root_desc{}; 182 D3D12_VERSIONED_ROOT_SIGNATURE_DESC root_desc{};
177 root_desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0; 183 root_desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0;
178 root_desc.Desc_1_0 = {3, params, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE}; 184 root_desc.Desc_1_0 = {2, params, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE};
185 const auto blob = serialize_root_signature(root_desc);
186 return !blob.empty() &&
187 SUCCEEDED(device->CreateRootSignature(0, blob.data(), blob.size(), IID_PPV_ARGS(&root.p)));
188 };
189 // Twenty constants: s8..s27 for a pixel shader, but past a mesh shader's 16-dword window (s16..s31). Thirty:
190 // past the graphics window (24 from s8) and the compute one (28 from s4) too, as a retail start-up signature is.
191 const auto wide_root_signature = [&](ID3D12Device* device, Ref<ID3D12RootSignature>& root, UINT values = 20) {
192 D3D12_ROOT_PARAMETER param{};
193 param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
194 param.Constants = {0, 0, values};
195 D3D12_VERSIONED_ROOT_SIGNATURE_DESC root_desc{};
196 root_desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0;
197 root_desc.Desc_1_0 = {1, &param, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE};
179 const auto blob = serialize_root_signature(root_desc); 198 const auto blob = serialize_root_signature(root_desc);
180 return !blob.empty() && 199 return !blob.empty() &&
181 SUCCEEDED(device->CreateRootSignature(0, blob.data(), blob.size(), IID_PPV_ARGS(&root.p))); 200 SUCCEEDED(device->CreateRootSignature(0, blob.data(), blob.size(), IID_PPV_ARGS(&root.p)));
182 }; 201 };
183 const D3D12_SHADER_BYTECODE ms{ms_container.data(), ms_container.size()}; 202 const D3D12_SHADER_BYTECODE ms{ms_container.data(), ms_container.size()};
203 const D3D12_SHADER_BYTECODE ms_old{ms_old_container.data(), ms_old_container.size()};
184 const D3D12_SHADER_BYTECODE ps{ps_container.data(), ps_container.size()}; 204 const D3D12_SHADER_BYTECODE ps{ps_container.data(), ps_container.size()};
185 const D3D12_SHADER_BYTECODE vs{vs_container.data(), vs_container.size()}; 205 const D3D12_SHADER_BYTECODE vs{vs_container.data(), vs_container.size()};
186 206
@@ -231,6 +251,14 @@ int main(int argc, char** argv) {
231 vs_stream.add(TopologySubobject{.inner = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE}); 251 vs_stream.add(TopologySubobject{.inner = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE});
232 vs_stream.add(TargetsSubobject{.inner = one_target()}); 252 vs_stream.add(TargetsSubobject{.inner = one_target()});
233 EXPECT(SUCCEEDED(create(device.p, vs_stream, vs_pso))); 253 EXPECT(SUCCEEDED(create(device.p, vs_stream, vs_pso)));
254 // A mesh shader translated before the graphics root window would read its root arguments from the wrong
255 // dwords: refused, with a log line that asks for the shaders stage again.
256 {
257 Stream old_stream;
258 old_stream.add(RootSubobject{.inner = root.p}).add(MsSubobject{.inner = ms_old}).add(PsSubobject{.inner = ps});
259 old_stream.add(TargetsSubobject{.inner = one_target()});
260 EXPECT(create(device.p, old_stream, refused) == E_INVALIDARG && !refused.p);
261 }
234 262
235 // Streams the PC runtime refuses. 263 // Streams the PC runtime refuses.
236 Stream bad = mesh_stream; 264 Stream bad = mesh_stream;
@@ -466,6 +494,39 @@ int main(int argc, char** argv) {
466 list->RSSetViewports(1, &viewport); 494 list->RSSetViewports(1, &viewport);
467 list6->DispatchMesh(4096, 1025, 1); 495 list6->DispatchMesh(4096, 1025, 1);
468 EXPECT(list->Close() == E_INVALIDARG); 496 EXPECT(list->Close() == E_INVALIDARG);
497 // A root signature the graphics bind point places (s8..s27) but a mesh shader's window cannot (s16..s31): a
498 // vertex draw may use it, DispatchMesh may not.
499 {
500 Ref<ID3D12RootSignature> wide;
501 EXPECT(wide_root_signature(device.p, wide));
502 EXPECT(SUCCEEDED(list->Reset(allocator.p, mesh_pso.p)));
503 list->SetGraphicsRootSignature(wide.p);
504 list->RSSetViewports(1, &viewport);
505 list6->DispatchMesh(1, 1, 1);
506 EXPECT(list->Close() == E_INVALIDARG);
507 // Past the console graphics window (24 dwords from s8): still created, on pack()'s s0 layout (logged).
508 // Setting its 30 constants is valid; a mesh shader, which reads the console layout, may not use it.
509 Ref<ID3D12RootSignature> huge;
510 EXPECT(wide_root_signature(device.p, huge, 30));
511 EXPECT(SUCCEEDED(list->Reset(allocator.p, mesh_pso.p)));
512 list->SetGraphicsRootSignature(huge.p);
513 const std::array<std::uint32_t, 30> values{};
514 list->SetGraphicsRoot32BitConstants(0, 30, values.data(), 0);
515 EXPECT(SUCCEEDED(list->Close()));
516 EXPECT(SUCCEEDED(list->Reset(allocator.p, mesh_pso.p)));
517 list->SetGraphicsRootSignature(huge.p);
518 list->RSSetViewports(1, &viewport);
519 list6->DispatchMesh(1, 1, 1);
520 EXPECT(list->Close() == E_INVALIDARG); // a mesh shader cannot read it
521 // Four constants: the console layout, and the mesh window holds them.
522 Ref<ID3D12RootSignature> console_layout;
523 EXPECT(wide_root_signature(device.p, console_layout, 4));
524 EXPECT(SUCCEEDED(list->Reset(allocator.p, mesh_pso.p)));
525 list->SetGraphicsRootSignature(console_layout.p);
526 list->RSSetViewports(1, &viewport);
527 list6->DispatchMesh(1, 1, 1);
528 EXPECT(SUCCEEDED(list->Close()));
529 }
469 // A DISPATCH_MESH command signature (D3D12_DISPATCH_MESH_ARGUMENTS, 12 bytes) is created; a stride below its 530 // A DISPATCH_MESH command signature (D3D12_DISPATCH_MESH_ARGUMENTS, 12 bytes) is created; a stride below its
470 // 12 bytes is refused as the PC runtime refuses it. ExecuteIndirect with it records nothing yet (#3777 replays 531 // 12 bytes is refused as the PC runtime refuses it. ExecuteIndirect with it records nothing yet (#3777 replays
471 // it), so the list still closes. 532 // it), so the list still closes.
diff --git a/runtime/test/glsl/ms_draw.mesh b/runtime/test/glsl/ms_draw.mesh
index 8bfd21785..e66b04bb6 100644
--- a/runtime/test/glsl/ms_draw.mesh
+++ b/runtime/test/glsl/ms_draw.mesh
@@ -2,7 +2,8 @@
2// A mesh shader written to the translator's runtime contract (docs/design.md, "User data" and "Mesh shaders"), 2// A mesh shader written to the translator's runtime contract (docs/design.md, "User data" and "Mesh shaders"),
3// standing in for a translated one in d3d12_mesh_test. Each workgroup emits one quad (4 vertices, 2 triangles) on a 3// standing in for a translated one in d3d12_mesh_test. Each workgroup emits one quad (4 vertices, 2 triangles) on a
4// 4x4 grid of clip-space cells: column = WorkgroupId.x + WorkgroupId.z, row = WorkgroupId.y, so all three 4// 4x4 grid of clip-space cells: column = WorkgroupId.x + WorkgroupId.z, row = WorkgroupId.y, so all three
5// DispatchMesh counts reach the shader. s0, s1 (root constants) move the quad in clip space; the colour is red. The 5// DispatchMesh counts reach the shader. Push dwords 8, 9 (the root constants, which a translated mesh shader reads as
6// s16, s17 through the graphics root window) move the quad in clip space; the colour is red. The
6// corners are top-left, top-right, bottom-left, bottom-right and the triangles (0,1,2) and (2,1,3), clockwise in D3D 7// corners are top-left, top-right, bottom-left, bottom-right and the triangles (0,1,2) and (2,1,3), clockwise in D3D
7// screen space as in d3d12_draw_test, so they are front-facing with the default winding. 8// screen space as in d3d12_draw_test, so they are front-facing with the default winding.
8#extension GL_EXT_mesh_shader : require 9#extension GL_EXT_mesh_shader : require
@@ -22,7 +23,7 @@ void main() {
22 SetMeshOutputsEXT(4, 2); 23 SetMeshOutputsEXT(4, 2);
23 const uint i = gl_LocalInvocationIndex; 24 const uint i = gl_LocalInvocationIndex;
24 const float column = float(gl_WorkGroupID.x + gl_WorkGroupID.z), row = float(gl_WorkGroupID.y); 25 const float column = float(gl_WorkGroupID.x + gl_WorkGroupID.z), row = float(gl_WorkGroupID.y);
25 const vec2 offset = vec2(uintBitsToFloat(pc.s[0]), uintBitsToFloat(pc.s[1])); 26 const vec2 offset = vec2(uintBitsToFloat(pc.s[8]), uintBitsToFloat(pc.s[9]));
26 if (i < 4) { 27 if (i < 4) {
27 const vec2 corner = vec2(float(i & 1u), float(i >> 1)); 28 const vec2 corner = vec2(float(i & 1u), float(i >> 1));
28 const vec2 top_left = vec2(-1.0 + 0.5 * column, 1.0 - 0.5 * row); 29 const vec2 top_left = vec2(-1.0 + 0.5 * column, 1.0 - 0.5 * row);
diff --git a/runtime/test/glsl/ps_draw.frag b/runtime/test/glsl/ps_draw.frag
index d8e29425d..5f2ab1e86 100644
--- a/runtime/test/glsl/ps_draw.frag
+++ b/runtime/test/glsl/ps_draw.frag
@@ -3,7 +3,7 @@
3// d3d12_draw_test. The tests' signatures are two root constants then a root CBV, so in the console's graphics layout 3// d3d12_draw_test. The tests' signatures are two root constants then a root CBV, so in the console's graphics layout
4// (from s8, two dwords per root view: docs/d3d12_vulkan.md, D3D-448) s10:s11 is the CBV: the console VA of three 4// (from s8, two dwords per root view: docs/d3d12_vulkan.md, D3D-448) s10:s11 is the CBV: the console VA of three
5// floats (a tint), read at heap base + VA. The output is (red * tint.x, tint.y, blue * tint.z, 1). 5// floats (a tint), read at heap base + VA. The output is (red * tint.x, tint.y, blue * tint.z, 1).
6// d3d12_mesh_test pads its signature onto the runtime's s0 fallback layout and builds this with -DROOT_BASE=0 (s2:s3). 6// d3d12_mesh_test uses it as is: its mesh shader reads the same block through the root window (push dword 8 = s16).
7#extension GL_EXT_buffer_reference : require 7#extension GL_EXT_buffer_reference : require
8#extension GL_EXT_buffer_reference_uvec2 : require 8#extension GL_EXT_buffer_reference_uvec2 : require
9 9
diff --git a/runtime/test/glsl/ps_image_atomic.frag b/runtime/test/glsl/ps_image_atomic.frag
index 97c9b53b5..b23d09ed7 100644
--- a/runtime/test/glsl/ps_image_atomic.frag
+++ b/runtime/test/glsl/ps_image_atomic.frag
@@ -19,6 +19,6 @@ layout(push_constant) uniform UserData {
19layout(set = 0, binding = 4, r32ui) uniform uimage2D counters[]; 19layout(set = 0, binding = 4, r32ui) uniform uimage2D counters[];
20 20
21void main() { 21void main() {
22 const uint before = imageAtomicMax(counters[0], ivec2(gl_FragCoord.xy), pc.s[0]); 22 const uint before = imageAtomicMax(counters[0], ivec2(gl_FragCoord.xy), pc.s[8]);
23 target = vec4(color.rgb, float(before & 1u)); 23 target = vec4(color.rgb, float(before & 1u));
24} 24}
diff --git a/runtime/test/root_signature_test.cpp b/runtime/test/root_signature_test.cpp
index 169c656f9..c7f726599 100644
--- a/runtime/test/root_signature_test.cpp
+++ b/runtime/test/root_signature_test.cpp
@@ -492,6 +492,48 @@ int main() {
492 "pack_stage: non-compute graphics stages still refuse spills"); 492 "pack_stage: non-compute graphics stages still refuse spills");
493 } 493 }
494 494
495 // The graphics root window (D3D-448-GRAPHICS): the graphics bind point lays a signature out once with
496 // Stage::Pixel, root dword k at push dword 8 + k. A vertex, pixel or geometry shader reads SGPR i from push
497 // dword i, and a mesh shader its s16 + k from push dword 8 + k (tools/rdna2spirv.py, user_data_dword), so every
498 // stage of a pipeline finds each parameter in the same dword. The mesh window holds 16 dwords, the others 24.
499 {
500 const std::vector<RootSignature> shapes = [] {
501 std::vector<RootSignature> out(4);
502 out[0].params = {consts(2), view()};
503 out[1].params = {table(), table(), consts(1)};
504 out[2].params = {table(), consts(4), view(), table()};
505 out[3].params.assign(16, table());
506 return out;
507 }();
508 for (std::size_t s = 0; s < shapes.size(); ++s) {
509 const StagePackResult vs = pack_stage(shapes[s], Stage::Vertex);
510 const StagePackResult ps = pack_stage(shapes[s], Stage::Pixel);
511 const StagePackResult gs = pack_stage(shapes[s], Stage::Geometry);
512 const StagePackResult ms = pack_stage(shapes[s], Stage::Mesh);
513 check(vs.ok && ps.ok && gs.ok && ms.ok, "graphics window: the shape fits every graphics stage");
514 check(vs.first_sgpr == ps.first_sgpr && vs.first_sgpr == gs.first_sgpr,
515 "graphics window: VS, PS and GS place every parameter in the same SGPR");
516 bool same_dword = vs.first_sgpr.size() == ms.first_sgpr.size();
517 for (std::size_t i = 0; same_dword && i < vs.first_sgpr.size(); ++i)
518 same_dword = vs.first_sgpr[i] - 8 == ms.first_sgpr[i] - 16;
519 check(same_dword, "graphics window: a mesh shader's s16 + k is the pixel shader's s8 + k");
520 }
521 RootSignature twenty;
522 twenty.params = {consts(20)};
523 check(pack_stage(twenty, Stage::Vertex).ok && !pack_stage(twenty, Stage::Mesh).ok,
524 "graphics window: 20 dwords fit a pixel shader (24 from s8) but not a mesh shader (16 from s16)");
525 RootSignature full;
526 full.params = {consts(24)};
527 check(pack_stage(full, Stage::Pixel).ok, "graphics window: 24 constants fill s8..s31 exactly");
528 full.params = {consts(23), view()};
529 check(!pack_stage(full, Stage::Pixel).ok, "graphics window: a root view past s31 spills");
530 RootSignature tables;
531 tables.params = {table(), table()};
532 const StagePackResult t = pack_stage(tables, Stage::Pixel);
533 check(t.ok && t.first_sgpr == std::vector<uint32_t>({8, 9}) && t.end_sgpr == 10,
534 "graphics window: two tables are s8 and s9, one dword each (pack() gave s[0:1] and s[2:3])");
535 }
536
495 // pack_stage keeps pack()'s validation. 537 // pack_stage keeps pack()'s validation.
496 { 538 {
497 RootSignature invalid_sig; 539 RootSignature invalid_sig;
diff --git a/runtime/test/subgroup_size_test.cpp b/runtime/test/subgroup_size_test.cpp
index 2628509fc..2a6fbdf97 100644
--- a/runtime/test/subgroup_size_test.cpp
+++ b/runtime/test/subgroup_size_test.cpp
@@ -7,8 +7,10 @@
7// - an old RADV: sizes 32..64, COMPUTE only. 7// - an old RADV: sizes 32..64, COMPUTE only.
8// No game data. 8// No game data.
9#include "../src/subgroup_size.h" 9#include "../src/subgroup_size.h"
10#include "test_temp_dir.h"
10 11
11#include <cstdio> 12#include <cstdio>
13#include <fstream>
12#include <string> 14#include <string>
13 15
14#define CHECK(condition) do { \ 16#define CHECK(condition) do { \
@@ -138,6 +140,31 @@ int main() {
138 CHECK(emulated.outcome == SubgroupOutcome::emulated && emulated.size == 0); 140 CHECK(emulated.outcome == SubgroupOutcome::emulated && emulated.size == 0);
139 } 141 }
140 142
143 // Read the translator's graphics tier through the same index lookup used at pipeline creation: tiers A and B are
144 // partition invariant (the device's 32-wide size is exact for them), C, an unknown tier and a non-string are not.
145 {
146 const testfiles::ScratchDir scratch("leonida_subgroup_graphics");
147 std::ofstream(scratch.path() / "index.json") << R"({
148 "a": {"stage":"vs","wave64":true,"subgroup_size":64,"fssm_sha256":"a","wave64_graphics":"A"},
149 "b": {"stage":"ps","wave64":true,"subgroup_size":64,"fssm_sha256":"b","wave64_graphics":"B"},
150 "c": {"stage":"gs","wave64":true,"subgroup_size":64,"fssm_sha256":"c","wave64_graphics":"C"},
151 "unknown": {"stage":"ps","wave64":true,"fssm_sha256":"unknown","wave64_graphics":"D"},
152 "bad": {"stage":"ps","wave64":true,"fssm_sha256":"bad","wave64_graphics":1}
153 })";
154 ShaderLibrary library;
155 CHECK(library.load(scratch.path()));
156 const auto* a = library.find("vs", "a");
157 const auto* b = library.find("ps", "b");
158 CHECK(a && b && graphics_partition_invariant(*a) && graphics_partition_invariant(*b));
159 for (const auto* shader : {library.find("gs", "c"), library.find("ps", "unknown"), library.find("ps", "bad")})
160 CHECK(shader && !graphics_partition_invariant(*shader));
161 // The size decision itself does not change: 64 cannot be had on NVIDIA, and AMD still gets it natively.
162 const auto fixed = decide_subgroup_size(*b, nvidia());
163 CHECK(fixed.outcome == SubgroupOutcome::unavailable && fixed.wanted == 64 && fixed.size == 0 && fixed.flags == 0);
164 const auto native = decide_subgroup_size(*b, amd());
165 CHECK(native.outcome == SubgroupOutcome::required && native.size == 64);
166 }
167
141 // --- An old RADV: COMPUTE only ---------------------------------------------------------------------------------- 168 // --- An old RADV: COMPUTE only ----------------------------------------------------------------------------------
142 { 169 {
143 const SubgroupSizeCaps caps = old_radv(); 170 const SubgroupSizeCaps caps = old_radv();