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
e2ff404f
Commit
e2ff404f
authored
Jun 15, 2017
by
John Kessenich
Committed by
GitHub
Jun 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #917 from KhronosGroup/remove-redundant-locations
Replace #422: Remove the redundant location setting in AST->SPIR-V.
parents
f790b161
7cdf3fc3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
30 deletions
+7
-30
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+7
-27
spv.450.tesc.out
Test/baseResults/spv.450.tesc.out
+0
-3
No files found.
SPIRV/GlslangToSpv.cpp
View file @
e2ff404f
...
@@ -2431,7 +2431,6 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
...
@@ -2431,7 +2431,6 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
// Create a vector of struct types for SPIR-V to consume
// Create a vector of struct types for SPIR-V to consume
std
::
vector
<
spv
::
Id
>
spvMembers
;
std
::
vector
<
spv
::
Id
>
spvMembers
;
int
memberDelta
=
0
;
// how much the member's index changes from glslang to SPIR-V, normally 0, except sometimes for blocks
int
memberDelta
=
0
;
// how much the member's index changes from glslang to SPIR-V, normally 0, except sometimes for blocks
int
locationOffset
=
0
;
// for use across struct members, when they are called recursively
for
(
int
i
=
0
;
i
<
(
int
)
glslangMembers
->
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
glslangMembers
->
size
();
i
++
)
{
glslang
::
TType
&
glslangMember
=
*
(
*
glslangMembers
)[
i
].
type
;
glslang
::
TType
&
glslangMember
=
*
(
*
glslangMembers
)[
i
].
type
;
if
(
glslangMember
.
hiddenMember
())
{
if
(
glslangMember
.
hiddenMember
())
{
...
@@ -2448,11 +2447,9 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
...
@@ -2448,11 +2447,9 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
glslang
::
TQualifier
memberQualifier
=
glslangMember
.
getQualifier
();
glslang
::
TQualifier
memberQualifier
=
glslangMember
.
getQualifier
();
InheritQualifiers
(
memberQualifier
,
qualifier
);
InheritQualifiers
(
memberQualifier
,
qualifier
);
// manually inherit location
; it's more complex
// manually inherit location
if
(
!
memberQualifier
.
hasLocation
()
&&
qualifier
.
hasLocation
())
if
(
!
memberQualifier
.
hasLocation
()
&&
qualifier
.
hasLocation
())
memberQualifier
.
layoutLocation
=
qualifier
.
layoutLocation
+
locationOffset
;
memberQualifier
.
layoutLocation
=
qualifier
.
layoutLocation
;
if
(
qualifier
.
hasLocation
())
locationOffset
+=
glslangIntermediate
->
computeTypeLocationSize
(
glslangMember
);
// recurse
// recurse
spvMembers
.
push_back
(
convertGlslangToSpvType
(
glslangMember
,
explicitLayout
,
memberQualifier
));
spvMembers
.
push_back
(
convertGlslangToSpvType
(
glslangMember
,
explicitLayout
,
memberQualifier
));
...
@@ -2515,29 +2512,12 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
...
@@ -2515,29 +2512,12 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
addMemberDecoration
(
spvType
,
member
,
memory
[
i
]);
addMemberDecoration
(
spvType
,
member
,
memory
[
i
]);
}
}
// Compute location decoration; tricky based on whether inheritance is at play and
// Location assignment was already completed correctly by the front end,
// what kind of container we have, etc.
// just track whether a member needs to be decorated.
// TODO: This algorithm (and it's cousin above doing almost the same thing) should
// probably move to the linker stage of the front end proper, and just have the
// answer sitting already distributed throughout the individual member locations.
int
location
=
-
1
;
// will only decorate if present or inherited
// Ignore member locations if the container is an array, as that's
// Ignore member locations if the container is an array, as that's
// ill-specified and decisions have been made to not allow this anyway.
// ill-specified and decisions have been made to not allow this.
// The object itself must have a location, and that comes out from decorating the object,
if
(
!
type
.
isArray
()
&&
memberQualifier
.
hasLocation
())
// not the type (this code decorates types).
builder
.
addMemberDecoration
(
spvType
,
member
,
spv
::
DecorationLocation
,
memberQualifier
.
layoutLocation
);
if
(
!
type
.
isArray
())
{
if
(
memberQualifier
.
hasLocation
())
{
// no inheritance, or override of inheritance
// struct members should not have explicit locations
assert
(
type
.
getBasicType
()
!=
glslang
::
EbtStruct
);
location
=
memberQualifier
.
layoutLocation
;
}
else
if
(
type
.
getBasicType
()
!=
glslang
::
EbtBlock
)
{
// If it is a not a Block, (...) Its members are assigned consecutive locations (...)
// The members, and their nested types, must not themselves have Location decorations.
}
else
if
(
qualifier
.
hasLocation
())
// inheritance
location
=
qualifier
.
layoutLocation
+
locationOffset
;
}
if
(
location
>=
0
)
builder
.
addMemberDecoration
(
spvType
,
member
,
spv
::
DecorationLocation
,
location
);
if
(
qualifier
.
hasLocation
())
// track for upcoming inheritance
if
(
qualifier
.
hasLocation
())
// track for upcoming inheritance
locationOffset
+=
glslangIntermediate
->
computeTypeLocationSize
(
glslangMember
);
locationOffset
+=
glslangIntermediate
->
computeTypeLocationSize
(
glslangMember
);
...
...
Test/baseResults/spv.450.tesc.out
View file @
e2ff404f
...
@@ -36,11 +36,8 @@ spv.450.tesc
...
@@ -36,11 +36,8 @@ spv.450.tesc
Decorate 11(TheBlock) Block
Decorate 11(TheBlock) Block
Decorate 16(tcBlock) Location 12
Decorate 16(tcBlock) Location 12
MemberDecorate 17(SingleBlock) 0 Patch
MemberDecorate 17(SingleBlock) 0 Patch
MemberDecorate 17(SingleBlock) 0 Location 2
MemberDecorate 17(SingleBlock) 1 Patch
MemberDecorate 17(SingleBlock) 1 Patch
MemberDecorate 17(SingleBlock) 1 Location 3
MemberDecorate 17(SingleBlock) 2 Patch
MemberDecorate 17(SingleBlock) 2 Patch
MemberDecorate 17(SingleBlock) 2 Location 4
Decorate 17(SingleBlock) Block
Decorate 17(SingleBlock) Block
Decorate 19(singleBlock) Location 2
Decorate 19(singleBlock) Location 2
MemberDecorate 20(bn) 0 Patch
MemberDecorate 20(bn) 0 Patch
...
...
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