yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
adaea0e99
master
1// gh-487.slang 2//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 3 4// This test is to confirm that we can apply builtin functions taht expect 5// a floating-point argument to an integer, with the compiler filling 6// in the implicit conversion. This is made tricky by the fact 7// that a builtin line `sqrt` is actually a constrained generic, 8// `sqrt<T:BuiltinFloatingPointType>` so that inference currently 9// fails to deduce `T=float` when presented with an `int` argument. 10 11int test(int val) 12{ 13 int squared = val * val; 14 float result = sqrt(squared); 15 return int(result); 16} 17 18//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name gBuffer 19RWStructuredBuffer<int> gBuffer; 20 21[numthreads(4, 1, 1)] 22void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 23{ 24 uint tid = dispatchThreadID.x; 25 26 int inVal = int(tid); 27 int outVal = test(inVal); 28 29 gBuffer[tid] = outVal; 30}