From 841db35bb3bf7d86771bef34080ed90176bd2a78 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Fri, 2 Sep 2016 21:12:23 -0600 Subject: [PATCH] HLSL: Fix issue #442, smear and truncate shape conversions for == and !=. --- Test/baseResults/hlsl.shapeConv.frag.out | 76 ++++++++++++++++++++++++++--- Test/hlsl.shapeConv.frag | 16 ++++-- glslang/MachineIndependent/Intermediate.cpp | 2 + hlsl/hlslGrammar.cpp | 2 +- 4 files changed, 84 insertions(+), 12 deletions(-) diff --git a/Test/baseResults/hlsl.shapeConv.frag.out b/Test/baseResults/hlsl.shapeConv.frag.out index beeda4a..cbf6228 100755 --- a/Test/baseResults/hlsl.shapeConv.frag.out +++ b/Test/baseResults/hlsl.shapeConv.frag.out @@ -82,8 +82,27 @@ gl_FragCoord origin is upper left 0:19 7.000000 0:19 7.000000 0:19 'foo' (temp 3-component vector of float) -0:21 Branch: Return with expression -0:21 'input' (in 4-component vector of float) +0:21 Compare Equal (temp bool) +0:21 Construct vec4 (temp 4-component vector of float) +0:21 direct index (temp float) +0:21 'v' (temp 4-component vector of float) +0:21 Constant: +0:21 0 (const int) +0:21 'v' (temp 4-component vector of float) +0:22 Compare Not Equal (temp bool) +0:22 Construct vec4 (temp 4-component vector of float) +0:22 'f' (in float) +0:22 'v' (temp 4-component vector of float) +0:26 Compare Equal (temp bool) +0:26 'f1' (temp 1-component vector of float) +0:26 Construct float (temp 1-component vector of float) +0:26 'v' (temp 4-component vector of float) +0:27 Compare Less Than (temp bool) +0:27 Construct float (temp 1-component vector of float) +0:27 'v' (temp 4-component vector of float) +0:27 'f1' (temp 1-component vector of float) +0:29 Branch: Return with expression +0:29 'input' (in 4-component vector of float) 0:? Linker Objects @@ -173,13 +192,32 @@ gl_FragCoord origin is upper left 0:19 7.000000 0:19 7.000000 0:19 'foo' (temp 3-component vector of float) -0:21 Branch: Return with expression -0:21 'input' (in 4-component vector of float) +0:21 Compare Equal (temp bool) +0:21 Construct vec4 (temp 4-component vector of float) +0:21 direct index (temp float) +0:21 'v' (temp 4-component vector of float) +0:21 Constant: +0:21 0 (const int) +0:21 'v' (temp 4-component vector of float) +0:22 Compare Not Equal (temp bool) +0:22 Construct vec4 (temp 4-component vector of float) +0:22 'f' (in float) +0:22 'v' (temp 4-component vector of float) +0:26 Compare Equal (temp bool) +0:26 'f1' (temp 1-component vector of float) +0:26 Construct float (temp 1-component vector of float) +0:26 'v' (temp 4-component vector of float) +0:27 Compare Less Than (temp bool) +0:27 Construct float (temp 1-component vector of float) +0:27 'v' (temp 4-component vector of float) +0:27 'f1' (temp 1-component vector of float) +0:29 Branch: Return with expression +0:29 'input' (in 4-component vector of float) 0:? Linker Objects // Module Version 10000 // Generated by (magic number): 80001 -// Id's are bound by 58 +// Id's are bound by 81 Capability Shader 1: ExtInstImport "GLSL.std.450" @@ -196,6 +234,7 @@ gl_FragCoord origin is upper left Name 33 "V" Name 34 "MyVal" Name 37 "foo" + Name 69 "f1" 2: TypeVoid 3: TypeFunction 2 6: TypeFloat 32 @@ -223,6 +262,9 @@ gl_FragCoord origin is upper left 48: 22(fvec3) ConstantComposite 47 47 47 51: 6(float) Constant 1088421888 52: 22(fvec3) ConstantComposite 51 51 51 + 55: TypeInt 32 0 + 56: 55(int) Constant 0 + 61: TypeVector 41(bool) 4 4(main): 2 Function None 3 5: Label FunctionEnd @@ -236,6 +278,7 @@ gl_FragCoord origin is upper left 33(V): 9(ptr) Variable Function 34(MyVal): 23(ptr) Variable Function 37(foo): 23(ptr) Variable Function + 69(f1): 9(ptr) Variable Function Store 15(v) 17 Store 15(v) 19 20: 6(float) Load 12(f) @@ -259,6 +302,25 @@ gl_FragCoord origin is upper left 50: 41(bool) FOrdLessThan 48 49 53: 22(fvec3) Load 37(foo) 54: 41(bool) FOrdLessThanEqual 52 53 - 55: 7(fvec4) Load 11(input) - ReturnValue 55 + 57: 9(ptr) AccessChain 15(v) 56 + 58: 6(float) Load 57 + 59: 7(fvec4) CompositeConstruct 58 58 58 58 + 60: 7(fvec4) Load 15(v) + 62: 61(bvec4) FOrdEqual 59 60 + 63: 41(bool) All 62 + 64: 6(float) Load 12(f) + 65: 7(fvec4) CompositeConstruct 64 64 64 64 + 66: 7(fvec4) Load 15(v) + 67: 61(bvec4) FOrdNotEqual 65 66 + 68: 41(bool) Any 67 + 70: 6(float) Load 69(f1) + 71: 7(fvec4) Load 15(v) + 72: 6(float) CompositeExtract 71 0 + 73: 41(bool) FOrdEqual 70 72 + 74: 7(fvec4) Load 15(v) + 75: 6(float) CompositeExtract 74 0 + 76: 6(float) Load 69(f1) + 77: 41(bool) FOrdLessThan 75 76 + 78: 7(fvec4) Load 11(input) + ReturnValue 78 FunctionEnd diff --git a/Test/hlsl.shapeConv.frag b/Test/hlsl.shapeConv.frag index 3147b61..3ecb33a 100644 --- a/Test/hlsl.shapeConv.frag +++ b/Test/hlsl.shapeConv.frag @@ -9,14 +9,22 @@ float4 PixelShaderFunction(float4 input, float f) : COLOR0 u = float(2.0); u = float(f); float2 w = 2.0; - float V = 1; + float V = 1; float3 MyVal = V; - float3 foo; - foo > 4.0; - foo >= 5.0; + float3 foo; + foo > 4.0; + foo >= 5.0; 6.0 < foo; 7.0 <= foo; + v.x == v; + f != v; + + float1 f1; + + f1 == v; + v < f1; + return input; } diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp index ee9c251..3a5a3f6 100644 --- a/glslang/MachineIndependent/Intermediate.cpp +++ b/glslang/MachineIndependent/Intermediate.cpp @@ -702,6 +702,8 @@ TIntermTyped* TIntermediate::addShapeConversion(TOperator op, const TType& type, case EOpGreaterThan: case EOpLessThanEqual: case EOpGreaterThanEqual: + case EOpEqual: + case EOpNotEqual: case EOpFunctionCall: break; default: diff --git a/hlsl/hlslGrammar.cpp b/hlsl/hlslGrammar.cpp index 6ddd1bf..a4fe38e 100755 --- a/hlsl/hlslGrammar.cpp +++ b/hlsl/hlslGrammar.cpp @@ -525,7 +525,7 @@ bool HlslGrammar::acceptQualifier(TQualifier& qualifier) // // layout_qualifier // : identifier -// | identifier EQUAL expresion +// | identifier EQUAL expression // // Zero or more of these, so this can't return false. // -- 2.7.4