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
64b9743c
Commit
64b9743c
authored
Sep 14, 2016
by
Rex Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Support simultaneous l-value swizzle and dynamic component selection.
parent
deb4940c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
95 deletions
+111
-95
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+14
-8
spv.accessChain.frag.out
Test/baseResults/spv.accessChain.frag.out
+96
-86
spv.accessChain.frag
Test/spv.accessChain.frag
+1
-1
No files found.
SPIRV/SpvBuilder.cpp
View file @
64b9743c
...
...
@@ -1328,15 +1328,20 @@ Id Builder::createRvalueSwizzle(Decoration precision, Id typeId, Id source, std:
// Comments in header
Id
Builder
::
createLvalueSwizzle
(
Id
typeId
,
Id
target
,
Id
source
,
std
::
vector
<
unsigned
>&
channels
)
{
assert
(
getNumComponents
(
source
)
==
(
int
)
channels
.
size
());
if
(
channels
.
size
()
==
1
&&
getNumComponents
(
source
)
==
1
)
return
createCompositeInsert
(
source
,
target
,
typeId
,
channels
.
front
());
Instruction
*
swizzle
=
new
Instruction
(
getUniqueId
(),
typeId
,
OpVectorShuffle
);
assert
(
isVector
(
source
));
assert
(
isVector
(
target
));
swizzle
->
addIdOperand
(
target
);
swizzle
->
addIdOperand
(
source
);
if
(
accessChain
.
component
!=
NoResult
)
// For dynamic component selection, source does not involve in l-value swizzle
swizzle
->
addIdOperand
(
target
);
else
{
assert
(
getNumComponents
(
source
)
==
(
int
)
channels
.
size
());
assert
(
isVector
(
source
));
swizzle
->
addIdOperand
(
source
);
}
// Set up an identity shuffle from the base value to the result value
unsigned
int
components
[
4
];
...
...
@@ -1345,8 +1350,12 @@ Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, std::vector<uns
components
[
i
]
=
i
;
// Punch in the l-value swizzle
for
(
int
i
=
0
;
i
<
(
int
)
channels
.
size
();
++
i
)
components
[
channels
[
i
]]
=
numTargetComponents
+
i
;
for
(
int
i
=
0
;
i
<
(
int
)
channels
.
size
();
++
i
)
{
if
(
accessChain
.
component
!=
NoResult
)
components
[
i
]
=
channels
[
i
];
// Only shuffle the base value
else
components
[
channels
[
i
]]
=
numTargetComponents
+
i
;
}
// finish the instruction with these components selectors
for
(
int
i
=
0
;
i
<
numTargetComponents
;
++
i
)
...
...
@@ -2118,9 +2127,6 @@ void Builder::accessChainStore(Id rvalue)
transferAccessChainSwizzle
(
true
);
Id
base
=
collapseAccessChain
();
if
(
accessChain
.
swizzle
.
size
()
&&
accessChain
.
component
!=
NoResult
)
logger
->
missingFunctionality
(
"simultaneous l-value swizzle and dynamic component selection"
);
// If swizzle still exists, it is out-of-order or not full, we must load the target vector,
// extract and insert elements to perform writeMask and/or swizzle.
Id
source
=
NoResult
;
...
...
Test/baseResults/spv.accessChain.frag.out
View file @
64b9743c
...
...
@@ -7,12 +7,12 @@ Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by
197
// Id's are bound by
206
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 65 1
49
EntryPoint Fragment 4 "main" 65 1
58
ExecutionMode 4 OriginUpperLeft
Source GLSL 420
Name 4 "main"
...
...
@@ -57,22 +57,22 @@ Linked fragment stage:
Name 60 "i"
Name 61 "comp"
Name 65 "OutColor"
Name 1
44
"s"
Name 1
49
"u"
Name 15
0
"param"
Name 1
54
"param"
Name 1
58
"param"
Name 1
62
"param"
Name 1
66
"param"
Name 17
0
"param"
Name 1
74
"param"
Name 1
78
"param"
Name 1
82
"param"
Name 1
86
"param"
Name 19
0
"param"
Name
194
"param"
Name 1
53
"s"
Name 1
58
"u"
Name 15
9
"param"
Name 1
63
"param"
Name 1
67
"param"
Name 1
71
"param"
Name 1
75
"param"
Name 17
9
"param"
Name 1
83
"param"
Name 1
87
"param"
Name 1
91
"param"
Name 1
95
"param"
Name 19
9
"param"
Name
203
"param"
Decorate 65(OutColor) Location 0
Decorate 1
49
(u) Flat
Decorate 1
58
(u) Flat
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
...
...
@@ -90,77 +90,77 @@ Linked fragment stage:
95: TypeVector 6(float) 2
109: 67(int) Constant 2
136: TypePointer Output 6(float)
1
41
: 6(float) Constant 0
1
42: 7(fvec3) ConstantComposite 141 141 141
1
43
: TypePointer Function 8(S)
1
48
: TypePointer Input 13(int)
1
49(u): 148
(ptr) Variable Input
1
50
: 6(float) Constant 0
1
51: 7(fvec3) ConstantComposite 150 150 150
1
52
: TypePointer Function 8(S)
1
57
: TypePointer Input 13(int)
1
58(u): 157
(ptr) Variable Input
4(main): 2 Function None 3
5: Label
1
44(s): 143
(ptr) Variable Function
15
0
(param): 14(ptr) Variable Function
1
54
(param): 14(ptr) Variable Function
1
58
(param): 14(ptr) Variable Function
1
62
(param): 14(ptr) Variable Function
1
66
(param): 14(ptr) Variable Function
17
0
(param): 14(ptr) Variable Function
1
74
(param): 14(ptr) Variable Function
1
78
(param): 14(ptr) Variable Function
1
82
(param): 14(ptr) Variable Function
1
86
(param): 14(ptr) Variable Function
19
0
(param): 14(ptr) Variable Function
194
(param): 14(ptr) Variable Function
Store 65(OutColor) 1
42
1
45: 8(S) Load 144
(s)
1
46: 2 FunctionCall 11(GetColor1(struct-S-vf31;) 145
1
47: 8(S) Load 144
(s)
1
51: 13(int) Load 149
(u)
Store 15
0(param) 151
1
52: 2 FunctionCall 18(GetColor2(struct-S-vf31;i1;) 147 150
(param)
1
53: 8(S) Load 144
(s)
1
55: 13(int) Load 149
(u)
Store 1
54(param) 155
1
56: 2 FunctionCall 22(GetColor3(struct-S-vf31;i1;) 153 154
(param)
1
57: 8(S) Load 144
(s)
1
59: 13(int) Load 149
(u)
Store 1
58(param) 159
16
0: 2 FunctionCall 26(GetColor4(struct-S-vf31;i1;) 157 158
(param)
1
61: 8(S) Load 144
(s)
1
63: 13(int) Load 149
(u)
Store 1
62(param) 163
1
64: 2 FunctionCall 30(GetColor5(struct-S-vf31;i1;) 161 162
(param)
1
65: 8(S) Load 144
(s)
1
67: 13(int) Load 149
(u)
Store 1
66(param) 167
1
68: 2 FunctionCall 34(GetColor6(struct-S-vf31;i1;) 165 166
(param)
1
69: 8(S) Load 144
(s)
1
71: 13(int) Load 149
(u)
Store 17
0(param) 171
1
72: 2 FunctionCall 38(GetColor7(struct-S-vf31;i1;) 169 170
(param)
1
73: 8(S) Load 144
(s)
1
75: 13(int) Load 149
(u)
Store 1
74(param) 175
1
76: 2 FunctionCall 42(GetColor8(struct-S-vf31;i1;) 173 174
(param)
1
77: 8(S) Load 144
(s)
1
79: 13(int) Load 149
(u)
Store 1
78(param) 179
18
0: 2 FunctionCall 46(GetColor9(struct-S-vf31;i1;) 177 178
(param)
1
81: 8(S) Load 144
(s)
1
83: 13(int) Load 149
(u)
Store 1
82(param) 183
1
84: 2 FunctionCall 50(GetColor10(struct-S-vf31;i1;) 181 182
(param)
1
85: 8(S) Load 144
(s)
1
87: 13(int) Load 149
(u)
Store 1
86(param) 187
1
88: 2 FunctionCall 54(GetColor11(struct-S-vf31;i1;) 185 186
(param)
1
89: 8(S) Load 144
(s)
191: 13(int) Load 149
(u)
Store 19
0(param) 191
192: 2 FunctionCall 58(GetColor12(struct-S-vf31;i1;) 189 190
(param)
193: 8(S) Load 144
(s)
195: 13(int) Load 149
(u)
Store
194(param) 195
196: 2 FunctionCall 62(GetColor13(struct-S-vf31;i1;) 193 194
(param)
1
53(s): 152
(ptr) Variable Function
15
9
(param): 14(ptr) Variable Function
1
63
(param): 14(ptr) Variable Function
1
67
(param): 14(ptr) Variable Function
1
71
(param): 14(ptr) Variable Function
1
75
(param): 14(ptr) Variable Function
17
9
(param): 14(ptr) Variable Function
1
83
(param): 14(ptr) Variable Function
1
87
(param): 14(ptr) Variable Function
1
91
(param): 14(ptr) Variable Function
1
95
(param): 14(ptr) Variable Function
19
9
(param): 14(ptr) Variable Function
203
(param): 14(ptr) Variable Function
Store 65(OutColor) 1
51
1
54: 8(S) Load 153
(s)
1
55: 2 FunctionCall 11(GetColor1(struct-S-vf31;) 154
1
56: 8(S) Load 153
(s)
1
60: 13(int) Load 158
(u)
Store 15
9(param) 160
1
61: 2 FunctionCall 18(GetColor2(struct-S-vf31;i1;) 156 159
(param)
1
62: 8(S) Load 153
(s)
1
64: 13(int) Load 158
(u)
Store 1
63(param) 164
1
65: 2 FunctionCall 22(GetColor3(struct-S-vf31;i1;) 162 163
(param)
1
66: 8(S) Load 153
(s)
1
68: 13(int) Load 158
(u)
Store 1
67(param) 168
16
9: 2 FunctionCall 26(GetColor4(struct-S-vf31;i1;) 166 167
(param)
1
70: 8(S) Load 153
(s)
1
72: 13(int) Load 158
(u)
Store 1
71(param) 172
1
73: 2 FunctionCall 30(GetColor5(struct-S-vf31;i1;) 170 171
(param)
1
74: 8(S) Load 153
(s)
1
76: 13(int) Load 158
(u)
Store 1
75(param) 176
1
77: 2 FunctionCall 34(GetColor6(struct-S-vf31;i1;) 174 175
(param)
1
78: 8(S) Load 153
(s)
1
80: 13(int) Load 158
(u)
Store 17
9(param) 180
1
81: 2 FunctionCall 38(GetColor7(struct-S-vf31;i1;) 178 179
(param)
1
82: 8(S) Load 153
(s)
1
84: 13(int) Load 158
(u)
Store 1
83(param) 184
1
85: 2 FunctionCall 42(GetColor8(struct-S-vf31;i1;) 182 183
(param)
1
86: 8(S) Load 153
(s)
1
88: 13(int) Load 158
(u)
Store 1
87(param) 188
18
9: 2 FunctionCall 46(GetColor9(struct-S-vf31;i1;) 186 187
(param)
1
90: 8(S) Load 153
(s)
1
92: 13(int) Load 158
(u)
Store 1
91(param) 192
1
93: 2 FunctionCall 50(GetColor10(struct-S-vf31;i1;) 190 191
(param)
1
94: 8(S) Load 153
(s)
1
96: 13(int) Load 158
(u)
Store 1
95(param) 196
1
97: 2 FunctionCall 54(GetColor11(struct-S-vf31;i1;) 194 195
(param)
1
98: 8(S) Load 153
(s)
200: 13(int) Load 158
(u)
Store 19
9(param) 200
201: 2 FunctionCall 58(GetColor12(struct-S-vf31;i1;) 198 199
(param)
202: 8(S) Load 153
(s)
204: 13(int) Load 158
(u)
Store
203(param) 204
205: 2 FunctionCall 62(GetColor13(struct-S-vf31;i1;) 202 203
(param)
Return
FunctionEnd
11(GetColor1(struct-S-vf31;): 2 Function None 9
...
...
@@ -319,5 +319,15 @@ Linked fragment stage:
60(i): 8(S) FunctionParameter
61(comp): 14(ptr) FunctionParameter
63: Label
141: 13(int) Load 61(comp)
142: 6(float) CompositeExtract 60(i) 0 0
143: 7(fvec3) Load 65(OutColor)
144: 95(fvec2) VectorShuffle 143 143 2 1
145: 6(float) VectorExtractDynamic 144 141
146: 6(float) FAdd 145 142
147: 7(fvec3) Load 65(OutColor)
148: 7(fvec3) VectorShuffle 147 147 2 1 2
149: 7(fvec3) VectorInsertDynamic 148 146 141
Store 65(OutColor) 149
Return
FunctionEnd
Test/spv.accessChain.frag
View file @
64b9743c
...
...
@@ -71,7 +71,7 @@ void GetColor12(const S i, int comp)
void
GetColor13
(
const
S
i
,
int
comp
)
{
// OutColor.zy[comp] += i.color.x; // not yet supported
OutColor
.
zy
[
comp
]
+=
i
.
color
.
x
;
}
void
main
()
...
...
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