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.
59 lines
2.7 KiB
Plaintext
59 lines
2.7 KiB
Plaintext
spv.register.autoassign-2.frag
|
|
|
|
Linked fragment stage:
|
|
|
|
|
|
// Module Version 10000
|
|
// Generated by (magic number): 80001
|
|
// Id's are bound by 31
|
|
|
|
Capability Shader
|
|
1: ExtInstImport "GLSL.std.450"
|
|
MemoryModel Logical GLSL450
|
|
EntryPoint Fragment 4 "main" 9
|
|
ExecutionMode 4 OriginUpperLeft
|
|
Name 4 "main"
|
|
Name 9 "Color"
|
|
Name 12 "g_tScene[0]"
|
|
Name 16 "g_tSamp"
|
|
Name 25 "g_tScene[1]"
|
|
Decorate 9(Color) Location 0
|
|
Decorate 12(g_tScene[0]) DescriptorSet 0
|
|
Decorate 12(g_tScene[0]) Binding 10
|
|
Decorate 16(g_tSamp) DescriptorSet 0
|
|
Decorate 16(g_tSamp) Binding 5
|
|
Decorate 25(g_tScene[1]) DescriptorSet 0
|
|
Decorate 25(g_tScene[1]) Binding 11
|
|
2: TypeVoid
|
|
3: TypeFunction 2
|
|
6: TypeFloat 32
|
|
7: TypeVector 6(float) 4
|
|
8: TypePointer Output 7(fvec4)
|
|
9(Color): 8(ptr) Variable Output
|
|
10: TypeImage 6(float) 2D sampled format:Unknown
|
|
11: TypePointer UniformConstant 10
|
|
12(g_tScene[0]): 11(ptr) Variable UniformConstant
|
|
14: TypeSampler
|
|
15: TypePointer UniformConstant 14
|
|
16(g_tSamp): 15(ptr) Variable UniformConstant
|
|
18: TypeSampledImage 10
|
|
20: TypeVector 6(float) 2
|
|
21: 6(float) Constant 1050253722
|
|
22: 6(float) Constant 1053609165
|
|
23: 20(fvec2) ConstantComposite 21 22
|
|
25(g_tScene[1]): 11(ptr) Variable UniformConstant
|
|
4(main): 2 Function None 3
|
|
5: Label
|
|
13: 10 Load 12(g_tScene[0])
|
|
17: 14 Load 16(g_tSamp)
|
|
19: 18 SampledImage 13 17
|
|
24: 7(fvec4) ImageSampleImplicitLod 19 23
|
|
26: 10 Load 25(g_tScene[1])
|
|
27: 14 Load 16(g_tSamp)
|
|
28: 18 SampledImage 26 27
|
|
29: 7(fvec4) ImageSampleImplicitLod 28 23
|
|
30: 7(fvec4) FAdd 24 29
|
|
Store 9(Color) 30
|
|
Return
|
|
FunctionEnd
|