Commit 8c8505c6 by John Kessenich

SPV: For AST interpolateAt* ops consuming a swizzle, invert the order.

Apply the interpolation first, then apply the swizzle to the result, the inverse of the order requested by the AST. This fixes issue #411.
parent 731cd83e
spv.swizzleInversion.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 46
Capability Shader
Capability InterpolationFunction
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 12 37
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 9 "v43"
Name 12 "in4"
Name 17 "v42"
Name 23 "v44"
Name 29 "v41"
Name 35 "v33"
Name 37 "in3"
Name 40 "v32"
Name 43 "v31"
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 3
8: TypePointer Function 7(fvec3)
10: TypeVector 6(float) 4
11: TypePointer Input 10(fvec4)
12(in4): 11(ptr) Variable Input
15: TypeVector 6(float) 2
16: TypePointer Function 15(fvec2)
18: TypeInt 32 1
19: 18(int) Constant 1
22: TypePointer Function 10(fvec4)
24: 6(float) Constant 1073741824
25: 15(fvec2) ConstantComposite 24 24
28: TypePointer Function 6(float)
30: TypeInt 32 0
31: 30(int) Constant 1
32: TypePointer Input 6(float)
36: TypePointer Input 7(fvec3)
37(in3): 36(ptr) Variable Input
4(main): 2 Function None 3
5: Label
9(v43): 8(ptr) Variable Function
17(v42): 16(ptr) Variable Function
23(v44): 22(ptr) Variable Function
29(v41): 28(ptr) Variable Function
35(v33): 8(ptr) Variable Function
40(v32): 16(ptr) Variable Function
43(v31): 28(ptr) Variable Function
13: 10(fvec4) ExtInst 1(GLSL.std.450) 76(InterpolateAtCentroid) 12(in4)
14: 7(fvec3) VectorShuffle 13 13 3 2 0
Store 9(v43) 14
20: 10(fvec4) ExtInst 1(GLSL.std.450) 77(InterpolateAtSample) 12(in4) 19
21: 15(fvec2) VectorShuffle 20 20 2 0
Store 17(v42) 21
26: 10(fvec4) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 12(in4) 25
27: 10(fvec4) VectorShuffle 26 26 2 1 0 3
Store 23(v44) 27
33: 32(ptr) AccessChain 12(in4) 31
34: 6(float) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 33 25
Store 29(v41) 34
38: 7(fvec3) ExtInst 1(GLSL.std.450) 76(InterpolateAtCentroid) 37(in3)
39: 7(fvec3) VectorShuffle 38 38 1 2 0
Store 35(v33) 39
41: 7(fvec3) ExtInst 1(GLSL.std.450) 77(InterpolateAtSample) 37(in3) 19
42: 15(fvec2) VectorShuffle 41 41 2 0
Store 40(v32) 42
44: 32(ptr) AccessChain 12(in4) 31
45: 6(float) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 44 25
Store 43(v31) 45
Return
FunctionEnd
#version 450
in vec4 in4;
in vec3 in3;
void main()
{
vec3 v43 = interpolateAtCentroid(in4.wzx);
vec2 v42 = interpolateAtSample(in4.zx, 1);
vec4 v44 = interpolateAtOffset(in4.zyxw, vec2(2.0));
float v41 = interpolateAtOffset(in4.y, vec2(2.0));
vec3 v33 = interpolateAtCentroid(in3.yzx);
vec2 v32 = interpolateAtSample(in3.zx, 1);
float v31 = interpolateAtOffset(in4.y, vec2(2.0));
}
......@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "SPIRV99.1339"
#define GLSLANG_DATE "25-Jul-2016"
#define GLSLANG_REVISION "SPIRV99.1340"
#define GLSLANG_DATE "26-Jul-2016"
......@@ -184,6 +184,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.structure.frag",
"spv.switch.frag",
"spv.swizzle.frag",
"spv.swizzleInversion.frag",
"spv.test.frag",
"spv.test.vert",
"spv.texture.frag",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment