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