Add a command-line option to override uniform locations
This commit is contained in:
parent
4508a8170a
commit
16f53474c8
5 changed files with 54 additions and 2 deletions
|
|
@ -1759,6 +1759,10 @@ void TShader::setAutoMapBindings(bool map) { intermediate->setAutoM
|
|||
void TShader::setInvertY(bool invert) { intermediate->setInvertY(invert); }
|
||||
// Fragile: currently within one stage: simple auto-assignment of location
|
||||
void TShader::setAutoMapLocations(bool map) { intermediate->setAutoMapLocations(map); }
|
||||
void TShader::addUniformLocationOverride(const char* name, int loc)
|
||||
{
|
||||
intermediate->addUniformLocationOverride(name, loc);
|
||||
}
|
||||
// See comment above TDefaultHlslIoMapper in iomapper.cpp:
|
||||
void TShader::setHlslIoMapping(bool hlslIoMap) { intermediate->setHlslIoMapping(hlslIoMap); }
|
||||
void TShader::setFlattenUniformArrays(bool flatten) { intermediate->setFlattenUniformArrays(flatten); }
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
|
|||
|
||||
return 0;
|
||||
}
|
||||
int resolveUniformLocation(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool /*is_live*/) override
|
||||
int resolveUniformLocation(EShLanguage /*stage*/, const char* name, const glslang::TType& type, bool /*is_live*/) override
|
||||
{
|
||||
// kick out of not doing this
|
||||
if (!doAutoLocationMapping())
|
||||
|
|
@ -455,7 +455,11 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
|
|||
return -1;
|
||||
}
|
||||
|
||||
int location = nextUniformLocation;
|
||||
int location = intermediate.getUniformLocationOverride(name);
|
||||
if (location != -1)
|
||||
return location;
|
||||
|
||||
location = nextUniformLocation;
|
||||
|
||||
nextUniformLocation += TIntermediate::computeTypeUniformLocationSize(type);
|
||||
|
||||
|
|
|
|||
|
|
@ -671,6 +671,20 @@ public:
|
|||
void addProcessArgument(const std::string& arg) { processes.addArgument(arg); }
|
||||
const std::vector<std::string>& getProcesses() const { return processes.getProcesses(); }
|
||||
|
||||
void addUniformLocationOverride(const TString& name, int location)
|
||||
{
|
||||
uniformLocationOverrides[name] = location;
|
||||
}
|
||||
|
||||
int getUniformLocationOverride(const TString& name) const
|
||||
{
|
||||
auto pos = uniformLocationOverrides.find(name);
|
||||
if (pos == uniformLocationOverrides.end())
|
||||
return -1;
|
||||
else
|
||||
return pos->second;
|
||||
}
|
||||
|
||||
void setNeedsLegalization() { needToLegalize = true; }
|
||||
bool needsLegalization() const { return needToLegalize; }
|
||||
|
||||
|
|
@ -796,6 +810,8 @@ protected:
|
|||
bool needToLegalize;
|
||||
bool binaryDoubleOutput;
|
||||
|
||||
std::unordered_map<TString, int> uniformLocationOverrides;
|
||||
|
||||
private:
|
||||
void operator=(TIntermediate&); // prevent assignments
|
||||
};
|
||||
|
|
|
|||
|
|
@ -413,6 +413,7 @@ public:
|
|||
void setResourceSetBinding(const std::vector<std::string>& base);
|
||||
void setAutoMapBindings(bool map);
|
||||
void setAutoMapLocations(bool map);
|
||||
void addUniformLocationOverride(const char* name, int loc);
|
||||
void setInvertY(bool invert);
|
||||
void setHlslIoMapping(bool hlslIoMap);
|
||||
void setFlattenUniformArrays(bool flatten);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue