yum-mirror/slang

Making it easier to work with shaders

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

Yong HeSupport `where` clause and type equality constraint. (#4986)d65530246

master
556 B20 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 parameters.
5
6T process<T, int N>(vector<T, N> v) where T : IFloat
7{
8    return v[0];
9}
10
11//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
12RWStructuredBuffer<float> outputBuffer;
13
14[numthreads(1,1,1)]
15void computeMain()
16{
17    float a = 1.0;
18    outputBuffer[0] = process(a);
19    // CHECK: 1.0
20}