yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
a8519e68b
master
1// sign-wgsl.slang 2 3//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry main -stage compute 4 5// Test that sign function returns correct type for WGSL 6// WGSL's sign returns float but Slang's sign should return int 7 8struct OutputBuffer 9{ 10 int scalar_result; 11 int2 vector_result; 12}; 13 14[[vk::binding(0, 0)]] 15RWStructuredBuffer<OutputBuffer> outputBuffer; 16 17[numthreads(1, 1, 1)] 18void main() 19{ 20 // Test scalar sign function 21 int scalar_result = sign(0.5); 22 23 // Test vector sign function 24 int2 vector_result = sign(float2(1.5, -0.5)); 25 26 outputBuffer[0].scalar_result = scalar_result; 27 outputBuffer[0].vector_result = vector_result; 28 29 // WGSL-DAG: i32(sign( 30 // WGSL-DAG: vec2<i32>(sign((vec2<f32> 31}