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
73e3ce78
Commit
73e3ce78
authored
Apr 27, 2016
by
Rex Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Handle matrix's OpFConvert vector by vector.
parent
9db3117e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
163 additions
and
133 deletions
+163
-133
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+5
-3
spv.matrix.frag.out
Test/baseResults/spv.matrix.frag.out
+152
-125
spv.matrix.frag
Test/spv.matrix.frag
+6
-5
No files found.
SPIRV/GlslangToSpv.cpp
View file @
73e3ce78
...
@@ -137,7 +137,7 @@ protected:
...
@@ -137,7 +137,7 @@ protected:
spv
::
Id
createBinaryMatrixOperation
(
spv
::
Op
,
spv
::
Decoration
precision
,
spv
::
Decoration
noContraction
,
spv
::
Id
typeId
,
spv
::
Id
left
,
spv
::
Id
right
);
spv
::
Id
createBinaryMatrixOperation
(
spv
::
Op
,
spv
::
Decoration
precision
,
spv
::
Decoration
noContraction
,
spv
::
Id
typeId
,
spv
::
Id
left
,
spv
::
Id
right
);
spv
::
Id
createUnaryOperation
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Decoration
noContraction
,
spv
::
Id
typeId
,
spv
::
Id
operand
,
glslang
::
TBasicType
typeProxy
);
spv
::
Id
createUnaryOperation
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Decoration
noContraction
,
spv
::
Id
typeId
,
spv
::
Id
operand
,
glslang
::
TBasicType
typeProxy
);
spv
::
Id
createUnaryMatrixOperation
(
spv
::
Op
,
spv
::
Decoration
precision
,
spv
::
Decoration
noContraction
,
spv
::
Id
typeId
,
spv
::
Id
operand
,
glslang
::
TBasicType
typeProxy
);
spv
::
Id
createUnaryMatrixOperation
(
spv
::
Op
,
spv
::
Decoration
precision
,
spv
::
Decoration
noContraction
,
spv
::
Id
typeId
,
spv
::
Id
operand
,
glslang
::
TBasicType
typeProxy
);
spv
::
Id
createConversion
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Id
destTypeId
,
spv
::
Id
operand
);
spv
::
Id
createConversion
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Decoration
noContraction
,
spv
::
Id
destTypeId
,
spv
::
Id
operand
,
glslang
::
TBasicType
typeProxy
);
spv
::
Id
makeSmearedConstant
(
spv
::
Id
constant
,
int
vectorSize
);
spv
::
Id
makeSmearedConstant
(
spv
::
Id
constant
,
int
vectorSize
);
spv
::
Id
createAtomicOperation
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Id
typeId
,
std
::
vector
<
spv
::
Id
>&
operands
,
glslang
::
TBasicType
typeProxy
);
spv
::
Id
createAtomicOperation
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Id
typeId
,
std
::
vector
<
spv
::
Id
>&
operands
,
glslang
::
TBasicType
typeProxy
);
spv
::
Id
createInvocationsOperation
(
glslang
::
TOperator
,
spv
::
Id
typeId
,
spv
::
Id
operand
);
spv
::
Id
createInvocationsOperation
(
glslang
::
TOperator
,
spv
::
Id
typeId
,
spv
::
Id
operand
);
...
@@ -1071,7 +1071,7 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
...
@@ -1071,7 +1071,7 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
// it could be a conversion
// it could be a conversion
if
(
!
result
)
if
(
!
result
)
result
=
createConversion
(
node
->
getOp
(),
precision
,
convertGlslangToSpvType
(
node
->
getType
()),
operand
);
result
=
createConversion
(
node
->
getOp
(),
precision
,
noContraction
,
convertGlslangToSpvType
(
node
->
getType
()),
operand
,
node
->
getOperand
()
->
getBasicType
()
);
// if not, then possibly an operation
// if not, then possibly an operation
if
(
!
result
)
if
(
!
result
)
...
@@ -3331,7 +3331,7 @@ spv::Id TGlslangToSpvTraverser::createUnaryMatrixOperation(spv::Op op, spv::Deco
...
@@ -3331,7 +3331,7 @@ spv::Id TGlslangToSpvTraverser::createUnaryMatrixOperation(spv::Op op, spv::Deco
return
builder
.
setPrecision
(
builder
.
createCompositeConstruct
(
typeId
,
results
),
precision
);
return
builder
.
setPrecision
(
builder
.
createCompositeConstruct
(
typeId
,
results
),
precision
);
}
}
spv
::
Id
TGlslangToSpvTraverser
::
createConversion
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Id
destType
,
spv
::
Id
operand
)
spv
::
Id
TGlslangToSpvTraverser
::
createConversion
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Decoration
noContraction
,
spv
::
Id
destType
,
spv
::
Id
operand
,
glslang
::
TBasicType
typeProxy
)
{
{
spv
::
Op
convOp
=
spv
::
OpNop
;
spv
::
Op
convOp
=
spv
::
OpNop
;
spv
::
Id
zero
=
0
;
spv
::
Id
zero
=
0
;
...
@@ -3400,6 +3400,8 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Dec
...
@@ -3400,6 +3400,8 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Dec
case
glslang
:
:
EOpConvDoubleToFloat
:
case
glslang
:
:
EOpConvDoubleToFloat
:
case
glslang
:
:
EOpConvFloatToDouble
:
case
glslang
:
:
EOpConvFloatToDouble
:
convOp
=
spv
::
OpFConvert
;
convOp
=
spv
::
OpFConvert
;
if
(
builder
.
isMatrixType
(
destType
))
return
createUnaryMatrixOperation
(
convOp
,
precision
,
noContraction
,
destType
,
operand
,
typeProxy
);
break
;
break
;
case
glslang
:
:
EOpConvFloatToInt
:
case
glslang
:
:
EOpConvFloatToInt
:
...
...
Test/baseResults/spv.matrix.frag.out
View file @
73e3ce78
spv.matrix.frag
spv.matrix.frag
Warning, version 420 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
Linked fragment stage:
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80001
// Generated by (magic number): 80001
// Id's are bound by 2
40
// Id's are bound by 2
61
Capability Shader
Capability Shader
Capability Float64
1: ExtInstImport "GLSL.std.450"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 12 14 28 1
40 148 166
EntryPoint Fragment 4 "main" 12 14 28 1
61 169 187
ExecutionMode 4 OriginUpperLeft
ExecutionMode 4 OriginUpperLeft
Source GLSL
14
0
Source GLSL
42
0
Name 4 "main"
Name 4 "main"
Name 10 "sum34"
Name 10 "sum34"
Name 12 "m1"
Name 12 "m1"
Name 14 "m2"
Name 14 "m2"
Name 28 "f"
Name 28 "f"
Name 138 "sum3"
Name 140 "dm"
Name 140 "v4"
Name 159 "sum3"
Name 145 "sum4"
Name 161 "v4"
Name 148 "v3"
Name 166 "sum4"
Name 153 "m43"
Name 169 "v3"
Name 158 "m4"
Name 174 "m43"
Name 166 "color"
Name 179 "m4"
Name 187 "color"
2: TypeVoid
2: TypeVoid
3: TypeFunction 2
3: TypeFunction 2
6: TypeFloat 32
6: TypeFloat 32
...
@@ -37,27 +41,32 @@ Linked fragment stage:
...
@@ -37,27 +41,32 @@ Linked fragment stage:
27: TypePointer Input 6(float)
27: TypePointer Input 6(float)
28(f): 27(ptr) Variable Input
28(f): 27(ptr) Variable Input
81: 6(float) Constant 1065353216
81: 6(float) Constant 1065353216
136: TypeVector 6(float) 3
136: TypeFloat 64
137: TypePointer Function 136(fvec3)
137: TypeVector 136(float) 4
139: TypePointer Input 7(fvec4)
138: TypeMatrix 137(fvec4) 3
140(v4): 139(ptr) Variable Input
139: TypePointer Function 138
144: TypePointer Function 7(fvec4)
157: TypeVector 6(float) 3
147: TypePointer Input 136(fvec3)
158: TypePointer Function 157(fvec3)
148(v3): 147(ptr) Variable Input
160: TypePointer Input 7(fvec4)
151: TypeMatrix 136(fvec3) 4
161(v4): 160(ptr) Variable Input
152: TypePointer Function 151
165: TypePointer Function 7(fvec4)
156: TypeMatrix 7(fvec4) 4
168: TypePointer Input 157(fvec3)
157: TypePointer Function 156
169(v3): 168(ptr) Variable Input
165: TypePointer Output 7(fvec4)
172: TypeMatrix 157(fvec3) 4
166(color): 165(ptr) Variable Output
173: TypePointer Function 172
187: 6(float) Constant 0
177: TypeMatrix 7(fvec4) 4
178: TypePointer Function 177
186: TypePointer Output 7(fvec4)
187(color): 186(ptr) Variable Output
208: 6(float) Constant 0
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
138(sum3): 137(ptr) Variable Function
140(dm): 139(ptr) Variable Function
145(sum4): 144(ptr) Variable Function
159(sum3): 158(ptr) Variable Function
153(m43): 152(ptr) Variable Function
166(sum4): 165(ptr) Variable Function
158(m4): 157(ptr) Variable Function
174(m43): 173(ptr) Variable Function
179(m4): 178(ptr) Variable Function
13: 8 Load 12(m1)
13: 8 Load 12(m1)
15: 8 Load 14(m2)
15: 8 Load 14(m2)
16: 7(fvec4) CompositeExtract 13 0
16: 7(fvec4) CompositeExtract 13 0
...
@@ -185,102 +194,120 @@ Linked fragment stage:
...
@@ -185,102 +194,120 @@ Linked fragment stage:
134: 7(fvec4) FSub 133 128
134: 7(fvec4) FSub 133 128
135: 8 CompositeConstruct 130 132 134
135: 8 CompositeConstruct 130 132 134
Store 10(sum34) 135
Store 10(sum34) 135
141: 7(fvec4) Load 140(v4)
141: 8 Load 10(sum34)
142: 8 Load 14(m2)
142: 137(fvec4) CompositeExtract 141 0
143: 136(fvec3) VectorTimesMatrix 141 142
143: 137(fvec4) FConvert 142
Store 138(sum3) 143
144: 137(fvec4) CompositeExtract 141 1
146: 8 Load 14(m2)
145: 137(fvec4) FConvert 144
149: 136(fvec3) Load 148(v3)
146: 137(fvec4) CompositeExtract 141 2
150: 7(fvec4) MatrixTimesVector 146 149
147: 137(fvec4) FConvert 146
Store 145(sum4) 150
148: 138 CompositeConstruct 143 145 147
154: 8 Load 10(sum34)
Store 140(dm) 148
155: 151 Transpose 154
149: 138 Load 140(dm)
Store 153(m43) 155
150: 7(fvec4) CompositeExtract 149 0
159: 8 Load 12(m1)
151: 7(fvec4) FConvert 150
160: 151 Load 153(m43)
152: 7(fvec4) CompositeExtract 149 1
161: 156 MatrixTimesMatrix 159 160
153: 7(fvec4) FConvert 152
Store 158(m4) 161
154: 7(fvec4) CompositeExtract 149 2
162: 7(fvec4) Load 140(v4)
155: 7(fvec4) FConvert 154
163: 156 Load 158(m4)
156: 8 CompositeConstruct 151 153 155
164: 7(fvec4) VectorTimesMatrix 162 163
Store 10(sum34) 156
Store 145(sum4) 164
162: 7(fvec4) Load 161(v4)
167: 7(fvec4) Load 145(sum4)
163: 8 Load 14(m2)
Store 166(color) 167
164: 157(fvec3) VectorTimesMatrix 162 163
168: 8 Load 10(sum34)
Store 159(sum3) 164
169: 7(fvec4) CompositeConstruct 81 81 81 81
167: 8 Load 14(m2)
170: 7(fvec4) CompositeExtract 168 0
170: 157(fvec3) Load 169(v3)
171: 7(fvec4) FAdd 170 169
171: 7(fvec4) MatrixTimesVector 167 170
172: 7(fvec4) CompositeExtract 168 1
Store 166(sum4) 171
173: 7(fvec4) FAdd 172 169
175: 8 Load 10(sum34)
174: 7(fvec4) CompositeExtract 168 2
176: 172 Transpose 175
175: 7(fvec4) FAdd 174 169
Store 174(m43) 176
176: 8 CompositeConstruct 171 173 175
180: 8 Load 12(m1)
Store 10(sum34) 176
181: 172 Load 174(m43)
177: 8 Load 10(sum34)
182: 177 MatrixTimesMatrix 180 181
178: 7(fvec4) CompositeConstruct 81 81 81 81
Store 179(m4) 182
179: 7(fvec4) CompositeExtract 177 0
183: 7(fvec4) Load 161(v4)
180: 7(fvec4) FSub 179 178
184: 177 Load 179(m4)
181: 7(fvec4) CompositeExtract 177 1
185: 7(fvec4) VectorTimesMatrix 183 184
182: 7(fvec4) FSub 181 178
Store 166(sum4) 185
183: 7(fvec4) CompositeExtract 177 2
188: 7(fvec4) Load 166(sum4)
184: 7(fvec4) FSub 183 178
Store 187(color) 188
185: 8 CompositeConstruct 180 182 184
189: 8 Load 10(sum34)
Store 10(sum34) 185
190: 7(fvec4) CompositeConstruct 81 81 81 81
186: 6(float) Load 28(f)
191: 7(fvec4) CompositeExtract 189 0
188: 7(fvec4) CompositeConstruct 186 187 187 187
192: 7(fvec4) FAdd 191 190
189: 7(fvec4) CompositeConstruct 187 186 187 187
193: 7(fvec4) CompositeExtract 189 1
190: 7(fvec4) CompositeConstruct 187 187 186 187
194: 7(fvec4) FAdd 193 190
191: 8 CompositeConstruct 188 189 190
195: 7(fvec4) CompositeExtract 189 2
192: 8 Load 10(sum34)
196: 7(fvec4) FAdd 195 190
193: 7(fvec4) CompositeExtract 192 0
197: 8 CompositeConstruct 192 194 196
194: 7(fvec4) CompositeExtract 191 0
Store 10(sum34) 197
195: 7(fvec4) FAdd 193 194
198: 8 Load 10(sum34)
196: 7(fvec4) CompositeExtract 192 1
199: 7(fvec4) CompositeConstruct 81 81 81 81
197: 7(fvec4) CompositeExtract 191 1
200: 7(fvec4) CompositeExtract 198 0
198: 7(fvec4) FAdd 196 197
201: 7(fvec4) FSub 200 199
199: 7(fvec4) CompositeExtract 192 2
202: 7(fvec4) CompositeExtract 198 1
200: 7(fvec4) CompositeExtract 191 2
203: 7(fvec4) FSub 202 199
201: 7(fvec4) FAdd 199 200
204: 7(fvec4) CompositeExtract 198 2
202: 8 CompositeConstruct 195 198 201
205: 7(fvec4) FSub 204 199
Store 10(sum34) 202
206: 8 CompositeConstruct 201 203 205
203: 136(fvec3) Load 148(v3)
Store 10(sum34) 206
204: 6(float) Load 28(f)
207: 6(float) Load 28(f)
205: 136(fvec3) Load 148(v3)
209: 7(fvec4) CompositeConstruct 207 208 208 208
206: 6(float) Load 28(f)
210: 7(fvec4) CompositeConstruct 208 207 208 208
207: 136(fvec3) Load 148(v3)
211: 7(fvec4) CompositeConstruct 208 208 207 208
208: 6(float) Load 28(f)
212: 8 CompositeConstruct 209 210 211
209: 6(float) CompositeExtract 203 0
213: 8 Load 10(sum34)
210: 6(float) CompositeExtract 203 1
214: 7(fvec4) CompositeExtract 213 0
211: 6(float) CompositeExtract 203 2
215: 7(fvec4) CompositeExtract 212 0
212: 6(float) CompositeExtract 205 0
216: 7(fvec4) FAdd 214 215
213: 6(float) CompositeExtract 205 1
217: 7(fvec4) CompositeExtract 213 1
214: 6(float) CompositeExtract 205 2
218: 7(fvec4) CompositeExtract 212 1
215: 6(float) CompositeExtract 207 0
219: 7(fvec4) FAdd 217 218
216: 6(float) CompositeExtract 207 1
220: 7(fvec4) CompositeExtract 213 2
217: 6(float) CompositeExtract 207 2
221: 7(fvec4) CompositeExtract 212 2
218: 7(fvec4) CompositeConstruct 209 210 211 204
222: 7(fvec4) FAdd 220 221
219: 7(fvec4) CompositeConstruct 212 213 214 206
223: 8 CompositeConstruct 216 219 222
220: 7(fvec4) CompositeConstruct 215 216 217 208
Store 10(sum34) 223
221: 8 CompositeConstruct 218 219 220
224: 157(fvec3) Load 169(v3)
222: 8 Load 10(sum34)
225: 6(float) Load 28(f)
223: 7(fvec4) CompositeExtract 222 0
226: 157(fvec3) Load 169(v3)
224: 7(fvec4) CompositeExtract 221 0
227: 6(float) Load 28(f)
225: 7(fvec4) FAdd 223 224
228: 157(fvec3) Load 169(v3)
226: 7(fvec4) CompositeExtract 222 1
229: 6(float) Load 28(f)
227: 7(fvec4) CompositeExtract 221 1
230: 6(float) CompositeExtract 224 0
228: 7(fvec4) FAdd 226 227
231: 6(float) CompositeExtract 224 1
229: 7(fvec4) CompositeExtract 222 2
232: 6(float) CompositeExtract 224 2
230: 7(fvec4) CompositeExtract 221 2
233: 6(float) CompositeExtract 226 0
231: 7(fvec4) FAdd 229 230
234: 6(float) CompositeExtract 226 1
232: 8 CompositeConstruct 225 228 231
235: 6(float) CompositeExtract 226 2
Store 10(sum34) 232
236: 6(float) CompositeExtract 228 0
233: 136(fvec3) Load 138(sum3)
237: 6(float) CompositeExtract 228 1
234: 151 Load 153(m43)
238: 6(float) CompositeExtract 228 2
235: 7(fvec4) VectorTimesMatrix 233 234
239: 7(fvec4) CompositeConstruct 230 231 232 225
236: 7(fvec4) Load 145(sum4)
240: 7(fvec4) CompositeConstruct 233 234 235 227
237: 7(fvec4) FAdd 235 236
241: 7(fvec4) CompositeConstruct 236 237 238 229
238: 7(fvec4) Load 166(color)
242: 8 CompositeConstruct 239 240 241
239: 7(fvec4) FAdd 238 237
243: 8 Load 10(sum34)
Store 166(color) 239
244: 7(fvec4) CompositeExtract 243 0
245: 7(fvec4) CompositeExtract 242 0
246: 7(fvec4) FAdd 244 245
247: 7(fvec4) CompositeExtract 243 1
248: 7(fvec4) CompositeExtract 242 1
249: 7(fvec4) FAdd 247 248
250: 7(fvec4) CompositeExtract 243 2
251: 7(fvec4) CompositeExtract 242 2
252: 7(fvec4) FAdd 250 251
253: 8 CompositeConstruct 246 249 252
Store 10(sum34) 253
254: 157(fvec3) Load 159(sum3)
255: 172 Load 174(m43)
256: 7(fvec4) VectorTimesMatrix 254 255
257: 7(fvec4) Load 166(sum4)
258: 7(fvec4) FAdd 256 257
259: 7(fvec4) Load 187(color)
260: 7(fvec4) FAdd 259 258
Store 187(color) 260
Return
Return
FunctionEnd
FunctionEnd
Test/spv.matrix.frag
View file @
73e3ce78
#version
14
0
#version
42
0
in
mat3x4
m1
;
in
mat3x4
m1
;
in
mat3x4
m2
;
in
mat3x4
m2
;
...
@@ -11,6 +11,7 @@ out vec4 color;
...
@@ -11,6 +11,7 @@ out vec4 color;
void
main
()
void
main
()
{
{
mat3x4
sum34
;
mat3x4
sum34
;
dmat3x4
dm
;
vec3
sum3
;
vec3
sum3
;
vec4
sum4
;
vec4
sum4
;
...
@@ -22,6 +23,8 @@ void main()
...
@@ -22,6 +23,8 @@ void main()
sum34
+=
f
/
m1
;
sum34
+=
f
/
m1
;
sum34
+=
f
;
sum34
+=
f
;
sum34
-=
f
;
sum34
-=
f
;
dm
=
dmat3x4
(
sum34
);
sum34
=
mat3x4
(
dm
);
sum3
=
v4
*
m2
;
sum3
=
v4
*
m2
;
sum4
=
m2
*
v3
;
sum4
=
m2
*
v3
;
...
@@ -33,10 +36,8 @@ void main()
...
@@ -33,10 +36,8 @@ void main()
color
=
sum4
;
color
=
sum4
;
//spv if (m1 != sum34)
++
sum34
;
++
sum34
;
--
sum34
;
// else
--
sum34
;
sum34
+=
mat3x4
(
f
);
sum34
+=
mat3x4
(
f
);
sum34
+=
mat3x4
(
v3
,
f
,
v3
,
f
,
v3
,
f
);
sum34
+=
mat3x4
(
v3
,
f
,
v3
,
f
,
v3
,
f
);
...
...
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