#version 460 // The mesh-stage fixture shares the graphics user-data block with the vertex and pixel stages. A translated mesh // shader maps root-window dword i to s(i+8); the layer supplies the heap dwords once after the explicit arguments. // With three root constants at s8..s10, the shared fixture reads the resource and sampler dwords at s11 and s12. // It hands them to its pixel shader, which writes them to the first render target. One triangle covers the draw's 1x1 viewport. #extension GL_EXT_mesh_shader : require layout(local_size_x = 32) in; layout(triangles, max_vertices = 3, max_primitives = 1) out; layout(location = 0) out uvec4 out_words[]; layout(push_constant) uniform UserData { uint s[32]; uvec2 heap_base; uvec2 code_base; } pc; void main() { SetMeshOutputsEXT(3, 1); const uint i = gl_LocalInvocationIndex; if (i < 3) { const vec2 corner = vec2(float(i & 1u), float(i >> 1)); // (0,0), (1,0), (0,1): a full-screen triangle gl_MeshVerticesEXT[i].gl_Position = vec4(corner * 4.0 - 1.0, 0.0, 1.0); // The heaps the mesh stage read, then 'MS' as a marker that these words came from it. out_words[i] = uvec4(pc.s[11], pc.s[12], 0x4d53u, 0u); } if (i == 0) gl_PrimitiveTriangleIndicesEXT[0] = uvec3(0, 1, 2); }