yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
133bd259c
master
1//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage compute -entry computeMain -target glsl 2//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly 3//TEST:SIMPLE(filecheck=CHECK_HLSL): -allow-glsl -stage compute -entry computeMain -target hlsl -DTARGET_HLSL 4 5// not testing cuda due to missing impl 6//DISABLE_TEST:SIMPLE(filecheck=CHECK_CUDA): -allow-glsl -stage compute -entry computeMain -target cuda -DTARGET_CUDA 7// not testing cpp due to missing impl 8//DISABLE_TEST:SIMPLE(filecheck=CHECK_CPP): -allow-glsl -stage compute -entry computeMain -target cpp -DTARGET_CPP 9 10//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl 11//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly 12//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-wgpu -compute -entry computeMain -allow-glsl -xslang -DWGPU 13//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -allow-glsl 14 15#version 430 16 17//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer 18buffer MyBlockName2 19{ 20 uint data[]; 21} outputBuffer; 22 23layout(local_size_x = 32) in; 24 25shared uint shareMem; 26 27[[ForceInline]] 28void _barrier() 29{ 30#if !defined(WGPU) 31 subgroupBarrier(); 32#else 33 GroupMemoryBarrier(); 34#endif 35} 36 37[[ForceInline]] 38void _memoryBarrier() 39{ 40#if !defined(WGPU) 41 subgroupMemoryBarrier(); 42#else 43 GroupMemoryBarrier(); 44#endif 45} 46 47[[ForceInline]] 48void _memoryBarrierShared() 49{ 50#if !defined(WGPU) 51 subgroupMemoryBarrierShared(); 52#else 53 GroupMemoryBarrier(); 54#endif 55} 56 57[[ForceInline]] 58void _memoryBarrierBuffer() 59{ 60#if !defined(WGPU) 61 subgroupMemoryBarrierBuffer(); 62#else 63 GroupMemoryBarrier(); 64#endif 65} 66 67void computeMain() 68{ 69 // TODO: no test for image memory was done -- subgroupMemoryBarrierImage(); 70 // tests are seperate since concurrency testing 71 72 shareMem = 100; 73 _memoryBarrierShared(); 74 outputBuffer.data[0] = 1; 75 _barrier(); 76 outputBuffer.data[0] = 2; 77 _barrier(); 78 79 outputBuffer.data[1] = 1; 80 _memoryBarrier(); 81 outputBuffer.data[1] = 2; 82 _barrier(); 83 84 outputBuffer.data[2] = 1; 85 _memoryBarrierBuffer(); 86 outputBuffer.data[2] = 2; 87 _barrier(); 88 89 shareMem = 2; 90 _memoryBarrierShared(); 91 outputBuffer.data[3] = shareMem; 92 _barrier(); 93 94 if (subgroupElect()) { 95 outputBuffer.data[4] = gl_GlobalInvocationID.x + 2; 96 } 97 98 // CHECK_GLSL: void main( 99 // CHECK_SPV: OpEntryPoint 100 // CHECK_HLSL: void computeMain( 101 // CHECK_CUDA: void computeMain( 102 // CHECK_CPP: void _computeMain( 103 104 // BUF: 2 105 // BUF-NEXT: 2 106 // BUF-NEXT: 2 107 // BUF-NEXT: 2 108 // BUF-NEXT: 2 109}