yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -cpu 2//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -vk -compute 3//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -cuda -compute 4//TODO: metal is currently failing even with emulation, investigate. 5//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -mtl -compute -profile metallib_2_4 6// No support for uint16_t on fxc - we need SM6.2 and dxil to use uint16_t with d3d12 7// https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/hlsl-shader-model-6-0-features-for-direct3d-12 8//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -dx12 -profile cs_6_2 -shaderobj -render-feature hardware-device 9// wgpu only has 32-bit support, so we do not try and test it here 10//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -vk -compute -emit-spirv-via-glsl 11 12//CHK:1 13 14//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer 15RWStructuredBuffer<uint> outputBuffer; 16 17[numthreads(1, 1, 1)] 18void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 19{ 20 uint r1 = countbits(uint16_t(0b1U) << 8); 21 uint2 r2 = countbits(uint16_t2(uint16_t(0b0U) << 8, uint16_t(0b1U) << 8)); 22 uint3 r3 = countbits(uint16_t3(uint16_t(0b0U) << 8, uint16_t(0b1U) << 8, uint16_t(0b11U) << 8)); 23 uint4 r4 = countbits(uint16_t4(uint16_t(0b0U) << 8, uint16_t(0b1U) << 8, uint16_t(0b11U) << 8, uint16_t(0b111U) << 8)); 24 25 uint r5 = countbits(int16_t(0b1) << 8); 26 uint2 r6 = countbits(int16_t2(int16_t(0b0) << 8, int16_t(0b1) << 8)); 27 uint3 r7 = countbits(int16_t3(int16_t(0b0) << 8, int16_t(0b1) << 8, int16_t(0b11) << 8)); 28 uint4 r8 = countbits(int16_t4(int16_t(0b0) << 8, int16_t(0b1) << 8, int16_t(0b11) << 8, int16_t(0b111) << 8)); 29 30 uint16_t smallShiftU16 = uint16_t(0b111) << 16; 31 int16_t smallShiftI16 = int16_t(0b1111) << 16; 32 33 uint bitCountBigShiftU16 = countbits(smallShiftU16); 34 uint bitCountBigShiftI16 = countbits(smallShiftI16); 35 36 outputBuffer[0] = true 37 && (r1 == 1) 38 && (r2.x == 0 && r2.y == 1) 39 && (r3.x == 0 && r3.y == 1 && r3.z == 2) 40 && (r4.x == 0 && r4.y == 1 && r4.z == 2 && r4.w == 3) 41 && (r5 == 1) 42 && (r6.x == 0 && r6.y == 1) 43 && (r7.x == 0 && r7.y == 1 && r7.z == 2) 44 && (r8.x == 0 && r8.y == 1 && r8.z == 2 && r8.w == 3) 45 && (bitCountBigShiftU16 == 0 && bitCountBigShiftI16 == 0) 46 ; 47}