Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
0302bdf0
Commit
0302bdf0
authored
Feb 17, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Fix #723: construct vectors from matrices.
parent
36852b83
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
18 deletions
+86
-18
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+53
-15
spv.matrix.frag.out
Test/baseResults/spv.matrix.frag.out
+28
-1
spv.matrix.frag
Test/spv.matrix.frag
+3
-0
revision.h
glslang/Include/revision.h
+2
-2
No files found.
SPIRV/SpvBuilder.cpp
View file @
0302bdf0
...
@@ -1832,34 +1832,72 @@ Id Builder::createConstructor(Decoration precision, const std::vector<Id>& sourc
...
@@ -1832,34 +1832,72 @@ Id Builder::createConstructor(Decoration precision, const std::vector<Id>& sourc
if
(
sources
.
size
()
==
1
&&
isScalar
(
sources
[
0
])
&&
numTargetComponents
>
1
)
if
(
sources
.
size
()
==
1
&&
isScalar
(
sources
[
0
])
&&
numTargetComponents
>
1
)
return
smearScalar
(
precision
,
sources
[
0
],
resultTypeId
);
return
smearScalar
(
precision
,
sources
[
0
],
resultTypeId
);
// accumulate the arguments for OpCompositeConstruct
std
::
vector
<
Id
>
constituents
;
Id
scalarTypeId
=
getScalarTypeId
(
resultTypeId
);
Id
scalarTypeId
=
getScalarTypeId
(
resultTypeId
);
std
::
vector
<
Id
>
constituents
;
// accumulate the arguments for OpCompositeConstruct
for
(
unsigned
int
i
=
0
;
i
<
sources
.
size
();
++
i
)
{
// lambda to store the result of visiting an argument component
assert
(
!
isAggregate
(
sources
[
i
]));
const
auto
latchResult
=
[
&
](
Id
comp
)
{
unsigned
int
sourceSize
=
getNumComponents
(
sources
[
i
]);
if
(
numTargetComponents
>
1
)
constituents
.
push_back
(
comp
);
else
result
=
comp
;
++
targetComponent
;
};
// lambda to visit a vector argument's components
const
auto
accumulateVectorConstituents
=
[
&
](
Id
sourceArg
)
{
unsigned
int
sourceSize
=
getNumComponents
(
sourceArg
);
unsigned
int
sourcesToUse
=
sourceSize
;
unsigned
int
sourcesToUse
=
sourceSize
;
if
(
sourcesToUse
+
targetComponent
>
numTargetComponents
)
if
(
sourcesToUse
+
targetComponent
>
numTargetComponents
)
sourcesToUse
=
numTargetComponents
-
targetComponent
;
sourcesToUse
=
numTargetComponents
-
targetComponent
;
for
(
unsigned
int
s
=
0
;
s
<
sourcesToUse
;
++
s
)
{
for
(
unsigned
int
s
=
0
;
s
<
sourcesToUse
;
++
s
)
{
Id
arg
=
sources
[
i
];
std
::
vector
<
unsigned
>
swiz
;
if
(
sourceSize
>
1
)
{
swiz
.
push_back
(
s
);
std
::
vector
<
unsigned
>
swiz
;
latchResult
(
createRvalueSwizzle
(
precision
,
scalarTypeId
,
sourceArg
,
swiz
));
swiz
.
push_back
(
s
);
}
arg
=
createRvalueSwizzle
(
precision
,
scalarTypeId
,
arg
,
swiz
);
};
}
if
(
numTargetComponents
>
1
)
// lambda to visit a matrix argument's components
constituents
.
push_back
(
arg
);
const
auto
accumulateMatrixConstituents
=
[
&
](
Id
sourceArg
)
{
else
unsigned
int
sourceSize
=
getNumColumns
(
sourceArg
)
*
getNumRows
(
sourceArg
);
result
=
arg
;
unsigned
int
sourcesToUse
=
sourceSize
;
++
targetComponent
;
if
(
sourcesToUse
+
targetComponent
>
numTargetComponents
)
sourcesToUse
=
numTargetComponents
-
targetComponent
;
int
col
=
0
;
int
row
=
0
;
for
(
unsigned
int
s
=
0
;
s
<
sourcesToUse
;
++
s
)
{
if
(
row
>=
getNumRows
(
sourceArg
))
{
row
=
0
;
col
++
;
}
std
::
vector
<
Id
>
indexes
;
indexes
.
push_back
(
col
);
indexes
.
push_back
(
row
);
latchResult
(
createCompositeExtract
(
sourceArg
,
scalarTypeId
,
indexes
));
row
++
;
}
}
};
// Go through the source arguments, each one could have either
// a single or multiple components to contribute.
for
(
unsigned
int
i
=
0
;
i
<
sources
.
size
();
++
i
)
{
if
(
isScalar
(
sources
[
i
]))
latchResult
(
sources
[
i
]);
else
if
(
isVector
(
sources
[
i
]))
accumulateVectorConstituents
(
sources
[
i
]);
else
if
(
isMatrix
(
sources
[
i
]))
accumulateMatrixConstituents
(
sources
[
i
]);
else
assert
(
0
);
if
(
targetComponent
>=
numTargetComponents
)
if
(
targetComponent
>=
numTargetComponents
)
break
;
break
;
}
}
// If the result is a vector, make it from the gathered constituents.
if
(
constituents
.
size
()
>
0
)
if
(
constituents
.
size
()
>
0
)
result
=
createCompositeConstruct
(
resultTypeId
,
constituents
);
result
=
createCompositeConstruct
(
resultTypeId
,
constituents
);
...
...
Test/baseResults/spv.matrix.frag.out
View file @
0302bdf0
...
@@ -3,7 +3,7 @@ Warning, version 420 is not yet complete; most version-specific features are pre
...
@@ -3,7 +3,7 @@ Warning, version 420 is not yet complete; most version-specific features are pre
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80001
// Generated by (magic number): 80001
// Id's are bound by 2
61
// Id's are bound by 2
86
Capability Shader
Capability Shader
Capability Float64
Capability Float64
...
@@ -55,6 +55,9 @@ Warning, version 420 is not yet complete; most version-specific features are pre
...
@@ -55,6 +55,9 @@ Warning, version 420 is not yet complete; most version-specific features are pre
186: TypePointer Output 7(fvec4)
186: TypePointer Output 7(fvec4)
187(color): 186(ptr) Variable Output
187(color): 186(ptr) Variable Output
208: 6(float) Constant 0
208: 6(float) Constant 0
270: TypeVector 6(float) 2
271: TypeMatrix 270(fvec2) 2
279: 6(float) Constant 1088841318
4(main): 2 Function None 3
4(main): 2 Function None 3
5: Label
5: Label
10(sum34): 9(ptr) Variable Function
10(sum34): 9(ptr) Variable Function
...
@@ -305,5 +308,29 @@ Warning, version 420 is not yet complete; most version-specific features are pre
...
@@ -305,5 +308,29 @@ Warning, version 420 is not yet complete; most version-specific features are pre
259: 7(fvec4) Load 187(color)
259: 7(fvec4) Load 187(color)
260: 7(fvec4) FAdd 259 258
260: 7(fvec4) FAdd 259 258
Store 187(color) 260
Store 187(color) 260
261: 172 Load 174(m43)
262: 6(float) CompositeExtract 261 0 0
263: 6(float) CompositeExtract 261 0 1
264: 6(float) CompositeExtract 261 0 2
265: 6(float) CompositeExtract 261 1 0
266: 7(fvec4) CompositeConstruct 262 263 264 265
267: 7(fvec4) Load 187(color)
268: 7(fvec4) FAdd 267 266
Store 187(color) 268
269: 6(float) Load 28(f)
272: 270(fvec2) CompositeConstruct 269 208
273: 270(fvec2) CompositeConstruct 208 269
274: 271 CompositeConstruct 272 273
275: 6(float) CompositeExtract 274 0 0
276: 6(float) CompositeExtract 274 0 1
277: 6(float) CompositeExtract 274 1 0
278: 157(fvec3) CompositeConstruct 275 276 277
280: 6(float) CompositeExtract 278 0
281: 6(float) CompositeExtract 278 1
282: 6(float) CompositeExtract 278 2
283: 7(fvec4) CompositeConstruct 280 281 282 279
284: 7(fvec4) Load 187(color)
285: 7(fvec4) FAdd 284 283
Store 187(color) 285
Return
Return
FunctionEnd
FunctionEnd
Test/spv.matrix.frag
View file @
0302bdf0
...
@@ -43,4 +43,7 @@ void main()
...
@@ -43,4 +43,7 @@ void main()
sum34
+=
mat3x4
(
v3
,
f
,
v3
,
f
,
v3
,
f
);
sum34
+=
mat3x4
(
v3
,
f
,
v3
,
f
,
v3
,
f
);
color
+=
sum3
*
m43
+
sum4
;
color
+=
sum3
*
m43
+
sum4
;
color
+=
vec4
(
m43
);
color
+=
vec4
(
vec3
(
mat2
(
f
)),
7
.
2
);
}
}
glslang/Include/revision.h
View file @
0302bdf0
...
@@ -2,5 +2,5 @@
...
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.18
28
"
#define GLSLANG_REVISION "Overload400-PrecQual.18
42
"
#define GLSLANG_DATE "1
3
-Feb-2017"
#define GLSLANG_DATE "1
7
-Feb-2017"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment