Add an option to set the base uniform location
This will be used to generate uniform locations with --aml
This commit is contained in:
parent
16f53474c8
commit
b0f3d794c8
@ -174,6 +174,7 @@ std::vector<std::string> Processes; // what should be record
|
||||
typedef std::map<unsigned int, unsigned int> TPerSetBaseBinding;
|
||||
|
||||
std::vector<std::pair<std::string, int>> uniformLocationOverrides;
|
||||
int uniformBase = 0;
|
||||
|
||||
std::array<std::array<unsigned int, EShLangCount>, glslang::EResCount> baseBinding;
|
||||
std::array<std::array<TPerSetBaseBinding, EShLangCount>, glslang::EResCount> baseBindingForSet;
|
||||
@ -465,6 +466,12 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
|
||||
} else if (lowerword == "auto-map-locations" || // synonyms
|
||||
lowerword == "aml") {
|
||||
Options |= EOptionAutoMapLocations;
|
||||
} else if (lowerword == "uniform-base") {
|
||||
if (argc <= 1)
|
||||
Error("no <base> provided for --uniform-base");
|
||||
uniformBase = ::strtol(argv[1], NULL, 10);
|
||||
bumpArg();
|
||||
break;
|
||||
} else if (lowerword == "client") {
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "vulkan100") == 0)
|
||||
@ -924,6 +931,8 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
|
||||
uniOverride.second);
|
||||
}
|
||||
|
||||
shader->setUniformLocationBase(uniformBase);
|
||||
|
||||
// Set up the environment, some subsettings take precedence over earlier
|
||||
// ways of setting things.
|
||||
if (Options & EOptionSpv) {
|
||||
@ -1444,6 +1453,7 @@ void usage()
|
||||
" suppress GLSL warnings, except as required by \"#extension : warn\"\n"
|
||||
" -x save binary output as text-based 32-bit hexadecimal numbers\n"
|
||||
" -u<name>:<loc> specify a uniform location override for --aml\n"
|
||||
" --uniform-base <base> set a base to use for generated uniform locations\n"
|
||||
" --auto-map-bindings | --amb automatically bind uniform variables\n"
|
||||
" without explicit bindings\n"
|
||||
" --auto-map-locations | --aml automatically locate input/output lacking\n"
|
||||
|
@ -1763,6 +1763,10 @@ void TShader::addUniformLocationOverride(const char* name, int loc)
|
||||
{
|
||||
intermediate->addUniformLocationOverride(name, loc);
|
||||
}
|
||||
void TShader::setUniformLocationBase(int base)
|
||||
{
|
||||
intermediate->setUniformLocationBase(base);
|
||||
}
|
||||
// See comment above TDefaultHlslIoMapper in iomapper.cpp:
|
||||
void TShader::setHlslIoMapping(bool hlslIoMap) { intermediate->setHlslIoMapping(hlslIoMap); }
|
||||
void TShader::setFlattenUniformArrays(bool flatten) { intermediate->setFlattenUniformArrays(flatten); }
|
||||
|
@ -359,7 +359,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
|
||||
{
|
||||
TDefaultIoResolverBase(const TIntermediate &intermediate) :
|
||||
intermediate(intermediate),
|
||||
nextUniformLocation(0),
|
||||
nextUniformLocation(intermediate.getUniformLocationBase()),
|
||||
nextInputLocation(0),
|
||||
nextOutputLocation(0)
|
||||
{ }
|
||||
|
@ -252,7 +252,8 @@ public:
|
||||
hlslIoMapping(false),
|
||||
textureSamplerTransformMode(EShTexSampTransKeep),
|
||||
needToLegalize(false),
|
||||
binaryDoubleOutput(false)
|
||||
binaryDoubleOutput(false),
|
||||
uniformLocationBase(0)
|
||||
{
|
||||
localSize[0] = 1;
|
||||
localSize[1] = 1;
|
||||
@ -685,6 +686,9 @@ public:
|
||||
return pos->second;
|
||||
}
|
||||
|
||||
void setUniformLocationBase(int base) { uniformLocationBase = base; }
|
||||
int getUniformLocationBase() const { return uniformLocationBase; }
|
||||
|
||||
void setNeedsLegalization() { needToLegalize = true; }
|
||||
bool needsLegalization() const { return needToLegalize; }
|
||||
|
||||
@ -811,6 +815,7 @@ protected:
|
||||
bool binaryDoubleOutput;
|
||||
|
||||
std::unordered_map<TString, int> uniformLocationOverrides;
|
||||
int uniformLocationBase;
|
||||
|
||||
private:
|
||||
void operator=(TIntermediate&); // prevent assignments
|
||||
|
@ -414,6 +414,7 @@ public:
|
||||
void setAutoMapBindings(bool map);
|
||||
void setAutoMapLocations(bool map);
|
||||
void addUniformLocationOverride(const char* name, int loc);
|
||||
void setUniformLocationBase(int base);
|
||||
void setInvertY(bool invert);
|
||||
void setHlslIoMapping(bool hlslIoMap);
|
||||
void setFlattenUniformArrays(bool flatten);
|
||||
|
Loading…
x
Reference in New Issue
Block a user