mirror of
https://github.com/RPCS3/glslang.git
synced 2024-11-23 19:29:44 +00:00
Merge pull request #917 from KhronosGroup/remove-redundant-locations
Replace #422: Remove the redundant location setting in AST->SPIR-V.
This commit is contained in:
commit
e2ff404f6b
@ -2431,7 +2431,6 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
|
||||
// Create a vector of struct types for SPIR-V to consume
|
||||
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 locationOffset = 0; // for use across struct members, when they are called recursively
|
||||
for (int i = 0; i < (int)glslangMembers->size(); i++) {
|
||||
glslang::TType& glslangMember = *(*glslangMembers)[i].type;
|
||||
if (glslangMember.hiddenMember()) {
|
||||
@ -2448,11 +2447,9 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
|
||||
glslang::TQualifier memberQualifier = glslangMember.getQualifier();
|
||||
InheritQualifiers(memberQualifier, qualifier);
|
||||
|
||||
// manually inherit location; it's more complex
|
||||
// manually inherit location
|
||||
if (! memberQualifier.hasLocation() && qualifier.hasLocation())
|
||||
memberQualifier.layoutLocation = qualifier.layoutLocation + locationOffset;
|
||||
if (qualifier.hasLocation())
|
||||
locationOffset += glslangIntermediate->computeTypeLocationSize(glslangMember);
|
||||
memberQualifier.layoutLocation = qualifier.layoutLocation;
|
||||
|
||||
// recurse
|
||||
spvMembers.push_back(convertGlslangToSpvType(glslangMember, explicitLayout, memberQualifier));
|
||||
@ -2515,29 +2512,12 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
|
||||
addMemberDecoration(spvType, member, memory[i]);
|
||||
}
|
||||
|
||||
// Compute location decoration; tricky based on whether inheritance is at play and
|
||||
// what kind of container we have, etc.
|
||||
// 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
|
||||
// Location assignment was already completed correctly by the front end,
|
||||
// just track whether a member needs to be decorated.
|
||||
// Ignore member locations if the container is an array, as that's
|
||||
// ill-specified and decisions have been made to not allow this anyway.
|
||||
// The object itself must have a location, and that comes out from decorating the object,
|
||||
// not the type (this code decorates types).
|
||||
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);
|
||||
// ill-specified and decisions have been made to not allow this.
|
||||
if (! type.isArray() && memberQualifier.hasLocation())
|
||||
builder.addMemberDecoration(spvType, member, spv::DecorationLocation, memberQualifier.layoutLocation);
|
||||
|
||||
if (qualifier.hasLocation()) // track for upcoming inheritance
|
||||
locationOffset += glslangIntermediate->computeTypeLocationSize(glslangMember);
|
||||
|
@ -36,11 +36,8 @@ spv.450.tesc
|
||||
Decorate 11(TheBlock) Block
|
||||
Decorate 16(tcBlock) Location 12
|
||||
MemberDecorate 17(SingleBlock) 0 Patch
|
||||
MemberDecorate 17(SingleBlock) 0 Location 2
|
||||
MemberDecorate 17(SingleBlock) 1 Patch
|
||||
MemberDecorate 17(SingleBlock) 1 Location 3
|
||||
MemberDecorate 17(SingleBlock) 2 Patch
|
||||
MemberDecorate 17(SingleBlock) 2 Location 4
|
||||
Decorate 17(SingleBlock) Block
|
||||
Decorate 19(singleBlock) Location 2
|
||||
MemberDecorate 20(bn) 0 Patch
|
||||
|
Loading…
Reference in New Issue
Block a user