yum-mirror/slang

Making it easier to work with shaders

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

James Helferty (NVIDIA)render-test: Change D3D12 default to sm_6_5 (#8320)f02b08490

master
1.6 KiB59 linesraw
1// Test packing a user provided value and typeID into an existential value.
2
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -vk -output-using-type
4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -output-using-type
5//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx11 -profile sm_5_0 -output-using-type
6//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type
7
8[anyValueSize(16)]
9interface IInterface
10{
11    float run();
12}
13
14struct UserDefinedPackedType
15{
16    float3 val;
17    uint flags;
18};
19
20//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=gOutputBuffer
21RWStructuredBuffer<float> gOutputBuffer;
22
23//TEST_INPUT: set gObj = new StructuredBuffer<UserDefinedPackedType>[new UserDefinedPackedType{[1.0, 2.0, 3.0], 3}, new UserDefinedPackedType{[2.0, 3.0, 4.0], 4}];
24RWStructuredBuffer<UserDefinedPackedType> gObj;
25
26//TEST_INPUT: type_conformance FloatVal:IInterface = 3
27//TEST_INPUT: type_conformance Float4Val:IInterface = 4
28
29[numthreads(1, 1, 1)]
30void computeMain(uint3       dispatchThreadID : SV_DispatchThreadID)
31{
32    float result = 0.0;
33    for (int i = 0; i < 2; i++)
34    {
35        var rawObj = gObj.Load(i);
36        IInterface dynamicObj = createDynamicObject<IInterface, UserDefinedPackedType>(rawObj.flags, rawObj);
37        result += dynamicObj.run();
38    }
39    gOutputBuffer[0] = result;
40}
41
42struct FloatVal : IInterface
43{
44    float val;
45    float run()
46    {
47        return val;
48    }
49};
50interface ISomething{void g();}
51struct Float4Struct : ISomething { float4 val; void g() {} }
52struct Float4Val : IInterface
53{
54    Float4Struct val;
55    float run()
56    {
57        return val.val.x + val.val.y;
58    }
59};