yum-mirror/slang

Making it easier to work with shaders

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

jsmall-nvidiaLanguage experiments (#2068)447b7e0e2

master
1.2 KiB44 linesraw
1//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
2
3/* This test trys to specialize an algorithm through generic parameters. 
4
5Using parameters in this way ensures the algorithm in function form 
6will have those values known at compile time, and presumably lead to a specialized version.
7
8Here (with 1 == 1) it's testing if a compile time knowable expression can be used.
9
10Does not work because
11
12.slang(25): note 99999: an internal error threw an exception while working on code near this location
13(0): error 99999: Slang compilation aborted due to an exception of class Slang::InternalError: unexpected: ErrorType
14*/
15
16//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
17RWStructuredBuffer<int> outputBuffer;
18
19enum class Enum
20{
21    A, B
22};
23
24// NOTE! Here we don't have let!
25int doThing<a : bool, b : int, c : Enum>()
26{
27    //if (a)
28    {
29        return 1;
30    }
31    return 0;
32    //return a ? b + b + int(c) : b - int(c);
33}
34
35
36[numthreads(4, 1, 1)]
37void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
38{    
39    int index = dispatchThreadID.x;
40    
41    let v = doThing<1 == 1, false, Enum::A>();
42    
43    outputBuffer[dispatchThreadID.x] = v;
44}