1#version 450 2 3#define BARRIER() \ 4 memoryBarrierShared(); \ 5 barrier(); 6 7#extension GL_EXT_mesh_shader : enable 8 9layout(local_size_x = 32) in; 10 11// test use of shared memory in task shaders: 12layout(binding=0) writeonly uniform image2D uni_image; 13uniform block0 { 14 uint uni_value; 15}; 16shared vec4 mem[10]; 17 18// use of storage qualifier "taskPayloadSharedEXT" in task shaders 19struct Task { 20 vec2 dummy; 21 vec2 submesh[3]; 22}; 23taskPayloadSharedEXT Task mytask; 24 25void main() 26{ 27 uint iid = gl_LocalInvocationID.x; 28 uint gid = gl_WorkGroupID.x; 29 30 // 1. shared memory load and stores 31 for (uint i = 0; i < 10; ++i) { 32 mem[i] = vec4(i + uni_value); 33 } 34 imageStore(uni_image, ivec2(iid), mem[gid]); 35 imageStore(uni_image, ivec2(iid), mem[gid+1]); 36 37 BARRIER(); 38 39 // 2. task memory stores 40 41 mytask.dummy = vec2(30.0, 31.0); 42 mytask.submesh[0] = vec2(32.0, 33.0); 43 mytask.submesh[1] = vec2(34.0, 35.0); 44 mytask.submesh[2] = mytask.submesh[gid%2]; 45 46 BARRIER(); 47 48 // 3. emit task count under uniform control flow 49 EmitMeshTasksEXT(3U, 1U, 1U); 50 51} 52