mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
Revert "(glslang) Syntax cleanups, other cleanups"
This reverts commit e480ebd29f
.
This commit is contained in:
parent
7a9679c7fd
commit
9ec7eaeb8b
@ -191,9 +191,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
|
||||
break;
|
||||
|
||||
case EbtUint8:
|
||||
if (rightUnionArray[i] == 0)
|
||||
if (rightUnionArray[i] == 0) {
|
||||
newConstArray[i].setU8Const(0xFF);
|
||||
else
|
||||
} else
|
||||
newConstArray[i].setU8Const(leftUnionArray[i].getU8Const() / rightUnionArray[i].getU8Const());
|
||||
break;
|
||||
|
||||
@ -207,9 +207,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
|
||||
break;
|
||||
|
||||
case EbtUint16:
|
||||
if (rightUnionArray[i] == 0)
|
||||
if (rightUnionArray[i] == 0) {
|
||||
newConstArray[i].setU16Const(0xFFFF);
|
||||
else
|
||||
} else
|
||||
newConstArray[i].setU16Const(leftUnionArray[i].getU16Const() / rightUnionArray[i].getU16Const());
|
||||
break;
|
||||
|
||||
|
@ -104,8 +104,7 @@ protected:
|
||||
return true; // traverse all code
|
||||
|
||||
TIntermConstantUnion* constant = node->getCondition()->getAsConstantUnion();
|
||||
if (constant)
|
||||
{
|
||||
if (constant) {
|
||||
// cull the path that is dead
|
||||
if (constant->getConstArray()[0].getBConst() == true && node->getTrueBlock())
|
||||
node->getTrueBlock()->traverse(this);
|
||||
@ -113,8 +112,8 @@ protected:
|
||||
node->getFalseBlock()->traverse(this);
|
||||
|
||||
return false; // don't traverse any more, we did it all above
|
||||
}
|
||||
return true; // traverse the whole subtree
|
||||
} else
|
||||
return true; // traverse the whole subtree
|
||||
}
|
||||
|
||||
// Track live functions as well as uniforms, so that we don't visit dead functions
|
||||
|
1438
deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp
vendored
1438
deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp
vendored
File diff suppressed because it is too large
Load Diff
@ -107,12 +107,12 @@ public:
|
||||
// N.B. Sources can have a length of 0.
|
||||
int sourceToRead = currentSource;
|
||||
size_t charToRead = currentChar;
|
||||
while(charToRead >= lengths[sourceToRead])
|
||||
{
|
||||
while(charToRead >= lengths[sourceToRead]) {
|
||||
charToRead = 0;
|
||||
sourceToRead += 1;
|
||||
if (sourceToRead >= numSources)
|
||||
if (sourceToRead >= numSources) {
|
||||
return EndOfInput;
|
||||
}
|
||||
}
|
||||
|
||||
// Here, we care about making negative valued characters positive
|
||||
@ -130,16 +130,15 @@ public:
|
||||
--currentChar;
|
||||
--loc[currentSource].column;
|
||||
--logicalSourceLoc.column;
|
||||
if (loc[currentSource].column < 0)
|
||||
{
|
||||
if (loc[currentSource].column < 0) {
|
||||
// We've moved back past a new line. Find the
|
||||
// previous newline (or start of the file) to compute
|
||||
// the column count on the now current line.
|
||||
size_t chIndex = currentChar;
|
||||
while (chIndex > 0)
|
||||
{
|
||||
if (sources[currentSource][chIndex] == '\n')
|
||||
while (chIndex > 0) {
|
||||
if (sources[currentSource][chIndex] == '\n') {
|
||||
break;
|
||||
}
|
||||
--chIndex;
|
||||
}
|
||||
logicalSourceLoc.column = (int)(currentChar - chIndex);
|
||||
@ -149,10 +148,10 @@ public:
|
||||
do {
|
||||
--currentSource;
|
||||
} while (currentSource > 0 && lengths[currentSource] == 0);
|
||||
if (lengths[currentSource] == 0)
|
||||
if (lengths[currentSource] == 0) {
|
||||
// set to 0 if we've backed up to the start of an empty string
|
||||
currentChar = 0;
|
||||
else
|
||||
} else
|
||||
currentChar = lengths[currentSource] - 1;
|
||||
}
|
||||
if (peek() == '\n') {
|
||||
@ -208,9 +207,11 @@ public:
|
||||
|
||||
const TSourceLoc& getSourceLoc() const
|
||||
{
|
||||
if (singleLogical)
|
||||
if (singleLogical) {
|
||||
return logicalSourceLoc;
|
||||
return loc[std::max(0, std::min(currentSource, numSources - finale - 1))];
|
||||
} else {
|
||||
return loc[std::max(0, std::min(currentSource, numSources - finale - 1))];
|
||||
}
|
||||
}
|
||||
// Returns the index (starting from 0) of the most recent valid source string we are reading from.
|
||||
int getLastValidSourceIndex() const { return std::min(currentSource, numSources - 1); }
|
||||
|
@ -65,23 +65,20 @@ namespace { // anonymous namespace for file-local functions and symbols
|
||||
|
||||
// Total number of successful initializers of glslang: a refcount
|
||||
// Shared global; access should be protected by a global mutex/critical section.
|
||||
static int NumberOfClients = 0;
|
||||
int NumberOfClients = 0;
|
||||
|
||||
using namespace glslang;
|
||||
|
||||
// Create a language specific version of parseables.
|
||||
TBuiltInParseables* CreateBuiltInParseables(
|
||||
TInfoSink& infoSink, EShSource source)
|
||||
TBuiltInParseables* CreateBuiltInParseables(TInfoSink& infoSink, EShSource source)
|
||||
{
|
||||
switch (source)
|
||||
{
|
||||
case EShSourceGlsl:
|
||||
return new TBuiltIns(); // GLSL builtIns
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Unable to determine source language");
|
||||
break;
|
||||
switch (source) {
|
||||
case EShSourceGlsl: return new TBuiltIns(); // GLSL builtIns
|
||||
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Unable to determine source language");
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create a language specific version of a parse context.
|
||||
@ -1236,7 +1233,7 @@ void ShDestruct(ShHandle handle)
|
||||
//
|
||||
// Cleanup symbol tables
|
||||
//
|
||||
int __fastcall ShFinalize(void)
|
||||
int __fastcall ShFinalize()
|
||||
{
|
||||
glslang::GetGlobalLock();
|
||||
--NumberOfClients;
|
||||
@ -1319,15 +1316,15 @@ int ShCompile(
|
||||
|
||||
TIntermediate intermediate(compiler->getLanguage());
|
||||
TShader::ForbidIncluder includer;
|
||||
bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, NULL, "", optLevel, resources, defaultVersion, ENoProfile, false,
|
||||
forwardCompatible, messages, intermediate, includer);
|
||||
bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, NULL,
|
||||
"", optLevel, resources, defaultVersion, ENoProfile, false,
|
||||
forwardCompatible, messages, intermediate, includer);
|
||||
|
||||
//
|
||||
// Call the machine dependent compiler
|
||||
if ( success
|
||||
&& intermediate.getTreeRoot()
|
||||
&& optLevel != EShOptNoGeneration)
|
||||
success = compiler->compile(intermediate.getTreeRoot(),
|
||||
intermediate.getVersion(), intermediate.getProfile());
|
||||
//
|
||||
if (success && intermediate.getTreeRoot() && optLevel != EShOptNoGeneration)
|
||||
success = compiler->compile(intermediate.getTreeRoot(), intermediate.getVersion(), intermediate.getProfile());
|
||||
|
||||
intermediate.removeTree();
|
||||
|
||||
@ -1354,13 +1351,13 @@ int ShLinkExt(
|
||||
|
||||
THandleList cObjects;
|
||||
|
||||
for (int i = 0; i < numHandles; ++i)
|
||||
{
|
||||
for (int i = 0; i < numHandles; ++i) {
|
||||
if (compHandles[i] == 0)
|
||||
return 0;
|
||||
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
|
||||
if (base->getAsLinker())
|
||||
if (base->getAsLinker()) {
|
||||
cObjects.push_back(base->getAsLinker());
|
||||
}
|
||||
if (base->getAsCompiler())
|
||||
cObjects.push_back(base->getAsCompiler());
|
||||
|
||||
@ -1378,28 +1375,33 @@ int ShLinkExt(
|
||||
|
||||
linker->infoSink.info.erase();
|
||||
|
||||
for (int i = 0; i < numHandles; ++i)
|
||||
{
|
||||
if (cObjects[i]->getAsCompiler())
|
||||
{
|
||||
if (! cObjects[i]->getAsCompiler()->linkable())
|
||||
{
|
||||
for (int i = 0; i < numHandles; ++i) {
|
||||
if (cObjects[i]->getAsCompiler()) {
|
||||
if (! cObjects[i]->getAsCompiler()->linkable()) {
|
||||
linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return linker->link(cObjects) ? 1 : 0;
|
||||
bool ret = linker->link(cObjects);
|
||||
|
||||
return ret ? 1 : 0;
|
||||
}
|
||||
|
||||
//
|
||||
// ShSetEncrpytionMethod is a place-holder for specifying
|
||||
// how source code is encrypted.
|
||||
//
|
||||
void ShSetEncryptionMethod(ShHandle handle) { }
|
||||
void ShSetEncryptionMethod(ShHandle handle)
|
||||
{
|
||||
if (handle == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Return any compiler/linker/uniformmap log of messages for the application.
|
||||
//
|
||||
const char* ShGetInfoLog(const ShHandle handle)
|
||||
{
|
||||
if (handle == 0)
|
||||
@ -1534,19 +1536,30 @@ namespace glslang {
|
||||
#define QUOTE(s) #s
|
||||
#define STR(n) QUOTE(n)
|
||||
|
||||
const char* GetEsslVersionString(void)
|
||||
const char* GetEsslVersionString()
|
||||
{
|
||||
return "OpenGL ES GLSL 3.20 glslang Khronos. " STR(GLSLANG_MINOR_VERSION) "." STR(GLSLANG_PATCH_LEVEL);
|
||||
}
|
||||
|
||||
const char* GetGlslVersionString(void)
|
||||
const char* GetGlslVersionString()
|
||||
{
|
||||
return "4.60 glslang Khronos. " STR(GLSLANG_MINOR_VERSION) "." STR(GLSLANG_PATCH_LEVEL);
|
||||
}
|
||||
|
||||
int GetKhronosToolId(void) { return 8; }
|
||||
bool InitializeProcess(void) { return ShInitialize() != 0; }
|
||||
void FinalizeProcess(void) { ShFinalize(); }
|
||||
int GetKhronosToolId()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
bool InitializeProcess()
|
||||
{
|
||||
return ShInitialize() != 0;
|
||||
}
|
||||
|
||||
void FinalizeProcess()
|
||||
{
|
||||
ShFinalize();
|
||||
}
|
||||
|
||||
class TDeferredCompiler : public TCompiler {
|
||||
public:
|
||||
@ -1585,20 +1598,19 @@ void TShader::setStrings(const char* const* s, int n)
|
||||
lengths = NULL;
|
||||
}
|
||||
|
||||
void TShader::setStringsWithLengths(
|
||||
const char* const* s, const int* l, int n)
|
||||
void TShader::setStringsWithLengths(const char* const* s, const int* l, int n)
|
||||
{
|
||||
strings = s;
|
||||
numStrings = n;
|
||||
lengths = l;
|
||||
strings = s;
|
||||
numStrings = n;
|
||||
lengths = l;
|
||||
}
|
||||
|
||||
void TShader::setStringsWithLengthsAndNames(
|
||||
const char* const* s, const int* l, const char* const* names, int n)
|
||||
{
|
||||
strings = s;
|
||||
numStrings = n;
|
||||
lengths = l;
|
||||
strings = s;
|
||||
numStrings = n;
|
||||
lengths = l;
|
||||
stringNames = names;
|
||||
}
|
||||
|
||||
@ -1659,10 +1671,8 @@ void TShader::setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode
|
||||
//
|
||||
// Returns true for success.
|
||||
//
|
||||
bool TShader::parse(const TBuiltInResource* builtInResources,
|
||||
int defaultVersion, EProfile defaultProfile,
|
||||
bool forceDefaultVersionAndProfile,
|
||||
bool forwardCompatible, EShMessages messages, Includer& includer)
|
||||
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
|
||||
bool forwardCompatible, EShMessages messages, Includer& includer)
|
||||
{
|
||||
if (! InitThread())
|
||||
return false;
|
||||
@ -1672,20 +1682,20 @@ bool TShader::parse(const TBuiltInResource* builtInResources,
|
||||
preamble = "";
|
||||
|
||||
return CompileDeferred(compiler, strings, numStrings, lengths, stringNames,
|
||||
preamble, EShOptNone, builtInResources, defaultVersion,
|
||||
defaultProfile, forceDefaultVersionAndProfile,
|
||||
forwardCompatible, messages, *intermediate, includer, sourceEntryPointName,
|
||||
&environment);
|
||||
preamble, EShOptNone, builtInResources, defaultVersion,
|
||||
defaultProfile, forceDefaultVersionAndProfile,
|
||||
forwardCompatible, messages, *intermediate, includer, sourceEntryPointName,
|
||||
&environment);
|
||||
}
|
||||
|
||||
// Fill in a string with the result of preprocessing ShaderStrings
|
||||
// Returns true if all extensions, pragmas and version strings were valid.
|
||||
bool TShader::preprocess(const TBuiltInResource* builtInResources,
|
||||
int defaultVersion, EProfile defaultProfile,
|
||||
bool forceDefaultVersionAndProfile,
|
||||
bool forwardCompatible, EShMessages message,
|
||||
std::string* output_string,
|
||||
Includer& includer)
|
||||
int defaultVersion, EProfile defaultProfile,
|
||||
bool forceDefaultVersionAndProfile,
|
||||
bool forwardCompatible, EShMessages message,
|
||||
std::string* output_string,
|
||||
Includer& includer)
|
||||
{
|
||||
if (! InitThread())
|
||||
return false;
|
||||
@ -1694,20 +1704,18 @@ bool TShader::preprocess(const TBuiltInResource* builtInResources,
|
||||
if (! preamble)
|
||||
preamble = "";
|
||||
|
||||
return PreprocessDeferred(
|
||||
compiler, strings, numStrings, lengths, stringNames, preamble,
|
||||
EShOptNone, builtInResources, defaultVersion,
|
||||
defaultProfile, forceDefaultVersionAndProfile,
|
||||
forwardCompatible, message, includer,
|
||||
*intermediate, output_string);
|
||||
return PreprocessDeferred(compiler, strings, numStrings, lengths, stringNames, preamble,
|
||||
EShOptNone, builtInResources, defaultVersion,
|
||||
defaultProfile, forceDefaultVersionAndProfile,
|
||||
forwardCompatible, message, includer, *intermediate, output_string);
|
||||
}
|
||||
|
||||
const char* TShader::getInfoLog(void)
|
||||
const char* TShader::getInfoLog()
|
||||
{
|
||||
return infoSink->info.c_str();
|
||||
}
|
||||
|
||||
const char* TShader::getInfoDebugLog(void)
|
||||
const char* TShader::getInfoDebugLog()
|
||||
{
|
||||
return infoSink->debug.c_str();
|
||||
}
|
||||
@ -1716,9 +1724,8 @@ TProgram::TProgram() : reflection(0), ioMapper(NULL), linked(false)
|
||||
{
|
||||
pool = new TPoolAllocator;
|
||||
infoSink = new TInfoSink;
|
||||
for (int s = 0; s < EShLangCount; ++s)
|
||||
{
|
||||
intermediate[s] = 0;
|
||||
for (int s = 0; s < EShLangCount; ++s) {
|
||||
intermediate[s] = 0;
|
||||
newedIntermediate[s] = false;
|
||||
}
|
||||
}
|
||||
@ -1781,32 +1788,28 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
|
||||
numNonEsShaders++;
|
||||
}
|
||||
|
||||
if (numEsShaders > 0 && numNonEsShaders > 0)
|
||||
{
|
||||
if (numEsShaders > 0 && numNonEsShaders > 0) {
|
||||
infoSink->info.message(EPrefixError, "Cannot mix ES profile with non-ES profile shaders");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numEsShaders > 1)
|
||||
{
|
||||
} else if (numEsShaders > 1) {
|
||||
infoSink->info.message(EPrefixError, "Cannot attach multiple ES shaders of the same type to a single program");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Be efficient for the common single compilation unit per stage case,
|
||||
// reusing it's TIntermediate instead of merging into a new one.
|
||||
//
|
||||
TIntermediate *firstIntermediate = stages[stage].front()->intermediate;
|
||||
if (stages[stage].size() == 1)
|
||||
intermediate[stage] = firstIntermediate;
|
||||
else
|
||||
{
|
||||
else {
|
||||
intermediate[stage] = new TIntermediate(stage,
|
||||
firstIntermediate->getVersion(),
|
||||
firstIntermediate->getProfile());
|
||||
firstIntermediate->getVersion(),
|
||||
firstIntermediate->getProfile());
|
||||
|
||||
|
||||
// The new TIntermediate must use the same
|
||||
// origin as the original TIntermediates.
|
||||
// The new TIntermediate must use the same origin as the original TIntermediates.
|
||||
// Otherwise linking will fail due to different coordinate systems.
|
||||
if (firstIntermediate->getOriginUpperLeft())
|
||||
intermediate[stage]->setOriginUpperLeft();
|
||||
@ -1853,10 +1856,8 @@ bool TProgram::buildReflection(void)
|
||||
|
||||
reflection = new TReflection;
|
||||
|
||||
for (int s = 0; s < EShLangCount; ++s)
|
||||
{
|
||||
if (intermediate[s])
|
||||
{
|
||||
for (int s = 0; s < EShLangCount; ++s) {
|
||||
if (intermediate[s]) {
|
||||
if (! reflection->addStage((EShLanguage)s, *intermediate[s]))
|
||||
return false;
|
||||
}
|
||||
@ -1894,10 +1895,8 @@ bool TProgram::mapIO(TIoMapResolver* resolver)
|
||||
|
||||
ioMapper = new TIoMapper;
|
||||
|
||||
for (int s = 0; s < EShLangCount; ++s)
|
||||
{
|
||||
if (intermediate[s])
|
||||
{
|
||||
for (int s = 0; s < EShLangCount; ++s) {
|
||||
if (intermediate[s]) {
|
||||
if (! ioMapper->addStage((EShLanguage)s, *intermediate[s], *infoSink, resolver))
|
||||
return false;
|
||||
}
|
||||
|
@ -173,8 +173,9 @@ void TType::buildMangledName(TString& mangledName) const
|
||||
void TVariable::dump(TInfoSink& infoSink) const
|
||||
{
|
||||
infoSink.debug << getName().c_str() << ": " << type.getStorageQualifierString() << " " << type.getBasicTypeString();
|
||||
if (type.isArray())
|
||||
if (type.isArray()) {
|
||||
infoSink.debug << "[0]";
|
||||
}
|
||||
infoSink.debug << "\n";
|
||||
}
|
||||
|
||||
@ -298,13 +299,15 @@ TVariable::TVariable(const TVariable& copyOf) : TSymbol(copyOf)
|
||||
|
||||
TVariable* TVariable::clone() const
|
||||
{
|
||||
return new TVariable(*this);
|
||||
TVariable *variable = new TVariable(*this);
|
||||
|
||||
return variable;
|
||||
}
|
||||
|
||||
TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf)
|
||||
{
|
||||
for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) {
|
||||
TParameter param = {};
|
||||
TParameter param;
|
||||
parameters.push_back(param);
|
||||
parameters.back().copyParam(copyOf.parameters[i]);
|
||||
}
|
||||
|
@ -129,8 +129,10 @@ protected:
|
||||
int numExtensions;
|
||||
const char** extensions; // an array of pointers to existing constant char strings
|
||||
|
||||
//
|
||||
// N.B.: Non-const functions that will be generally used should assert on this,
|
||||
// to avoid overwriting shared symbol-table information.
|
||||
//
|
||||
bool writable;
|
||||
};
|
||||
|
||||
@ -398,7 +400,8 @@ public:
|
||||
// Only supporting amend of anonymous blocks so far.
|
||||
if (IsAnonymous(symbol.getName()))
|
||||
return insertAnonymousMembers(symbol, firstNewMember);
|
||||
return false;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool insertAnonymousMembers(TSymbol& symbol, int firstMember)
|
||||
@ -418,7 +421,8 @@ public:
|
||||
tLevel::const_iterator it = level.find(name);
|
||||
if (it == level.end())
|
||||
return 0;
|
||||
return (*it).second;
|
||||
else
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
void findFunctionNameList(const TString& name, TVector<const TFunction*>& list)
|
||||
@ -529,8 +533,12 @@ protected:
|
||||
|
||||
class TSymbolTable {
|
||||
public:
|
||||
// This symbol table cannot be used until push() is called.
|
||||
TSymbolTable() : uniqueId(0), noBuiltInRedeclarations(false), separateNameSpaces(false), adoptedLevels(0) { }
|
||||
TSymbolTable() : uniqueId(0), noBuiltInRedeclarations(false), separateNameSpaces(false), adoptedLevels(0)
|
||||
{
|
||||
//
|
||||
// This symbol table cannot be used until push() is called.
|
||||
//
|
||||
}
|
||||
~TSymbolTable()
|
||||
{
|
||||
// this can be called explicitly; safest to code it so it can be called multiple times
|
||||
@ -669,8 +677,10 @@ public:
|
||||
table[globalLevel]->insert(*copy, separateNameSpaces);
|
||||
if (shared->getAsVariable())
|
||||
return copy;
|
||||
// return the copy of the anonymous member
|
||||
return table[globalLevel]->find(shared->getName());
|
||||
else {
|
||||
// return the copy of the anonymous member
|
||||
return table[globalLevel]->find(shared->getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Normal find of a symbol, that can optionally say whether the symbol was found
|
||||
|
@ -253,26 +253,27 @@ struct TResolverUniformAdaptor
|
||||
ent.newBinding = -1;
|
||||
ent.newSet = -1;
|
||||
ent.newIndex = -1;
|
||||
const bool isValid = resolver.validateBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live);
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
ent.newBinding = resolver.resolveBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live);
|
||||
const bool isValid = resolver.validateBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(),
|
||||
ent.live);
|
||||
if (isValid) {
|
||||
ent.newBinding = resolver.resolveBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(),
|
||||
ent.live);
|
||||
ent.newSet = resolver.resolveSet(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live);
|
||||
ent.newLocation = resolver.resolveUniformLocation(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live);
|
||||
ent.newLocation = resolver.resolveUniformLocation(stage, ent.symbol->getName().c_str(),
|
||||
ent.symbol->getType(), ent.live);
|
||||
|
||||
if (ent.newBinding != -1) {
|
||||
if (ent.newBinding >= int(TQualifier::layoutBindingEnd)) {
|
||||
TString err = "mapped binding out of range: "
|
||||
+ ent.symbol->getName();
|
||||
TString err = "mapped binding out of range: " + ent.symbol->getName();
|
||||
|
||||
infoSink.info.message(EPrefixInternalError, err.c_str());
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
if (ent.newSet != -1) {
|
||||
if (ent.newSet >= int(TQualifier::layoutSetEnd)) {
|
||||
TString err = "mapped set out of range: "
|
||||
+ ent.symbol->getName();
|
||||
TString err = "mapped set out of range: " + ent.symbol->getName();
|
||||
|
||||
infoSink.info.message(EPrefixInternalError, err.c_str());
|
||||
error = true;
|
||||
}
|
||||
@ -313,25 +314,23 @@ struct TResolverInOutAdaptor
|
||||
ent.newSet = -1;
|
||||
ent.newIndex = -1;
|
||||
const bool isValid = resolver.validateInOut(stage,
|
||||
ent.symbol->getName().c_str(),
|
||||
ent.symbol->getType(),
|
||||
ent.live);
|
||||
ent.symbol->getName().c_str(),
|
||||
ent.symbol->getType(),
|
||||
ent.live);
|
||||
if (isValid) {
|
||||
ent.newLocation = resolver.resolveInOutLocation(stage,
|
||||
ent.symbol->getName().c_str(),
|
||||
ent.symbol->getType(),
|
||||
ent.live);
|
||||
ent.symbol->getName().c_str(),
|
||||
ent.symbol->getType(),
|
||||
ent.live);
|
||||
ent.newComponent = resolver.resolveInOutComponent(stage,
|
||||
ent.symbol->getName().c_str(),
|
||||
ent.symbol->getType(),
|
||||
ent.live);
|
||||
ent.symbol->getName().c_str(),
|
||||
ent.symbol->getType(),
|
||||
ent.live);
|
||||
ent.newIndex = resolver.resolveInOutIndex(stage,
|
||||
ent.symbol->getName().c_str(),
|
||||
ent.symbol->getType(),
|
||||
ent.live);
|
||||
}
|
||||
else
|
||||
{
|
||||
ent.symbol->getName().c_str(),
|
||||
ent.symbol->getType(),
|
||||
ent.live);
|
||||
} else {
|
||||
TString errorMsg = "Invalid shader In/Out variable semantic: ";
|
||||
errorMsg += ent.symbol->getType().getQualifier().semanticName;
|
||||
infoSink.info.message(EPrefixInternalError, errorMsg.c_str());
|
||||
@ -360,33 +359,37 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
|
||||
{ }
|
||||
|
||||
int getBaseBinding(TResourceType res, unsigned int set) const {
|
||||
// Return descriptor set specific base if
|
||||
// there is one, and the generic base otherwise.
|
||||
int base = intermediate.getShiftBinding(res);
|
||||
int descriptorSetBase = intermediate.getShiftBindingForSet(res, set);
|
||||
return descriptorSetBase != -1 ? descriptorSetBase : base;
|
||||
return selectBaseBinding(intermediate.getShiftBinding(res),
|
||||
intermediate.getShiftBindingForSet(res, set));
|
||||
}
|
||||
|
||||
const std::vector<std::string>& getResourceSetBinding() const { return intermediate.getResourceSetBinding(); }
|
||||
|
||||
bool doAutoBindingMapping() const { return intermediate.getAutoMapBindings(); }
|
||||
bool doAutoLocationMapping() const { return intermediate.getAutoMapLocations(); }
|
||||
|
||||
typedef std::vector<int> TSlotSet;
|
||||
typedef std::unordered_map<int, TSlotSet> TSlotSetMap;
|
||||
TSlotSetMap slots;
|
||||
|
||||
TSlotSet::iterator findSlot(int set, int slot)
|
||||
{
|
||||
return std::lower_bound(slots[set].begin(), slots[set].end(), slot);
|
||||
}
|
||||
|
||||
bool checkEmpty(int set, int slot)
|
||||
{
|
||||
TSlotSet::iterator at = std::lower_bound(slots[set].begin(), slots[set].end(), slot);
|
||||
TSlotSet::iterator at = findSlot(set, slot);
|
||||
return !(at != slots[set].end() && *at == slot);
|
||||
}
|
||||
|
||||
int reserveSlot(int set, int slot, int size = 1)
|
||||
{
|
||||
TSlotSet::iterator at = std::lower_bound(slots[set].begin(), slots[set].end(), slot);
|
||||
TSlotSet::iterator at = findSlot(set, slot);
|
||||
|
||||
// tolerate aliasing, by not double-recording aliases
|
||||
// (policy about appropriateness of the alias is higher up)
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (at == slots[set].end() || *at != slot + i)
|
||||
at = slots[set].insert(at, slot + i);
|
||||
++at;
|
||||
@ -397,13 +400,12 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
|
||||
|
||||
int getFreeSlot(int set, int base, int size = 1)
|
||||
{
|
||||
TSlotSet::iterator at = std::lower_bound(slots[set].begin(), slots[set].end(), base);
|
||||
TSlotSet::iterator at = findSlot(set, base);
|
||||
if (at == slots[set].end())
|
||||
return reserveSlot(set, base, size);
|
||||
|
||||
// look for a big enough gap
|
||||
for (; at != slots[set].end(); ++at)
|
||||
{
|
||||
for (; at != slots[set].end(); ++at) {
|
||||
if (*at - base >= size)
|
||||
break;
|
||||
base = *at + 1;
|
||||
@ -415,7 +417,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
|
||||
|
||||
virtual int resolveBinding(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool is_live) override = 0;
|
||||
|
||||
int resolveSet(EShLanguage stage, const char* name, const glslang::TType& type, bool is_live) override
|
||||
int resolveSet(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool /*is_live*/) override
|
||||
{
|
||||
if (type.getQualifier().hasSet())
|
||||
return type.getQualifier().layoutSet;
|
||||
@ -426,24 +428,21 @@ 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 (!intermediate.getAutoMapLocations())
|
||||
if (!doAutoLocationMapping())
|
||||
return -1;
|
||||
|
||||
// no locations added if already present,
|
||||
// a built-in variable, a block, or an opaque
|
||||
if ( type.getQualifier().hasLocation()
|
||||
|| type.isBuiltIn()
|
||||
|| type.getBasicType() == EbtBlock
|
||||
|| type.getBasicType() == EbtAtomicUint
|
||||
|| (type.containsOpaque() && intermediate.getSpv().openGl == 0))
|
||||
// no locations added if already present, a built-in variable, a block, or an opaque
|
||||
if (type.getQualifier().hasLocation() || type.isBuiltIn() ||
|
||||
type.getBasicType() == EbtBlock ||
|
||||
type.getBasicType() == EbtAtomicUint ||
|
||||
(type.containsOpaque() && intermediate.getSpv().openGl == 0))
|
||||
return -1;
|
||||
|
||||
// no locations on blocks of built-in variables
|
||||
if (type.isStruct())
|
||||
{
|
||||
if (type.isStruct()) {
|
||||
if (type.getStruct()->size() < 1)
|
||||
return -1;
|
||||
if ((*type.getStruct())[0].type->isBuiltIn())
|
||||
@ -456,16 +455,14 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
bool validateInOut(EShLanguage stage, const char* name, const TType& type, bool is_live) override
|
||||
bool validateInOut(EShLanguage /*stage*/, const char* /*name*/, const TType& /*type*/, bool /*is_live*/) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int resolveInOutLocation(EShLanguage stage, const char* name, const TType& type, bool is_live) override
|
||||
int resolveInOutLocation(EShLanguage stage, const char* /*name*/, const TType& type, bool /*is_live*/) override
|
||||
{
|
||||
// kick out of not doing this
|
||||
if (!intermediate.getAutoMapLocations())
|
||||
if (!doAutoLocationMapping())
|
||||
return -1;
|
||||
|
||||
// no locations added if already present, or a built-in variable
|
||||
@ -473,8 +470,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
|
||||
return -1;
|
||||
|
||||
// no locations on blocks of built-in variables
|
||||
if (type.isStruct())
|
||||
{
|
||||
if (type.isStruct()) {
|
||||
if (type.getStruct()->size() < 1)
|
||||
return -1;
|
||||
if ((*type.getStruct())[0].type->isBuiltIn())
|
||||
@ -490,30 +486,27 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
|
||||
int typeLocationSize;
|
||||
// Don’t take into account the outer-most array if the stage’s
|
||||
// interface is automatically an array.
|
||||
if (type.getQualifier().isArrayedIo(stage))
|
||||
{
|
||||
if (type.getQualifier().isArrayedIo(stage)) {
|
||||
TType elementType(type, 0);
|
||||
typeLocationSize = TIntermediate::computeTypeLocationSize(elementType, stage);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
typeLocationSize = TIntermediate::computeTypeLocationSize(type, stage);
|
||||
}
|
||||
nextLocation += typeLocationSize;
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
int resolveInOutComponent(EShLanguage stage, const char* name, const TType& type, bool is_live) override
|
||||
int resolveInOutComponent(EShLanguage /*stage*/, const char* /*name*/, const TType& /*type*/, bool /*is_live*/) override
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int resolveInOutIndex(EShLanguage /*stage*/, const char* /*name*/, const TType& /*type*/, bool /*is_live*/) override
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int resolveInOutIndex(EShLanguage stage, const char* name, const TType& type, bool is_live) override
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void notifyBinding(EShLanguage, const char* name, const TType&, bool is_live) override {}
|
||||
void notifyInOut(EShLanguage, const char* name, const TType&, bool is_live) override {}
|
||||
void notifyBinding(EShLanguage, const char* /*name*/, const TType&, bool /*is_live*/) override {}
|
||||
void notifyInOut(EShLanguage, const char* /*name*/, const TType&, bool /*is_live*/) override {}
|
||||
void endNotifications(EShLanguage) override {}
|
||||
void beginNotifications(EShLanguage) override {}
|
||||
void beginResolve(EShLanguage) override {}
|
||||
@ -525,10 +518,30 @@ protected:
|
||||
int nextInputLocation;
|
||||
int nextOutputLocation;
|
||||
|
||||
// Return descriptor set specific base if there is one, and the generic base otherwise.
|
||||
int selectBaseBinding(int base, int descriptorSetBase) const {
|
||||
return descriptorSetBase != -1 ? descriptorSetBase : base;
|
||||
}
|
||||
|
||||
static int getLayoutSet(const glslang::TType& type) {
|
||||
if (type.getQualifier().hasSet())
|
||||
return type.getQualifier().layoutSet;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool isSamplerType(const glslang::TType& type) {
|
||||
return type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler();
|
||||
}
|
||||
|
||||
static bool isTextureType(const glslang::TType& type) {
|
||||
return (type.getBasicType() == glslang::EbtSampler &&
|
||||
(type.getSampler().isTexture() || type.getSampler().isSubpass()));
|
||||
}
|
||||
|
||||
static bool isUboType(const glslang::TType& type) {
|
||||
return type.getQualifier().storage == EvqUniform;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
@ -545,57 +558,63 @@ struct TDefaultIoResolver : public TDefaultIoResolverBase
|
||||
{
|
||||
TDefaultIoResolver(const TIntermediate &intermediate) : TDefaultIoResolverBase(intermediate) { }
|
||||
|
||||
bool validateBinding(EShLanguage stage, const char* name, const glslang::TType& type, bool is_live) override
|
||||
bool validateBinding(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& /*type*/, bool /*is_live*/) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int resolveBinding(EShLanguage stage, const char* name, const glslang::TType& type, bool is_live) override
|
||||
int resolveBinding(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool is_live) override
|
||||
{
|
||||
const int set = (type.getQualifier().hasSet()) ? type.getQualifier().layoutSet : 0;
|
||||
const int set = getLayoutSet(type);
|
||||
// On OpenGL arrays of opaque types take a seperate binding for each element
|
||||
int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
|
||||
|
||||
if (type.getQualifier().hasBinding())
|
||||
{
|
||||
if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage())
|
||||
if (type.getQualifier().hasBinding()) {
|
||||
if (isImageType(type))
|
||||
return reserveSlot(set, getBaseBinding(EResImage, set) + type.getQualifier().layoutBinding, numBindings);
|
||||
|
||||
if (isTextureType(type))
|
||||
return reserveSlot(set, getBaseBinding(EResTexture, set) + type.getQualifier().layoutBinding, numBindings);
|
||||
|
||||
if (type.getQualifier().storage == EvqBuffer)
|
||||
if (isSsboType(type))
|
||||
return reserveSlot(set, getBaseBinding(EResSsbo, set) + type.getQualifier().layoutBinding, numBindings);
|
||||
|
||||
if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler())
|
||||
if (isSamplerType(type))
|
||||
return reserveSlot(set, getBaseBinding(EResSampler, set) + type.getQualifier().layoutBinding, numBindings);
|
||||
|
||||
if (type.getQualifier().storage == EvqUniform)
|
||||
if (isUboType(type))
|
||||
return reserveSlot(set, getBaseBinding(EResUbo, set) + type.getQualifier().layoutBinding, numBindings);
|
||||
}
|
||||
else if (is_live && intermediate.getAutoMapBindings())
|
||||
{
|
||||
} else if (is_live && doAutoBindingMapping()) {
|
||||
// find free slot, the caller did make sure it passes all vars with binding
|
||||
// first and now all are passed that do not have a binding and needs one
|
||||
|
||||
if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage())
|
||||
if (isImageType(type))
|
||||
return getFreeSlot(set, getBaseBinding(EResImage, set), numBindings);
|
||||
|
||||
if (isTextureType(type))
|
||||
return getFreeSlot(set, getBaseBinding(EResTexture, set), numBindings);
|
||||
|
||||
if (type.getQualifier().storage == EvqBuffer)
|
||||
if (isSsboType(type))
|
||||
return getFreeSlot(set, getBaseBinding(EResSsbo, set), numBindings);
|
||||
|
||||
if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler())
|
||||
if (isSamplerType(type))
|
||||
return getFreeSlot(set, getBaseBinding(EResSampler, set), numBindings);
|
||||
|
||||
if (type.getQualifier().storage == EvqUniform)
|
||||
if (isUboType(type))
|
||||
return getFreeSlot(set, getBaseBinding(EResUbo, set), numBindings);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected:
|
||||
static bool isImageType(const glslang::TType& type) {
|
||||
return type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage();
|
||||
}
|
||||
|
||||
static bool isSsboType(const glslang::TType& type) {
|
||||
return type.getQualifier().storage == EvqBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
/********************************************************************************
|
||||
@ -652,37 +671,34 @@ struct TDefaultHlslIoResolver : public TDefaultIoResolverBase
|
||||
|
||||
int resolveBinding(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool is_live) override
|
||||
{
|
||||
const int set = (type.getQualifier().hasSet()) ? type.getQualifier().layoutSet : 0;
|
||||
const int set = getLayoutSet(type);
|
||||
|
||||
if (type.getQualifier().hasBinding())
|
||||
{
|
||||
if (type.getQualifier().hasBinding()) {
|
||||
if (isUavType(type))
|
||||
return reserveSlot(set, getBaseBinding(EResUav, set) + type.getQualifier().layoutBinding);
|
||||
|
||||
if (isTextureType(type) || type.getQualifier().storage == EvqBuffer)
|
||||
if (isSrvType(type))
|
||||
return reserveSlot(set, getBaseBinding(EResTexture, set) + type.getQualifier().layoutBinding);
|
||||
|
||||
if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler())
|
||||
if (isSamplerType(type))
|
||||
return reserveSlot(set, getBaseBinding(EResSampler, set) + type.getQualifier().layoutBinding);
|
||||
|
||||
if (type.getQualifier().storage == EvqUniform)
|
||||
if (isUboType(type))
|
||||
return reserveSlot(set, getBaseBinding(EResUbo, set) + type.getQualifier().layoutBinding);
|
||||
}
|
||||
else if (is_live && intermediate.getAutoMapBindings())
|
||||
{
|
||||
} else if (is_live && doAutoBindingMapping()) {
|
||||
// find free slot, the caller did make sure it passes all vars with binding
|
||||
// first and now all are passed that do not have a binding and needs one
|
||||
|
||||
if (isUavType(type))
|
||||
return getFreeSlot(set, getBaseBinding(EResUav, set));
|
||||
|
||||
if (isTextureType(type) || type.getQualifier().storage == EvqBuffer)
|
||||
if (isSrvType(type))
|
||||
return getFreeSlot(set, getBaseBinding(EResTexture, set));
|
||||
|
||||
if (type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler())
|
||||
if (isSamplerType(type))
|
||||
return getFreeSlot(set, getBaseBinding(EResSampler, set));
|
||||
|
||||
if (type.getQualifier().storage == EvqUniform)
|
||||
if (isUboType(type))
|
||||
return getFreeSlot(set, getBaseBinding(EResUbo, set));
|
||||
}
|
||||
|
||||
@ -690,13 +706,18 @@ struct TDefaultHlslIoResolver : public TDefaultIoResolverBase
|
||||
}
|
||||
|
||||
protected:
|
||||
// Return true if this is a SRV (shader resource view) type:
|
||||
static bool isSrvType(const glslang::TType& type) {
|
||||
return isTextureType(type) || type.getQualifier().storage == EvqBuffer;
|
||||
}
|
||||
|
||||
// Return true if this is a UAV (unordered access view) type:
|
||||
static bool isUavType(const glslang::TType& type) {
|
||||
if (type.getQualifier().readonly)
|
||||
return false;
|
||||
return ( type.getBasicType() == glslang::EbtSampler
|
||||
&& type.getSampler().isImage())
|
||||
|| (type.getQualifier().storage == EvqBuffer);
|
||||
|
||||
return (type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage()) ||
|
||||
(type.getQualifier().storage == EvqBuffer);
|
||||
}
|
||||
};
|
||||
|
||||
@ -707,16 +728,14 @@ protected:
|
||||
// Returns false if the input is too malformed to do this.
|
||||
bool TIoMapper::addStage(EShLanguage stage, TIntermediate &intermediate, TInfoSink &infoSink, TIoMapResolver *resolver)
|
||||
{
|
||||
bool somethingToDo =
|
||||
!intermediate.getResourceSetBinding().empty()
|
||||
|| intermediate.getAutoMapBindings()
|
||||
|| intermediate.getAutoMapLocations();
|
||||
bool somethingToDo = !intermediate.getResourceSetBinding().empty() ||
|
||||
intermediate.getAutoMapBindings() ||
|
||||
intermediate.getAutoMapLocations();
|
||||
|
||||
for (int res = 0; res < EResCount; ++res)
|
||||
{
|
||||
somethingToDo = somethingToDo
|
||||
|| (intermediate.getShiftBinding(TResourceType(res)) != 0)
|
||||
|| intermediate.hasShiftBindingForSet(TResourceType(res));
|
||||
for (int res = 0; res < EResCount; ++res) {
|
||||
somethingToDo = somethingToDo ||
|
||||
(intermediate.getShiftBinding(TResourceType(res)) != 0) ||
|
||||
intermediate.hasShiftBindingForSet(TResourceType(res));
|
||||
}
|
||||
|
||||
if (!somethingToDo && resolver == NULL)
|
||||
|
@ -267,7 +267,7 @@ public:
|
||||
shiftBinding[res] = shift;
|
||||
|
||||
const char* name = getResourceName(res);
|
||||
if (name)
|
||||
if (name != NULL)
|
||||
processes.addIfNonZero(name, shift);
|
||||
}
|
||||
|
||||
|
@ -104,9 +104,10 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
|
||||
_parseContext.ppError(ppToken->loc, "must be followed by macro name", "#define", "");
|
||||
return token;
|
||||
}
|
||||
// We are in user code; check for reserved name use:
|
||||
if (ppToken->loc.string >= 0)
|
||||
if (ppToken->loc.string >= 0) {
|
||||
// We are in user code; check for reserved name use:
|
||||
_parseContext.reservedPpErrorCheck(ppToken->loc, ppToken->name, "#define");
|
||||
}
|
||||
|
||||
// save the macro name
|
||||
const int defAtom = atomStrings.getAddAtom(ppToken->name);
|
||||
@ -119,22 +120,18 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
|
||||
token = scanToken(ppToken);
|
||||
if (mac.args.size() == 0 && token == ')')
|
||||
break;
|
||||
if (token != PpAtomIdentifier)
|
||||
{
|
||||
if (token != PpAtomIdentifier) {
|
||||
_parseContext.ppError(ppToken->loc, "bad argument", "#define", "");
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
mac.emptyArgs = 0;
|
||||
const int argAtom = atomStrings.getAddAtom(ppToken->name);
|
||||
|
||||
// check for duplication of parameter name
|
||||
bool duplicate = false;
|
||||
for (size_t a = 0; a < mac.args.size(); ++a)
|
||||
{
|
||||
if (mac.args[a] == argAtom)
|
||||
{
|
||||
for (size_t a = 0; a < mac.args.size(); ++a) {
|
||||
if (mac.args[a] == argAtom) {
|
||||
_parseContext.ppError(ppToken->loc, "duplicate macro parameter", "#define", "");
|
||||
duplicate = true;
|
||||
break;
|
||||
@ -144,9 +141,7 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
|
||||
mac.args.push_back(argAtom);
|
||||
token = scanToken(ppToken);
|
||||
} while (token == ',');
|
||||
|
||||
if (token != ')')
|
||||
{
|
||||
if (token != ')') {
|
||||
_parseContext.ppError(ppToken->loc, "missing parenthesis", "#define", "");
|
||||
|
||||
return token;
|
||||
@ -157,8 +152,7 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
|
||||
|
||||
// record the definition of the macro
|
||||
TSourceLoc defineLoc = ppToken->loc; // because ppToken is going to go to the next line before we report errors
|
||||
while (token != '\n' && token != EndOfInput)
|
||||
{
|
||||
while (token != '\n' && token != EndOfInput) {
|
||||
mac.body.putToken(token, ppToken);
|
||||
token = scanToken(ppToken);
|
||||
if (token != '\n' && ppToken->space)
|
||||
@ -167,17 +161,14 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
|
||||
|
||||
// check for duplicate definition
|
||||
MacroSymbol* existing = lookupMacroDef(defAtom);
|
||||
if (existing != NULL)
|
||||
{
|
||||
if (! existing->undef)
|
||||
{
|
||||
if (existing != NULL) {
|
||||
if (! existing->undef) {
|
||||
// Already defined -- need to make sure they are identical:
|
||||
// "Two replacement lists are identical if and only if the preprocessing tokens in both have the same number,
|
||||
// ordering, spelling, and white-space separation, where all white-space separations are considered identical."
|
||||
if (existing->args.size() != mac.args.size() || existing->emptyArgs != mac.emptyArgs)
|
||||
_parseContext.ppError(defineLoc, "Macro redefined; different number of arguments:", "#define", atomStrings.getString(defAtom));
|
||||
else
|
||||
{
|
||||
else {
|
||||
if (existing->args != mac.args)
|
||||
_parseContext.ppError(defineLoc, "Macro redefined; different argument names:", "#define", atomStrings.getString(defAtom));
|
||||
existing->body.reset();
|
||||
@ -189,8 +180,7 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
|
||||
TPpToken newPpToken;
|
||||
oldToken = existing->body.getToken(_parseContext, &oldPpToken);
|
||||
newToken = mac.body.getToken(_parseContext, &newPpToken);
|
||||
if (oldToken != newToken || oldPpToken != newPpToken)
|
||||
{
|
||||
if (oldToken != newToken || oldPpToken != newPpToken) {
|
||||
_parseContext.ppError(defineLoc, "Macro redefined; different substitutions:", "#define", atomStrings.getString(defAtom));
|
||||
break;
|
||||
}
|
||||
@ -208,8 +198,7 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
|
||||
int TPpContext::CPPundef(TPpToken* ppToken)
|
||||
{
|
||||
int token = scanToken(ppToken);
|
||||
if (token != PpAtomIdentifier)
|
||||
{
|
||||
if (token != PpAtomIdentifier) {
|
||||
_parseContext.ppError(ppToken->loc, "must be followed by macro name", "#undef", "");
|
||||
|
||||
return token;
|
||||
@ -218,7 +207,7 @@ int TPpContext::CPPundef(TPpToken* ppToken)
|
||||
_parseContext.reservedPpErrorCheck(ppToken->loc, ppToken->name, "#undef");
|
||||
|
||||
MacroSymbol* macro = lookupMacroDef(atomStrings.getAtom(ppToken->name));
|
||||
if (macro)
|
||||
if (macro != NULL)
|
||||
macro->undef = 1;
|
||||
token = scanToken(ppToken);
|
||||
if (token != '\n')
|
||||
@ -237,10 +226,8 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
|
||||
int depth = 0;
|
||||
int token = scanToken(ppToken);
|
||||
|
||||
while (token != EndOfInput)
|
||||
{
|
||||
if (token != '#')
|
||||
{
|
||||
while (token != EndOfInput) {
|
||||
if (token != '#') {
|
||||
while (token != '\n' && token != EndOfInput)
|
||||
token = scanToken(ppToken);
|
||||
|
||||
@ -255,25 +242,20 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
|
||||
continue;
|
||||
|
||||
int nextAtom = atomStrings.getAtom(ppToken->name);
|
||||
if (nextAtom == PpAtomIf || nextAtom == PpAtomIfdef || nextAtom == PpAtomIfndef)
|
||||
{
|
||||
if (nextAtom == PpAtomIf || nextAtom == PpAtomIfdef || nextAtom == PpAtomIfndef) {
|
||||
depth++;
|
||||
if (ifdepth >= maxIfNesting || elsetracker >= maxIfNesting)
|
||||
{
|
||||
if (ifdepth >= maxIfNesting || elsetracker >= maxIfNesting) {
|
||||
_parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#if/#ifdef/#ifndef", "");
|
||||
return EndOfInput;
|
||||
} else {
|
||||
ifdepth++;
|
||||
elsetracker++;
|
||||
}
|
||||
|
||||
ifdepth++;
|
||||
elsetracker++;
|
||||
}
|
||||
else if (nextAtom == PpAtomEndif)
|
||||
{
|
||||
} else if (nextAtom == PpAtomEndif) {
|
||||
token = extraTokenCheck(nextAtom, ppToken, scanToken(ppToken));
|
||||
elseSeen[elsetracker] = false;
|
||||
--elsetracker;
|
||||
if (depth == 0)
|
||||
{
|
||||
if (depth == 0) {
|
||||
// found the #endif we are looking for
|
||||
if (ifdepth > 0)
|
||||
--ifdepth;
|
||||
@ -281,24 +263,18 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
|
||||
}
|
||||
--depth;
|
||||
--ifdepth;
|
||||
}
|
||||
else if (matchelse && depth == 0)
|
||||
{
|
||||
if (nextAtom == PpAtomElse)
|
||||
{
|
||||
} else if (matchelse && depth == 0) {
|
||||
if (nextAtom == PpAtomElse) {
|
||||
elseSeen[elsetracker] = true;
|
||||
token = extraTokenCheck(nextAtom, ppToken, scanToken(ppToken));
|
||||
// found the #else we are looking for
|
||||
break;
|
||||
}
|
||||
else if (nextAtom == PpAtomElif)
|
||||
{
|
||||
} else if (nextAtom == PpAtomElif) {
|
||||
if (elseSeen[elsetracker])
|
||||
_parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", "");
|
||||
/* we decrement ifdepth here, because CPPif will increment
|
||||
* it and we really want to leave it alone */
|
||||
if (ifdepth > 0)
|
||||
{
|
||||
if (ifdepth > 0) {
|
||||
--ifdepth;
|
||||
elseSeen[elsetracker] = false;
|
||||
--elsetracker;
|
||||
@ -306,17 +282,13 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
|
||||
|
||||
return CPPif(ppToken);
|
||||
}
|
||||
}
|
||||
else if (nextAtom == PpAtomElse)
|
||||
{
|
||||
} else if (nextAtom == PpAtomElse) {
|
||||
if (elseSeen[elsetracker])
|
||||
_parseContext.ppError(ppToken->loc, "#else after #else", "#else", "");
|
||||
else
|
||||
elseSeen[elsetracker] = true;
|
||||
token = extraTokenCheck(nextAtom, ppToken, scanToken(ppToken));
|
||||
}
|
||||
else if (nextAtom == PpAtomElif)
|
||||
{
|
||||
} else if (nextAtom == PpAtomElif) {
|
||||
if (elseSeen[elsetracker])
|
||||
_parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", "");
|
||||
}
|
||||
@ -328,30 +300,30 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
|
||||
// Call when there should be no more tokens left on a line.
|
||||
int TPpContext::extraTokenCheck(int contextAtom, TPpToken* ppToken, int token)
|
||||
{
|
||||
if (token != '\n' && token != EndOfInput)
|
||||
{
|
||||
static const char* message = "unexpected tokens following directive";
|
||||
const char* label;
|
||||
if (contextAtom == PpAtomElse)
|
||||
label = "#else";
|
||||
else if (contextAtom == PpAtomElif)
|
||||
label = "#elif";
|
||||
else if (contextAtom == PpAtomEndif)
|
||||
label = "#endif";
|
||||
else if (contextAtom == PpAtomIf)
|
||||
label = "#if";
|
||||
else if (contextAtom == PpAtomLine)
|
||||
label = "#line";
|
||||
else
|
||||
label = "";
|
||||
if (token != '\n' && token != EndOfInput) {
|
||||
static const char* message = "unexpected tokens following directive";
|
||||
|
||||
if (_parseContext.relaxedErrors())
|
||||
_parseContext.ppWarn(ppToken->loc, message, label, "");
|
||||
else
|
||||
_parseContext.ppError(ppToken->loc, message, label, "");
|
||||
const char* label;
|
||||
if (contextAtom == PpAtomElse)
|
||||
label = "#else";
|
||||
else if (contextAtom == PpAtomElif)
|
||||
label = "#elif";
|
||||
else if (contextAtom == PpAtomEndif)
|
||||
label = "#endif";
|
||||
else if (contextAtom == PpAtomIf)
|
||||
label = "#if";
|
||||
else if (contextAtom == PpAtomLine)
|
||||
label = "#line";
|
||||
else
|
||||
label = "";
|
||||
|
||||
while (token != '\n' && token != EndOfInput)
|
||||
token = scanToken(ppToken);
|
||||
if (_parseContext.relaxedErrors())
|
||||
_parseContext.ppWarn(ppToken->loc, message, label, "");
|
||||
else
|
||||
_parseContext.ppError(ppToken->loc, message, label, "");
|
||||
|
||||
while (token != '\n' && token != EndOfInput)
|
||||
token = scanToken(ppToken);
|
||||
}
|
||||
|
||||
return token;
|
||||
@ -593,24 +565,20 @@ int TPpContext::CPPif(TPpToken* ppToken)
|
||||
int TPpContext::CPPifdef(int defined, TPpToken* ppToken)
|
||||
{
|
||||
int token = scanToken(ppToken);
|
||||
if (ifdepth > maxIfNesting || elsetracker > maxIfNesting)
|
||||
{
|
||||
if (ifdepth > maxIfNesting || elsetracker > maxIfNesting) {
|
||||
_parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#ifdef", "");
|
||||
return EndOfInput;
|
||||
} else {
|
||||
elsetracker++;
|
||||
ifdepth++;
|
||||
}
|
||||
|
||||
elsetracker++;
|
||||
ifdepth++;
|
||||
|
||||
if (token != PpAtomIdentifier)
|
||||
{
|
||||
if (token != PpAtomIdentifier) {
|
||||
if (defined)
|
||||
_parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifdef", "");
|
||||
else
|
||||
_parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifndef", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
MacroSymbol* macro = lookupMacroDef(atomStrings.getAtom(ppToken->name));
|
||||
token = scanToken(ppToken);
|
||||
if (token != '\n') {
|
||||
@ -764,18 +732,18 @@ int TPpContext::CPPerror(TPpToken* ppToken)
|
||||
std::string message;
|
||||
TSourceLoc loc = ppToken->loc;
|
||||
|
||||
while (token != '\n' && token != EndOfInput)
|
||||
{
|
||||
while (token != '\n' && token != EndOfInput) {
|
||||
if (token == PpAtomConstInt16 || token == PpAtomConstUint16 ||
|
||||
token == PpAtomConstInt || token == PpAtomConstUint ||
|
||||
token == PpAtomConstInt64 || token == PpAtomConstUint64 ||
|
||||
token == PpAtomConstFloat16 ||
|
||||
token == PpAtomConstFloat || token == PpAtomConstDouble)
|
||||
token == PpAtomConstFloat || token == PpAtomConstDouble) {
|
||||
message.append(ppToken->name);
|
||||
else if (token == PpAtomIdentifier || token == PpAtomConstString)
|
||||
} else if (token == PpAtomIdentifier || token == PpAtomConstString) {
|
||||
message.append(ppToken->name);
|
||||
else
|
||||
} else {
|
||||
message.append(atomStrings.getString(token));
|
||||
}
|
||||
message.append(" ");
|
||||
token = scanToken(ppToken);
|
||||
}
|
||||
@ -839,8 +807,7 @@ int TPpContext::CPPversion(TPpToken* ppToken)
|
||||
}
|
||||
versionSeen = true;
|
||||
|
||||
if (token == '\n')
|
||||
{
|
||||
if (token == '\n') {
|
||||
_parseContext.ppError(ppToken->loc, "must be followed by version number", "#version", "");
|
||||
|
||||
return token;
|
||||
@ -854,13 +821,10 @@ int TPpContext::CPPversion(TPpToken* ppToken)
|
||||
int line = ppToken->loc.line;
|
||||
token = scanToken(ppToken);
|
||||
|
||||
if (token == '\n')
|
||||
{
|
||||
if (token == '\n') {
|
||||
_parseContext.notifyVersion(line, versionNumber, NULL);
|
||||
return token;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int profileAtom = atomStrings.getAtom(ppToken->name);
|
||||
if (profileAtom != PpAtomCore &&
|
||||
profileAtom != PpAtomCompatibility &&
|
||||
@ -871,7 +835,8 @@ int TPpContext::CPPversion(TPpToken* ppToken)
|
||||
|
||||
if (token == '\n')
|
||||
return token;
|
||||
_parseContext.ppError(ppToken->loc, "bad tokens following profile -- expected newline", "#version", "");
|
||||
else
|
||||
_parseContext.ppError(ppToken->loc, "bad tokens following profile -- expected newline", "#version", "");
|
||||
}
|
||||
|
||||
return token;
|
||||
@ -895,15 +860,13 @@ int TPpContext::CPPextension(TPpToken* ppToken)
|
||||
strcpy(extensionName, ppToken->name);
|
||||
|
||||
token = scanToken(ppToken);
|
||||
if (token != ':')
|
||||
{
|
||||
if (token != ':') {
|
||||
_parseContext.ppError(ppToken->loc, "':' missing after extension name", "#extension", "");
|
||||
return token;
|
||||
}
|
||||
|
||||
token = scanToken(ppToken);
|
||||
if (token != PpAtomIdentifier)
|
||||
{
|
||||
if (token != PpAtomIdentifier) {
|
||||
_parseContext.ppError(ppToken->loc, "behavior for extension not specified", "#extension", "");
|
||||
return token;
|
||||
}
|
||||
@ -914,8 +877,8 @@ int TPpContext::CPPextension(TPpToken* ppToken)
|
||||
token = scanToken(ppToken);
|
||||
if (token == '\n')
|
||||
return token;
|
||||
|
||||
_parseContext.ppError(ppToken->loc, "extra tokens -- expected newline", "#extension","");
|
||||
else
|
||||
_parseContext.ppError(ppToken->loc, "extra tokens -- expected newline", "#extension","");
|
||||
|
||||
return token;
|
||||
}
|
||||
@ -1017,19 +980,16 @@ int TPpContext::scanHeaderName(TPpToken* ppToken, char delimit)
|
||||
|
||||
int len = 0;
|
||||
ppToken->name[0] = '\0';
|
||||
for (;;)
|
||||
{
|
||||
do {
|
||||
int ch = inputStack.back()->getch();
|
||||
|
||||
// done yet?
|
||||
if (ch == delimit)
|
||||
{
|
||||
if (ch == delimit) {
|
||||
ppToken->name[len] = '\0';
|
||||
if (tooLong)
|
||||
_parseContext.ppError(ppToken->loc, "header name too long", "", "");
|
||||
return PpAtomConstString;
|
||||
}
|
||||
else if (ch == EndOfInput)
|
||||
} else if (ch == EndOfInput)
|
||||
return EndOfInput;
|
||||
|
||||
// found a character to expand the name with
|
||||
@ -1037,7 +997,7 @@ int TPpContext::scanHeaderName(TPpToken* ppToken, char delimit)
|
||||
ppToken->name[len++] = (char)ch;
|
||||
else
|
||||
tooLong = true;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
// Macro-expand a macro argument 'arg' to create 'expandedArg'.
|
||||
@ -1050,8 +1010,7 @@ TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream& arg, TPpToken*
|
||||
pushInput(new tMarkerInput(this));
|
||||
pushTokenStreamInput(arg);
|
||||
int token;
|
||||
while ((token = scanToken(ppToken)) != tMarkerInput::marker && token != EndOfInput)
|
||||
{
|
||||
while ((token = scanToken(ppToken)) != tMarkerInput::marker && token != EndOfInput) {
|
||||
token = tokenPaste(token, *ppToken);
|
||||
if (token == tMarkerInput::marker || token == EndOfInput)
|
||||
break;
|
||||
@ -1060,14 +1019,14 @@ TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream& arg, TPpToken*
|
||||
expandedArg->putToken(token, ppToken);
|
||||
}
|
||||
|
||||
if (token == EndOfInput)
|
||||
{
|
||||
if (token == EndOfInput) {
|
||||
// MacroExpand ate the marker, so had bad input, recover
|
||||
delete expandedArg;
|
||||
expandedArg = NULL;
|
||||
}
|
||||
else // remove the marker
|
||||
} else {
|
||||
// remove the marker
|
||||
popInput();
|
||||
}
|
||||
|
||||
return expandedArg;
|
||||
}
|
||||
@ -1097,15 +1056,13 @@ int TPpContext::tMacroInput::scan(TPpToken* ppToken)
|
||||
// corresponding argument's preprocessing token sequence."
|
||||
|
||||
bool pasting = false;
|
||||
if (postpaste)
|
||||
{
|
||||
if (postpaste) {
|
||||
// don't expand next token
|
||||
pasting = true;
|
||||
postpaste = false;
|
||||
}
|
||||
|
||||
if (prepaste)
|
||||
{
|
||||
if (prepaste) {
|
||||
// already know we should be on a ##, verify
|
||||
prepaste = false;
|
||||
postpaste = true;
|
||||
|
@ -164,8 +164,7 @@ TStringAtomMap::TStringAtomMap()
|
||||
char t[2];
|
||||
|
||||
t[1] = '\0';
|
||||
while (*s)
|
||||
{
|
||||
while (*s) {
|
||||
t[0] = *s;
|
||||
addAtomFixed(t, s[0]);
|
||||
s++;
|
||||
|
@ -334,7 +334,8 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
|
||||
return PpAtomConstDouble;
|
||||
else if (isFloat16)
|
||||
return PpAtomConstFloat16;
|
||||
return PpAtomConstFloat;
|
||||
else
|
||||
return PpAtomConstFloat;
|
||||
}
|
||||
|
||||
// Recognize a character literal.
|
||||
@ -348,9 +349,10 @@ int TPpContext::characterLiteral(TPpToken* ppToken)
|
||||
ppToken->name[0] = 0;
|
||||
ppToken->ival = 0;
|
||||
|
||||
// illegal, except in macro definition, for which case we report the character
|
||||
if (_parseContext.intermediate.getSource() != EShSourceHlsl)
|
||||
if (_parseContext.intermediate.getSource() != EShSourceHlsl) {
|
||||
// illegal, except in macro definition, for which case we report the character
|
||||
return '\'';
|
||||
}
|
||||
|
||||
int ch = getChar();
|
||||
switch (ch) {
|
||||
@ -444,8 +446,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
||||
ppToken->i64val = 0;
|
||||
ppToken->space = false;
|
||||
ch = getch();
|
||||
for (;;)
|
||||
{
|
||||
for (;;) {
|
||||
while (ch == ' ' || ch == '\t') {
|
||||
ppToken->space = true;
|
||||
ch = getch();
|
||||
@ -849,37 +850,49 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
||||
}
|
||||
case '*':
|
||||
ch = getch();
|
||||
if (ch == '=')
|
||||
if (ch == '=') {
|
||||
return PPAtomMulAssign;
|
||||
ungetch();
|
||||
return '*';
|
||||
} else {
|
||||
ungetch();
|
||||
return '*';
|
||||
}
|
||||
case '%':
|
||||
ch = getch();
|
||||
if (ch == '=')
|
||||
if (ch == '=') {
|
||||
return PPAtomModAssign;
|
||||
ungetch();
|
||||
return '%';
|
||||
} else {
|
||||
ungetch();
|
||||
return '%';
|
||||
}
|
||||
case '^':
|
||||
ch = getch();
|
||||
if (ch == '^')
|
||||
if (ch == '^') {
|
||||
return PpAtomXor;
|
||||
if (ch == '=')
|
||||
return PpAtomXorAssign;
|
||||
ungetch();
|
||||
return '^';
|
||||
} else {
|
||||
if (ch == '=')
|
||||
return PpAtomXorAssign;
|
||||
else{
|
||||
ungetch();
|
||||
return '^';
|
||||
}
|
||||
}
|
||||
|
||||
case '=':
|
||||
ch = getch();
|
||||
if (ch == '=')
|
||||
if (ch == '=') {
|
||||
return PpAtomEQ;
|
||||
ungetch();
|
||||
return '=';
|
||||
} else {
|
||||
ungetch();
|
||||
return '=';
|
||||
}
|
||||
case '!':
|
||||
ch = getch();
|
||||
if (ch == '=')
|
||||
if (ch == '=') {
|
||||
return PpAtomNE;
|
||||
ungetch();
|
||||
return '!';
|
||||
} else {
|
||||
ungetch();
|
||||
return '!';
|
||||
}
|
||||
case '|':
|
||||
ch = getch();
|
||||
if (ch == '|') {
|
||||
@ -1030,18 +1043,14 @@ int TPpContext::tokenize(TPpToken& ppToken)
|
||||
return EndOfInput;
|
||||
}
|
||||
if (token == '#') {
|
||||
if (previous_token == '\n')
|
||||
{
|
||||
if (previous_token == '\n') {
|
||||
token = readCPPline(&ppToken);
|
||||
if (token == EndOfInput)
|
||||
{
|
||||
if (token == EndOfInput) {
|
||||
missingEndifCheck();
|
||||
return EndOfInput;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
_parseContext.ppError(ppToken.loc, "preprocessor directive cannot be preceded by another token", "#", "");
|
||||
return EndOfInput;
|
||||
}
|
||||
@ -1096,8 +1105,7 @@ int TPpContext::tokenize(TPpToken& ppToken)
|
||||
int TPpContext::tokenPaste(int token, TPpToken& ppToken)
|
||||
{
|
||||
// starting with ## is illegal, skip to next token
|
||||
if (token == PpAtomPaste)
|
||||
{
|
||||
if (token == PpAtomPaste) {
|
||||
_parseContext.ppError(ppToken.loc, "unexpected location", "##", "");
|
||||
return scanToken(&ppToken);
|
||||
}
|
||||
@ -1105,16 +1113,14 @@ int TPpContext::tokenPaste(int token, TPpToken& ppToken)
|
||||
int resultToken = token; // "foo" pasted with "35" is an identifier, not a number
|
||||
|
||||
// ## can be chained, process all in the chain at once
|
||||
while (peekPasting())
|
||||
{
|
||||
while (peekPasting()) {
|
||||
TPpToken pastedPpToken;
|
||||
|
||||
// next token has to be ##
|
||||
token = scanToken(&pastedPpToken);
|
||||
|
||||
// This covers end of macro expansion
|
||||
if (endOfReplacementList())
|
||||
{
|
||||
if (endOfReplacementList()) {
|
||||
_parseContext.ppError(ppToken.loc, "unexpected location; end of replacement list", "##", "");
|
||||
break;
|
||||
}
|
||||
@ -1129,36 +1135,35 @@ int TPpContext::tokenPaste(int token, TPpToken& ppToken)
|
||||
}
|
||||
|
||||
// get the token text
|
||||
switch (resultToken)
|
||||
{
|
||||
case PpAtomIdentifier:
|
||||
// already have the correct text in token.names
|
||||
break;
|
||||
case '=':
|
||||
case '!':
|
||||
case '-':
|
||||
case '~':
|
||||
case '+':
|
||||
case '*':
|
||||
case '/':
|
||||
case '%':
|
||||
case '<':
|
||||
case '>':
|
||||
case '|':
|
||||
case '^':
|
||||
case '&':
|
||||
case PpAtomRight:
|
||||
case PpAtomLeft:
|
||||
case PpAtomAnd:
|
||||
case PpAtomOr:
|
||||
case PpAtomXor:
|
||||
strcpy(ppToken.name, atomStrings.getString(resultToken));
|
||||
strcpy(pastedPpToken.name, atomStrings.getString(token));
|
||||
break;
|
||||
default:
|
||||
_parseContext.ppError(ppToken.loc, "not supported for these tokens", "##", "");
|
||||
return resultToken;
|
||||
}
|
||||
switch (resultToken) {
|
||||
case PpAtomIdentifier:
|
||||
// already have the correct text in token.names
|
||||
break;
|
||||
case '=':
|
||||
case '!':
|
||||
case '-':
|
||||
case '~':
|
||||
case '+':
|
||||
case '*':
|
||||
case '/':
|
||||
case '%':
|
||||
case '<':
|
||||
case '>':
|
||||
case '|':
|
||||
case '^':
|
||||
case '&':
|
||||
case PpAtomRight:
|
||||
case PpAtomLeft:
|
||||
case PpAtomAnd:
|
||||
case PpAtomOr:
|
||||
case PpAtomXor:
|
||||
strcpy(ppToken.name, atomStrings.getString(resultToken));
|
||||
strcpy(pastedPpToken.name, atomStrings.getString(token));
|
||||
break;
|
||||
default:
|
||||
_parseContext.ppError(ppToken.loc, "not supported for these tokens", "##", "");
|
||||
return resultToken;
|
||||
}
|
||||
|
||||
// combine the tokens
|
||||
if (strlen(ppToken.name) + strlen(pastedPpToken.name) > MaxTokenLength) {
|
||||
@ -1168,8 +1173,7 @@ int TPpContext::tokenPaste(int token, TPpToken& ppToken)
|
||||
strncat(ppToken.name, pastedPpToken.name, MaxTokenLength - strlen(ppToken.name));
|
||||
|
||||
// correct the kind of token we are making, if needed (identifiers stay identifiers)
|
||||
if (resultToken != PpAtomIdentifier)
|
||||
{
|
||||
if (resultToken != PpAtomIdentifier) {
|
||||
int newToken = atomStrings.getAtom(ppToken.name);
|
||||
if (newToken > 0)
|
||||
resultToken = newToken;
|
||||
|
@ -105,50 +105,46 @@ namespace {
|
||||
// be saved (restored)?
|
||||
bool SaveName(int atom)
|
||||
{
|
||||
switch (atom)
|
||||
{
|
||||
case PpAtomIdentifier:
|
||||
case PpAtomConstString:
|
||||
case PpAtomConstInt:
|
||||
case PpAtomConstUint:
|
||||
case PpAtomConstInt64:
|
||||
case PpAtomConstUint64:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case PpAtomConstInt16:
|
||||
case PpAtomConstUint16:
|
||||
#endif
|
||||
case PpAtomConstFloat:
|
||||
case PpAtomConstDouble:
|
||||
case PpAtomConstFloat16:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
switch (atom) {
|
||||
case PpAtomIdentifier:
|
||||
case PpAtomConstString:
|
||||
case PpAtomConstInt:
|
||||
case PpAtomConstUint:
|
||||
case PpAtomConstInt64:
|
||||
case PpAtomConstUint64:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case PpAtomConstInt16:
|
||||
case PpAtomConstUint16:
|
||||
#endif
|
||||
case PpAtomConstFloat:
|
||||
case PpAtomConstDouble:
|
||||
case PpAtomConstFloat16:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// When recording (and playing back) should the numeric value
|
||||
// be saved (restored)?
|
||||
bool SaveValue(int atom)
|
||||
{
|
||||
switch (atom)
|
||||
{
|
||||
case PpAtomConstInt:
|
||||
case PpAtomConstUint:
|
||||
case PpAtomConstInt64:
|
||||
case PpAtomConstUint64:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case PpAtomConstInt16:
|
||||
case PpAtomConstUint16:
|
||||
#endif
|
||||
case PpAtomConstFloat:
|
||||
case PpAtomConstDouble:
|
||||
case PpAtomConstFloat16:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
switch (atom) {
|
||||
case PpAtomConstInt:
|
||||
case PpAtomConstUint:
|
||||
case PpAtomConstInt64:
|
||||
case PpAtomConstUint64:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case PpAtomConstInt16:
|
||||
case PpAtomConstUint16:
|
||||
#endif
|
||||
case PpAtomConstFloat:
|
||||
case PpAtomConstDouble:
|
||||
case PpAtomConstFloat16:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,8 +178,7 @@ void TPpContext::TokenStream::putToken(int atom, TPpToken* ppToken)
|
||||
putSubtoken(static_cast<char>(atom));
|
||||
|
||||
// save the backing name string
|
||||
if (SaveName(atom))
|
||||
{
|
||||
if (SaveName(atom)) {
|
||||
const char* s = ppToken->name;
|
||||
while (*s)
|
||||
putSubtoken(*s++);
|
||||
@ -191,8 +186,7 @@ void TPpContext::TokenStream::putToken(int atom, TPpToken* ppToken)
|
||||
}
|
||||
|
||||
// save the numeric value
|
||||
if (SaveValue(atom))
|
||||
{
|
||||
if (SaveValue(atom)) {
|
||||
const char* n = reinterpret_cast<const char*>(&ppToken->i64val);
|
||||
for (size_t i = 0; i < sizeof(ppToken->i64val); ++i)
|
||||
putSubtoken(*n++);
|
||||
@ -213,20 +207,15 @@ int TPpContext::TokenStream::getToken(TParseContextBase& _parseContext, TPpToken
|
||||
ppToken->loc = _parseContext.getCurrentLoc();
|
||||
|
||||
// get the backing name string
|
||||
if (SaveName(atom))
|
||||
{
|
||||
if (SaveName(atom)) {
|
||||
int ch = getSubtoken();
|
||||
int len = 0;
|
||||
while (ch != 0 && ch != EndOfInput)
|
||||
{
|
||||
if (len < MaxTokenLength)
|
||||
{
|
||||
while (ch != 0 && ch != EndOfInput) {
|
||||
if (len < MaxTokenLength) {
|
||||
ppToken->name[len] = (char)ch;
|
||||
len++;
|
||||
ch = getSubtoken();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
_parseContext.error(ppToken->loc, "token too long", "", "");
|
||||
break;
|
||||
}
|
||||
@ -235,17 +224,13 @@ int TPpContext::TokenStream::getToken(TParseContextBase& _parseContext, TPpToken
|
||||
}
|
||||
|
||||
// Check for ##, unless the current # is the last character
|
||||
if (atom == '#')
|
||||
{
|
||||
if (current < data.size())
|
||||
{
|
||||
if (getSubtoken() == '#')
|
||||
{
|
||||
if (atom == '#') {
|
||||
if (current < data.size()) {
|
||||
if (getSubtoken() == '#') {
|
||||
_parseContext.requireProfile(ppToken->loc, ~EEsProfile, "token pasting (##)");
|
||||
_parseContext.profileRequires(ppToken->loc, ~EEsProfile, 130, 0, "token pasting (##)");
|
||||
atom = PpAtomPaste;
|
||||
}
|
||||
else
|
||||
} else
|
||||
ungetSubtoken();
|
||||
}
|
||||
}
|
||||
@ -288,17 +273,15 @@ bool TPpContext::TokenStream::peekTokenizedPasting(bool lastTokenPastes)
|
||||
// Are we at the last non-whitespace token?
|
||||
savePos = current;
|
||||
bool moreTokens = false;
|
||||
for (;;)
|
||||
{
|
||||
do {
|
||||
subtoken = getSubtoken();
|
||||
if (subtoken == EndOfInput)
|
||||
break;
|
||||
if (subtoken != ' ')
|
||||
{
|
||||
if (subtoken != ' ') {
|
||||
moreTokens = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (true);
|
||||
current = savePos;
|
||||
|
||||
return !moreTokens;
|
||||
@ -340,9 +323,9 @@ int TPpContext::tUngotTokenInput::scan(TPpToken* ppToken)
|
||||
if (done)
|
||||
return EndOfInput;
|
||||
|
||||
int ret = token;
|
||||
int ret = token;
|
||||
*ppToken = lval;
|
||||
done = true;
|
||||
done = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -93,9 +93,8 @@ bool isDereferenceOperation(glslang::TOperator op)
|
||||
case glslang::EOpMatrixSwizzle:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns true if the opcode leads to an assignment operation.
|
||||
@ -124,9 +123,8 @@ bool isAssignOperation(glslang::TOperator op)
|
||||
case glslang::EOpPreDecrement:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// A helper function to get the unsigned int from a given constant union node.
|
||||
@ -182,9 +180,8 @@ bool isArithmeticOperation(glslang::TOperator op)
|
||||
case glslang::EOpPreDecrement:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// A helper class to help manage the populating_initial_no_contraction_ flag.
|
||||
@ -235,11 +232,10 @@ ObjectAccessChain getSubAccessChainAfterPrefix(const ObjectAccessChain& chain,
|
||||
//
|
||||
class TSymbolDefinitionCollectingTraverser : public glslang::TIntermTraverser {
|
||||
public:
|
||||
TSymbolDefinitionCollectingTraverser(
|
||||
NodeMapping* symbol_definition_mapping,
|
||||
AccessChainMapping* accesschain_mapping,
|
||||
ObjectAccesschainSet* precise_objects,
|
||||
ReturnBranchNodeSet* precise_return_nodes);
|
||||
TSymbolDefinitionCollectingTraverser(NodeMapping* symbol_definition_mapping,
|
||||
AccessChainMapping* accesschain_mapping,
|
||||
ObjectAccesschainSet* precise_objects,
|
||||
ReturnBranchNodeSet* precise_return_nodes);
|
||||
|
||||
bool visitUnary(glslang::TVisit, glslang::TIntermUnary*) override;
|
||||
bool visitBinary(glslang::TVisit, glslang::TIntermBinary*) override;
|
||||
@ -292,7 +288,7 @@ void TSymbolDefinitionCollectingTraverser::visitSymbol(glslang::TIntermSymbol* n
|
||||
|
||||
// Visits an aggregate node, traverses all of its children.
|
||||
bool TSymbolDefinitionCollectingTraverser::visitAggregate(glslang::TVisit,
|
||||
glslang::TIntermAggregate* node)
|
||||
glslang::TIntermAggregate* node)
|
||||
{
|
||||
// This aggregate node might be a function definition node, in which case we need to
|
||||
// cache this node, so we can get the preciseness information of the return value
|
||||
@ -314,13 +310,11 @@ bool TSymbolDefinitionCollectingTraverser::visitAggregate(glslang::TVisit,
|
||||
}
|
||||
|
||||
bool TSymbolDefinitionCollectingTraverser::visitBranch(glslang::TVisit,
|
||||
glslang::TIntermBranch* node)
|
||||
glslang::TIntermBranch* node)
|
||||
{
|
||||
if ( node->getFlowOp() == glslang::EOpReturn
|
||||
&& node->getExpression()
|
||||
&& current_function_definition_node_
|
||||
&& current_function_definition_node_->getType().getQualifier().noContraction)
|
||||
{
|
||||
if (node->getFlowOp() == glslang::EOpReturn && node->getExpression() &&
|
||||
current_function_definition_node_ &&
|
||||
current_function_definition_node_->getType().getQualifier().noContraction) {
|
||||
// This node is a return node with an expression, and its function has a
|
||||
// precise return value. We need to find the involved objects in its
|
||||
// expression and add them to the set of initial precise objects.
|
||||
@ -331,20 +325,17 @@ bool TSymbolDefinitionCollectingTraverser::visitBranch(glslang::TVisit,
|
||||
}
|
||||
|
||||
// Visits a unary node. This might be an implicit assignment like i++, i--. etc.
|
||||
bool TSymbolDefinitionCollectingTraverser::visitUnary(
|
||||
glslang::TVisit visit,
|
||||
glslang::TIntermUnary* node)
|
||||
bool TSymbolDefinitionCollectingTraverser::visitUnary(glslang::TVisit /* visit */,
|
||||
glslang::TIntermUnary* node)
|
||||
{
|
||||
current_object_.clear();
|
||||
node->getOperand()->traverse(this);
|
||||
if (isAssignOperation(node->getOp()))
|
||||
{
|
||||
if (isAssignOperation(node->getOp())) {
|
||||
// We should always be able to get an access chain of the operand node.
|
||||
|
||||
// If the operand node object is 'precise', we collect its access chain
|
||||
// for the initial set of 'precise' objects.
|
||||
if (isPreciseObjectNode(node->getOperand()))
|
||||
{
|
||||
if (isPreciseObjectNode(node->getOperand())) {
|
||||
// The operand node is an 'precise' object node, add its
|
||||
// access chain to the set of 'precise' objects. This is to collect
|
||||
// the initial set of 'precise' objects.
|
||||
@ -363,8 +354,8 @@ bool TSymbolDefinitionCollectingTraverser::visitUnary(
|
||||
|
||||
// Visits a binary node and updates the mapping from symbol IDs to the definition
|
||||
// nodes. Also collects the access chains for the initial precise objects.
|
||||
bool TSymbolDefinitionCollectingTraverser::visitBinary(glslang::TVisit visit,
|
||||
glslang::TIntermBinary* node)
|
||||
bool TSymbolDefinitionCollectingTraverser::visitBinary(glslang::TVisit /* visit */,
|
||||
glslang::TIntermBinary* node)
|
||||
{
|
||||
// Traverses the left node to build the access chain info for the object.
|
||||
current_object_.clear();
|
||||
@ -423,19 +414,21 @@ bool TSymbolDefinitionCollectingTraverser::visitBinary(glslang::TVisit visit,
|
||||
std::tuple<NodeMapping, AccessChainMapping, ObjectAccesschainSet, ReturnBranchNodeSet>
|
||||
getSymbolToDefinitionMappingAndPreciseSymbolIDs(const glslang::TIntermediate& intermediate)
|
||||
{
|
||||
auto result_tuple = std::make_tuple(NodeMapping(), AccessChainMapping(),
|
||||
ObjectAccesschainSet(), ReturnBranchNodeSet());
|
||||
auto result_tuple = std::make_tuple(NodeMapping(), AccessChainMapping(), ObjectAccesschainSet(),
|
||||
ReturnBranchNodeSet());
|
||||
|
||||
TIntermNode* root = intermediate.getTreeRoot();
|
||||
if (root == 0)
|
||||
return result_tuple;
|
||||
|
||||
NodeMapping& symbol_definition_mapping = std::get<0>(result_tuple);
|
||||
AccessChainMapping& accesschain_mapping = std::get<1>(result_tuple);
|
||||
ObjectAccesschainSet& precise_objects = std::get<2>(result_tuple);
|
||||
NodeMapping& symbol_definition_mapping = std::get<0>(result_tuple);
|
||||
AccessChainMapping& accesschain_mapping = std::get<1>(result_tuple);
|
||||
ObjectAccesschainSet& precise_objects = std::get<2>(result_tuple);
|
||||
ReturnBranchNodeSet& precise_return_nodes = std::get<3>(result_tuple);
|
||||
|
||||
// Traverses the AST and populate the results.
|
||||
TSymbolDefinitionCollectingTraverser collector(&symbol_definition_mapping, &accesschain_mapping, &precise_objects, &precise_return_nodes);
|
||||
TSymbolDefinitionCollectingTraverser collector(&symbol_definition_mapping, &accesschain_mapping,
|
||||
&precise_objects, &precise_return_nodes);
|
||||
root->traverse(&collector);
|
||||
|
||||
return result_tuple;
|
||||
|
@ -389,24 +389,24 @@ public:
|
||||
switch ((int)sampler.dim) {
|
||||
case Esd1D:
|
||||
switch ((int)sampler.shadow) {
|
||||
case 0: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY : GL_SAMPLER_1D;
|
||||
case 1: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY_SHADOW : GL_SAMPLER_1D_SHADOW;
|
||||
case false: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY : GL_SAMPLER_1D;
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY_SHADOW : GL_SAMPLER_1D_SHADOW;
|
||||
}
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case 0:
|
||||
case false:
|
||||
switch ((int)sampler.shadow) {
|
||||
case 0: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY : GL_SAMPLER_2D;
|
||||
case 1: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY_SHADOW : GL_SAMPLER_2D_SHADOW;
|
||||
case false: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY : GL_SAMPLER_2D;
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY_SHADOW : GL_SAMPLER_2D_SHADOW;
|
||||
}
|
||||
case 1: return sampler.arrayed ? GL_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_SAMPLER_2D_MULTISAMPLE;
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_SAMPLER_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_SAMPLER_3D;
|
||||
case EsdCube:
|
||||
switch ((int)sampler.shadow) {
|
||||
case 0: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY : GL_SAMPLER_CUBE;
|
||||
case 1: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW : GL_SAMPLER_CUBE_SHADOW;
|
||||
case false: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY : GL_SAMPLER_CUBE;
|
||||
case true: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW : GL_SAMPLER_CUBE_SHADOW;
|
||||
}
|
||||
case EsdRect:
|
||||
return sampler.shadow ? GL_SAMPLER_2D_RECT_SHADOW : GL_SAMPLER_2D_RECT;
|
||||
@ -418,24 +418,24 @@ public:
|
||||
switch ((int)sampler.dim) {
|
||||
case Esd1D:
|
||||
switch ((int)sampler.shadow) {
|
||||
case 0: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_AMD : GL_FLOAT16_SAMPLER_1D_AMD;
|
||||
case 1: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_1D_SHADOW_AMD;
|
||||
case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_AMD : GL_FLOAT16_SAMPLER_1D_AMD;
|
||||
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_1D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_1D_SHADOW_AMD;
|
||||
}
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case 0:
|
||||
case false:
|
||||
switch ((int)sampler.shadow) {
|
||||
case 0: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_AMD;
|
||||
case 1: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_SHADOW_AMD;
|
||||
case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_AMD;
|
||||
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_SHADOW_AMD;
|
||||
}
|
||||
case 1: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_AMD;
|
||||
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_AMD;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_FLOAT16_SAMPLER_3D_AMD;
|
||||
case EsdCube:
|
||||
switch ((int)sampler.shadow) {
|
||||
case 0: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_AMD : GL_FLOAT16_SAMPLER_CUBE_AMD;
|
||||
case 1: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_CUBE_SHADOW_AMD;
|
||||
case false: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_AMD : GL_FLOAT16_SAMPLER_CUBE_AMD;
|
||||
case true: return sampler.arrayed ? GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_SHADOW_AMD : GL_FLOAT16_SAMPLER_CUBE_SHADOW_AMD;
|
||||
}
|
||||
case EsdRect:
|
||||
return sampler.shadow ? GL_FLOAT16_SAMPLER_2D_RECT_SHADOW_AMD : GL_FLOAT16_SAMPLER_2D_RECT_AMD;
|
||||
@ -449,8 +449,8 @@ public:
|
||||
return sampler.arrayed ? GL_INT_SAMPLER_1D_ARRAY : GL_INT_SAMPLER_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case 0: return sampler.arrayed ? GL_INT_SAMPLER_2D_ARRAY : GL_INT_SAMPLER_2D;
|
||||
case 1: return sampler.arrayed ? GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
|
||||
case false: return sampler.arrayed ? GL_INT_SAMPLER_2D_ARRAY : GL_INT_SAMPLER_2D;
|
||||
case true: return sampler.arrayed ? GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
|
||||
: GL_INT_SAMPLER_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
@ -468,8 +468,8 @@ public:
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_1D_ARRAY : GL_UNSIGNED_INT_SAMPLER_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case 0: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D;
|
||||
case 1: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
|
||||
case false: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D;
|
||||
case true: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
|
||||
: GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
@ -493,8 +493,8 @@ public:
|
||||
return sampler.arrayed ? GL_IMAGE_1D_ARRAY : GL_IMAGE_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case 0: return sampler.arrayed ? GL_IMAGE_2D_ARRAY : GL_IMAGE_2D;
|
||||
case 1: return sampler.arrayed ? GL_IMAGE_2D_MULTISAMPLE_ARRAY : GL_IMAGE_2D_MULTISAMPLE;
|
||||
case false: return sampler.arrayed ? GL_IMAGE_2D_ARRAY : GL_IMAGE_2D;
|
||||
case true: return sampler.arrayed ? GL_IMAGE_2D_MULTISAMPLE_ARRAY : GL_IMAGE_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_IMAGE_3D;
|
||||
@ -512,8 +512,8 @@ public:
|
||||
return sampler.arrayed ? GL_FLOAT16_IMAGE_1D_ARRAY_AMD : GL_FLOAT16_IMAGE_1D_AMD;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case 0: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_AMD;
|
||||
case 1: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_MULTISAMPLE_AMD;
|
||||
case false: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_AMD;
|
||||
case true: return sampler.arrayed ? GL_FLOAT16_IMAGE_2D_MULTISAMPLE_ARRAY_AMD : GL_FLOAT16_IMAGE_2D_MULTISAMPLE_AMD;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_FLOAT16_IMAGE_3D_AMD;
|
||||
@ -531,8 +531,8 @@ public:
|
||||
return sampler.arrayed ? GL_INT_IMAGE_1D_ARRAY : GL_INT_IMAGE_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case 0: return sampler.arrayed ? GL_INT_IMAGE_2D_ARRAY : GL_INT_IMAGE_2D;
|
||||
case 1: return sampler.arrayed ? GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_INT_IMAGE_2D_MULTISAMPLE;
|
||||
case false: return sampler.arrayed ? GL_INT_IMAGE_2D_ARRAY : GL_INT_IMAGE_2D;
|
||||
case true: return sampler.arrayed ? GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_INT_IMAGE_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
return GL_INT_IMAGE_3D;
|
||||
@ -549,8 +549,8 @@ public:
|
||||
return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_1D_ARRAY : GL_UNSIGNED_INT_IMAGE_1D;
|
||||
case Esd2D:
|
||||
switch ((int)sampler.ms) {
|
||||
case 0: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_ARRAY : GL_UNSIGNED_INT_IMAGE_2D;
|
||||
case 1: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
|
||||
case false: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_ARRAY : GL_UNSIGNED_INT_IMAGE_2D;
|
||||
case true: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
|
||||
: GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE;
|
||||
}
|
||||
case Esd3D:
|
||||
|
Loading…
Reference in New Issue
Block a user