GLSL/SPV: Fix #1310: don't create unnecessary integer matrices.
This commit is contained in:
parent
88a6a18119
commit
b92ce60fc7
87
Test/baseResults/spv.vecMatConstruct.frag.out
Executable file
87
Test/baseResults/spv.vecMatConstruct.frag.out
Executable file
@ -0,0 +1,87 @@
|
|||||||
|
spv.vecMatConstruct.frag
|
||||||
|
// Module Version 10000
|
||||||
|
// Generated by (magic number): 80006
|
||||||
|
// Id's are bound by 62
|
||||||
|
|
||||||
|
Capability Shader
|
||||||
|
1: ExtInstImport "GLSL.std.450"
|
||||||
|
MemoryModel Logical GLSL450
|
||||||
|
EntryPoint Fragment 4 "main"
|
||||||
|
ExecutionMode 4 OriginUpperLeft
|
||||||
|
Source GLSL 450
|
||||||
|
Name 4 "main"
|
||||||
|
Name 9 "v2"
|
||||||
|
Name 13 "m"
|
||||||
|
Name 19 "v3"
|
||||||
|
Name 27 "v4"
|
||||||
|
Name 37 "iv2"
|
||||||
|
Name 45 "iv3"
|
||||||
|
Name 54 "iv4"
|
||||||
|
2: TypeVoid
|
||||||
|
3: TypeFunction 2
|
||||||
|
6: TypeFloat 32
|
||||||
|
7: TypeVector 6(float) 2
|
||||||
|
8: TypePointer Function 7(fvec2)
|
||||||
|
10: TypeVector 6(float) 3
|
||||||
|
11: TypeMatrix 10(fvec3) 4
|
||||||
|
12: TypePointer Function 11
|
||||||
|
18: TypePointer Function 10(fvec3)
|
||||||
|
25: TypeVector 6(float) 4
|
||||||
|
26: TypePointer Function 25(fvec4)
|
||||||
|
34: TypeInt 32 1
|
||||||
|
35: TypeVector 34(int) 2
|
||||||
|
36: TypePointer Function 35(ivec2)
|
||||||
|
43: TypeVector 34(int) 3
|
||||||
|
44: TypePointer Function 43(ivec3)
|
||||||
|
52: TypeVector 34(int) 4
|
||||||
|
53: TypePointer Function 52(ivec4)
|
||||||
|
4(main): 2 Function None 3
|
||||||
|
5: Label
|
||||||
|
9(v2): 8(ptr) Variable Function
|
||||||
|
13(m): 12(ptr) Variable Function
|
||||||
|
19(v3): 18(ptr) Variable Function
|
||||||
|
27(v4): 26(ptr) Variable Function
|
||||||
|
37(iv2): 36(ptr) Variable Function
|
||||||
|
45(iv3): 44(ptr) Variable Function
|
||||||
|
54(iv4): 53(ptr) Variable Function
|
||||||
|
14: 11 Load 13(m)
|
||||||
|
15: 6(float) CompositeExtract 14 0 0
|
||||||
|
16: 6(float) CompositeExtract 14 0 1
|
||||||
|
17: 7(fvec2) CompositeConstruct 15 16
|
||||||
|
Store 9(v2) 17
|
||||||
|
20: 11 Load 13(m)
|
||||||
|
21: 6(float) CompositeExtract 20 0 0
|
||||||
|
22: 6(float) CompositeExtract 20 0 1
|
||||||
|
23: 6(float) CompositeExtract 20 0 2
|
||||||
|
24: 10(fvec3) CompositeConstruct 21 22 23
|
||||||
|
Store 19(v3) 24
|
||||||
|
28: 11 Load 13(m)
|
||||||
|
29: 6(float) CompositeExtract 28 0 0
|
||||||
|
30: 6(float) CompositeExtract 28 0 1
|
||||||
|
31: 6(float) CompositeExtract 28 0 2
|
||||||
|
32: 6(float) CompositeExtract 28 1 0
|
||||||
|
33: 25(fvec4) CompositeConstruct 29 30 31 32
|
||||||
|
Store 27(v4) 33
|
||||||
|
38: 11 Load 13(m)
|
||||||
|
39: 6(float) CompositeExtract 38 0 0
|
||||||
|
40: 6(float) CompositeExtract 38 0 1
|
||||||
|
41: 7(fvec2) CompositeConstruct 39 40
|
||||||
|
42: 35(ivec2) ConvertFToS 41
|
||||||
|
Store 37(iv2) 42
|
||||||
|
46: 11 Load 13(m)
|
||||||
|
47: 6(float) CompositeExtract 46 0 0
|
||||||
|
48: 6(float) CompositeExtract 46 0 1
|
||||||
|
49: 6(float) CompositeExtract 46 0 2
|
||||||
|
50: 10(fvec3) CompositeConstruct 47 48 49
|
||||||
|
51: 43(ivec3) ConvertFToS 50
|
||||||
|
Store 45(iv3) 51
|
||||||
|
55: 11 Load 13(m)
|
||||||
|
56: 6(float) CompositeExtract 55 0 0
|
||||||
|
57: 6(float) CompositeExtract 55 0 1
|
||||||
|
58: 6(float) CompositeExtract 55 0 2
|
||||||
|
59: 6(float) CompositeExtract 55 1 0
|
||||||
|
60: 25(fvec4) CompositeConstruct 56 57 58 59
|
||||||
|
61: 52(ivec4) ConvertFToS 60
|
||||||
|
Store 54(iv4) 61
|
||||||
|
Return
|
||||||
|
FunctionEnd
|
14
Test/spv.vecMatConstruct.frag
Normal file
14
Test/spv.vecMatConstruct.frag
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
mat4x3 m;
|
||||||
|
|
||||||
|
vec2 v2 = vec2(m);
|
||||||
|
vec3 v3 = vec3(m);
|
||||||
|
vec4 v4 = vec4(m);
|
||||||
|
|
||||||
|
ivec2 iv2 = ivec2(m);
|
||||||
|
ivec3 iv3 = ivec3(m);
|
||||||
|
ivec4 iv4 = ivec4(m);
|
||||||
|
}
|
@ -5771,8 +5771,22 @@ TIntermTyped* TParseContext::addConstructor(const TSourceLoc& loc, TIntermNode*
|
|||||||
//
|
//
|
||||||
// Returns nullptr for an error or the constructed node.
|
// Returns nullptr for an error or the constructed node.
|
||||||
//
|
//
|
||||||
TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, TIntermTyped* node, const TSourceLoc& loc, bool subset)
|
TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, TIntermTyped* node, const TSourceLoc& loc,
|
||||||
|
bool subset)
|
||||||
{
|
{
|
||||||
|
// If we are changing a matrix in both domain of basic type and to a non matrix,
|
||||||
|
// do the shape change first (by default, below, basic type is changed before shape).
|
||||||
|
// This avoids requesting a matrix of a new type that is going to be discarded anyway.
|
||||||
|
// TODO: This could be generalized to more type combinations, but that would require
|
||||||
|
// more extensive testing and full algorithm rework. For now, the need to do two changes makes
|
||||||
|
// the recursive call work, and avoids the most aggregious case of creating integer matrices.
|
||||||
|
if (node->getType().isMatrix() && (type.isScalar() || type.isVector()) &&
|
||||||
|
type.isFloatingDomain() != node->getType().isFloatingDomain()) {
|
||||||
|
TType transitionType(node->getBasicType(), glslang::EvqTemporary, type.getVectorSize(), 0, 0, node->isVector());
|
||||||
|
TOperator transitionOp = intermediate.mapTypeToConstructorOp(transitionType);
|
||||||
|
node = constructBuiltIn(transitionType, transitionOp, node, loc, false);
|
||||||
|
}
|
||||||
|
|
||||||
TIntermTyped* newNode;
|
TIntermTyped* newNode;
|
||||||
TOperator basicOp;
|
TOperator basicOp;
|
||||||
|
|
||||||
|
@ -322,6 +322,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
"spv.variableArrayIndex.frag",
|
"spv.variableArrayIndex.frag",
|
||||||
"spv.varyingArray.frag",
|
"spv.varyingArray.frag",
|
||||||
"spv.varyingArrayIndirect.frag",
|
"spv.varyingArrayIndirect.frag",
|
||||||
|
"spv.vecMatConstruct.frag",
|
||||||
"spv.voidFunction.frag",
|
"spv.voidFunction.frag",
|
||||||
"spv.whileLoop.frag",
|
"spv.whileLoop.frag",
|
||||||
"spv.AofA.frag",
|
"spv.AofA.frag",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user