yum-mirror/slang

Making it easier to work with shaders

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

Tim FoleyRework command-line options handling for entry points and targets (#697)725985528

master
930 B43 linesraw
1// Disabled because Slang IR path is missing support for [fastopt]
2//TEST_IGNORE_FILE
3
4//TEST:COMPARE_HLSL: -profile vs_4_0
5
6// Confirm that we pass through `[fastopt]` attributes
7//
8// This shader does indexing into the elements of
9// a vector, fetched from a `cbuffer`, based on
10// a loop counter (or a loop with a small trip
11// count), so `fxc` seems to want to unroll the
12// loop. The `[fastopt]` attribute changes this
13// behavior and results in a `loop` instruction
14// in the DX bytecode, so we can use this to
15// test whether Slang is passing through the
16// attribute or not.
17
18// Import Slang code so that we aren't just in
19// the 100% pass-through mode.
20#ifdef __SLANG__
21__import empty;
22#endif
23
24cbuffer C
25{
26	float4 b[4];
27}
28float test(float x, float c)
29{
30	[fastopt]
31	for(int ii = 0; ii < 2; ++ii)
32	{
33		x = x*x + c + b[ii][ii];
34	}
35	return x;
36}
37
38float4 main(float4 a : A) : SV_Position
39{
40	a.x = test(a.x, a.y);
41
42	return a;
43}