summaryrefslogtreecommitdiffstats
path: root/tests/bugs/do-loop.hlsl
blob: e293258b2df3c8772e148577f59b54a00bbea4da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//TEST_DISABLED:COMPARE_HLSL: -profile vs_5_0

// Check output for `do` loops

cbuffer C : register(b0)
{
	int n;
};

float4 main() : SV_Position
{
	float4 x = 0;
	int i = n;
	{
		do
		{
			x = (x + (float)1) * x;

			// Note(tfoley): The "right" thing here would be
			// `i--`, but that leads to a subtle difference
			// in the final code between just invokeing `fxc`
			// and invoking it on the Slang-generated output
			// (despite the generated HLSL for this line being
			// identical, modulo some `#line` directives).
			//
			// I'm using a binary operator that will yield
			// the same code with its operands swapped, just
			// to work around it. A better long-term fix
			// is to have this test be an end-to-end test
			// that we execute.
			i = i*i;
		} while((bool) i);
	}
    return x;
}