HLSL: Allow arbitrary baseType -> baseType conversion of calling arguments.

This also puts a stake in the ground as to which is better when selection
from multiple signatures.
This commit is contained in:
John Kessenich 2016-08-25 10:49:21 -06:00
parent 4c3a7fd100
commit 90dd70f752
6 changed files with 1395 additions and 464 deletions

View File

@ -1,50 +1,31 @@
hlsl.intrinsics.negative.frag
ERROR: 0:5: 'asdouble' : no matching overloaded function found
ERROR: 0:6: 'CheckAccessFullyMapped' : no matching overloaded function found
ERROR: 0:7: 'countbits' : no matching overloaded function found
ERROR: 0:8: 'cross' : no matching overloaded function found
ERROR: 0:9: 'D3DCOLORtoUBYTE4' : no matching overloaded function found
ERROR: 0:10: 'determinant' : no matching overloaded function found
ERROR: 0:12: 'f16tof32' : no matching overloaded function found
ERROR: 0:13: 'firstbithigh' : no matching overloaded function found
ERROR: 0:14: 'firstbitlow' : no matching overloaded function found
ERROR: 0:12: 'f32tof16' : unimplemented intrinsic: handle natively
ERROR: 0:23: 'length' : no matching overloaded function found
ERROR: 0:24: 'msad4' : no matching overloaded function found
ERROR: 0:25: 'normalize' : no matching overloaded function found
ERROR: 0:26: 'reflect' : no matching overloaded function found
ERROR: 0:27: 'refract' : no matching overloaded function found
ERROR: 0:28: 'refract' : no matching overloaded function found
ERROR: 0:29: 'reversebits' : no matching overloaded function found
ERROR: 0:30: 'transpose' : no matching overloaded function found
ERROR: 0:39: 'GetRenderTargetSamplePosition' : no matching overloaded function found
ERROR: 0:46: 'asdouble' : no matching overloaded function found
ERROR: 0:46: 'asdouble' : double2 conversion not implemented
ERROR: 0:47: 'CheckAccessFullyMapped' : no matching overloaded function found
ERROR: 0:48: 'countbits' : no matching overloaded function found
ERROR: 0:49: 'cross' : no matching overloaded function found
ERROR: 0:50: 'D3DCOLORtoUBYTE4' : no matching overloaded function found
ERROR: 0:51: 'determinant' : no matching overloaded function found
ERROR: 0:52: 'f16tof32' : no matching overloaded function found
ERROR: 0:53: 'firstbithigh' : no matching overloaded function found
ERROR: 0:54: 'firstbitlow' : no matching overloaded function found
ERROR: 0:56: 'reversebits' : no matching overloaded function found
ERROR: 0:52: 'f32tof16' : unimplemented intrinsic: handle natively
ERROR: 0:57: 'transpose' : no matching overloaded function found
ERROR: 0:64: 'CheckAccessFullyMapped' : no matching overloaded function found
ERROR: 0:65: 'countbits' : no matching overloaded function found
ERROR: 0:66: 'D3DCOLORtoUBYTE4' : no matching overloaded function found
ERROR: 0:67: 'determinant' : no matching overloaded function found
ERROR: 0:68: 'f16tof32' : no matching overloaded function found
ERROR: 0:69: 'firstbithigh' : no matching overloaded function found
ERROR: 0:70: 'firstbitlow' : no matching overloaded function found
ERROR: 0:72: 'reversebits' : no matching overloaded function found
ERROR: 0:68: 'f32tof16' : unimplemented intrinsic: handle natively
ERROR: 0:73: 'transpose' : no matching overloaded function found
ERROR: 0:81: 'CheckAccessFullyMapped' : no matching overloaded function found
ERROR: 0:82: 'countbits' : no matching overloaded function found
ERROR: 0:83: 'cross' : no matching overloaded function found
ERROR: 0:84: 'determinant' : no matching overloaded function found
ERROR: 0:85: 'f16tof32' : no matching overloaded function found
ERROR: 0:86: 'firstbithigh' : no matching overloaded function found
ERROR: 0:87: 'firstbitlow' : no matching overloaded function found
ERROR: 0:89: 'reversebits' : no matching overloaded function found
ERROR: 0:85: 'f32tof16' : unimplemented intrinsic: handle natively
ERROR: 0:90: 'transpose' : no matching overloaded function found
ERROR: 0:117: 'countbits' : no matching overloaded function found
ERROR: 0:117: 'D3DCOLORtoUBYTE4' : no matching overloaded function found
@ -85,7 +66,7 @@ ERROR: 0:133: 'normalize' : no matching overloaded function found
ERROR: 0:133: 'reflect' : no matching overloaded function found
ERROR: 0:133: 'refract' : no matching overloaded function found
ERROR: 0:133: 'reversebits' : no matching overloaded function found
ERROR: 86 compilation errors. No code generated.
ERROR: 67 compilation errors. No code generated.
Shader version: 450
@ -98,28 +79,47 @@ ERROR: node is still EOpNull!
0:2 'inF2' (in float)
0:2 'inI0' (in int)
0:? Sequence
0:5 Constant:
0:5 0.000000
0:6 Constant:
0:6 0.000000
0:7 Constant:
0:7 0.000000
0:5 uint64BitsToDouble (temp double)
0:5 Construct uvec2 (temp 2-component vector of uint)
0:5 Convert float to uint (temp uint)
0:5 'inF0' (in float)
0:5 Convert float to uint (temp uint)
0:5 'inF1' (in float)
0:6 Function Call: CheckAccessFullyMapped(u1; (global bool)
0:6 Constant:
0:6 3 (const uint)
0:7 bitCount (global uint)
0:7 Convert float to uint (temp uint)
0:7 'inF0' (in float)
0:8 Constant:
0:8 0.000000
0:9 Constant:
0:9 0.000000
0:10 Constant:
0:10 0.000000
0:12 Constant:
0:12 0.000000
0:13 Constant:
0:13 0.000000
0:14 Constant:
0:14 0.000000
0:12 ERROR: Bad unary op
(global float)
0:12 Convert float to uint (temp uint)
0:12 'inF0' (in float)
0:13 findMSB (global uint)
0:13 Convert float to uint (temp uint)
0:13 'inF0' (in float)
0:14 findLSB (global uint)
0:14 Convert float to uint (temp uint)
0:14 'inF0' (in float)
0:23 Constant:
0:23 0.000000
0:24 Constant:
0:24 0.000000
0:24 Function Call: msad4(u1;vu2;vu4; (global 4-component vector of uint)
0:24 Convert float to uint (temp uint)
0:24 'inF0' (in float)
0:24 Constant:
0:24 0 (const uint)
0:24 0 (const uint)
0:24 Constant:
0:24 0 (const uint)
0:24 0 (const uint)
0:24 0 (const uint)
0:24 0 (const uint)
0:25 Constant:
0:25 0.000000
0:26 Constant:
@ -128,8 +128,9 @@ ERROR: node is still EOpNull!
0:27 0.000000
0:28 Constant:
0:28 0.000000
0:29 Constant:
0:29 0.000000
0:29 bitFieldReverse (global uint)
0:29 Convert float to uint (temp uint)
0:29 'inF0' (in float)
0:30 Constant:
0:30 0.000000
0:32 Branch: Return with expression
@ -154,26 +155,36 @@ ERROR: node is still EOpNull!
0:45 'inF2' (in 2-component vector of float)
0:45 'inI0' (in 2-component vector of int)
0:? Sequence
0:46 Constant:
0:46 0.000000
0:46 ERROR: Bad aggregation op
(global 2-component vector of double)
0:46 Convert float to uint (temp 2-component vector of uint)
0:46 'inF0' (in 2-component vector of float)
0:46 Convert float to uint (temp 2-component vector of uint)
0:46 'inF1' (in 2-component vector of float)
0:47 Constant:
0:47 0.000000
0:48 Constant:
0:48 0.000000
0:48 bitCount (global 2-component vector of uint)
0:48 Convert float to uint (temp 2-component vector of uint)
0:48 'inF0' (in 2-component vector of float)
0:49 Constant:
0:49 0.000000
0:50 Constant:
0:50 0.000000
0:51 Constant:
0:51 0.000000
0:52 Constant:
0:52 0.000000
0:53 Constant:
0:53 0.000000
0:54 Constant:
0:54 0.000000
0:56 Constant:
0:56 0.000000
0:52 ERROR: Bad unary op
(global 2-component vector of float)
0:52 Convert float to uint (temp 2-component vector of uint)
0:52 'inF0' (in 2-component vector of float)
0:53 findMSB (global 2-component vector of uint)
0:53 Convert float to uint (temp 2-component vector of uint)
0:53 'inF0' (in 2-component vector of float)
0:54 findLSB (global 2-component vector of uint)
0:54 Convert float to uint (temp 2-component vector of uint)
0:54 'inF0' (in 2-component vector of float)
0:56 bitFieldReverse (global 2-component vector of uint)
0:56 Convert float to uint (temp 2-component vector of uint)
0:56 'inF0' (in 2-component vector of float)
0:57 Constant:
0:57 0.000000
0:59 Branch: Return with expression
@ -189,20 +200,26 @@ ERROR: node is still EOpNull!
0:? Sequence
0:64 Constant:
0:64 0.000000
0:65 Constant:
0:65 0.000000
0:65 bitCount (global 3-component vector of uint)
0:65 Convert float to uint (temp 3-component vector of uint)
0:65 'inF0' (in 3-component vector of float)
0:66 Constant:
0:66 0.000000
0:67 Constant:
0:67 0.000000
0:68 Constant:
0:68 0.000000
0:69 Constant:
0:69 0.000000
0:70 Constant:
0:70 0.000000
0:72 Constant:
0:72 0.000000
0:68 ERROR: Bad unary op
(global 3-component vector of float)
0:68 Convert float to uint (temp 3-component vector of uint)
0:68 'inF0' (in 3-component vector of float)
0:69 findMSB (global 3-component vector of uint)
0:69 Convert float to uint (temp 3-component vector of uint)
0:69 'inF0' (in 3-component vector of float)
0:70 findLSB (global 3-component vector of uint)
0:70 Convert float to uint (temp 3-component vector of uint)
0:70 'inF0' (in 3-component vector of float)
0:72 bitFieldReverse (global 3-component vector of uint)
0:72 Convert float to uint (temp 3-component vector of uint)
0:72 'inF0' (in 3-component vector of float)
0:73 Constant:
0:73 0.000000
0:76 Branch: Return with expression
@ -219,20 +236,26 @@ ERROR: node is still EOpNull!
0:? Sequence
0:81 Constant:
0:81 0.000000
0:82 Constant:
0:82 0.000000
0:82 bitCount (global 4-component vector of uint)
0:82 Convert float to uint (temp 4-component vector of uint)
0:82 'inF0' (in 4-component vector of float)
0:83 Constant:
0:83 0.000000
0:84 Constant:
0:84 0.000000
0:85 Constant:
0:85 0.000000
0:86 Constant:
0:86 0.000000
0:87 Constant:
0:87 0.000000
0:89 Constant:
0:89 0.000000
0:85 ERROR: Bad unary op
(global 4-component vector of float)
0:85 Convert float to uint (temp 4-component vector of uint)
0:85 'inF0' (in 4-component vector of float)
0:86 findMSB (global 4-component vector of uint)
0:86 Convert float to uint (temp 4-component vector of uint)
0:86 'inF0' (in 4-component vector of float)
0:87 findLSB (global 4-component vector of uint)
0:87 Convert float to uint (temp 4-component vector of uint)
0:87 'inF0' (in 4-component vector of float)
0:89 bitFieldReverse (global 4-component vector of uint)
0:89 Convert float to uint (temp 4-component vector of uint)
0:89 'inF0' (in 4-component vector of float)
0:90 Constant:
0:90 0.000000
0:92 Branch: Return with expression
@ -388,28 +411,47 @@ ERROR: node is still EOpNull!
0:2 'inF2' (in float)
0:2 'inI0' (in int)
0:? Sequence
0:5 Constant:
0:5 0.000000
0:6 Constant:
0:6 0.000000
0:7 Constant:
0:7 0.000000
0:5 uint64BitsToDouble (temp double)
0:5 Construct uvec2 (temp 2-component vector of uint)
0:5 Convert float to uint (temp uint)
0:5 'inF0' (in float)
0:5 Convert float to uint (temp uint)
0:5 'inF1' (in float)
0:6 Function Call: CheckAccessFullyMapped(u1; (global bool)
0:6 Constant:
0:6 3 (const uint)
0:7 bitCount (global uint)
0:7 Convert float to uint (temp uint)
0:7 'inF0' (in float)
0:8 Constant:
0:8 0.000000
0:9 Constant:
0:9 0.000000
0:10 Constant:
0:10 0.000000
0:12 Constant:
0:12 0.000000
0:13 Constant:
0:13 0.000000
0:14 Constant:
0:14 0.000000
0:12 ERROR: Bad unary op
(global float)
0:12 Convert float to uint (temp uint)
0:12 'inF0' (in float)
0:13 findMSB (global uint)
0:13 Convert float to uint (temp uint)
0:13 'inF0' (in float)
0:14 findLSB (global uint)
0:14 Convert float to uint (temp uint)
0:14 'inF0' (in float)
0:23 Constant:
0:23 0.000000
0:24 Constant:
0:24 0.000000
0:24 Function Call: msad4(u1;vu2;vu4; (global 4-component vector of uint)
0:24 Convert float to uint (temp uint)
0:24 'inF0' (in float)
0:24 Constant:
0:24 0 (const uint)
0:24 0 (const uint)
0:24 Constant:
0:24 0 (const uint)
0:24 0 (const uint)
0:24 0 (const uint)
0:24 0 (const uint)
0:25 Constant:
0:25 0.000000
0:26 Constant:
@ -418,8 +460,9 @@ ERROR: node is still EOpNull!
0:27 0.000000
0:28 Constant:
0:28 0.000000
0:29 Constant:
0:29 0.000000
0:29 bitFieldReverse (global uint)
0:29 Convert float to uint (temp uint)
0:29 'inF0' (in float)
0:30 Constant:
0:30 0.000000
0:32 Branch: Return with expression
@ -444,26 +487,36 @@ ERROR: node is still EOpNull!
0:45 'inF2' (in 2-component vector of float)
0:45 'inI0' (in 2-component vector of int)
0:? Sequence
0:46 Constant:
0:46 0.000000
0:46 ERROR: Bad aggregation op
(global 2-component vector of double)
0:46 Convert float to uint (temp 2-component vector of uint)
0:46 'inF0' (in 2-component vector of float)
0:46 Convert float to uint (temp 2-component vector of uint)
0:46 'inF1' (in 2-component vector of float)
0:47 Constant:
0:47 0.000000
0:48 Constant:
0:48 0.000000
0:48 bitCount (global 2-component vector of uint)
0:48 Convert float to uint (temp 2-component vector of uint)
0:48 'inF0' (in 2-component vector of float)
0:49 Constant:
0:49 0.000000
0:50 Constant:
0:50 0.000000
0:51 Constant:
0:51 0.000000
0:52 Constant:
0:52 0.000000
0:53 Constant:
0:53 0.000000
0:54 Constant:
0:54 0.000000
0:56 Constant:
0:56 0.000000
0:52 ERROR: Bad unary op
(global 2-component vector of float)
0:52 Convert float to uint (temp 2-component vector of uint)
0:52 'inF0' (in 2-component vector of float)
0:53 findMSB (global 2-component vector of uint)
0:53 Convert float to uint (temp 2-component vector of uint)
0:53 'inF0' (in 2-component vector of float)
0:54 findLSB (global 2-component vector of uint)
0:54 Convert float to uint (temp 2-component vector of uint)
0:54 'inF0' (in 2-component vector of float)
0:56 bitFieldReverse (global 2-component vector of uint)
0:56 Convert float to uint (temp 2-component vector of uint)
0:56 'inF0' (in 2-component vector of float)
0:57 Constant:
0:57 0.000000
0:59 Branch: Return with expression
@ -479,20 +532,26 @@ ERROR: node is still EOpNull!
0:? Sequence
0:64 Constant:
0:64 0.000000
0:65 Constant:
0:65 0.000000
0:65 bitCount (global 3-component vector of uint)
0:65 Convert float to uint (temp 3-component vector of uint)
0:65 'inF0' (in 3-component vector of float)
0:66 Constant:
0:66 0.000000
0:67 Constant:
0:67 0.000000
0:68 Constant:
0:68 0.000000
0:69 Constant:
0:69 0.000000
0:70 Constant:
0:70 0.000000
0:72 Constant:
0:72 0.000000
0:68 ERROR: Bad unary op
(global 3-component vector of float)
0:68 Convert float to uint (temp 3-component vector of uint)
0:68 'inF0' (in 3-component vector of float)
0:69 findMSB (global 3-component vector of uint)
0:69 Convert float to uint (temp 3-component vector of uint)
0:69 'inF0' (in 3-component vector of float)
0:70 findLSB (global 3-component vector of uint)
0:70 Convert float to uint (temp 3-component vector of uint)
0:70 'inF0' (in 3-component vector of float)
0:72 bitFieldReverse (global 3-component vector of uint)
0:72 Convert float to uint (temp 3-component vector of uint)
0:72 'inF0' (in 3-component vector of float)
0:73 Constant:
0:73 0.000000
0:76 Branch: Return with expression
@ -509,20 +568,26 @@ ERROR: node is still EOpNull!
0:? Sequence
0:81 Constant:
0:81 0.000000
0:82 Constant:
0:82 0.000000
0:82 bitCount (global 4-component vector of uint)
0:82 Convert float to uint (temp 4-component vector of uint)
0:82 'inF0' (in 4-component vector of float)
0:83 Constant:
0:83 0.000000
0:84 Constant:
0:84 0.000000
0:85 Constant:
0:85 0.000000
0:86 Constant:
0:86 0.000000
0:87 Constant:
0:87 0.000000
0:89 Constant:
0:89 0.000000
0:85 ERROR: Bad unary op
(global 4-component vector of float)
0:85 Convert float to uint (temp 4-component vector of uint)
0:85 'inF0' (in 4-component vector of float)
0:86 findMSB (global 4-component vector of uint)
0:86 Convert float to uint (temp 4-component vector of uint)
0:86 'inF0' (in 4-component vector of float)
0:87 findLSB (global 4-component vector of uint)
0:87 Convert float to uint (temp 4-component vector of uint)
0:87 'inF0' (in 4-component vector of float)
0:89 bitFieldReverse (global 4-component vector of uint)
0:89 Convert float to uint (temp 4-component vector of uint)
0:89 'inF0' (in 4-component vector of float)
0:90 Constant:
0:90 0.000000
0:92 Branch: Return with expression

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +1,117 @@
// function selection under type conversion
void foo1(double a, bool b) {}
void foo1(double a, uint b) {}
void foo1(double a, int b) {}
void foo1(double a, float b) {}
void foo1(double a, double b){}
// uint -> int
void foo2(int a, bool b) {}
void foo2(int a, uint b) {}
void foo2(int a, int b) {}
void foo2(int a, float b) {}
void foo2(int a, double b){}
// everything can promote
void foo3(bool b) {}
void foo4(uint b) {}
void foo5(int b) {}
void foo6(float b) {}
void foo7(double b){}
// shorter forward chain better than longer or backward chain
void foo8(float);
void foo8(double);
void foo9(int);
void foo9(uint);
void foo10(bool);
void foo10(int);
float4 PixelShaderFunction(float4 input) : COLOR0
{
bool b;
double d;
uint u;
int i;
float f;
foo1(d, b);
foo1(d, d);
foo1(d, u);
foo1(d, i);
foo1(d, f);
foo1(f, b);
foo1(f, d);
foo1(f, u);
foo1(f, i);
foo1(f, f);
foo1(u, b);
foo1(u, d);
foo1(u, u);
foo1(u, i);
foo1(u, f);
foo1(i, b);
foo1(i, d);
foo1(i, u);
foo1(i, i);
foo1(i, f);
foo2(u, b);
foo2(u, d);
foo2(u, u);
foo2(u, i);
foo2(u, f);
foo2(i, b);
foo2(i, d);
foo2(i, u);
foo2(i, i);
foo2(i, f);
foo3(b);
foo3(d);
foo3(u);
foo3(i);
foo3(f);
foo4(b);
foo4(d);
foo4(u);
foo4(i);
foo4(f);
foo5(b);
foo5(d);
foo5(u);
foo5(i);
foo5(f);
foo6(b);
foo6(d);
foo6(u);
foo6(i);
foo6(f);
foo7(b);
foo7(d);
foo7(u);
foo7(i);
foo7(f);
foo8(b);
foo8(u);
foo8(i);
foo9(b);
foo9(f);
foo9(d);
foo10(u);
foo10(f);
foo10(d);
return input;
}

View File

@ -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 "Overload400-PrecQual.1433"
#define GLSLANG_DATE "24-Aug-2016"
#define GLSLANG_REVISION "Overload400-PrecQual.1434"
#define GLSLANG_DATE "25-Aug-2016"

View File

@ -750,6 +750,7 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
case EOpDivAssign: // ...
case EOpModAssign: // ...
case EOpReturn: // function returns can also perform arbitrary conversions
case EOpFunctionCall: // conversion of a calling parameter
return true;
default:
break;

View File

@ -3567,27 +3567,46 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, const TFu
return true;
if (from.isArray() || to.isArray() || ! from.sameElementShape(to))
return false;
return intermediate.canImplicitlyPromote(from.getBasicType(), to.getBasicType());
return intermediate.canImplicitlyPromote(from.getBasicType(), to.getBasicType(), EOpFunctionCall);
};
// Is 'to2' a better conversion than 'to1'?
// Ties should not be considered as better.
// Assumes 'convertible' already said true.
auto better = [](const TType& from, const TType& to1, const TType& to2) {
// 1. exact match
// exact match is always better than mismatch
if (from == to2)
return from != to1;
if (from == to1)
return false;
// 2. float -> double is better
// float -> double is better than any other float conversion
if (from.getBasicType() == EbtFloat) {
if (to2.getBasicType() == EbtDouble && to1.getBasicType() != EbtDouble)
return true;
}
// 3. -> float is better than -> double
return to2.getBasicType() == EbtFloat && to1.getBasicType() == EbtDouble;
// int -> uint is better than any other int conversion
if (from.getBasicType() == EbtInt) {
if (to2.getBasicType() == EbtUint && to1.getBasicType() != EbtUint)
return true;
}
// TODO: these should be replaced by a more generic "shorter chain is better than longer chain" rule
// -> float is better than -> double
if (to2.getBasicType() == EbtFloat && to1.getBasicType() == EbtDouble)
return true;
// -> int is better than -> bool
if ((to2.getBasicType() == EbtInt || to2.getBasicType() == EbtUint) && to1.getBasicType() == EbtBool)
return true;
// -> uint is better than -> int
if (to2.getBasicType() == EbtUint && to1.getBasicType() == EbtInt)
return true;
return false;
};
// for ambiguity reporting