Commit abfc4c2c by John Kessenich

Fix part of #2070: Correctly handle promotion for <unary-op>(int).

This still only handles a scalar correctly, and some vector cases need additional fixes.
parent 113d07a6
...@@ -17,8 +17,13 @@ gl_FragCoord origin is upper left ...@@ -17,8 +17,13 @@ gl_FragCoord origin is upper left
0:7 'inF0' ( in 1-component vector of uint) 0:7 'inF0' ( in 1-component vector of uint)
0:? Sequence 0:? Sequence
0:8 Branch: Return with expression 0:8 Branch: Return with expression
0:8 Constant: 0:8 Construct float ( temp 1-component vector of float)
0:8 0.000000 0:8 direct index ( temp float)
0:8 unpackHalf2x16 ( temp 2-component vector of float)
0:8 Construct uint ( in uint)
0:8 'inF0' ( in 1-component vector of uint)
0:8 Constant:
0:8 0 (const int)
0:12 Function Definition: PixelShaderFunction2(vu2; ( temp 2-component vector of float) 0:12 Function Definition: PixelShaderFunction2(vu2; ( temp 2-component vector of float)
0:12 Function Parameters: 0:12 Function Parameters:
0:12 'inF0' ( in 2-component vector of uint) 0:12 'inF0' ( in 2-component vector of uint)
...@@ -149,8 +154,13 @@ gl_FragCoord origin is upper left ...@@ -149,8 +154,13 @@ gl_FragCoord origin is upper left
0:7 'inF0' ( in 1-component vector of uint) 0:7 'inF0' ( in 1-component vector of uint)
0:? Sequence 0:? Sequence
0:8 Branch: Return with expression 0:8 Branch: Return with expression
0:8 Constant: 0:8 Construct float ( temp 1-component vector of float)
0:8 0.000000 0:8 direct index ( temp float)
0:8 unpackHalf2x16 ( temp 2-component vector of float)
0:8 Construct uint ( in uint)
0:8 'inF0' ( in 1-component vector of uint)
0:8 Constant:
0:8 0 (const int)
0:12 Function Definition: PixelShaderFunction2(vu2; ( temp 2-component vector of float) 0:12 Function Definition: PixelShaderFunction2(vu2; ( temp 2-component vector of float)
0:12 Function Parameters: 0:12 Function Parameters:
0:12 'inF0' ( in 2-component vector of uint) 0:12 'inF0' ( in 2-component vector of uint)
...@@ -261,12 +271,12 @@ gl_FragCoord origin is upper left ...@@ -261,12 +271,12 @@ gl_FragCoord origin is upper left
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80008 // Generated by (magic number): 80008
// Id's are bound by 103 // Id's are bound by 106
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 101 EntryPoint Fragment 4 "main" 104
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
...@@ -281,8 +291,8 @@ gl_FragCoord origin is upper left ...@@ -281,8 +291,8 @@ gl_FragCoord origin is upper left
Name 35 "PixelShaderFunction(vu4;" Name 35 "PixelShaderFunction(vu4;"
Name 34 "inF0" Name 34 "inF0"
Name 38 "@main(" Name 38 "@main("
Name 101 "@entryPointOutput" Name 104 "@entryPointOutput"
Decorate 101(@entryPointOutput) Location 0 Decorate 104(@entryPointOutput) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 0 6: TypeInt 32 0
...@@ -303,17 +313,17 @@ gl_FragCoord origin is upper left ...@@ -303,17 +313,17 @@ gl_FragCoord origin is upper left
33: TypeFunction 32(fvec4) 31(ptr) 33: TypeFunction 32(fvec4) 31(ptr)
37: TypeFunction 32(fvec4) 37: TypeFunction 32(fvec4)
42: 6(int) Constant 0 42: 6(int) Constant 0
46: 8(float) Constant 0 55: 6(int) Constant 1
53: 6(int) Constant 1 71: 6(int) Constant 2
69: 6(int) Constant 2 91: 6(int) Constant 3
89: 6(int) Constant 3 99: 8(float) Constant 0
97: 32(fvec4) ConstantComposite 46 46 46 46 100: 32(fvec4) ConstantComposite 99 99 99 99
100: TypePointer Output 32(fvec4) 103: TypePointer Output 32(fvec4)
101(@entryPointOutput): 100(ptr) Variable Output 104(@entryPointOutput): 103(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
102: 32(fvec4) FunctionCall 38(@main() 105: 32(fvec4) FunctionCall 38(@main()
Store 101(@entryPointOutput) 102 Store 104(@entryPointOutput) 105
Return Return
FunctionEnd FunctionEnd
11(PixelShaderFunctionS(u1;): 8(float) Function None 9 11(PixelShaderFunctionS(u1;): 8(float) Function None 9
...@@ -327,63 +337,66 @@ gl_FragCoord origin is upper left ...@@ -327,63 +337,66 @@ gl_FragCoord origin is upper left
14(PixelShaderFunction1(vu1;): 8(float) Function None 9 14(PixelShaderFunction1(vu1;): 8(float) Function None 9
13(inF0): 7(ptr) FunctionParameter 13(inF0): 7(ptr) FunctionParameter
15: Label 15: Label
ReturnValue 46 46: 6(int) Load 13(inF0)
47: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 46
48: 8(float) CompositeExtract 47 0
ReturnValue 48
FunctionEnd FunctionEnd
21(PixelShaderFunction2(vu2;): 18(fvec2) Function None 19 21(PixelShaderFunction2(vu2;): 18(fvec2) Function None 19
20(inF0): 17(ptr) FunctionParameter 20(inF0): 17(ptr) FunctionParameter
22: Label 22: Label
49: 7(ptr) AccessChain 20(inF0) 42 51: 7(ptr) AccessChain 20(inF0) 42
50: 6(int) Load 49 52: 6(int) Load 51
51: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 50 53: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 52
52: 8(float) CompositeExtract 51 0 54: 8(float) CompositeExtract 53 0
54: 7(ptr) AccessChain 20(inF0) 53 56: 7(ptr) AccessChain 20(inF0) 55
55: 6(int) Load 54 57: 6(int) Load 56
56: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 55 58: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 57
57: 8(float) CompositeExtract 56 0 59: 8(float) CompositeExtract 58 0
58: 18(fvec2) CompositeConstruct 52 57 60: 18(fvec2) CompositeConstruct 54 59
ReturnValue 58 ReturnValue 60
FunctionEnd FunctionEnd
28(PixelShaderFunction3(vu3;): 25(fvec3) Function None 26 28(PixelShaderFunction3(vu3;): 25(fvec3) Function None 26
27(inF0): 24(ptr) FunctionParameter 27(inF0): 24(ptr) FunctionParameter
29: Label 29: Label
61: 7(ptr) AccessChain 27(inF0) 42 63: 7(ptr) AccessChain 27(inF0) 42
62: 6(int) Load 61 64: 6(int) Load 63
63: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 62 65: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 64
64: 8(float) CompositeExtract 63 0 66: 8(float) CompositeExtract 65 0
65: 7(ptr) AccessChain 27(inF0) 53 67: 7(ptr) AccessChain 27(inF0) 55
66: 6(int) Load 65 68: 6(int) Load 67
67: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 66 69: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 68
68: 8(float) CompositeExtract 67 0 70: 8(float) CompositeExtract 69 0
70: 7(ptr) AccessChain 27(inF0) 69 72: 7(ptr) AccessChain 27(inF0) 71
71: 6(int) Load 70 73: 6(int) Load 72
72: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 71 74: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 73
73: 8(float) CompositeExtract 72 0 75: 8(float) CompositeExtract 74 0
74: 25(fvec3) CompositeConstruct 64 68 73 76: 25(fvec3) CompositeConstruct 66 70 75
ReturnValue 74 ReturnValue 76
FunctionEnd FunctionEnd
35(PixelShaderFunction(vu4;): 32(fvec4) Function None 33 35(PixelShaderFunction(vu4;): 32(fvec4) Function None 33
34(inF0): 31(ptr) FunctionParameter 34(inF0): 31(ptr) FunctionParameter
36: Label 36: Label
77: 7(ptr) AccessChain 34(inF0) 42 79: 7(ptr) AccessChain 34(inF0) 42
78: 6(int) Load 77 80: 6(int) Load 79
79: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 78 81: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 80
80: 8(float) CompositeExtract 79 0 82: 8(float) CompositeExtract 81 0
81: 7(ptr) AccessChain 34(inF0) 53 83: 7(ptr) AccessChain 34(inF0) 55
82: 6(int) Load 81 84: 6(int) Load 83
83: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 82 85: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 84
84: 8(float) CompositeExtract 83 0 86: 8(float) CompositeExtract 85 0
85: 7(ptr) AccessChain 34(inF0) 69 87: 7(ptr) AccessChain 34(inF0) 71
86: 6(int) Load 85 88: 6(int) Load 87
87: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 86 89: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 88
88: 8(float) CompositeExtract 87 0 90: 8(float) CompositeExtract 89 0
90: 7(ptr) AccessChain 34(inF0) 89 92: 7(ptr) AccessChain 34(inF0) 91
91: 6(int) Load 90 93: 6(int) Load 92
92: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 91 94: 18(fvec2) ExtInst 1(GLSL.std.450) 62(UnpackHalf2x16) 93
93: 8(float) CompositeExtract 92 0 95: 8(float) CompositeExtract 94 0
94: 32(fvec4) CompositeConstruct 80 84 88 93 96: 32(fvec4) CompositeConstruct 82 86 90 95
ReturnValue 94 ReturnValue 96
FunctionEnd FunctionEnd
38(@main(): 32(fvec4) Function None 37 38(@main(): 32(fvec4) Function None 37
39: Label 39: Label
ReturnValue 97 ReturnValue 100
FunctionEnd FunctionEnd
float main(): SV_Target0
{
int d = 4;
int2 d2 = int2(5,d);
float f1 = log2(5);
float2 f2 = log(d2);
float3 f3 = log(int3(7,2,3));
float2 f22 = log(int2(5,d)); // This case does not work yet, due to a different bug that turns this into 2 args.
int a = 5;
min16float b = min16float(f16tof32(a));
b *= b;
uint c = f32tof16(b);
return f1 + f2.x + f3.z + f22.y + c;
}
\ No newline at end of file
...@@ -3237,10 +3237,17 @@ bool TIntermediate::promoteUnary(TIntermUnary& node) ...@@ -3237,10 +3237,17 @@ bool TIntermediate::promoteUnary(TIntermUnary& node)
return false; return false;
break; break;
default: default:
if (operand->getBasicType() != EbtFloat) // HLSL uses this path for initial function signature finding for built-ins
// taking a single argument, which generally don't participate in
// operator-based type promotion (type conversion will occur later).
// For now, scalar argument cases are relying on the setType() call below.
if (getSource() == EShSourceHlsl)
break;
// GLSL only allows integer arguments for the cases identified above in the
// case statements.
if (operand->getBasicType() != EbtFloat)
return false; return false;
} }
......
...@@ -350,6 +350,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -350,6 +350,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.semicolons.frag", "main"}, {"hlsl.semicolons.frag", "main"},
{"hlsl.shapeConv.frag", "main"}, {"hlsl.shapeConv.frag", "main"},
{"hlsl.shapeConvRet.frag", "main"}, {"hlsl.shapeConvRet.frag", "main"},
{"hlsl.singleArgIntPromo.vert", "main"},
{"hlsl.self_cast.frag", "main"}, {"hlsl.self_cast.frag", "main"},
{"hlsl.snorm.uav.comp", "main"}, {"hlsl.snorm.uav.comp", "main"},
{"hlsl.specConstant.frag", "main"}, {"hlsl.specConstant.frag", "main"},
......
...@@ -7572,7 +7572,7 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, TFunction ...@@ -7572,7 +7572,7 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, TFunction
if (args->getAsAggregate()) { if (args->getAsAggregate()) {
// Handle aggregates: put all args into the new function call // Handle aggregates: put all args into the new function call
for (int arg=0; arg<int(args->getAsAggregate()->getSequence().size()); ++arg) { for (int arg = 0; arg < int(args->getAsAggregate()->getSequence().size()); ++arg) {
// TODO: But for constness, we could avoid the new & shallowCopy, and use the pointer directly. // TODO: But for constness, we could avoid the new & shallowCopy, and use the pointer directly.
TParameter param = { 0, new TType, nullptr }; TParameter param = { 0, new TType, nullptr };
param.type->shallowCopy(args->getAsAggregate()->getSequence()[arg]->getAsTyped()->getType()); param.type->shallowCopy(args->getAsAggregate()->getSequence()[arg]->getAsTyped()->getType());
......
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