yum-mirror/slang

Making it easier to work with shaders

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

Mukund KeshavaIR: Add SPIR-V disassembly for embedded downstream IR dumps (#6529)f59e0ef40

master
1.4 KiB48 linesraw
1// This test checks the SPIR-V output when compiling a library containing generics with embedded downstream IR.
2
3//TEST:SIMPLE(filecheck=CHECK): -o tests/library/export-library-generics-test.slang-module -target spirv -embed-downstream-ir -profile lib_6_6 -incomplete-library -dump-ir -verbose-paths
4
5// export-library-generics.slang
6
7module "export-library-generics";
8
9public cbuffer Constants {
10    public float x;
11    public float y;
12}
13
14interface MyInterface
15{
16    int myMethod(int a);
17}
18
19struct MyType : MyInterface
20{
21    int myMethod(int a)
22    {
23        return a * 3;
24    }
25}
26
27int genericFunc<T: MyInterface>(T arg)
28{
29    return arg.myMethod(3);
30}
31
32public int normalFuncUsesGeneric(int a)
33{
34    MyType obj;
35    return genericFunc(obj);
36}
37
38public int normalFunc(int a, float b)
39{
40    return a - floor(b);
41}
42
43// CHECK:[availableInDownstreamIR(6 : Int)]
44// CHECK:EmbeddedDownstreamIR(6 : Int,
45// CHECK:               OpCapability Linkage
46// CHECK:OpDecorate %SLANG_ParameterGroup_Constants__init LinkageAttributes "_SR29export_2Dxlibrary_2Dxgenerics30SLANG_ParameterGroup_ConstantsR8_24xinitp2pi_fi_f" Export
47// CHECK:               OpDecorate %MyType_myMethod LinkageAttributes "_SR29export_2Dxlibrary_2Dxgenerics6MyType8myMethodp1pi_ii" Export
48// CHECK:               OpDecorate %normalFuncUsesGeneric LinkageAttributes "_SR29export_2Dxlibrary_2Dxgenerics21normalFuncUsesGenericp1pi_ii" Export