yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj 2//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 3//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj 4//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -shaderobj 5// TODO(JS): Doesn't work on vk currently 6//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj 7//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj 8 9// Doesn't work on CUDA, not clear why yet 10//DISABLE_TEST_INPUT: Texture1D(format=R16Float, size=4, content = one, mipMaps=1):name tLoad1D 11//Texture1D<float> tLoad1D; 12 13//TEST_INPUT: Texture1D(format=R16Float, size=4, content = one):name t1D 14Texture1D<float> t1D; 15//TEST_INPUT: Texture2D(format=R16Float, size=4, content = one):name t2D 16Texture2D<float> t2D; 17//TEST_INPUT: Texture3D(format=R16Float, size=4, content = one):name t3D 18Texture3D<float> t3D; 19//TEST_INPUT: TextureCube(format=R16Float, size=4, content = one):name tCube 20TextureCube<float> tCube; 21 22//TEST_INPUT: Texture1D(format=R16Float, size=4, content = one, arrayLength=2):name t1DArray 23Texture1DArray<float> t1DArray; 24//TEST_INPUT: Texture2D(format=R16Float, size=4, content = one, arrayLength=2):name t2DArray 25Texture2DArray<float> t2DArray; 26//TEST_INPUT: TextureCube(format=R16Float, size=4, content = one, arrayLength=2):name tCubeArray 27TextureCubeArray<float> tCubeArray; 28 29//TEST_INPUT: Sampler:name samplerState 30SamplerState samplerState; 31 32//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 33RWStructuredBuffer<float> outputBuffer; 34 35[numthreads(4, 1, 1)] 36void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 37{ 38 uint idx = dispatchThreadID.x; 39 float u = idx * (1.0f / 4); 40 41 float val = 0.0f; 42 43 val += t1D.SampleLevel(samplerState, u, 0); 44 val += t2D.SampleLevel(samplerState, float2(u, u), 0); 45 val += t3D.SampleLevel(samplerState, float3(u, u, u), 0); 46 val += tCube.SampleLevel(samplerState, normalize(float3(u, 1 - u, u)), 0); 47 48 val += t1DArray.SampleLevel(samplerState, float2(u, 0), 0); 49 val += t2DArray.SampleLevel(samplerState, float3(u, u, 0), 0); 50 val += tCubeArray.SampleLevel(samplerState, float4(u, u, u, 0), 0); 51 52 outputBuffer[idx] = val; 53}