yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
8086adc90
master
1//DISABLE_TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal -DEMIT_SOURCE 2//DISABLE_TEST:SIMPLE(filecheck=METALLIB): -stage compute -entry computeMain -target metallib 3//DISABLE_TEST(compute, metal):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -output-using-type 4//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -output-using-type 5 6// Test framework has issues with RWTexture2D on Metal 7// TODO: github issue #8454 8 9//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 10RWStructuredBuffer<float4> outputBuffer; 11 12// for some reason, metal textures dont have an overload for less-than-four component 13// writes, they need to be converted to 4-components in a legalize step, as the other components 14// get discarded 15 16//TEST_INPUT: RWTexture2D(format=R32Float, size=4, content=zero):name pWrites.tex1 17//TEST_INPUT: RWTexture2D(format=RG32Float, size=4, content=zero):name pWrites.tex2 18//TEST_INPUT: RWTexture2D(format=RGBA32Float, size=4, content=zero):name pWrites.tex4 19//TEST_INPUT: RWTexture2D(format=R32Float, size=4, content=zero, arrayLength=2):name pWrites.tex1Array 20//TEST_INPUT: RWTexture2D(format=RG32Float, size=4, content=zero, arrayLength=2):name pWrites.tex2Array 21//TEST_INPUT: RWTexture2D(format=RGBA32Float, size=4, content=zero, arrayLength=2):name pWrites.tex4Array 22struct TextureWrite 23{ 24 RWTexture2D<float> tex1; 25 RWTexture2D<float2> tex2; 26 RWTexture2D<float4> tex4; 27 28 RWTexture2DArray<float> tex1Array; 29 RWTexture2DArray<float2> tex2Array; 30 RWTexture2DArray<float4> tex4Array; 31} 32ParameterBlock<TextureWrite> pWrites; 33 34[numthreads(1, 1, 1)] 35void computeMain() 36{ 37 // TODO: check for the type of first parameter to be a 4-component vector 38 // METALLIB: call {{.*}}.write_texture_2d.v4f32( 39 // METAL: .write( 40 pWrites.tex1[uint2(0, 0)] = float(1); 41 // METALLIB: call {{.*}}.write_texture_2d.v4f32( 42 // METAL: .write( 43 pWrites.tex2[uint2(1, 1)] = float2(1, 2); 44 // METALLIB: call {{.*}}.write_texture_2d.v4f32( 45 // METAL: .write( 46 pWrites.tex4[uint2(3, 3)] = float4(1, 2, 3, 4); 47 48 // METALLIB: call {{.*}}.write_texture_2d_array.v4f32( 49 // METAL: .write( 50 pWrites.tex1Array[uint3(0, 0, 0)] = 1; 51 // METALLIB: call {{.*}}.write_texture_2d_array.v4f32( 52 // METAL: .write( 53 pWrites.tex2Array[uint3(1, 1, 0)] = float2(1, 2); 54 // METALLIB: call {{.*}}.write_texture_2d_array.v4f32( 55 // METAL: .write( 56 pWrites.tex4Array[uint3(3, 3, 0)] = float4(1, 2, 3, 4); 57 58 // BUF: 6.000000 59 // BUF: 8.000000 60 // BUF: 6.000000 61 // BUF: 8.000000 62 outputBuffer[0] = float4(0) 63 + float4(pWrites.tex1[uint2(0, 0)], 0, 0, 0) 64 + float4(pWrites.tex2[uint2(1, 1)], 0, 0) 65 + float4(pWrites.tex4[uint2(3, 3)]) 66 + float4(pWrites.tex1Array[uint3(0, 0, 0)], 0, 0, 0) 67 + float4(pWrites.tex2Array[uint3(1, 1, 0)], 0, 0) 68 + float4(pWrites.tex4Array[uint3(3, 3, 0)]) 69 ; 70}