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
701 B33 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 associatedtype of generic type parameters.
5
6interface IFoo
7{
8    associatedtype TA;
9}
10
11struct FooImpl : IFoo
12{
13    typealias TA = int;
14}
15
16__generic<typename T>
17T.TA process(T v)
18    where T : IFoo
19    where T.TA == int
20{
21    return 1;
22}
23
24//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
25RWStructuredBuffer<float> outputBuffer;
26
27[numthreads(1,1,1)]
28void computeMain()
29{
30    FooImpl fooImpl;
31    outputBuffer[0] = process(fooImpl);
32    // CHECK: 1.0
33}