Commit c0275796 by John Kessenich

Put in infrastructure for tessellation, geometry, and compute stages, and…

Put in infrastructure for tessellation, geometry, and compute stages, and partially flesh out with built-in functions. Added the built-in functions EmitVertex(), EndPrimitive(), barrier(), memoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(), memoryBarrierImage(), memoryBarrierShared(), and groupMemoryBarrier(). Have not added any new built-in variables. Also changed the linear performance relateToOperator() to a high-performance version. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22659 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent 317f1af2
...@@ -18,8 +18,13 @@ To use the standalone binary form, execute glslangValidator, and it will print ...@@ -18,8 +18,13 @@ To use the standalone binary form, execute glslangValidator, and it will print
a usage statement. Basic operation is to give it a file containing a shader, a usage statement. Basic operation is to give it a file containing a shader,
and it will print out warnings/errors and optionally an AST. and it will print out warnings/errors and optionally an AST.
The applied stage-specific rules are based on the file extension. Currently, The applied stage-specific rules are based on the file extension:
either .frag or .vert, but soon to also include all stages. .vert for a vertex shader
.tesc for a tessellation control shader
.tese for a tessellation evaluation shader
.geom for a geometry shader
.frag for a fragment shader
.comp for a compute shader
Source: Build and run on linux Source: Build and run on linux
------------------------------- -------------------------------
......
...@@ -251,6 +251,8 @@ static EShLanguage FindLanguage(const std::string& name) ...@@ -251,6 +251,8 @@ static EShLanguage FindLanguage(const std::string& name)
return EShLangGeometry; return EShLangGeometry;
else if (suffix == "frag") else if (suffix == "frag")
return EShLangFragment; return EShLangFragment;
else if (suffix == "comp")
return EShLangCompute;
usage(); usage();
return EShLangVertex; return EShLangVertex;
...@@ -306,7 +308,13 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons ...@@ -306,7 +308,13 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons
void usage() void usage()
{ {
printf("Usage: standalone [ options ] filename\n" printf("Usage: standalone [ options ] filename\n"
"Where: filename is a name ending in .frag or .vert\n\n" "Where: filename is a name ending in\n"
" .vert for a vertex shader\n"
" .tesc for a tessellation control shader\n"
" .tese for a tessellation evaluation shader\n"
" .geom for a geometry shader\n"
" .frag for a fragment shader\n"
" .comp for a compute shader\n\n"
"Compilation warnings and errors will be printed to stdout.\n" "Compilation warnings and errors will be printed to stdout.\n"
"To get other information, use one of the following options:\n" "To get other information, use one of the following options:\n"
"-i: intermediate tree (glslang AST) is printed out\n" "-i: intermediate tree (glslang AST) is printed out\n"
......
#version 150 core
void main()
{
EmitVertex();
EndPrimitive();
EmitStreamVertex(1); // ERROR
EndStreamPrimitive(0); // ERROR
}
#version 400 core
void main()
{
EmitStreamVertex(1);
EndStreamPrimitive(0);
EmitVertex();
EndPrimitive();
}
#version 400 core
void main()
{
barrier();
}
#version 400 core
void main()
{
barrier(); // ERROR
}
#version 420 core
void main()
{
memoryBarrier();
}
#version 430 core
void main()
{
memoryBarrierAtomicCounter();
memoryBarrierBuffer();
memoryBarrierShared();
memoryBarrierImage();
groupMemoryBarrier();
}
...@@ -230,6 +230,28 @@ ERROR: node is still EOpNull! ...@@ -230,6 +230,28 @@ ERROR: node is still EOpNull!
0:98 3.200000 0:98 3.200000
0:99 Function Call: foo(f1; (int) 0:99 Function Call: foo(f1; (int)
0:99 'a' (out float) 0:99 'a' (out float)
0:102 Function Definition: gen(vf3; (bool)
0:102 Function Parameters:
0:102 'v' (in 3-component vector of float)
0:104 Sequence
0:104 Test condition and select (void)
0:104 Condition
0:104 logical-and (bool)
0:104 Compare Less Than (bool)
0:104 Absolute value (float)
0:104 direct index (in float)
0:104 'v' (in 3-component vector of float)
0:104 0 (const int)
0:104 0.000100
0:104 Compare Less Than (bool)
0:104 Absolute value (float)
0:104 direct index (in float)
0:104 'v' (in 3-component vector of float)
0:104 1 (const int)
0:104 0.000100
0:104 true case
0:105 Branch: Return with expression
0:105 true (const bool)
0:? Linker Objects 0:? Linker Objects
0:? 'i' (smooth in 4-component vector of float) 0:? 'i' (smooth in 4-component vector of float)
0:? 'o' (out 4-component vector of float) 0:? 'o' (out 4-component vector of float)
......
0:3Function Definition: main( (void)
0:3 Function Parameters:
0:5 Sequence
0:5 EmitStreamVertex (void)
0:5 1 (const int)
0:6 EndStreamPrimitive (void)
0:6 0 (const int)
0:7 EmitVertex (void)
0:8 EndPrimitive (void)
0:3Function Definition: main( (void)
0:3 Function Parameters:
0:5 Sequence
0:5 Barrier (void)
ERROR: 0:5: 'barrier' : no matching overloaded function found
ERROR: 1 compilation errors. No code generated.
0:3Function Definition: main( (void)
0:3 Function Parameters:
0:5 Sequence
0:5 0.000000
0:3Function Definition: main( (void)
0:3 Function Parameters:
0:5 Sequence
0:5 MemoryBarrier (void)
0:3Function Definition: main( (void)
0:3 Function Parameters:
0:5 Sequence
0:5 MemoryBarrierAtomicCounter (void)
0:6 MemoryBarrierBuffer (void)
0:7 MemoryBarrierShared (void)
0:8 MemoryBarrierImage (void)
0:9 GroupMemoryBarrier (void)
...@@ -44,6 +44,11 @@ tokenLength.vert ...@@ -44,6 +44,11 @@ tokenLength.vert
430scope.vert 430scope.vert
lineContinuation.vert lineContinuation.vert
numeral.frag numeral.frag
400.geom
400.tesc
400.tese
420.tese
430.comp
../../LunarGLASS/test/aggOps.frag ../../LunarGLASS/test/aggOps.frag
../../LunarGLASS/test/always-discard.frag ../../LunarGLASS/test/always-discard.frag
../../LunarGLASS/test/always-discard2.frag ../../LunarGLASS/test/always-discard2.frag
......
...@@ -213,6 +213,19 @@ enum TOperator { ...@@ -213,6 +213,19 @@ enum TOperator {
EOpMatrixInverse, EOpMatrixInverse,
EOpTranspose, EOpTranspose,
EOpEmitVertex, // geometry only
EOpEndPrimitive, // geometry only
EOpEmitStreamVertex, // geometry only
EOpEndStreamPrimitive, // geometry only
EOpBarrier,
EOpMemoryBarrier,
EOpMemoryBarrierAtomicCounter,
EOpMemoryBarrierBuffer,
EOpMemoryBarrierImage,
EOpMemoryBarrierShared, // compute only
EOpGroupMemoryBarrier, // compute only
EOpAny, EOpAny,
EOpAll, EOpAll,
......
...@@ -402,6 +402,11 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType, ...@@ -402,6 +402,11 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
newConstArray = new constUnion[1]; newConstArray = new constUnion[1];
break; break;
case EOpEmitStreamVertex:
case EOpEndStreamPrimitive:
// These don't actually fold
return 0;
default: default:
newConstArray = new constUnion[objectSize]; newConstArray = new constUnion[objectSize];
} }
......
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
#include "SymbolTable.h" #include "SymbolTable.h"
#include "Versions.h" #include "Versions.h"
typedef TVector<TString> TBuiltInStrings;
class TBuiltIns { class TBuiltIns {
public: public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
...@@ -52,7 +50,8 @@ public: ...@@ -52,7 +50,8 @@ public:
virtual ~TBuiltIns(); virtual ~TBuiltIns();
void initialize(int version, EProfile); void initialize(int version, EProfile);
void initialize(const TBuiltInResource& resources, int version, EProfile, EShLanguage); void initialize(const TBuiltInResource& resources, int version, EProfile, EShLanguage);
TBuiltInStrings* getBuiltInStrings() { return builtInStrings; } const TString& getCommonString() const { return commonBuiltins; }
const TString& getStageString(EShLanguage language) const { return stageBuiltins[language]; }
protected: protected:
void add2ndGenerationSamplingImaging(int version, EProfile profile); void add2ndGenerationSamplingImaging(int version, EProfile profile);
...@@ -60,7 +59,8 @@ protected: ...@@ -60,7 +59,8 @@ protected:
void addImageFunctions(TSampler, TString& typeName, int version, EProfile profile); void addImageFunctions(TSampler, TString& typeName, int version, EProfile profile);
void addSamplingFunctions(TSampler, TString& typeName, int version, EProfile profile); void addSamplingFunctions(TSampler, TString& typeName, int version, EProfile profile);
TBuiltInStrings builtInStrings[EShLangCount]; TString commonBuiltins;
TString stageBuiltins[EShLangCount];
// Helpers for making text // Helpers for making text
const char* postfixes[5]; const char* postfixes[5];
......
...@@ -264,7 +264,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, ...@@ -264,7 +264,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode,
return node; return node;
} }
TIntermTyped* TIntermediate::addBuiltInFunctionCall(TOperator op, bool unary, TIntermNode* childNode, const TType& returnType) TIntermTyped* TIntermediate::addBuiltInFunctionCall(TSourceLoc loc, TOperator op, bool unary, TIntermNode* childNode, const TType& returnType)
{ {
if (unary) { if (unary) {
// //
...@@ -279,9 +279,11 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(TOperator op, bool unary, TI ...@@ -279,9 +279,11 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(TOperator op, bool unary, TI
return 0; return 0;
} }
if (child->getAsConstantUnion()) if (child->getAsConstantUnion()) {
TIntermTyped* folded = child->getAsConstantUnion()->fold(op, returnType, infoSink);
return child->getAsConstantUnion()->fold(op, returnType, infoSink); if (folded)
return folded;
}
TIntermUnary* node = new TIntermUnary(op); TIntermUnary* node = new TIntermUnary(op);
node->setLoc(child->getLoc()); node->setLoc(child->getLoc());
...@@ -299,7 +301,7 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(TOperator op, bool unary, TI ...@@ -299,7 +301,7 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(TOperator op, bool unary, TI
return node; return node;
} else { } else {
// setAggregateOperater() calls fold() for constant folding // setAggregateOperater() calls fold() for constant folding
TIntermTyped* node = setAggregateOperator(childNode, op, returnType, childNode->getLoc()); TIntermTyped* node = setAggregateOperator(childNode, op, returnType, loc);
TPrecisionQualifier correctPrecision = returnType.getQualifier().precision; TPrecisionQualifier correctPrecision = returnType.getQualifier().precision;
if (correctPrecision == EpqNone && profile == EEsProfile) { if (correctPrecision == EpqNone && profile == EEsProfile) {
......
...@@ -81,7 +81,7 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb, ...@@ -81,7 +81,7 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb,
defaultPrecision[EbtSampler] = EpqLow; defaultPrecision[EbtSampler] = EpqLow;
break; break;
default: default:
infoSink.info.message(EPrefixError, "unexpected language"); infoSink.info.message(EPrefixError, "unexpected es-profile stage");
} }
} }
...@@ -1965,13 +1965,11 @@ void TParseContext::updateTypedDefaults(TSourceLoc loc, TQualifier qualifier, co ...@@ -1965,13 +1965,11 @@ void TParseContext::updateTypedDefaults(TSourceLoc loc, TQualifier qualifier, co
if (qualifier.layoutPacking != ElpNone) if (qualifier.layoutPacking != ElpNone)
error(loc, "cannot specify packing on a variable declaration", id->c_str(), ""); error(loc, "cannot specify packing on a variable declaration", id->c_str(), "");
} else if (qualifier.storage == EvqVaryingIn) { } else if (qualifier.storage == EvqVaryingIn) {
if (qualifier.hasLayout() && language != EShLangVertex) { if (qualifier.hasLayout() && language != EShLangVertex)
error(loc, "can only use location layout qualifier on a vertex input or fragment output", id->c_str(), ""); error(loc, "can only use location layout qualifier on a vertex input or fragment output", id->c_str(), "");
}
} else if (qualifier.storage == EvqVaryingOut) { } else if (qualifier.storage == EvqVaryingOut) {
if (qualifier.hasLayout() && language != EShLangFragment) { if (qualifier.hasLayout() && language != EShLangFragment)
error(loc, "can only use location layout qualifier on a vertex input or fragment output", id->c_str(), ""); error(loc, "can only use location layout qualifier on a vertex input or fragment output", id->c_str(), "");
}
} else { } else {
if (qualifier.layoutMatrix != ElmNone || if (qualifier.layoutMatrix != ElmNone ||
qualifier.layoutPacking != ElpNone) qualifier.layoutPacking != ElpNone)
......
...@@ -89,7 +89,7 @@ TSymbolTable* SharedSymbolTables[VersionCount][EProfileCount][EShLangCount] = {} ...@@ -89,7 +89,7 @@ TSymbolTable* SharedSymbolTables[VersionCount][EProfileCount][EShLangCount] = {}
TPoolAllocator* PerProcessGPA = 0; TPoolAllocator* PerProcessGPA = 0;
bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfile profile, EShLanguage language, TInfoSink& infoSink, bool InitializeSymbolTable(const TBuiltIns& builtIns, int version, EProfile profile, EShLanguage language, TInfoSink& infoSink,
const TBuiltInResource* resources, TSymbolTable* symbolTables) const TBuiltInResource* resources, TSymbolTable* symbolTables)
{ {
TIntermediate intermediate(infoSink, version, profile); TIntermediate intermediate(infoSink, version, profile);
...@@ -119,26 +119,25 @@ bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfil ...@@ -119,26 +119,25 @@ bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfil
symbolTable->push(); symbolTable->push();
for (TBuiltInStrings::iterator i = BuiltInStrings[parseContext.language].begin(); const char* builtInShaders[2];
i != BuiltInStrings[parseContext.language].end(); ++i) { int builtInLengths[2];
const char* builtInShaders[1]; builtInShaders[0] = builtIns.getCommonString().c_str();
int builtInLengths[1]; builtInLengths[0] = builtIns.getCommonString().size();
builtInShaders[1] = builtIns.getStageString(language).c_str();
builtInLengths[1] = builtIns.getStageString(language).size();
builtInShaders[0] = (*i).c_str(); if (! parseContext.parseShaderStrings(ppContext, const_cast<char**>(builtInShaders), builtInLengths, 2) != 0) {
builtInLengths[0] = (int) (*i).size(); infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
if (! parseContext.parseShaderStrings(ppContext, const_cast<char**>(builtInShaders), builtInLengths, 1) != 0) { printf("Unable to parse built-ins\n");
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
printf("Unable to parse built-ins\n");
return false; return false;
}
} }
if (resources) { if (resources)
IdentifyBuiltIns(version, profile, parseContext.language, *symbolTable, *resources); IdentifyBuiltIns(version, profile, parseContext.language, *symbolTable, *resources);
} else { else
IdentifyBuiltIns(version, profile, parseContext.language, *symbolTable); IdentifyBuiltIns(version, profile, parseContext.language, *symbolTable);
}
return true; return true;
} }
...@@ -147,8 +146,16 @@ bool GenerateBuiltInSymbolTable(TInfoSink& infoSink, TSymbolTable* symbolTables, ...@@ -147,8 +146,16 @@ bool GenerateBuiltInSymbolTable(TInfoSink& infoSink, TSymbolTable* symbolTables,
TBuiltIns builtIns; TBuiltIns builtIns;
builtIns.initialize(version, profile); builtIns.initialize(version, profile);
InitializeSymbolTable(builtIns.getBuiltInStrings(), version, profile, EShLangVertex, infoSink, 0, symbolTables); InitializeSymbolTable(builtIns, version, profile, EShLangVertex, infoSink, 0, symbolTables);
InitializeSymbolTable(builtIns.getBuiltInStrings(), version, profile, EShLangFragment, infoSink, 0, symbolTables); if (profile != EEsProfile && version >= 400) {
InitializeSymbolTable(builtIns, version, profile, EShLangTessControl, infoSink, 0, symbolTables);
InitializeSymbolTable(builtIns, version, profile, EShLangTessEvaluation, infoSink, 0, symbolTables);
}
if (profile != EEsProfile && version >= 150)
InitializeSymbolTable(builtIns, version, profile, EShLangGeometry, infoSink, 0, symbolTables);
InitializeSymbolTable(builtIns, version, profile, EShLangFragment, infoSink, 0, symbolTables);
if (profile != EEsProfile && version >= 430)
InitializeSymbolTable(builtIns, version, profile, EShLangCompute, infoSink, 0, symbolTables);
return true; return true;
} }
...@@ -158,7 +165,7 @@ bool AddContextSpecificSymbols(const TBuiltInResource* resources, TInfoSink& inf ...@@ -158,7 +165,7 @@ bool AddContextSpecificSymbols(const TBuiltInResource* resources, TInfoSink& inf
TBuiltIns builtIns; TBuiltIns builtIns;
builtIns.initialize(*resources, version, profile, language); builtIns.initialize(*resources, version, profile, language);
InitializeSymbolTable(builtIns.getBuiltInStrings(), version, profile, language, infoSink, resources, symbolTables); InitializeSymbolTable(builtIns, version, profile, language, infoSink, resources, symbolTables);
return true; return true;
} }
...@@ -207,10 +214,12 @@ void SetupBuiltinSymbolTable(int version, EProfile profile) ...@@ -207,10 +214,12 @@ void SetupBuiltinSymbolTable(int version, EProfile profile)
SetThreadPoolAllocator(*PerProcessGPA); SetThreadPoolAllocator(*PerProcessGPA);
// Copy the symbol table from the new pool to the process-global pool // Copy the symbol table from the new pool to the process-global pool
SharedSymbolTables[versionIndex][profile][EShLangVertex] = new TSymbolTable; for (int stage = 0; stage < EShLangCount; ++stage) {
SharedSymbolTables[versionIndex][profile][EShLangVertex]->copyTable(symTables[EShLangVertex]); if (! symTables[stage].isEmpty()) {
SharedSymbolTables[versionIndex][profile][EShLangFragment] = new TSymbolTable; SharedSymbolTables[versionIndex][profile][stage] = new TSymbolTable;
SharedSymbolTables[versionIndex][profile][EShLangFragment]->copyTable(symTables[EShLangFragment]); SharedSymbolTables[versionIndex][profile][stage]->copyTable(symTables[stage]);
}
}
delete builtInPoolAllocator; delete builtInPoolAllocator;
SetThreadPoolAllocator(savedGPA); SetThreadPoolAllocator(savedGPA);
...@@ -416,9 +425,18 @@ int ShCompile( ...@@ -416,9 +425,18 @@ int ShCompile(
TIntermediate intermediate(compiler->infoSink, version, profile); TIntermediate intermediate(compiler->infoSink, version, profile);
SetupBuiltinSymbolTable(version, profile); SetupBuiltinSymbolTable(version, profile);
TSymbolTable symbolTable(*SharedSymbolTables[MapVersionToIndex(version)]
[profile] TSymbolTable* cachedTable = SharedSymbolTables[MapVersionToIndex(version)]
[compiler->getLanguage()]); [profile]
[compiler->getLanguage()];
TSymbolTable* errorTable = 0;
if (! cachedTable) {
errorTable = new TSymbolTable;
cachedTable = errorTable;
}
TSymbolTable symbolTable(*cachedTable);
if (errorTable)
delete errorTable;
// Add built-in symbols that are potentially context dependent; // Add built-in symbols that are potentially context dependent;
// they get popped again further down. // they get popped again further down.
...@@ -436,13 +454,13 @@ int ShCompile( ...@@ -436,13 +454,13 @@ int ShCompile(
if (! goodProfile) if (! goodProfile)
parseContext.error(beginning, "incorrect", "#version", ""); parseContext.error(beginning, "incorrect", "#version", "");
parseContext.initializeExtensionBehavior();
if (versionStatementMissing) if (versionStatementMissing)
parseContext.warn(beginning, "statement missing: use #version on first line of shader", "#version", ""); parseContext.warn(beginning, "statement missing: use #version on first line of shader", "#version", "");
else if (profile == EEsProfile && version >= 300 && versionNotFirst) else if (profile == EEsProfile && version >= 300 && versionNotFirst)
parseContext.error(beginning, "statement must appear first in ESSL shader; before comments or newlines", "#version", ""); parseContext.error(beginning, "statement must appear first in ESSL shader; before comments or newlines", "#version", "");
parseContext.initializeExtensionBehavior();
// //
// Parse the application's shaders. All the following symbol table // Parse the application's shaders. All the following symbol table
// work will be throw-away, so push a new allocation scope that can // work will be throw-away, so push a new allocation scope that can
......
...@@ -188,19 +188,20 @@ TSymbolTableLevel::~TSymbolTableLevel() ...@@ -188,19 +188,20 @@ TSymbolTableLevel::~TSymbolTableLevel()
// //
// Change all function entries in the table with the non-mangled name // Change all function entries in the table with the non-mangled name
// to be related to the provided built-in operation. This is a low // to be related to the provided built-in operation.
// performance operation, and only intended for symbol tables that
// live across a large number of compiles.
// //
void TSymbolTableLevel::relateToOperator(const char* name, TOperator op) void TSymbolTableLevel::relateToOperator(const char* name, TOperator op)
{ {
tLevel::iterator it; tLevel::const_iterator candidate = level.lower_bound(name);
for (it = level.begin(); it != level.end(); ++it) { while (candidate != level.end()) {
TFunction* function = (*it).second->getAsFunction(); const TString& candidateName = (*candidate).first;
if (function) { TString::size_type parenAt = candidateName.find_first_of('(');
if (function->getName() == name) if (parenAt != candidateName.npos && candidateName.substr(0, parenAt) == name) {
function->relateToOperator(op); TFunction* function = (*candidate).second->getAsFunction();
} function->relateToOperator(op);
} else
break;
++candidate;
} }
} }
......
...@@ -373,10 +373,12 @@ public: ...@@ -373,10 +373,12 @@ public:
} }
explicit TSymbolTable(TSymbolTable& symTable) explicit TSymbolTable(TSymbolTable& symTable)
{ {
table.push_back(symTable.table[0]); if (! symTable.isEmpty()) {
adoptedLevels = 1; table.push_back(symTable.table[0]);
uniqueId = symTable.uniqueId; adoptedLevels = 1;
noBuiltInRedeclarations = symTable.noBuiltInRedeclarations; uniqueId = symTable.uniqueId;
noBuiltInRedeclarations = symTable.noBuiltInRedeclarations;
} // else should only be to handle error paths
} }
~TSymbolTable() ~TSymbolTable()
{ {
...@@ -391,6 +393,9 @@ public: ...@@ -391,6 +393,9 @@ public:
// built-ins specific to a compile are at level 1 and the shader // built-ins specific to a compile are at level 1 and the shader
// globals are at level 2. // globals are at level 2.
// //
// TODO: compile-time memory: have an even earlier level for all built-ins
// common to all stages. Currently, each stage has copy.
//
bool isEmpty() { return table.size() == 0; } bool isEmpty() { return table.size() == 0; }
bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); } bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
bool atSharedBuiltInLevel() { return table.size() == 1; } bool atSharedBuiltInLevel() { return table.size() == 1; }
......
...@@ -491,7 +491,7 @@ function_call ...@@ -491,7 +491,7 @@ function_call
op = fnCandidate->getBuiltInOp(); op = fnCandidate->getBuiltInOp();
if (builtIn && op != EOpNull) { if (builtIn && op != EOpNull) {
// A function call mapped to a built-in operation. // A function call mapped to a built-in operation.
$$ = parseContext.intermediate.addBuiltInFunctionCall(op, fnCandidate->getParamCount() == 1, $1.intermNode, fnCandidate->getReturnType()); $$ = parseContext.intermediate.addBuiltInFunctionCall($1.loc, op, fnCandidate->getParamCount() == 1, $1.intermNode, fnCandidate->getReturnType());
if ($$ == 0) { if ($$ == 0) {
parseContext.error($1.intermNode->getLoc(), " wrong operand type", "Internal Error", parseContext.error($1.intermNode->getLoc(), " wrong operand type", "Internal Error",
"built in unary operator function. Type: %s", "built in unary operator function. Type: %s",
......
...@@ -260,6 +260,9 @@ bool OutputUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it) ...@@ -260,6 +260,9 @@ bool OutputUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
case EOpAny: out.debug << "any"; break; case EOpAny: out.debug << "any"; break;
case EOpAll: out.debug << "all"; break; case EOpAll: out.debug << "all"; break;
case EOpEmitStreamVertex: out.debug << "EmitStreamVertex"; break;
case EOpEndStreamPrimitive: out.debug << "EndStreamPrimitive"; break;
default: out.debug.message(EPrefixError, "Bad unary op"); default: out.debug.message(EPrefixError, "Bad unary op");
} }
...@@ -355,6 +358,17 @@ bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTravers ...@@ -355,6 +358,17 @@ bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTravers
case EOpMul: out.debug << "component-wise multiply"; break; case EOpMul: out.debug << "component-wise multiply"; break;
case EOpOuterProduct: out.debug << "outer product"; break; case EOpOuterProduct: out.debug << "outer product"; break;
case EOpEmitVertex: out.debug << "EmitVertex"; break;
case EOpEndPrimitive: out.debug << "EndPrimitive"; break;
case EOpBarrier: out.debug << "Barrier"; break;
case EOpMemoryBarrier: out.debug << "MemoryBarrier"; break;
case EOpMemoryBarrierAtomicCounter: out.debug << "MemoryBarrierAtomicCounter"; break;
case EOpMemoryBarrierBuffer: out.debug << "MemoryBarrierBuffer"; break;
case EOpMemoryBarrierImage: out.debug << "MemoryBarrierImage"; break;
case EOpMemoryBarrierShared: out.debug << "MemoryBarrierShared"; break;
case EOpGroupMemoryBarrier: out.debug << "GroupMemoryBarrier"; break;
default: out.debug.message(EPrefixError, "Bad aggregation op"); default: out.debug.message(EPrefixError, "Bad aggregation op");
} }
......
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc); TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc); TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
TIntermTyped* addUnaryMath(TOperator, TIntermNode* child, TSourceLoc); TIntermTyped* addUnaryMath(TOperator, TIntermNode* child, TSourceLoc);
TIntermTyped* addBuiltInFunctionCall(TOperator, bool unary, TIntermNode*, const TType& returnType); TIntermTyped* addBuiltInFunctionCall(TSourceLoc line, TOperator, bool unary, TIntermNode*, const TType& returnType);
bool canImplicitlyPromote(TBasicType from, TBasicType to); bool canImplicitlyPromote(TBasicType from, TBasicType to);
TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right); TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right);
TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc); TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment