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
d2386d0e
Commit
d2386d0e
authored
Sep 09, 2015
by
John Kessenich
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #68 from jekstrand/stride-decorations
SPIRV: Decorate matrices and arrays with their strides
parents
023f7e00
54aedf1f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+24
-0
No files found.
SPIRV/GlslangToSpv.cpp
View file @
d2386d0e
...
@@ -88,6 +88,8 @@ protected:
...
@@ -88,6 +88,8 @@ protected:
spv
::
Id
createSpvVariable
(
const
glslang
::
TIntermSymbol
*
);
spv
::
Id
createSpvVariable
(
const
glslang
::
TIntermSymbol
*
);
spv
::
Id
getSampledType
(
const
glslang
::
TSampler
&
);
spv
::
Id
getSampledType
(
const
glslang
::
TSampler
&
);
spv
::
Id
convertGlslangToSpvType
(
const
glslang
::
TType
&
type
);
spv
::
Id
convertGlslangToSpvType
(
const
glslang
::
TType
&
type
);
int
getArrayStride
(
const
glslang
::
TType
&
arrayType
);
int
getMatrixStride
(
const
glslang
::
TType
&
matrixType
);
void
updateMemberOffset
(
const
glslang
::
TType
&
structType
,
const
glslang
::
TType
&
memberType
,
int
&
currentOffset
,
int
&
nextOffset
);
void
updateMemberOffset
(
const
glslang
::
TType
&
structType
,
const
glslang
::
TType
&
memberType
,
int
&
currentOffset
,
int
&
nextOffset
);
bool
isShaderEntrypoint
(
const
glslang
::
TIntermAggregate
*
node
);
bool
isShaderEntrypoint
(
const
glslang
::
TIntermAggregate
*
node
);
...
@@ -1418,6 +1420,10 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
...
@@ -1418,6 +1420,10 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
offset
=
nextOffset
;
offset
=
nextOffset
;
}
}
if
(
glslangType
.
isMatrix
())
{
builder
.
addMemberDecoration
(
spvType
,
member
,
spv
::
DecorationMatrixStride
,
getMatrixStride
(
glslangType
));
}
// built-in variable decorations
// built-in variable decorations
spv
::
BuiltIn
builtIn
=
TranslateBuiltInDecoration
(
glslangType
.
getQualifier
().
builtIn
);
spv
::
BuiltIn
builtIn
=
TranslateBuiltInDecoration
(
glslangType
.
getQualifier
().
builtIn
);
if
(
builtIn
!=
spv
::
BadValue
)
if
(
builtIn
!=
spv
::
BadValue
)
...
@@ -1459,11 +1465,29 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
...
@@ -1459,11 +1465,29 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
}
else
}
else
arraySize
=
type
.
getOuterArraySize
();
arraySize
=
type
.
getOuterArraySize
();
spvType
=
builder
.
makeArrayType
(
spvType
,
arraySize
);
spvType
=
builder
.
makeArrayType
(
spvType
,
arraySize
);
builder
.
addDecoration
(
spvType
,
spv
::
DecorationArrayStride
,
getArrayStride
(
type
));
}
}
return
spvType
;
return
spvType
;
}
}
// Given an array type, returns the integer stride required for that array
int
TGlslangToSpvTraverser
::
getArrayStride
(
const
glslang
::
TType
&
arrayType
)
{
glslang
::
TType
derefType
(
arrayType
,
0
);
int
size
;
glslangIntermediate
->
getBaseAlignment
(
derefType
,
size
,
true
);
return
size
;
}
// Given a matrix type, returns the integer stride required for that matrix
// when used as a member of an interface block
int
TGlslangToSpvTraverser
::
getMatrixStride
(
const
glslang
::
TType
&
matrixType
)
{
int
size
;
return
glslangIntermediate
->
getBaseAlignment
(
matrixType
,
size
,
true
);
}
// Given a member type of a struct, realign the current offset for it, and compute
// Given a member type of a struct, realign the current offset for it, and compute
// the next (not yet aligned) offset for the next member, which will get aligned
// the next (not yet aligned) offset for the next member, which will get aligned
// on the next call.
// on the next call.
...
...
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