mirror of
https://github.com/RPCS3/glslang.git
synced 2024-11-23 19:29:44 +00:00
ef33ec0925
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.
50 lines
880 B
GLSL
50 lines
880 B
GLSL
|
|
struct PS_OUTPUT { float4 color : SV_Target0; };
|
|
|
|
int i;
|
|
uint u;
|
|
float f;
|
|
bool b;
|
|
|
|
int2 i2;
|
|
uint2 u2;
|
|
float2 f2;
|
|
bool2 b2;
|
|
|
|
Buffer <float> g_tTexbfs;
|
|
Texture1D <float4> g_tTex1df4;
|
|
uint upos;
|
|
float fpos;
|
|
|
|
PS_OUTPUT main()
|
|
{
|
|
int MipLevel;
|
|
|
|
uint WidthU;
|
|
uint HeightU;
|
|
uint ElementsU;
|
|
uint DepthU;
|
|
uint NumberOfLevelsU;
|
|
uint NumberOfSamplesU;
|
|
|
|
int WidthI;
|
|
int HeightI;
|
|
int ElementsI;
|
|
int DepthI;
|
|
int NumberOfLevelsI;
|
|
int NumberOfSamplesI;
|
|
|
|
saturate(fpos);
|
|
|
|
// Test output promotions
|
|
g_tTex1df4 . GetDimensions(WidthI);
|
|
g_tTex1df4 . GetDimensions(6, WidthI, NumberOfLevelsU);
|
|
g_tTex1df4 . GetDimensions(6, WidthU, NumberOfLevelsI);
|
|
g_tTex1df4 . GetDimensions(6, WidthI, NumberOfLevelsI);
|
|
|
|
// max(i2, f2);
|
|
PS_OUTPUT ps_output;
|
|
ps_output.color = 0;
|
|
return ps_output;
|
|
};
|