HLSL: add intrinsic function implicit promotions
This PR handles implicit promotions for intrinsics when there is no exact match, such as for example clamp(int, bool, float). In this case the int and bool will be promoted to a float, and the clamp(float, float, float) form used. These promotions can be mixed with shape conversions, e.g, clamp(int, bool2, float2). Output conversions are handled either via the existing addOutputArgumentConversion function, which this PR generalizes to handle either aggregates or unaries, or by intrinsic decomposition. If there are methods or intrinsics to be decomposed, then decomposition is responsible for any output conversions, which turns out to happen automatically in all current cases. This can be revisited once inout conversions are in place. Some cases of actual ambiguity were fixed in several tests, e.g, spv.register.autoassign.* Some intrinsics with only uint versions were expanded to signed ints natively, where the underlying AST and SPIR-V supports that. E.g, countbits. This avoids extraneous conversion nodes. A new function promoteAggregate is added, and used by findFunction. This is essentially a generalization of the "promote 1st or 2nd arg" algorithm in promoteBinary. The actual selection proceeds in three steps, as described in the comments in hlslParseContext::findFunction: 1. Attempt an exact match. If found, use it. 2. If not, obtain the operator from step 1, and promote arguments. 3. Re-select the intrinsic overload from the results of step 2.
This commit is contained in:
@@ -33,7 +33,7 @@ float PixelShaderFunctionS(float inF0, float inF1, float inF2, uint inU0, uint i
|
||||
clip(inF0);
|
||||
float r014 = cos(inF0);
|
||||
float r015 = cosh(inF0);
|
||||
uint r016 = countbits(7);
|
||||
int r016 = countbits(7);
|
||||
float r017 = ddx(inF0);
|
||||
float r018 = ddx_coarse(inF0);
|
||||
float r019 = ddx_fine(inF0);
|
||||
@@ -111,7 +111,7 @@ float2 PixelShaderFunction2(float2 inF0, float2 inF1, float2 inF2, uint2 inU0, u
|
||||
clip(inF0);
|
||||
float2 r013 = cos(inF0);
|
||||
float2 r015 = cosh(inF0);
|
||||
uint2 r016 = countbits(int2(7,3));
|
||||
int2 r016 = countbits(int2(7,3));
|
||||
float2 r017 = ddx(inF0);
|
||||
float2 r018 = ddx_coarse(inF0);
|
||||
float2 r019 = ddx_fine(inF0);
|
||||
|
||||
Reference in New Issue
Block a user