yum-mirror/slang

Making it easier to work with shaders

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

Tim FoleyConvert more tests to use shader objects (#1659)2a5d5b323

master
900 B46 linesraw
1//TEST(compute):COMPARE_COMPUTE: -shaderobj
2//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
3
4// Confirm that generics syntax can be used in user
5// code and generates valid output.
6
7//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
8RWStructuredBuffer<float4> outputBuffer;
9
10interface IElement
11{
12    float4 getValue();
13};
14
15struct SingleElement : IElement
16{
17    float4 value;
18    float4 getValue()
19    {
20        return value;
21    }
22};
23
24struct ListElement<THead : IElement> : IElement
25{
26    THead head;
27    float4 getValue()
28    {
29        return head.getValue();
30    }
31};
32
33float4 test<T : IElement>(T val)
34{
35	return val.getValue();
36}
37
38
39[numthreads(1, 1, 1)]
40void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
41{
42    ListElement<SingleElement> list;
43    list.head.value = float4(1.0);
44    float4 outVal = test<ListElement<SingleElement> >(list);
45	outputBuffer[0] = outVal;
46}