Fix #2227, which was coded incorrectly, to be simpler/safer.
This commit is contained in:
parent
9514c6be66
commit
2e0f0a0517
2 changed files with 15 additions and 19 deletions
|
|
@ -579,7 +579,7 @@ TDefaultGlslIoResolver::TDefaultGlslIoResolver(const TIntermediate& intermediate
|
||||||
|
|
||||||
int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInfo& ent) {
|
int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInfo& ent) {
|
||||||
const TType& type = ent.symbol->getType();
|
const TType& type = ent.symbol->getType();
|
||||||
TString& name = getAccessName(ent.symbol);
|
const TString& name = getAccessName(ent.symbol);
|
||||||
if (currentStage != stage) {
|
if (currentStage != stage) {
|
||||||
preStage = currentStage;
|
preStage = currentStage;
|
||||||
currentStage = stage;
|
currentStage = stage;
|
||||||
|
|
@ -627,7 +627,7 @@ int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInf
|
||||||
TVarSlotMap::iterator iter = storageSlotMap[resourceKey].find(name);
|
TVarSlotMap::iterator iter = storageSlotMap[resourceKey].find(name);
|
||||||
if (iter != storageSlotMap[resourceKey].end()) {
|
if (iter != storageSlotMap[resourceKey].end()) {
|
||||||
// If interface resource be found, set it has location and this symbol's new location
|
// If interface resource be found, set it has location and this symbol's new location
|
||||||
// equal the symbol's explicit location declarated in pre or next stage.
|
// equal the symbol's explicit location declaration in pre or next stage.
|
||||||
//
|
//
|
||||||
// vs: out vec4 a;
|
// vs: out vec4 a;
|
||||||
// fs: layout(..., location = 3,...) in vec4 a;
|
// fs: layout(..., location = 3,...) in vec4 a;
|
||||||
|
|
@ -663,7 +663,7 @@ int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInf
|
||||||
|
|
||||||
int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEntryInfo& ent) {
|
int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEntryInfo& ent) {
|
||||||
const TType& type = ent.symbol->getType();
|
const TType& type = ent.symbol->getType();
|
||||||
TString& name = getAccessName(ent.symbol);
|
const TString& name = getAccessName(ent.symbol);
|
||||||
// kick out of not doing this
|
// kick out of not doing this
|
||||||
if (! doAutoLocationMapping()) {
|
if (! doAutoLocationMapping()) {
|
||||||
return ent.newLocation = -1;
|
return ent.newLocation = -1;
|
||||||
|
|
@ -706,7 +706,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
|
||||||
TVarSlotMap::iterator iter = slotMap.find(name);
|
TVarSlotMap::iterator iter = slotMap.find(name);
|
||||||
if (iter != slotMap.end()) {
|
if (iter != slotMap.end()) {
|
||||||
// If uniform resource be found, set it has location and this symbol's new location
|
// If uniform resource be found, set it has location and this symbol's new location
|
||||||
// equal the uniform's explicit location declarated in other stage.
|
// equal the uniform's explicit location declaration in other stage.
|
||||||
//
|
//
|
||||||
// vs: uniform vec4 a;
|
// vs: uniform vec4 a;
|
||||||
// fs: layout(..., location = 3,...) uniform vec4 a;
|
// fs: layout(..., location = 3,...) uniform vec4 a;
|
||||||
|
|
@ -714,7 +714,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
|
||||||
location = iter->second;
|
location = iter->second;
|
||||||
}
|
}
|
||||||
if (! hasLocation) {
|
if (! hasLocation) {
|
||||||
// No explicit location declaraten in other stage.
|
// No explicit location declaration in other stage.
|
||||||
// So we should find a new slot for this uniform.
|
// So we should find a new slot for this uniform.
|
||||||
//
|
//
|
||||||
// vs: uniform vec4 a;
|
// vs: uniform vec4 a;
|
||||||
|
|
@ -723,7 +723,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
|
||||||
storageSlotMap[resourceKey][name] = location;
|
storageSlotMap[resourceKey][name] = location;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// the first uniform declarated in a program.
|
// the first uniform declaration in a program.
|
||||||
TVarSlotMap varSlotMap;
|
TVarSlotMap varSlotMap;
|
||||||
location = getFreeSlot(resourceKey, 0, size);
|
location = getFreeSlot(resourceKey, 0, size);
|
||||||
varSlotMap[name] = location;
|
varSlotMap[name] = location;
|
||||||
|
|
@ -734,8 +734,8 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
|
||||||
|
|
||||||
int TDefaultGlslIoResolver::resolveBinding(EShLanguage /*stage*/, TVarEntryInfo& ent) {
|
int TDefaultGlslIoResolver::resolveBinding(EShLanguage /*stage*/, TVarEntryInfo& ent) {
|
||||||
const TType& type = ent.symbol->getType();
|
const TType& type = ent.symbol->getType();
|
||||||
TString& name = getAccessName(ent.symbol);
|
const TString& name = getAccessName(ent.symbol);
|
||||||
// On OpenGL arrays of opaque types take a seperate binding for each element
|
// On OpenGL arrays of opaque types take a separate binding for each element
|
||||||
int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
|
int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
|
||||||
TResourceType resource = getResourceType(type);
|
TResourceType resource = getResourceType(type);
|
||||||
// don't need to handle uniform symbol, it will be handled in resolveUniformLocation
|
// don't need to handle uniform symbol, it will be handled in resolveUniformLocation
|
||||||
|
|
@ -809,7 +809,7 @@ void TDefaultGlslIoResolver::endCollect(EShLanguage /*stage*/) {
|
||||||
|
|
||||||
void TDefaultGlslIoResolver::reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& infoSink) {
|
void TDefaultGlslIoResolver::reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& infoSink) {
|
||||||
const TType& type = ent.symbol->getType();
|
const TType& type = ent.symbol->getType();
|
||||||
TString& name = getAccessName(ent.symbol);
|
const TString& name = getAccessName(ent.symbol);
|
||||||
TStorageQualifier storage = type.getQualifier().storage;
|
TStorageQualifier storage = type.getQualifier().storage;
|
||||||
EShLanguage stage(EShLangCount);
|
EShLanguage stage(EShLangCount);
|
||||||
switch (storage) {
|
switch (storage) {
|
||||||
|
|
@ -869,7 +869,7 @@ void TDefaultGlslIoResolver::reserverStorageSlot(TVarEntryInfo& ent, TInfoSink&
|
||||||
|
|
||||||
void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& infoSink) {
|
void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& infoSink) {
|
||||||
const TType& type = ent.symbol->getType();
|
const TType& type = ent.symbol->getType();
|
||||||
TString& name = getAccessName(ent.symbol);
|
const TString& name = getAccessName(ent.symbol);
|
||||||
int resource = getResourceType(type);
|
int resource = getResourceType(type);
|
||||||
if (type.getQualifier().hasBinding()) {
|
if (type.getQualifier().hasBinding()) {
|
||||||
TVarSlotMap& varSlotMap = resourceSlotMap[resource];
|
TVarSlotMap& varSlotMap = resourceSlotMap[resource];
|
||||||
|
|
@ -892,15 +892,11 @@ void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TString& TDefaultGlslIoResolver::getAccessName(const TIntermSymbol* symbol)
|
const TString& TDefaultGlslIoResolver::getAccessName(const TIntermSymbol* symbol)
|
||||||
{
|
{
|
||||||
TString name;
|
return symbol->getBasicType() == EbtBlock ?
|
||||||
if (symbol->getBasicType() == EbtBlock) {
|
symbol->getType().getTypeName() :
|
||||||
name = symbol->getType().getTypeName();
|
symbol->getName();
|
||||||
} else {
|
|
||||||
name = symbol->getName();
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TDefaultGlslIoResolver end
|
//TDefaultGlslIoResolver end
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ public:
|
||||||
void endCollect(EShLanguage) override;
|
void endCollect(EShLanguage) override;
|
||||||
void reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& infoSink) override;
|
void reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& infoSink) override;
|
||||||
void reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& infoSink) override;
|
void reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& infoSink) override;
|
||||||
TString& getAccessName(const TIntermSymbol*);
|
const TString& getAccessName(const TIntermSymbol*);
|
||||||
// in/out symbol and uniform symbol are stored in the same resourceSlotMap, the storage key is used to identify each type of symbol.
|
// in/out symbol and uniform symbol are stored in the same resourceSlotMap, the storage key is used to identify each type of symbol.
|
||||||
// We use stage and storage qualifier to construct a storage key. it can help us identify the same storage resource used in different stage.
|
// We use stage and storage qualifier to construct a storage key. it can help us identify the same storage resource used in different stage.
|
||||||
// if a resource is a program resource and we don't need know it usage stage, we can use same stage to build storage key.
|
// if a resource is a program resource and we don't need know it usage stage, we can use same stage to build storage key.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue