mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 13:28:35 +00:00
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.
36 lines
1.7 KiB
Plaintext
36 lines
1.7 KiB
Plaintext
#version 460
|
|
// A mesh shader written to the translator's runtime contract (docs/design.md, "User data" and "Mesh shaders"),
|
|
// standing in for a translated one in d3d12_mesh_test. Each workgroup emits one quad (4 vertices, 2 triangles) on a
|
|
// 4x4 grid of clip-space cells: column = WorkgroupId.x + WorkgroupId.z, row = WorkgroupId.y, so all three
|
|
// DispatchMesh counts reach the shader. Push dwords 8, 9 (the root constants, which a translated mesh shader reads as
|
|
// s16, s17 through the graphics root window) move the quad in clip space; the colour is red. The
|
|
// corners are top-left, top-right, bottom-left, bottom-right and the triangles (0,1,2) and (2,1,3), clockwise in D3D
|
|
// screen space as in d3d12_draw_test, so they are front-facing with the default winding.
|
|
#extension GL_EXT_mesh_shader : require
|
|
|
|
layout(local_size_x = 32) in;
|
|
layout(triangles, max_vertices = 4, max_primitives = 2) out;
|
|
|
|
layout(location = 0) out vec4 out_color[];
|
|
|
|
layout(push_constant) uniform UserData {
|
|
uint s[32];
|
|
uvec2 heap_base;
|
|
uvec2 code_base;
|
|
} pc;
|
|
|
|
void main() {
|
|
SetMeshOutputsEXT(4, 2);
|
|
const uint i = gl_LocalInvocationIndex;
|
|
const float column = float(gl_WorkGroupID.x + gl_WorkGroupID.z), row = float(gl_WorkGroupID.y);
|
|
const vec2 offset = vec2(uintBitsToFloat(pc.s[8]), uintBitsToFloat(pc.s[9]));
|
|
if (i < 4) {
|
|
const vec2 corner = vec2(float(i & 1u), float(i >> 1));
|
|
const vec2 top_left = vec2(-1.0 + 0.5 * column, 1.0 - 0.5 * row);
|
|
gl_MeshVerticesEXT[i].gl_Position = vec4(top_left + vec2(0.5, -0.5) * corner + offset, 0.0, 1.0);
|
|
out_color[i] = vec4(1.0, 0.0, 0.0, 1.0);
|
|
}
|
|
if (i == 0) gl_PrimitiveTriangleIndicesEXT[0] = uvec3(0, 1, 2);
|
|
if (i == 1) gl_PrimitiveTriangleIndicesEXT[1] = uvec3(2, 1, 3);
|
|
}
|