yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f4d5372d3
master
1//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl 2//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly 3//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-wgpu -compute -entry computeMain -allow-glsl 4 5 6// There are some issues with the Metal backend when using glsl-style syntax - this should be fixed. 7//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -entry computeMain -allow-glsl 8 9#version 430 10 11//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 12buffer MyBlockName2 13{ 14 int data[]; 15} outputBuffer; 16 17layout(local_size_x = 4) in; 18 19[shader("compute")] 20void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 21{ 22 // There may be some issues with structure padding for global context containing 23 // global builtin variables. 24 // int idx = gl_GlobalInvocationID.x; 25 int idx = dispatchThreadID.x; 26 27 uint laneId = gl_SubgroupInvocationID; 28 // The laneCount will be dependent on target hardware. It seems a count of 1 is valid in spec. 29 // For now we'll just check it's not 0. 30 uint laneCount = gl_SubgroupSize; 31 outputBuffer.data[idx] = int(((laneCount > 0) ? 0x100 : 0) + laneId); 32 33 // BUF: 100 34 // BUF-NEXT: 101 35 // BUF-NEXT: 102 36 // BUF-NEXT: 103 37}