yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

RonanAdded getCanonicalGenericConstraints2 (sorts constraints and allows more generic expressions) (#6787)a5efbb1b7

master
631 B22 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type
2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type
3
4// Test that we can use `where` clause to constrain generic type dependant on generic parameters.
5
6T process<T, int N>(vector<T, N> v) 
7    where T : IFloat
8    where vector<T, N> : IArithmetic
9{
10    return (v.mul(T(2)))[0];
11}
12
13//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
14RWStructuredBuffer<float> outputBuffer;
15
16[numthreads(1,1,1)]
17void computeMain()
18{
19    float a = 1.0;
20    outputBuffer[0] = process(a);
21    // CHECK: 2.0
22}