glslang/Test/baseResults/hlsl.intrinsics.promote.down.frag.out
steve-lunarg ef33ec0925 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.
2016-11-23 10:36:34 -07:00

185 lines
11 KiB
Plaintext

hlsl.intrinsics.promote.down.frag
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:15 Function Definition: main( (temp structure{temp 4-component vector of float color})
0:15 Function Parameters:
0:? Sequence
0:16 Sequence
0:16 move second child to first child (temp uint)
0:16 'r00' (temp uint)
0:16 bitCount (temp uint)
0:16 Convert float to uint (temp uint)
0:16 f: direct index for structure (layout(offset=8 ) uniform float)
0:16 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int i, layout(offset=4 ) uniform uint u, layout(offset=8 ) uniform float f, layout(offset=12 ) uniform bool b, layout(offset=16 ) uniform 2-component vector of int i2, layout(offset=24 ) uniform 2-component vector of uint u2, layout(offset=32 ) uniform 2-component vector of float f2, layout(offset=40 ) uniform 2-component vector of bool b2})
0:16 Constant:
0:16 2 (const uint)
0:17 Sequence
0:17 move second child to first child (temp 2-component vector of uint)
0:17 'r01' (temp 2-component vector of uint)
0:17 bitFieldReverse (temp 2-component vector of uint)
0:17 Convert float to uint (temp 2-component vector of uint)
0:17 f2: direct index for structure (layout(offset=32 ) uniform 2-component vector of float)
0:17 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int i, layout(offset=4 ) uniform uint u, layout(offset=8 ) uniform float f, layout(offset=12 ) uniform bool b, layout(offset=16 ) uniform 2-component vector of int i2, layout(offset=24 ) uniform 2-component vector of uint u2, layout(offset=32 ) uniform 2-component vector of float f2, layout(offset=40 ) uniform 2-component vector of bool b2})
0:17 Constant:
0:17 6 (const uint)
0:20 move second child to first child (temp 4-component vector of float)
0:20 color: direct index for structure (temp 4-component vector of float)
0:20 'ps_output' (temp structure{temp 4-component vector of float color})
0:20 Constant:
0:20 0 (const int)
0:? Constant:
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:21 Sequence
0:21 Sequence
0:21 move second child to first child (temp 4-component vector of float)
0:? 'color' (layout(location=0 ) out 4-component vector of float)
0:21 color: direct index for structure (temp 4-component vector of float)
0:21 'ps_output' (temp structure{temp 4-component vector of float color})
0:21 Constant:
0:21 0 (const int)
0:21 Branch: Return
0:? Linker Objects
0:? 'color' (layout(location=0 ) out 4-component vector of float)
0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int i, layout(offset=4 ) uniform uint u, layout(offset=8 ) uniform float f, layout(offset=12 ) uniform bool b, layout(offset=16 ) uniform 2-component vector of int i2, layout(offset=24 ) uniform 2-component vector of uint u2, layout(offset=32 ) uniform 2-component vector of float f2, layout(offset=40 ) uniform 2-component vector of bool b2})
Linked fragment stage:
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:15 Function Definition: main( (temp structure{temp 4-component vector of float color})
0:15 Function Parameters:
0:? Sequence
0:16 Sequence
0:16 move second child to first child (temp uint)
0:16 'r00' (temp uint)
0:16 bitCount (temp uint)
0:16 Convert float to uint (temp uint)
0:16 f: direct index for structure (layout(offset=8 ) uniform float)
0:16 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int i, layout(offset=4 ) uniform uint u, layout(offset=8 ) uniform float f, layout(offset=12 ) uniform bool b, layout(offset=16 ) uniform 2-component vector of int i2, layout(offset=24 ) uniform 2-component vector of uint u2, layout(offset=32 ) uniform 2-component vector of float f2, layout(offset=40 ) uniform 2-component vector of bool b2})
0:16 Constant:
0:16 2 (const uint)
0:17 Sequence
0:17 move second child to first child (temp 2-component vector of uint)
0:17 'r01' (temp 2-component vector of uint)
0:17 bitFieldReverse (temp 2-component vector of uint)
0:17 Convert float to uint (temp 2-component vector of uint)
0:17 f2: direct index for structure (layout(offset=32 ) uniform 2-component vector of float)
0:17 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int i, layout(offset=4 ) uniform uint u, layout(offset=8 ) uniform float f, layout(offset=12 ) uniform bool b, layout(offset=16 ) uniform 2-component vector of int i2, layout(offset=24 ) uniform 2-component vector of uint u2, layout(offset=32 ) uniform 2-component vector of float f2, layout(offset=40 ) uniform 2-component vector of bool b2})
0:17 Constant:
0:17 6 (const uint)
0:20 move second child to first child (temp 4-component vector of float)
0:20 color: direct index for structure (temp 4-component vector of float)
0:20 'ps_output' (temp structure{temp 4-component vector of float color})
0:20 Constant:
0:20 0 (const int)
0:? Constant:
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:? 0.000000
0:21 Sequence
0:21 Sequence
0:21 move second child to first child (temp 4-component vector of float)
0:? 'color' (layout(location=0 ) out 4-component vector of float)
0:21 color: direct index for structure (temp 4-component vector of float)
0:21 'ps_output' (temp structure{temp 4-component vector of float color})
0:21 Constant:
0:21 0 (const int)
0:21 Branch: Return
0:? Linker Objects
0:? 'color' (layout(location=0 ) out 4-component vector of float)
0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int i, layout(offset=4 ) uniform uint u, layout(offset=8 ) uniform float f, layout(offset=12 ) uniform bool b, layout(offset=16 ) uniform 2-component vector of int i2, layout(offset=24 ) uniform 2-component vector of uint u2, layout(offset=32 ) uniform 2-component vector of float f2, layout(offset=40 ) uniform 2-component vector of bool b2})
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 45
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 41
ExecutionMode 4 OriginUpperLeft
Name 4 "main"
Name 8 "r00"
Name 14 "$Global"
MemberName 14($Global) 0 "i"
MemberName 14($Global) 1 "u"
MemberName 14($Global) 2 "f"
MemberName 14($Global) 3 "b"
MemberName 14($Global) 4 "i2"
MemberName 14($Global) 5 "u2"
MemberName 14($Global) 6 "f2"
MemberName 14($Global) 7 "b2"
Name 16 ""
Name 24 "r01"
Name 32 "PS_OUTPUT"
MemberName 32(PS_OUTPUT) 0 "color"
Name 34 "ps_output"
Name 41 "color"
MemberDecorate 14($Global) 0 Offset 0
MemberDecorate 14($Global) 1 Offset 4
MemberDecorate 14($Global) 2 Offset 8
MemberDecorate 14($Global) 3 Offset 12
MemberDecorate 14($Global) 4 Offset 16
MemberDecorate 14($Global) 5 Offset 24
MemberDecorate 14($Global) 6 Offset 32
MemberDecorate 14($Global) 7 Offset 40
Decorate 14($Global) Block
Decorate 16 DescriptorSet 0
Decorate 41(color) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: TypePointer Function 6(int)
9: TypeInt 32 1
10: TypeFloat 32
11: TypeVector 9(int) 2
12: TypeVector 6(int) 2
13: TypeVector 10(float) 2
14($Global): TypeStruct 9(int) 6(int) 10(float) 6(int) 11(ivec2) 12(ivec2) 13(fvec2) 12(ivec2)
15: TypePointer Uniform 14($Global)
16: 15(ptr) Variable Uniform
17: 9(int) Constant 2
18: TypePointer Uniform 10(float)
23: TypePointer Function 12(ivec2)
25: 9(int) Constant 6
26: TypePointer Uniform 13(fvec2)
31: TypeVector 10(float) 4
32(PS_OUTPUT): TypeStruct 31(fvec4)
33: TypePointer Function 32(PS_OUTPUT)
35: 9(int) Constant 0
36: 10(float) Constant 0
37: 31(fvec4) ConstantComposite 36 36 36 36
38: TypePointer Function 31(fvec4)
40: TypePointer Output 31(fvec4)
41(color): 40(ptr) Variable Output
4(main): 2 Function None 3
5: Label
8(r00): 7(ptr) Variable Function
24(r01): 23(ptr) Variable Function
34(ps_output): 33(ptr) Variable Function
19: 18(ptr) AccessChain 16 17
20: 10(float) Load 19
21: 6(int) ConvertFToU 20
22: 6(int) BitCount 21
Store 8(r00) 22
27: 26(ptr) AccessChain 16 25
28: 13(fvec2) Load 27
29: 12(ivec2) ConvertFToU 28
30: 12(ivec2) BitReverse 29
Store 24(r01) 30
39: 38(ptr) AccessChain 34(ps_output) 35
Store 39 37
42: 38(ptr) AccessChain 34(ps_output) 35
43: 31(fvec4) Load 42
Store 41(color) 43
Return
FunctionEnd