yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
ae1a5e408
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(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl 4//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly 5 6//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer 7buffer MyBlockName2 8{ 9 uint data[1]; 10} outputBuffer; 11 12layout(local_size_x = 4) in; 13 14// The memory qualifier `restrict` is allowed to be dropped 15// when passing a variable into a function as an argument. 16 17//CHECK_SPV: OpEntryPoint 18 19//CHECK_GLSL: {{(restrict|writeonly|readonly)}} {{(restrict|writeonly|readonly)}} {{(restrict|writeonly|readonly)}} 20//CHECK_SPV: OpDecorate %{{.*}} {{(Restrict|NonWritable|NonReadable)}} 21//CHECK_SPV: OpDecorate %{{.*}} {{(Restrict|NonWritable|NonReadable)}} 22//CHECK_SPV: OpDecorate %{{.*}} {{(Restrict|NonWritable|NonReadable)}} 23//TEST_INPUT: set someImage = RWTexture2D(format=RGBA16Float, size=1, content=one, mipMaps = 1) 24uniform layout(binding=0,rgba16f) restrict writeonly readonly image2D someImage; 25 26//CHECK_GLSL: writeonly 27//CHECK_SPV: OpDecorate {{.*}} {{(Restrict|NonWritable|NonReadable)}} 28//TEST_INPUT: set someImage2 = RWTexture2D(format=RGBA16Float, size=1, content=one, mipMaps = 1) 29uniform layout(binding=1,rgba16f) writeonly image2D someImage2; 30 31bool checkAllImageSizesParamSameQualifiers(writeonly readonly image2D val) 32{ 33 return true 34 && imageSize(val) == ivec2(1) 35 ; 36} 37bool checkAllImageSizesParamMoreQualifiers(readonly writeonly image2D val) 38{ 39 return true 40 && imageSize(val) == ivec2(1) 41 ; 42} 43 44// CHECK_GLSL: void main( 45void computeMain() 46{ 47 outputBuffer.data[0] = true 48 && checkAllImageSizesParamSameQualifiers(someImage) 49 && checkAllImageSizesParamMoreQualifiers(someImage2) 50 ; 51 // BUF: 1 52 53}