Merge pull request #831 from steve-lunarg/isfinite

HLSL: fix return type for isfinite
This commit is contained in:
John Kessenich 2017-04-10 11:59:52 -06:00 committed by GitHub
commit e9f18fd92c
3 changed files with 294 additions and 106 deletions

View File

@ -2,37 +2,85 @@ hlsl.isfinite.frag
Shader version: 500 Shader version: 500
gl_FragCoord origin is upper left gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
0:5 Function Definition: @main( ( temp 4-component vector of float) 0:7 Function Definition: test1(f1; ( temp bool)
0:5 Function Parameters: 0:7 Function Parameters:
0:7 'v' ( in float)
0:? Sequence 0:? Sequence
0:6 Sequence
0:6 move second child to first child ( temp float)
0:6 '@finitetmp' ( temp float)
0:6 f: direct index for structure ( uniform float)
0:6 'anon@0' (layout( row_major std140) uniform block{ uniform float f})
0:6 Constant:
0:6 0 (const uint)
0:6 logical-and ( temp bool)
0:6 Negate conditional ( temp bool)
0:6 isnan ( temp bool)
0:6 '@finitetmp' ( temp float)
0:6 Negate conditional ( temp bool)
0:6 isinf ( temp bool)
0:6 '@finitetmp' ( temp float)
0:8 Branch: Return with expression 0:8 Branch: Return with expression
0:8 Constant: 0:8 logical-and ( temp bool)
0:8 0.000000 0:8 Negate conditional ( temp bool)
0:8 0.000000 0:8 isnan ( temp bool)
0:8 0.000000 0:8 'v' ( in float)
0:8 0.000000 0:8 Sequence
0:5 Function Definition: main( ( temp void) 0:8 move second child to first child ( temp float)
0:5 Function Parameters: 0:8 '@finitetmp' ( temp float)
0:8 'v' ( in float)
0:8 logical-and ( temp bool)
0:8 Negate conditional ( temp bool)
0:8 isnan ( temp bool)
0:8 '@finitetmp' ( temp float)
0:8 Negate conditional ( temp bool)
0:8 isinf ( temp bool)
0:8 '@finitetmp' ( temp float)
0:12 Function Definition: @main( ( temp 4-component vector of float)
0:12 Function Parameters:
0:? Sequence 0:? Sequence
0:5 move second child to first child ( temp 4-component vector of float) 0:13 Sequence
0:13 move second child to first child ( temp float)
0:13 '@finitetmp' ( temp float)
0:13 f: direct index for structure ( uniform float)
0:13 'anon@0' (layout( row_major std140) uniform block{ uniform float f, uniform 2-component vector of float f2, uniform 3-component vector of float f3})
0:13 Constant:
0:13 0 (const uint)
0:13 logical-and ( temp bool)
0:13 Negate conditional ( temp bool)
0:13 isnan ( temp bool)
0:13 '@finitetmp' ( temp float)
0:13 Negate conditional ( temp bool)
0:13 isinf ( temp bool)
0:13 '@finitetmp' ( temp float)
0:14 Sequence
0:14 move second child to first child ( temp 2-component vector of float)
0:14 '@finitetmp' ( temp 2-component vector of float)
0:14 f2: direct index for structure ( uniform 2-component vector of float)
0:14 'anon@0' (layout( row_major std140) uniform block{ uniform float f, uniform 2-component vector of float f2, uniform 3-component vector of float f3})
0:14 Constant:
0:14 1 (const uint)
0:14 logical-and ( temp 2-component vector of bool)
0:14 Negate conditional ( temp 2-component vector of bool)
0:14 isnan ( temp 2-component vector of bool)
0:14 '@finitetmp' ( temp 2-component vector of float)
0:14 Negate conditional ( temp 2-component vector of bool)
0:14 isinf ( temp 2-component vector of bool)
0:14 '@finitetmp' ( temp 2-component vector of float)
0:15 Sequence
0:15 move second child to first child ( temp 3-component vector of float)
0:15 '@finitetmp' ( temp 3-component vector of float)
0:15 f3: direct index for structure ( uniform 3-component vector of float)
0:15 'anon@0' (layout( row_major std140) uniform block{ uniform float f, uniform 2-component vector of float f2, uniform 3-component vector of float f3})
0:15 Constant:
0:15 2 (const uint)
0:15 logical-and ( temp 3-component vector of bool)
0:15 Negate conditional ( temp 3-component vector of bool)
0:15 isnan ( temp 3-component vector of bool)
0:15 '@finitetmp' ( temp 3-component vector of float)
0:15 Negate conditional ( temp 3-component vector of bool)
0:15 isinf ( temp 3-component vector of bool)
0:15 '@finitetmp' ( temp 3-component vector of float)
0:17 Branch: Return with expression
0:17 Constant:
0:17 0.000000
0:17 0.000000
0:17 0.000000
0:17 0.000000
0:12 Function Definition: main( ( temp void)
0:12 Function Parameters:
0:? Sequence
0:12 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:5 Function Call: @main( ( temp 4-component vector of float) 0:12 Function Call: @main( ( temp 4-component vector of float)
0:? Linker Objects 0:? Linker Objects
0:? 'anon@0' (layout( row_major std140) uniform block{ uniform float f}) 0:? 'anon@0' (layout( row_major std140) uniform block{ uniform float f, uniform 2-component vector of float f2, uniform 3-component vector of float f3})
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
@ -42,100 +90,229 @@ Linked fragment stage:
Shader version: 500 Shader version: 500
gl_FragCoord origin is upper left gl_FragCoord origin is upper left
0:? Sequence 0:? Sequence
0:5 Function Definition: @main( ( temp 4-component vector of float) 0:7 Function Definition: test1(f1; ( temp bool)
0:5 Function Parameters: 0:7 Function Parameters:
0:7 'v' ( in float)
0:? Sequence 0:? Sequence
0:6 Sequence
0:6 move second child to first child ( temp float)
0:6 '@finitetmp' ( temp float)
0:6 f: direct index for structure ( uniform float)
0:6 'anon@0' (layout( row_major std140) uniform block{ uniform float f})
0:6 Constant:
0:6 0 (const uint)
0:6 logical-and ( temp bool)
0:6 Negate conditional ( temp bool)
0:6 isnan ( temp bool)
0:6 '@finitetmp' ( temp float)
0:6 Negate conditional ( temp bool)
0:6 isinf ( temp bool)
0:6 '@finitetmp' ( temp float)
0:8 Branch: Return with expression 0:8 Branch: Return with expression
0:8 Constant: 0:8 logical-and ( temp bool)
0:8 0.000000 0:8 Negate conditional ( temp bool)
0:8 0.000000 0:8 isnan ( temp bool)
0:8 0.000000 0:8 'v' ( in float)
0:8 0.000000 0:8 Sequence
0:5 Function Definition: main( ( temp void) 0:8 move second child to first child ( temp float)
0:5 Function Parameters: 0:8 '@finitetmp' ( temp float)
0:8 'v' ( in float)
0:8 logical-and ( temp bool)
0:8 Negate conditional ( temp bool)
0:8 isnan ( temp bool)
0:8 '@finitetmp' ( temp float)
0:8 Negate conditional ( temp bool)
0:8 isinf ( temp bool)
0:8 '@finitetmp' ( temp float)
0:12 Function Definition: @main( ( temp 4-component vector of float)
0:12 Function Parameters:
0:? Sequence 0:? Sequence
0:5 move second child to first child ( temp 4-component vector of float) 0:13 Sequence
0:13 move second child to first child ( temp float)
0:13 '@finitetmp' ( temp float)
0:13 f: direct index for structure ( uniform float)
0:13 'anon@0' (layout( row_major std140) uniform block{ uniform float f, uniform 2-component vector of float f2, uniform 3-component vector of float f3})
0:13 Constant:
0:13 0 (const uint)
0:13 logical-and ( temp bool)
0:13 Negate conditional ( temp bool)
0:13 isnan ( temp bool)
0:13 '@finitetmp' ( temp float)
0:13 Negate conditional ( temp bool)
0:13 isinf ( temp bool)
0:13 '@finitetmp' ( temp float)
0:14 Sequence
0:14 move second child to first child ( temp 2-component vector of float)
0:14 '@finitetmp' ( temp 2-component vector of float)
0:14 f2: direct index for structure ( uniform 2-component vector of float)
0:14 'anon@0' (layout( row_major std140) uniform block{ uniform float f, uniform 2-component vector of float f2, uniform 3-component vector of float f3})
0:14 Constant:
0:14 1 (const uint)
0:14 logical-and ( temp 2-component vector of bool)
0:14 Negate conditional ( temp 2-component vector of bool)
0:14 isnan ( temp 2-component vector of bool)
0:14 '@finitetmp' ( temp 2-component vector of float)
0:14 Negate conditional ( temp 2-component vector of bool)
0:14 isinf ( temp 2-component vector of bool)
0:14 '@finitetmp' ( temp 2-component vector of float)
0:15 Sequence
0:15 move second child to first child ( temp 3-component vector of float)
0:15 '@finitetmp' ( temp 3-component vector of float)
0:15 f3: direct index for structure ( uniform 3-component vector of float)
0:15 'anon@0' (layout( row_major std140) uniform block{ uniform float f, uniform 2-component vector of float f2, uniform 3-component vector of float f3})
0:15 Constant:
0:15 2 (const uint)
0:15 logical-and ( temp 3-component vector of bool)
0:15 Negate conditional ( temp 3-component vector of bool)
0:15 isnan ( temp 3-component vector of bool)
0:15 '@finitetmp' ( temp 3-component vector of float)
0:15 Negate conditional ( temp 3-component vector of bool)
0:15 isinf ( temp 3-component vector of bool)
0:15 '@finitetmp' ( temp 3-component vector of float)
0:17 Branch: Return with expression
0:17 Constant:
0:17 0.000000
0:17 0.000000
0:17 0.000000
0:17 0.000000
0:12 Function Definition: main( ( temp void)
0:12 Function Parameters:
0:? Sequence
0:12 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:5 Function Call: @main( ( temp 4-component vector of float) 0:12 Function Call: @main( ( temp 4-component vector of float)
0:? Linker Objects 0:? Linker Objects
0:? 'anon@0' (layout( row_major std140) uniform block{ uniform float f}) 0:? 'anon@0' (layout( row_major std140) uniform block{ uniform float f, uniform 2-component vector of float f2, uniform 3-component vector of float f3})
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) 0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 38 // Id's are bound by 95
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 36 EntryPoint Fragment 4 "main" 93
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source HLSL 500 Source HLSL 500
Name 4 "main" Name 4 "main"
Name 9 "@main(" Name 11 "test1(f1;"
Name 12 "@finitetmp" Name 10 "v"
Name 13 "$Global" Name 15 "@main("
MemberName 13($Global) 0 "f" Name 22 "@finitetmp"
Name 15 "" Name 36 "@finitetmp"
Name 36 "@entryPointOutput" Name 39 "$Global"
MemberDecorate 13($Global) 0 Offset 0 MemberName 39($Global) 0 "f"
Decorate 13($Global) Block MemberName 39($Global) 1 "f2"
Decorate 15 DescriptorSet 0 MemberName 39($Global) 2 "f3"
Decorate 36(@entryPointOutput) Location 0 Name 41 ""
Name 57 "@finitetmp"
Name 73 "@finitetmp"
Name 93 "@entryPointOutput"
MemberDecorate 39($Global) 0 Offset 0
MemberDecorate 39($Global) 1 Offset 8
MemberDecorate 39($Global) 2 Offset 16
Decorate 39($Global) Block
Decorate 41 DescriptorSet 0
Decorate 93(@entryPointOutput) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
7: TypeVector 6(float) 4 7: TypePointer Function 6(float)
8: TypeFunction 7(fvec4) 8: TypeBool
11: TypePointer Function 6(float) 9: TypeFunction 8(bool) 7(ptr)
13($Global): TypeStruct 6(float) 13: TypeVector 6(float) 4
14: TypePointer Uniform 13($Global) 14: TypeFunction 13(fvec4)
15: 14(ptr) Variable Uniform 37: TypeVector 6(float) 2
16: TypeInt 32 1 38: TypeVector 6(float) 3
17: 16(int) Constant 0 39($Global): TypeStruct 6(float) 37(fvec2) 38(fvec3)
18: TypePointer Uniform 6(float) 40: TypePointer Uniform 39($Global)
21: TypeBool 41: 40(ptr) Variable Uniform
31: 6(float) Constant 0 42: TypeInt 32 1
32: 7(fvec4) ConstantComposite 31 31 31 31 43: 42(int) Constant 0
35: TypePointer Output 7(fvec4) 44: TypePointer Uniform 6(float)
36(@entryPointOutput): 35(ptr) Variable Output 56: TypePointer Function 37(fvec2)
58: 42(int) Constant 1
59: TypePointer Uniform 37(fvec2)
63: TypeVector 8(bool) 2
72: TypePointer Function 38(fvec3)
74: 42(int) Constant 2
75: TypePointer Uniform 38(fvec3)
79: TypeVector 8(bool) 3
88: 6(float) Constant 0
89: 13(fvec4) ConstantComposite 88 88 88 88
92: TypePointer Output 13(fvec4)
93(@entryPointOutput): 92(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
37: 7(fvec4) FunctionCall 9(@main() 94: 13(fvec4) FunctionCall 15(@main()
Store 36(@entryPointOutput) 37 Store 93(@entryPointOutput) 94
Return Return
FunctionEnd FunctionEnd
9(@main(): 7(fvec4) Function None 8 11(test1(f1;): 8(bool) Function None 9
10: Label 10(v): 7(ptr) FunctionParameter
12(@finitetmp): 11(ptr) Variable Function 12: Label
19: 18(ptr) AccessChain 15 17 22(@finitetmp): 7(ptr) Variable Function
20: 6(float) Load 19 17: 6(float) Load 10(v)
Store 12(@finitetmp) 20 18: 8(bool) IsNan 17
22: 6(float) Load 12(@finitetmp) 19: 8(bool) LogicalNot 18
23: 21(bool) IsNan 22 SelectionMerge 21 None
24: 21(bool) LogicalNot 23 BranchConditional 19 20 21
SelectionMerge 26 None 20: Label
BranchConditional 24 25 26 23: 6(float) Load 10(v)
25: Label Store 22(@finitetmp) 23
27: 6(float) Load 12(@finitetmp) 24: 6(float) Load 22(@finitetmp)
28: 21(bool) IsInf 27 25: 8(bool) IsNan 24
29: 21(bool) LogicalNot 28 26: 8(bool) LogicalNot 25
Branch 26 SelectionMerge 28 None
26: Label BranchConditional 26 27 28
30: 21(bool) Phi 24 10 29 25 27: Label
ReturnValue 32 29: 6(float) Load 22(@finitetmp)
30: 8(bool) IsInf 29
31: 8(bool) LogicalNot 30
Branch 28
28: Label
32: 8(bool) Phi 26 20 31 27
Branch 21
21: Label
33: 8(bool) Phi 19 12 32 28
ReturnValue 33
FunctionEnd
15(@main(): 13(fvec4) Function None 14
16: Label
36(@finitetmp): 7(ptr) Variable Function
57(@finitetmp): 56(ptr) Variable Function
73(@finitetmp): 72(ptr) Variable Function
45: 44(ptr) AccessChain 41 43
46: 6(float) Load 45
Store 36(@finitetmp) 46
47: 6(float) Load 36(@finitetmp)
48: 8(bool) IsNan 47
49: 8(bool) LogicalNot 48
SelectionMerge 51 None
BranchConditional 49 50 51
50: Label
52: 6(float) Load 36(@finitetmp)
53: 8(bool) IsInf 52
54: 8(bool) LogicalNot 53
Branch 51
51: Label
55: 8(bool) Phi 49 16 54 50
60: 59(ptr) AccessChain 41 58
61: 37(fvec2) Load 60
Store 57(@finitetmp) 61
62: 37(fvec2) Load 57(@finitetmp)
64: 63(bvec2) IsNan 62
65: 63(bvec2) LogicalNot 64
SelectionMerge 67 None
BranchConditional 65 66 67
66: Label
68: 37(fvec2) Load 57(@finitetmp)
69: 63(bvec2) IsInf 68
70: 63(bvec2) LogicalNot 69
Branch 67
67: Label
71: 8(bool) Phi 65 51 70 66
76: 75(ptr) AccessChain 41 74
77: 38(fvec3) Load 76
Store 73(@finitetmp) 77
78: 38(fvec3) Load 73(@finitetmp)
80: 79(bvec3) IsNan 78
81: 79(bvec3) LogicalNot 80
SelectionMerge 83 None
BranchConditional 81 82 83
82: Label
84: 38(fvec3) Load 73(@finitetmp)
85: 79(bvec3) IsInf 84
86: 79(bvec3) LogicalNot 85
Branch 83
83: Label
87: 8(bool) Phi 81 67 86 82
ReturnValue 89
FunctionEnd FunctionEnd

View File

@ -1,9 +1,18 @@
uniform float f; uniform float f;
uniform float2 f2;
uniform float3 f3;
bool test1(float v)
{
return !isnan(v) && isfinite(v);
}
float4 main() : SV_Target0 float4 main() : SV_Target0
{ {
isfinite(f); isfinite(f);
isfinite(f2);
isfinite(f3);
return 0; return 0;
} }

View File

@ -3907,25 +3907,27 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
TIntermAggregate* compoundStatement = intermediate.makeAggregate(tmpArgAssign, loc); TIntermAggregate* compoundStatement = intermediate.makeAggregate(tmpArgAssign, loc);
const TType boolType(EbtBool, EvqTemporary, arg0->getVectorSize(), arg0->getMatrixCols(), arg0->getMatrixRows());
TIntermTyped* isnan = handleUnaryMath(loc, "isnan", EOpIsNan, intermediate.addSymbol(*tempArg, loc)); TIntermTyped* isnan = handleUnaryMath(loc, "isnan", EOpIsNan, intermediate.addSymbol(*tempArg, loc));
isnan->setType(TType(EbtBool)); isnan->setType(boolType);
TIntermTyped* notnan = handleUnaryMath(loc, "!", EOpLogicalNot, isnan); TIntermTyped* notnan = handleUnaryMath(loc, "!", EOpLogicalNot, isnan);
notnan->setType(TType(EbtBool)); notnan->setType(boolType);
TIntermTyped* isinf = handleUnaryMath(loc, "isinf", EOpIsInf, intermediate.addSymbol(*tempArg, loc)); TIntermTyped* isinf = handleUnaryMath(loc, "isinf", EOpIsInf, intermediate.addSymbol(*tempArg, loc));
isinf->setType(TType(EbtBool)); isinf->setType(boolType);
TIntermTyped* notinf = handleUnaryMath(loc, "!", EOpLogicalNot, isinf); TIntermTyped* notinf = handleUnaryMath(loc, "!", EOpLogicalNot, isinf);
notinf->setType(TType(EbtBool)); notinf->setType(boolType);
TIntermTyped* andNode = handleBinaryMath(loc, "and", EOpLogicalAnd, notnan, notinf); TIntermTyped* andNode = handleBinaryMath(loc, "and", EOpLogicalAnd, notnan, notinf);
andNode->setType(TType(EbtBool)); andNode->setType(boolType);
compoundStatement = intermediate.growAggregate(compoundStatement, andNode); compoundStatement = intermediate.growAggregate(compoundStatement, andNode);
compoundStatement->setOperator(EOpSequence); compoundStatement->setOperator(EOpSequence);
compoundStatement->setLoc(loc); compoundStatement->setLoc(loc);
compoundStatement->setType(TType(EbtVoid)); compoundStatement->setType(boolType);
node = compoundStatement; node = compoundStatement;