yum-mirror/slang

Making it easier to work with shaders

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

Tim FoleyAdd proper IR codegen support for local static const variables (#779)f0633a7d0

master
539 B27 linesraw
1// function-static-const.slang
2
3//TEST:CROSS_COMPILE:-target dxbc-assembly  -entry main -stage fragment -profile sm_5_0
4
5// This test ensures that we compile `static const` variables inside
6// of functions to reasonable HLSL output so that we don't introduce
7// unexpected overhead by treating them as just `static`.
8//
9
10int test(int val)
11{
12	static const int kArray[] = {
13		1, 2, 3, 4, 5, 6, 7, 8,
14		9, 10, 11, 12, 13, 14, 15, 16
15	};
16	return kArray[val];
17}
18
19cbuffer C
20{
21    int index;
22}
23
24float4 main() : SV_Target
25{
26	return test(index);
27}