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
7a53f76d
Commit
7a53f76d
authored
Jan 20, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Add unary-matrix operations, operating at vector level.
parent
dd1c2235
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
3 deletions
+39
-3
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+38
-2
spv.branch-return.vert.out
Test/baseResults/spv.branch-return.vert.out
+1
-1
spv.matrix2.frag.out
Test/baseResults/spv.matrix2.frag.out
+0
-0
No files found.
SPIRV/GlslangToSpv.cpp
View file @
7a53f76d
...
@@ -110,6 +110,7 @@ protected:
...
@@ -110,6 +110,7 @@ protected:
spv
::
Id
createBinaryOperation
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Id
typeId
,
spv
::
Id
left
,
spv
::
Id
right
,
glslang
::
TBasicType
typeProxy
,
bool
reduceComparison
=
true
);
spv
::
Id
createBinaryOperation
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Id
typeId
,
spv
::
Id
left
,
spv
::
Id
right
,
glslang
::
TBasicType
typeProxy
,
bool
reduceComparison
=
true
);
spv
::
Id
createBinaryMatrixOperation
(
spv
::
Op
,
spv
::
Decoration
precision
,
spv
::
Id
typeId
,
spv
::
Id
left
,
spv
::
Id
right
);
spv
::
Id
createBinaryMatrixOperation
(
spv
::
Op
,
spv
::
Decoration
precision
,
spv
::
Id
typeId
,
spv
::
Id
left
,
spv
::
Id
right
);
spv
::
Id
createUnaryOperation
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Id
typeId
,
spv
::
Id
operand
,
glslang
::
TBasicType
typeProxy
);
spv
::
Id
createUnaryOperation
(
glslang
::
TOperator
op
,
spv
::
Decoration
precision
,
spv
::
Id
typeId
,
spv
::
Id
operand
,
glslang
::
TBasicType
typeProxy
);
spv
::
Id
createUnaryMatrixOperation
(
spv
::
Op
,
spv
::
Decoration
precision
,
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
::
Id
destTypeId
,
spv
::
Id
operand
);
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
);
...
@@ -2601,9 +2602,11 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
...
@@ -2601,9 +2602,11 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
switch
(
op
)
{
switch
(
op
)
{
case
glslang
:
:
EOpNegative
:
case
glslang
:
:
EOpNegative
:
if
(
isFloat
)
if
(
isFloat
)
{
unaryOp
=
spv
::
OpFNegate
;
unaryOp
=
spv
::
OpFNegate
;
else
if
(
builder
.
isMatrixType
(
typeId
))
return
createUnaryMatrixOperation
(
unaryOp
,
precision
,
typeId
,
operand
,
typeProxy
);
}
else
unaryOp
=
spv
::
OpSNegate
;
unaryOp
=
spv
::
OpSNegate
;
break
;
break
;
...
@@ -2862,6 +2865,39 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
...
@@ -2862,6 +2865,39 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
return
id
;
return
id
;
}
}
// Create a unary operation on a matrix
spv
::
Id
TGlslangToSpvTraverser
::
createUnaryMatrixOperation
(
spv
::
Op
op
,
spv
::
Decoration
precision
,
spv
::
Id
typeId
,
spv
::
Id
operand
,
glslang
::
TBasicType
/* typeProxy */
)
{
// Handle unary operations vector by vector.
// The result type is the same type as the original type.
// The algorithm is to:
// - break the matrix into vectors
// - apply the operation to each vector
// - make a matrix out the vector results
// get the types sorted out
int
numCols
=
builder
.
getNumColumns
(
operand
);
int
numRows
=
builder
.
getNumRows
(
operand
);
spv
::
Id
scalarType
=
builder
.
getScalarTypeId
(
typeId
);
spv
::
Id
vecType
=
builder
.
makeVectorType
(
scalarType
,
numRows
);
std
::
vector
<
spv
::
Id
>
results
;
// do each vector op
for
(
int
c
=
0
;
c
<
numCols
;
++
c
)
{
std
::
vector
<
unsigned
int
>
indexes
;
indexes
.
push_back
(
c
);
spv
::
Id
vec
=
builder
.
createCompositeExtract
(
operand
,
vecType
,
indexes
);
results
.
push_back
(
builder
.
createUnaryOp
(
op
,
vecType
,
vec
));
builder
.
setPrecision
(
results
.
back
(),
precision
);
}
// put the pieces together
spv
::
Id
id
=
builder
.
createCompositeConstruct
(
typeId
,
results
);
builder
.
setPrecision
(
id
,
precision
);
return
id
;
}
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
::
Id
destType
,
spv
::
Id
operand
)
{
{
spv
::
Op
convOp
=
spv
::
OpNop
;
spv
::
Op
convOp
=
spv
::
OpNop
;
...
...
Test/baseResults/spv.branch-return.vert.out
View file @
7a53f76d
...
@@ -60,4 +60,4 @@ Linked vertex stage:
...
@@ -60,4 +60,4 @@ Linked vertex stage:
33: 29(ptr) AccessChain 19(gl_Position) 28
33: 29(ptr) AccessChain 19(gl_Position) 28
Store 33 32
Store 33 32
Return
Return
FunctionEnd
FunctionEnd
Test/baseResults/spv.matrix2.frag.out
View file @
7a53f76d
This diff is collapsed.
Click to expand it.
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