Commit b603f918 by John Kessenich

Put all glslang internals (but not the external interface) into the glslang namespace.

parent 23bdb29e
......@@ -41,6 +41,8 @@
#include "Public/ShaderLang.h"
namespace glslang {
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
bool InitProcess()
......@@ -144,3 +146,5 @@ bool DetachProcess()
return success;
}
} // end namespace glslang
......@@ -37,11 +37,14 @@
#include "osinclude.h"
namespace glslang {
bool InitProcess();
bool InitThread();
bool DetachThread();
bool DetachProcess();
} // end namespace glslang
#endif // __INITIALIZEDLL_H
......@@ -72,7 +72,7 @@ ShBinding FixedAttributeBindings[] = {
ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
static EShLanguage FindLanguage(const std::string& name);
EShLanguage FindLanguage(const std::string& name);
bool CompileFile(const char *fileName, ShHandle, int options, const TBuiltInResource*);
void usage();
void FreeFileData(char **data);
......@@ -232,7 +232,7 @@ int C_DECL main(int argc, char* argv[])
// .geom = geometry
// .frag = fragment
//
static EShLanguage FindLanguage(const std::string& name)
EShLanguage FindLanguage(const std::string& name)
{
size_t ext = name.rfind('.');
if (ext == std::string::npos) {
......
......@@ -78,6 +78,6 @@ namespace glslang {
std::list<std::string> worklist;
};
};
} // end namespace glslang
#endif // WORKLIST_H_INCLUDED
......@@ -9,10 +9,7 @@ Performance
Testing
- thread safety
Interfacing
- finish putting into a glslang namespace
Shader Linking Validation
Link Validation
- ensure no static references thrown away
Cross-stage linking
- type consistency check of uniform and ins <-> outs, both variables and blocks, stage-specific arrayness matching
......@@ -22,6 +19,9 @@ Shader Linking Validation
- statically consumed input not produced by previous stage
- matching between gl_PerVertex blocks and gl_PerFragment blocks
- compute shader not with other stages
- 1.3: deprecated mixing fixed vertex/fragment stage with programmable fragment/vertex stage.
- 4.3: remove cross-version linking restrictions.
- 4.3: Allow mismatches in interpolation and auxiliary qualification across stages.
Intra-stage linking
- exactly one main
- type consistency check of uniforms, globals, ins, and outs, both variables and blocks
......@@ -32,17 +32,20 @@ Shader Linking Validation
- mixed es/non-es profiles
- matching initializers for globals
- recursion for both functions and subroutines
- Even the potential for recursion through subroutine uniforms is an error.
- matching redeclarations of interface blocks
- read or write to both gl_ClipVertex and gl_ClipDistance
- write to only one of gl_FragColor, gl_FragData, or user-declared
- 4.3: Be clear that early_fragment_tests is only needed in one fragment-stage compilation unit.
- 4.3: Be clear that implicit array sizing is only within a stage, not cross stage.
- 4.4: overlapping transform/feedback offsets, offset/stride overflow checks, and stride matching
Functionality to Implement/Finish
Shader Functionality to Implement/Finish
ESSL 3.0
- "const" compile-time constant propagation in the front-end has to be complete, for all built-in functions
GLSL 1.2
- Handle multiple compilation units per stage
- Allow initializers on uniform declarations. The value is set at link time.
- Allow initializers on uniform declarations
- signature matching takes type conversions into account, ambiguity is an error
GLSL 1.3
. flat is for both user and predeclared built-in in/out variables
......@@ -51,7 +54,6 @@ Functionality to Implement/Finish
- non-perspective (linear) interpolation (noperspective)
- add gl_ClipDistance[] to both vertex and fragment shaders
- only statically used built-ins have to be redeclared as flat
- Link: Deprecated mixing fixed vertex/fragment stage with programmable fragment/vertex stage.
- Deprecated gl_ClipVertex
- deprecate almost all built-in state
- ftransform() is deprecated
......@@ -78,7 +80,6 @@ Functionality to Implement/Finish
- Added geometry shaders. This includes targeting layers in FBO rendering.
- geometry shader layouts: they must be declared, telling the system the primitive input and output types and maximum number of vertices.
- Added geometry shader constants.
- gl_FragCoord qualifiers use the layout(): origin_upper_left and pixel_center_integer.
- Broaden structure usage to include geometry inputs and geometry outputs.
GLSL 4.0
- tessellation control stage and tessellation evaluation stage. Includes barrier() built-in for synchronization.
......@@ -93,7 +94,7 @@ Functionality to Implement/Finish
- Sampler arrays can take a variable index now, as long as it's value is uniform for all uses.
- Per-sample shading. Including sample input mask gl_SampleMaskIn[] and per-sample interpolation, with explicit interpolation built-ins interpolateAtCentroid(), interpolateAtSample(), and interpolateAtOffset().
- New precise qualifier to disallow optimizations that re-order operations or treat different instances of the same operator with different precision.
- Add a fused multiply andadd built-in, fma(), in relation to the new precise qualifier. (Because “a * b + c” will require two operations under new rules for precise.)
- Add a fused multiply and add built-in, fma(), in relation to the new precise qualifier. (Because “a * b + c” will require two operations under new rules for precise.)
- Added new built-in floating-point functions
- frexp() and ldexp()
- packUnorm2x16(), packUnorm4x8(),packSnorm4x8(), and packDouble2x32()
......@@ -121,7 +122,7 @@ Functionality to Implement/Finish
- Add 64-bit floating-point attributes for vertex shader inputs.
- Support viewport arrays so where the geometry shader selects which viewport array will transform its output.
GLSL 4.2
- Add 420-style function signature matching rules
- Add 420-style function signature matching rules (or did this start in 4.0?)
+ Move these previously deprecated features to be only in the compatibility profile:
+ The keyword attribute for vertex shader inputs. (Use in instead.)
+ The keyword varying for inputs and outputs. (Use in and out instead.)
......@@ -156,7 +157,6 @@ Functionality to Implement/Finish
- Allow .length() to be applied to vectors and matrices, returning the number of components or columns.
+ Clarify that .length() returns an int type and can be used as a constant integer expression.
- Allow swizzle operations on scalars.
- Even the potential for recursion through subroutine uniforms is an error.
- Positive signed decimal literals, as well as octal and hexadecimal, can set all 32 bits. This includes setting the sign bit to create a negative value.
- Make GLSL consistent with the API regarding user clipping, by no longer referring to gl_Positionwhen gl_ClipVertex is not written. Rather, user clipping becomes undefined.
- Minor consistency fixes, corrections
......@@ -188,33 +188,24 @@ Functionality to Implement/Finish
GL_ARB_explicit_uniform_location extension.
- Accept ES GLSL shader #version statements, which will request ES functionality for ES GLSL
versions 100 and 300, as per the GL_ARB_ES3_compatibility extension.
- Clarified about 90 errors as being either compile time, link time, or either.
- Clarify and correct scoping rules to what would normally be expected and what was intended.
(Function parameters and body nest inside global space. Loop variables and body nest inside
loop scope.)
- There are no digraphs (trigraphs were already disallowed).
- Remove the CPP difference that it is a compile-time error to use #if or #elif on expressions
containing undefined macro names. This reverts back to following expected CPP behavior.
- Set both gl_MaxFragmentImageUniformsand gl_MaxCombinedImageUniformsto 8.
- Set both gl_MaxFragmentImageUniformsand gl_MaxCombinedImageUniforms to 8.
- Clarify textureSize() for cube map arrays.
- For layout qualifiers,
- make negative output locations a compile-time error, and
- make indexes outside the range [0,1] a compile-time error.
- Allow mismatches in interpolation and auxiliary qualification across stages.
- Remove cross-version linking restrictions.
- Add textureQueryLevels() built-ins to query the number of mipmap levels, as per the
GL_ARB_texture_query_levels extension.
- Make gl_Layer and gl_ViewportIndex also be inputs to the fragment shader, as per the
GL_ARB_fragment_layer_viewport extension.
- Be explicit that compile-time constant expressions evaluating on the host may get a different
value than the same expression on the target. Also reinforce that compile-time constant
expressions are evaluated as if precise and invariantwere used.
- Add more examples and rules to be more specific about the required behavior of the precise
qualifier.
- Clarify fragment output variables cannot be double precision.
- Clarify that “floating-point” generally means both single- and double-precision and be more
consistent with that.
- Be clear that early_fragment_tests is only needed in one fragment-stage compilation unit.
- Allow the new shared keyword to be in layout-qualifier-id, allowing backward compatibility
with the shared identifier that was previously used.
+ Added overlooked texture function float textureOffset (sampler2DArrayShadow sampler, vec4 P, vec2 offset [, float bias] ).
......
......@@ -188,7 +188,6 @@ xcopy /y $(IntDir)$(TargetName)$(TargetExt) Test</Command>
<ItemGroup>
<ClInclude Include="glslang\MachineIndependent\glslang_tab.cpp.h" />
<ClInclude Include="glslang\MachineIndependent\Initialize.h" />
<ClInclude Include="glslang\MachineIndependent\MMap.h" />
<ClInclude Include="glslang\MachineIndependent\ParseHelper.h" />
<ClInclude Include="glslang\MachineIndependent\preprocessor\PpContext.h" />
<ClInclude Include="glslang\MachineIndependent\preprocessor\PpTokens.h" />
......
......@@ -114,9 +114,6 @@
<ClInclude Include="glslang\MachineIndependent\Initialize.h">
<Filter>Machine Independent</Filter>
</ClInclude>
<ClInclude Include="glslang\MachineIndependent\MMap.h">
<Filter>Machine Independent</Filter>
</ClInclude>
<ClInclude Include="glslang\MachineIndependent\ParseHelper.h">
<Filter>Machine Independent</Filter>
</ClInclude>
......
......@@ -37,6 +37,8 @@
#ifndef _BASICTYPES_INCLUDED_
#define _BASICTYPES_INCLUDED_
namespace glslang {
//
// Basic type. Arrays, vectors, sampler details, etc., are orthogonal to this.
//
......@@ -97,7 +99,7 @@ enum TStorageQualifier {
};
// These will show up in error messages
__inline const char* getStorageQualifierString(TStorageQualifier q)
__inline const char* GetStorageQualifierString(TStorageQualifier q)
{
switch (q) {
case EvqTemporary: return "temporary"; break;
......@@ -133,7 +135,7 @@ enum TPrecisionQualifier {
EpqHigh
};
__inline const char* getPrecisionQualifierString(TPrecisionQualifier p)
__inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
{
switch(p) {
case EpqNone: return ""; break;
......@@ -144,4 +146,6 @@ __inline const char* getPrecisionQualifierString(TPrecisionQualifier p)
}
}
} // end namespace glslang
#endif // _BASICTYPES_INCLUDED_
......@@ -85,6 +85,8 @@
#define TBaseList std::list
#define TBaseSet std::set
namespace glslang {
//
// Pool version of string.
//
......@@ -170,4 +172,6 @@ typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
const int GlslangMaxTokenLength = 1024;
} // end namespace glslang
#endif // _COMMON_INCLUDED_
......@@ -37,8 +37,9 @@
#ifndef _CONSTANT_UNION_INCLUDED_
#define _CONSTANT_UNION_INCLUDED_
namespace glslang {
class constUnion {
class TConstUnion {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
......@@ -103,7 +104,7 @@ public:
return false;
}
bool operator==(const constUnion& constant) const
bool operator==(const TConstUnion& constant) const
{
if (constant.type != type)
return false;
......@@ -156,12 +157,12 @@ public:
return !operator==(b);
}
bool operator!=(const constUnion& constant) const
bool operator!=(const TConstUnion& constant) const
{
return !operator==(constant);
}
bool operator>(const constUnion& constant) const
bool operator>(const TConstUnion& constant) const
{
assert(type == constant.type);
switch (type) {
......@@ -188,7 +189,7 @@ public:
return false;
}
bool operator<(const constUnion& constant) const
bool operator<(const TConstUnion& constant) const
{
assert(type == constant.type);
switch (type) {
......@@ -215,9 +216,9 @@ public:
return false;
}
constUnion operator+(const constUnion& constant) const
TConstUnion operator+(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
......@@ -229,9 +230,9 @@ public:
return returnValue;
}
constUnion operator-(const constUnion& constant) const
TConstUnion operator-(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
......@@ -243,9 +244,9 @@ public:
return returnValue;
}
constUnion operator*(const constUnion& constant) const
TConstUnion operator*(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
......@@ -257,9 +258,9 @@ public:
return returnValue;
}
constUnion operator%(const constUnion& constant) const
TConstUnion operator%(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
......@@ -270,9 +271,9 @@ public:
return returnValue;
}
constUnion operator>>(const constUnion& constant) const
TConstUnion operator>>(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
switch (type) {
case EbtInt:
switch (constant.type) {
......@@ -294,9 +295,9 @@ public:
return returnValue;
}
constUnion operator<<(const constUnion& constant) const
TConstUnion operator<<(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
switch (type) {
case EbtInt:
switch (constant.type) {
......@@ -318,9 +319,9 @@ public:
return returnValue;
}
constUnion operator&(const constUnion& constant) const
TConstUnion operator&(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
......@@ -331,9 +332,9 @@ public:
return returnValue;
}
constUnion operator|(const constUnion& constant) const
TConstUnion operator|(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
......@@ -344,9 +345,9 @@ public:
return returnValue;
}
constUnion operator^(const constUnion& constant) const
TConstUnion operator^(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
......@@ -357,9 +358,9 @@ public:
return returnValue;
}
constUnion operator~() const
TConstUnion operator~() const
{
constUnion returnValue;
TConstUnion returnValue;
switch (type) {
case EbtInt: returnValue.setIConst(~iConst); break;
case EbtUint: returnValue.setUConst(~uConst); break;
......@@ -369,9 +370,9 @@ public:
return returnValue;
}
constUnion operator&&(const constUnion& constant) const
TConstUnion operator&&(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
......@@ -381,9 +382,9 @@ public:
return returnValue;
}
constUnion operator||(const constUnion& constant) const
TConstUnion operator||(const TConstUnion& constant) const
{
constUnion returnValue;
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
......@@ -406,4 +407,6 @@ private:
TBasicType type;
};
} // end namespace glslang
#endif // _CONSTANT_UNION_INCLUDED_
......@@ -38,6 +38,8 @@
#include "../Include/Common.h"
#include <math.h>
namespace glslang {
//
// TPrefixType is used to centralize how info log messages start.
// See below.
......@@ -131,10 +133,12 @@ protected:
int outputStream;
};
} // end namespace glslang
class TInfoSink {
public:
TInfoSinkBase info;
TInfoSinkBase debug;
glslang::TInfoSinkBase info;
glslang::TInfoSinkBase debug;
};
#endif // _INFOSINK_INCLUDED_
......@@ -35,9 +35,13 @@
#ifndef __INITIALIZE_GLOBALS_INCLUDED_
#define __INITIALIZE_GLOBALS_INCLUDED_
namespace glslang {
void InitializeGlobalPools();
void FreeGlobalPools();
bool InitializePoolIndex();
void FreePoolIndex();
} // end namespace glslang
#endif // __INITIALIZE_GLOBALS_INCLUDED_
......@@ -65,6 +65,8 @@
#include <string.h>
#include <vector>
namespace glslang {
// If we are using guard blocks, we must track each indivual
// allocation. If we aren't using guard blocks, these
// never get instantiated, so won't have any impact.
......@@ -316,4 +318,6 @@ protected:
TPoolAllocator& allocator;
};
} // end namespace glslang
#endif // _POOLALLOC_INCLUDED_
......@@ -58,4 +58,5 @@ struct TBuiltInResource {
int minProgramTexelOffset;
int maxProgramTexelOffset;
};
#endif // _RESOURCE_LIMITS_INCLUDED_
......@@ -52,7 +52,6 @@ class TCompiler;
class TLinker;
class TUniformMap;
//
// The base class used to back handles returned to the driver.
//
......@@ -78,6 +77,7 @@ public:
virtual TInfoSink& getInfoSink() { return infoSink; }
TInfoSink infoSink;
};
class TIntermNode;
//
......@@ -105,8 +105,8 @@ protected:
//
// Link operations are base on a list of compile results...
//
typedef TVector<TCompiler*> TCompilerList;
typedef TVector<TShHandleBase*> THandleList;
typedef glslang::TVector<TCompiler*> TCompilerList;
typedef glslang::TVector<TShHandleBase*> THandleList;
//
// The base class for the machine dependent linker to derive from
......
......@@ -40,6 +40,8 @@
#include "../Include/Common.h"
#include "../Include/BaseTypes.h"
namespace glslang {
const int GlslangMaxTypeLength = 200;
//
......@@ -680,8 +682,8 @@ public:
return getBasicString();
}
const char* getStorageQualifierString() const { return ::getStorageQualifierString(qualifier.storage); }
const char* getPrecisionQualifierString() const { return ::getPrecisionQualifierString(qualifier.precision); }
const char* getStorageQualifierString() const { return GetStorageQualifierString(qualifier.storage); }
const char* getPrecisionQualifierString() const { return GetPrecisionQualifierString(qualifier.precision); }
TTypeList* getStruct() { return structure; }
TTypeList* getStruct() const { return structure; }
......@@ -753,4 +755,6 @@ protected:
TString *typeName; // for structure field type name
};
} // end namespace glslang
#endif // _TYPES_INCLUDED_
......@@ -50,6 +50,8 @@
#include "../Include/Types.h"
#include "../Include/ConstantUnion.h"
namespace glslang {
//
// Operators used by the high-level (parse tree) representation.
//
......@@ -324,34 +326,41 @@ class TIntermBranch;
class TIntermTyped;
class TIntermMethod;
class TIntermSymbol;
class TInfoSink;
} // end namespace glslang
//
// Base class for the tree nodes
//
// (Put outside the glslang namespace, as it's used as part of the external interface.)
//
class TIntermNode {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
POOL_ALLOCATOR_NEW_DELETE(glslang::GetThreadPoolAllocator())
TIntermNode() { loc.line = 0; loc.string = 0; }
virtual TSourceLoc getLoc() const { return loc; }
virtual void setLoc(TSourceLoc l) { loc = l; }
virtual void traverse(TIntermTraverser*) = 0;
virtual TIntermTyped* getAsTyped() { return 0; }
virtual TIntermConstantUnion* getAsConstantUnion() { return 0; }
virtual TIntermAggregate* getAsAggregate() { return 0; }
virtual TIntermUnary* getAsUnaryNode() { return 0; }
virtual TIntermBinary* getAsBinaryNode() { return 0; }
virtual TIntermSelection* getAsSelectionNode() { return 0; }
virtual TIntermSwitch* getAsSwitchNode() { return 0; }
virtual TIntermMethod* getAsMethodNode() { return 0; }
virtual TIntermSymbol* getAsSymbolNode() { return 0; }
virtual TIntermBranch* getAsBranchNode() { return 0; }
virtual glslang::TSourceLoc getLoc() const { return loc; }
virtual void setLoc(glslang::TSourceLoc l) { loc = l; }
virtual void traverse(glslang::TIntermTraverser*) = 0;
virtual glslang::TIntermTyped* getAsTyped() { return 0; }
virtual glslang::TIntermConstantUnion* getAsConstantUnion() { return 0; }
virtual glslang::TIntermAggregate* getAsAggregate() { return 0; }
virtual glslang::TIntermUnary* getAsUnaryNode() { return 0; }
virtual glslang::TIntermBinary* getAsBinaryNode() { return 0; }
virtual glslang::TIntermSelection* getAsSelectionNode() { return 0; }
virtual glslang::TIntermSwitch* getAsSwitchNode() { return 0; }
virtual glslang::TIntermMethod* getAsMethodNode() { return 0; }
virtual glslang::TIntermSymbol* getAsSymbolNode() { return 0; }
virtual glslang::TIntermBranch* getAsBranchNode() { return 0; }
virtual ~TIntermNode() { }
protected:
TSourceLoc loc;
glslang::TSourceLoc loc;
};
class TInfoSink;
namespace glslang {
//
// This is just to help yacc.
//
......@@ -465,15 +474,15 @@ protected:
class TIntermConstantUnion : public TIntermTyped {
public:
TIntermConstantUnion(constUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
constUnion* getUnionArrayPointer() const { return unionArrayPointer; }
void setUnionArrayPointer(constUnion *c) { unionArrayPointer = c; }
TIntermConstantUnion(TConstUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
TConstUnion* getUnionArrayPointer() const { return unionArrayPointer; }
void setUnionArrayPointer(TConstUnion *c) { unionArrayPointer = c; }
virtual TIntermConstantUnion* getAsConstantUnion() { return this; }
virtual void traverse(TIntermTraverser* );
virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&);
virtual TIntermTyped* fold(TOperator, const TType&, TInfoSink&);
protected:
constUnion *unionArrayPointer;
TConstUnion *unionArrayPointer;
};
//
......@@ -646,4 +655,6 @@ public:
bool rightToLeft;
};
} // end namespace glslang
#endif // __INTERMEDIATE_H
......@@ -36,6 +36,8 @@
#include <string.h>
namespace glslang {
void TInfoSinkBase::append(const char *s)
{
if (outputStream & EString) {
......@@ -103,3 +105,5 @@ void TInfoSinkBase::append(const TString& t)
if (outputStream & EStdOut)
fprintf(stdout, "%s", t.c_str());
}
} // end namespace glslang
......@@ -43,6 +43,8 @@
#include "../Include/intermediate.h"
#include "Initialize.h"
namespace glslang {
const int FirstProfileVersion = 150;
const bool ForwardCompatibility = false;
......@@ -1663,3 +1665,5 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
break;
}
}
} // end namespace glslang
......@@ -43,6 +43,8 @@
#include "SymbolTable.h"
#include "Versions.h"
namespace glslang {
class TBuiltIns {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
......@@ -71,4 +73,6 @@ protected:
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&);
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
} // end namespace glslang
#endif // _INITIALIZE_INCLUDED_
......@@ -36,6 +36,8 @@
#include "../Include/intermediate.h"
namespace glslang {
//
// Traverse the intermediate representation tree, and
// call a node type specific function for each node.
......@@ -275,3 +277,5 @@ void TIntermSwitch::traverse(TIntermTraverser* it)
if (visit && it->postVisit && it->visitSwitch)
it->visitSwitch(false, this, it);
}
} // end namespace glslang
......@@ -43,6 +43,8 @@
#include "RemoveTree.h"
#include <float.h>
namespace glslang {
////////////////////////////////////////////////////////////////////////////
//
// First set of functions are to help build the intermediate representation.
......@@ -794,7 +796,7 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
// Returns the constant union node created.
//
TIntermConstantUnion* TIntermediate::addConstantUnion(constUnion* unionArrayPointer, const TType& t, TSourceLoc loc)
TIntermConstantUnion* TIntermediate::addConstantUnion(TConstUnion* unionArrayPointer, const TType& t, TSourceLoc loc)
{
TIntermConstantUnion* node = new TIntermConstantUnion(unionArrayPointer, t);
node->setLoc(loc);
......@@ -810,10 +812,10 @@ TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc loc)
node->setLoc(loc);
TIntermConstantUnion* constIntNode;
TIntermSequence &sequenceVector = node->getSequence();
constUnion* unionArray;
TConstUnion* unionArray;
for (int i = 0; i < fields.num; i++) {
unionArray = new constUnion[1];
unionArray = new TConstUnion[1];
unionArray->setIConst(fields.offsets[i]);
constIntNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
sequenceVector.push_back(constIntNode);
......@@ -1398,10 +1400,10 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
if (node->getType().isArray())
infoSink.info.message(EPrefixInternalError, "Cannot promote array", node->getLoc());
constUnion *rightUnionArray = node->getUnionArrayPointer();
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
int size = node->getType().getObjectSize();
constUnion *leftUnionArray = new constUnion[size];
TConstUnion *leftUnionArray = new TConstUnion[size];
for (int i=0; i < size; i++) {
switch (promoteTo) {
......@@ -1526,3 +1528,4 @@ void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)
*pragmaTable = pTable;
}
} // end namespace glslang
//
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _MMAP_INCLUDED_
#define _MMAP_INCLUDED_
//
// Encapsulate memory mapped files
//
class TMMap {
public:
TMMap(const char* fileName) :
fSize(-1), // -1 is the error value returned by GetFileSize()
fp(NULL),
fBuff(0) // 0 is the error value returned by MapViewOfFile()
{
if ((fp = fopen(fileName, "r")) == NULL)
return;
char c = getc(fp);
fSize = 0;
while (c != EOF) {
fSize++;
c = getc(fp);
}
if (c == EOF)
fSize++;
rewind(fp);
fBuff = (char*)malloc(sizeof(char) * fSize);
int count = 0;
c = getc(fp);
while (c != EOF) {
fBuff[count++] = c;
c = getc(fp);
}
fBuff[count++] = c;
}
char* getData() { return fBuff; }
int getSize() { return fSize; }
~TMMap() {
if (fp != NULL)
fclose(fp);
}
private:
int fSize; // size of file to map in
FILE *fp;
char* fBuff; // the actual data;
};
#endif // _MMAP_INCLUDED_
......@@ -41,6 +41,8 @@
#include "SymbolTable.h"
#include "localintermediate.h"
namespace glslang {
typedef enum {
EBhRequire,
EBhEnable,
......@@ -55,12 +57,9 @@ struct TPragma {
TPragmaTable pragmaTable;
};
class TScanContext;
class TPpContext;
namespace glslang {
class TScanContext;
};
//
// The following are extra variables needed during parsing, grouped together so
// they can be passed to the parser without needing a global.
......@@ -70,7 +69,7 @@ public:
TParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins, int version, EProfile, EShLanguage, TInfoSink&,
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
glslang::TScanContext* scanContext;
TScanContext* scanContext;
TPpContext* ppContext;
TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
......@@ -200,4 +199,6 @@ public:
void doubleCheck(TSourceLoc, const char* op);
};
} // end namespace glslang
#endif // _PARSER_HELPER_INCLUDED_
......@@ -38,6 +38,8 @@
#include "Include/InitializeGlobals.h"
#include "osinclude.h"
namespace glslang {
OS_TLSIndex PoolIndex;
void InitializeGlobalPools()
......@@ -333,3 +335,5 @@ void TAllocation::checkAllocList() const
for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
alloc->check();
}
} // end namespace glslang
......@@ -36,6 +36,8 @@
#include "../Include/intermediate.h"
namespace glslang {
class TAliveTraverser : public TIntermTraverser {
public:
TAliveTraverser(TStorageQualifier q) : TIntermTraverser(), found(false), qualifier(q)
......@@ -92,4 +94,6 @@ bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
return true;
}
} // end namespace glslang
#endif
......@@ -32,4 +32,8 @@
//POSSIBILITY OF SUCH DAMAGE.
//
namespace glslang {
bool QualifierWritten(TIntermNode* root, TStorageQualifier);
} // end namespace glslang
......@@ -36,6 +36,9 @@
#include "../Include/intermediate.h"
#include "RemoveTree.h"
namespace glslang {
//
// Code to recursively delete the intermediate tree.
//
......@@ -106,3 +109,4 @@ void RemoveAllTreeNodes(TIntermNode* root)
root->traverse(&it);
}
} // end namespace glslang
......@@ -32,4 +32,8 @@
//POSSIBILITY OF SUCH DAMAGE.
//
namespace glslang {
void RemoveAllTreeNodes(TIntermNode*);
} // end namespace glslang
......@@ -230,10 +230,6 @@ bool ScanVersion(TInputScanner& input, int& version, EProfile& profile)
return foundNonSpaceTab;
}
}; // end glslang namespace
namespace glslang {
// Fill this in when doing glslang-level scanning, to hand back to the parser.
class TParserToken {
public:
......@@ -242,10 +238,10 @@ public:
YYSTYPE& sType;
};
}; // end namespace glslang
} // end namespace glslang
// This is the function the glslang parser (i.e., bison) calls to get its next token
int yylex(YYSTYPE* glslangTokenDesc, TParseContext& parseContext)
int yylex(YYSTYPE* glslangTokenDesc, glslang::TParseContext& parseContext)
{
glslang::TParserToken token(*glslangTokenDesc);
......@@ -1012,4 +1008,4 @@ int TScanContext::secondGenerationImage()
return identifierOrType();
}
};
} // end namespace glslang
......@@ -112,4 +112,4 @@ bool ConsumeComment(TInputScanner& input);
void ConsumeWhitespaceComment(TInputScanner& input, bool& foundNonSpaceTab);
bool ScanVersion(TInputScanner& input, int& version, EProfile& profile);
}; // end glslang namespace
} // end namespace glslang
......@@ -40,11 +40,10 @@
#include "ParseHelper.h"
class TPpContext;
class TPpToken;
namespace glslang {
class TPpContext;
class TPpToken;
class TParserToken;
class TScanContext {
......@@ -79,4 +78,4 @@ protected:
int keyword;
};
};
} // end namespace glslang
......@@ -57,6 +57,8 @@
namespace { // anonymous namespace for file-local functions and symbols
using namespace glslang;
int MapVersionToIndex(int version)
{
switch(version) {
......@@ -105,7 +107,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
TParseContext parseContext(symbolTable, intermediate, true, version, profile, language, infoSink);
TPpContext ppContext(parseContext);
glslang::TScanContext scanContext(parseContext);
TScanContext scanContext(parseContext);
parseContext.scanContext = &scanContext;
parseContext.ppContext = &ppContext;
......@@ -310,7 +312,7 @@ bool DeduceProfile(TInfoSink& infoSink, int version, EProfile& profile)
return true;
}
}; // end anonymous namespace for local functions
} // end anonymous namespace for local functions
//
// ShInitialize() should be called exactly once per process, not per thread.
......
......@@ -41,6 +41,8 @@
#include "SymbolTable.h"
namespace glslang {
//
// TType helper function needs a place to live.
//
......@@ -222,7 +224,7 @@ TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol
if (copyOf.unionArray) {
assert(!copyOf.type.getStruct());
assert(copyOf.type.getObjectSize() == 1);
unionArray = new constUnion[1];
unionArray = new TConstUnion[1];
unionArray[0] = copyOf.unionArray[0];
} else
unionArray = 0;
......@@ -283,3 +285,5 @@ void TSymbolTable::copyTable(const TSymbolTable& copyOf)
for (unsigned int i = 0; i < copyOf.table.size(); ++i)
table.push_back(copyOf.table[i]->clone(remapper));
}
} // end namespace glslang
......@@ -69,6 +69,8 @@
#include "../Include/intermediate.h"
#include "../Include/InfoSink.h"
namespace glslang {
//
// Symbol base class. (Can build functions or variables out of these...)
//
......@@ -126,16 +128,16 @@ public:
virtual void dump(TInfoSink &infoSink) const;
constUnion* getConstUnionPointer() {
TConstUnion* getConstUnionPointer() {
if (!unionArray)
unionArray = new constUnion[type.getObjectSize()];
unionArray = new TConstUnion[type.getObjectSize()];
return unionArray;
}
constUnion* getConstUnionPointer() const { return unionArray; }
TConstUnion* getConstUnionPointer() const { return unionArray; }
void shareConstPointer( constUnion *constArray)
void shareConstPointer( TConstUnion *constArray)
{
delete unionArray;
unionArray = constArray;
......@@ -150,7 +152,7 @@ protected:
bool userType;
// we are assuming that Pool Allocator will free the memory allocated to unionArray
// when this object is destroyed
constUnion *unionArray;
TConstUnion *unionArray;
TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
};
......@@ -479,4 +481,6 @@ protected:
unsigned int adoptedLevels;
};
} // end namespace glslang
#endif // _SYMBOL_TABLE_INCLUDED_
......@@ -44,6 +44,8 @@
#include "ParseHelper.h"
namespace glslang {
const char* StageName[EShLangCount] = {
"vertex",
"tessellation control",
......@@ -164,3 +166,5 @@ void TParseContext::doubleCheck(TSourceLoc loc, const char* op)
profileRequires(loc, ECoreProfile, 400, 0, op);
profileRequires(loc, ECompatibilityProfile, 400, 0, op);
}
} // end namespace glslang
......@@ -35,8 +35,8 @@
//
/**
* This is bison grammar and production code for parsing the OpenGL 2.0 shading
* languages.
* This is bison grammar and productions for parsing all versions of the
* GLSL shading languages.
*/
%{
......@@ -59,37 +59,39 @@ Jutta Degener, 1995
#include "ParseHelper.h"
#include "../Public/ShaderLang.h"
using namespace glslang;
%}
%union {
struct {
TSourceLoc loc;
glslang::TSourceLoc loc;
union {
TString *string;
glslang::TString *string;
int i;
unsigned int u;
bool b;
double d;
};
TSymbol* symbol;
glslang::TSymbol* symbol;
} lex;
struct {
TSourceLoc loc;
TOperator op;
glslang::TSourceLoc loc;
glslang::TOperator op;
union {
TIntermNode* intermNode;
TIntermNodePair nodePair;
TIntermTyped* intermTypedNode;
TIntermAggregate* intermAggregate;
glslang::TIntermNodePair nodePair;
glslang::TIntermTyped* intermTypedNode;
glslang::TIntermAggregate* intermAggregate;
};
union {
TPublicType type;
TFunction* function;
TParameter param;
TTypeLoc typeLine;
TTypeList* typeList;
TArraySizes arraySizes;
TIdentifierList* identifierList;
glslang::TPublicType type;
glslang::TFunction* function;
glslang::TParameter param;
glslang::TTypeLoc typeLine;
glslang::TTypeList* typeList;
glslang::TArraySizes arraySizes;
glslang::TIdentifierList* identifierList;
};
} interm;
}
......@@ -224,29 +226,29 @@ primary_expression
$$ = $1;
}
| INTCONSTANT {
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setIConst($1.i);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.loc);
}
| UINTCONSTANT {
parseContext.fullIntegerCheck($1.loc, "unsigned literal");
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setUConst($1.u);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), $1.loc);
}
| FLOATCONSTANT {
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setDConst($1.d);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.loc);
}
| DOUBLECONSTANT {
parseContext.doubleCheck($1.loc, "double literal");
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setDConst($1.d);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtDouble, EvqConst), $1.loc);
}
| BOOLCONSTANT {
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst($1.b);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.loc);
}
......@@ -511,7 +513,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "<", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
......@@ -520,7 +522,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, ">", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
......@@ -529,7 +531,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "<=", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
......@@ -538,7 +540,7 @@ relational_expression
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, ">=", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
......@@ -551,7 +553,7 @@ equality_expression
$$ = parseContext.intermediate.addBinaryMath(EOpEqual, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "==", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} else if (($1->isArray() || $3->isArray()))
......@@ -561,7 +563,7 @@ equality_expression
$$ = parseContext.intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "!=", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
} else if (($1->isArray() || $3->isArray()))
......@@ -611,7 +613,7 @@ logical_and_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "&&", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
......@@ -624,7 +626,7 @@ logical_xor_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "^^", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
......@@ -637,7 +639,7 @@ logical_or_expression
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.loc);
if ($$ == 0) {
parseContext.binaryOpError($2.loc, "||", $1->getCompleteString(), $3->getCompleteString());
constUnion *unionArray = new constUnion[1];
TConstUnion *unionArray = new TConstUnion[1];
unionArray->setBConst(false);
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
}
......@@ -871,7 +873,7 @@ function_header
: fully_specified_type IDENTIFIER LEFT_PAREN {
if ($1.qualifier.storage != EvqGlobal && $1.qualifier.storage != EvqTemporary) {
parseContext.error($2.loc, "no qualifiers allowed for function return",
getStorageQualifierString($1.qualifier.storage), "");
GetStorageQualifierString($1.qualifier.storage), "");
}
// Add the function as a prototype after parsing it (we do not support recursion)
......
......@@ -36,6 +36,8 @@
#include "localintermediate.h"
namespace glslang {
//
// Two purposes:
// 1. Show an example of how to iterate tree. Functions can
......@@ -584,3 +586,5 @@ void TIntermediate::outputTree(TIntermNode* root)
root->traverse(&it);
}
} // end namespace glslang
......@@ -40,6 +40,8 @@
#include "SymbolTable.h"
#include "Versions.h"
namespace glslang {
struct TVectorFields {
int offsets[4];
int num;
......@@ -48,7 +50,6 @@ struct TVectorFields {
//
// Set of helper functions to help parse and build the tree.
//
class TInfoSink;
class TIntermediate {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
......@@ -74,9 +75,9 @@ public:
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, TSourceLoc);
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
TIntermConstantUnion* addConstantUnion(TConstUnion*, const TType&, TSourceLoc);
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, const TType&, bool singleConstantParam = false);
bool parseConstTree(TSourceLoc, TIntermNode*, TConstUnion*, TOperator, const TType&, bool singleConstantParam = false);
TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
TIntermBranch* addBranch(TOperator, TSourceLoc);
TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
......@@ -97,4 +98,6 @@ private:
void operator=(TIntermediate&); // prevent assignments
};
} // end namespace glslang
#endif // _LOCAL_INTERMEDIATE_INCLUDED_
......@@ -34,17 +34,19 @@
#include "ParseHelper.h"
namespace glslang {
//
// Use this class to carry along data from node to node in
// the traversal
//
class TConstTraverser : public TIntermTraverser {
public:
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, const TType& t) : unionArray(cUnion), type(t),
TConstTraverser(TConstUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, const TType& t) : unionArray(cUnion), type(t),
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), error(false), isMatrix(false),
matrixCols(0), matrixRows(0) { index = 0; tOp = EOpNull;}
int index ;
constUnion *unionArray;
TConstUnion *unionArray;
TOperator tOp;
const TType& type;
TOperator constructorType;
......@@ -173,7 +175,7 @@ bool ParseSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverse
void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
{
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
constUnion* leftUnionArray = oit->unionArray;
TConstUnion* leftUnionArray = oit->unionArray;
int instanceSize = oit->type.getObjectSize();
if (oit->index >= instanceSize)
......@@ -182,7 +184,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
if (!oit->singleConstantParam) {
int size = node->getType().getObjectSize();
constUnion *rightUnionArray = node->getUnionArrayPointer();
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
for (int i=0; i < size; i++) {
if (oit->index >= instanceSize)
return;
......@@ -198,7 +200,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
matrixRows = oit->matrixRows;
isMatrix = oit->isMatrix;
totalSize = oit->index + size;
constUnion *rightUnionArray = node->getUnionArrayPointer();
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
if (!isMatrix) {
int count = 0;
for (int i = oit->index; i < totalSize; i++) {
......@@ -255,7 +257,7 @@ bool ParseBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)
// Individual functions can be initialized to 0 to skip processing of that
// type of node. It's children will still be processed.
//
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, const TType& t, bool singleConstantParam)
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, TConstUnion* unionArray, TOperator constructorType, const TType& t, bool singleConstantParam)
{
if (root == 0)
return false;
......@@ -277,3 +279,5 @@ bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnio
else
return false;
}
} // end namespace glslang
......@@ -94,6 +94,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef malloc
#undef free
namespace glslang {
int TPpContext::InitCPP()
{
TPpContext::AtomTable* atable = &atomTable;
......@@ -821,8 +823,8 @@ void TPpContext::FreeMacro(MacroSymbol *s) {
DeleteTokenStream(s->body);
}
static int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
static void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
void TPpContext::PushEofSrc()
{
......@@ -1074,3 +1076,5 @@ int TPpContext::ChkCorrectElseNesting()
return 0;
}
} // end namespace glslang
\ No newline at end of file
......@@ -94,11 +94,15 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef realloc
#undef free
namespace {
using namespace glslang;
///////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////// String table: //////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
static const struct {
const struct {
int val;
const char *str;
} tokens[] = {
......@@ -135,7 +139,6 @@ static const struct {
* InitStringTable() - Initialize the string table.
*
*/
int InitStringTable(TPpContext::StringTable *stable)
{
stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);
......@@ -151,7 +154,6 @@ int InitStringTable(TPpContext::StringTable *stable)
* FreeStringTable() - Free the string table.
*
*/
void FreeStringTable(TPpContext::StringTable *stable)
{
if (stable->strings)
......@@ -165,8 +167,7 @@ void FreeStringTable(TPpContext::StringTable *stable)
* HashString() - Hash a string with the base hash function.
*
*/
static int HashString(const char *s)
int HashString(const char *s)
{
int hval = 0;
......@@ -181,8 +182,7 @@ static int HashString(const char *s)
* HashString2() - Hash a string with the incrimenting hash function.
*
*/
static int HashString2(const char *s)
int HashString2(const char *s)
{
int hval = 0;
......@@ -197,8 +197,7 @@ static int HashString2(const char *s)
* AddString() - Add a string to a string table. Return it's offset.
*
*/
static int AddString(TPpContext::StringTable *stable, const char *s)
int AddString(TPpContext::StringTable *stable, const char *s)
{
int len, loc;
char *str;
......@@ -227,8 +226,7 @@ static int AddString(TPpContext::StringTable *stable, const char *s)
* InitHashTable() - Initialize the hash table.
*
*/
static int InitHashTable(TPpContext::HashTable *htable, int fsize)
int InitHashTable(TPpContext::HashTable *htable, int fsize)
{
int ii;
......@@ -250,8 +248,7 @@ static int InitHashTable(TPpContext::HashTable *htable, int fsize)
* FreeHashTable() - Free the hash table.
*
*/
static void FreeHashTable(TPpContext::HashTable *htable)
void FreeHashTable(TPpContext::HashTable *htable)
{
if (htable->entry)
free(htable->entry);
......@@ -264,8 +261,7 @@ static void FreeHashTable(TPpContext::HashTable *htable)
* Empty() - See if a hash table entry is empty.
*
*/
static int Empty(TPpContext::HashTable *htable, int hashloc)
int Empty(TPpContext::HashTable *htable, int hashloc)
{
assert(hashloc >= 0 && hashloc < htable->size);
if (htable->entry[hashloc].index == 0) {
......@@ -279,8 +275,7 @@ static int Empty(TPpContext::HashTable *htable, int hashloc)
* Match() - See if a hash table entry is matches a string.
*
*/
static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
{
int strloc;
......@@ -302,7 +297,6 @@ static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable,
* GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.
*
*/
int GrowAtomTable(TPpContext::AtomTable *atable, int size)
{
int *newmap, *newrev;
......@@ -337,8 +331,7 @@ int GrowAtomTable(TPpContext::AtomTable *atable, int size)
* lReverse() - Reverse the bottom 20 bits of a 32 bit int.
*
*/
static int lReverse(int fval)
int lReverse(int fval)
{
unsigned int in = fval;
int result = 0, cnt = 0;
......@@ -362,7 +355,6 @@ static int lReverse(int fval)
* AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1.
*
*/
int AllocateAtom(TPpContext::AtomTable *atable)
{
if (atable->nextFree >= atable->size)
......@@ -377,7 +369,6 @@ int AllocateAtom(TPpContext::AtomTable *atable)
* SetAtomValue() - Allocate a new atom associated with "hashindex".
*
*/
void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
{
atable->amap[atomnumber] = atable->htable.entry[hashindex].index;
......@@ -388,7 +379,6 @@ void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
* FindHashLoc() - Find the hash location for this string. Return -1 it hash table is full.
*
*/
int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
{
int hashloc, hashdelta, count;
......@@ -438,11 +428,14 @@ int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
return hashloc;
} // FindHashLoc
} // end anonymous namespace
namespace glslang {
/*
* IncreaseHashTableSize()
*
*/
int TPpContext::IncreaseHashTableSize(AtomTable *atable)
{
int ii, strloc, oldhashloc, value, size;
......@@ -705,7 +698,4 @@ void TPpContext::FreeAtomTable(AtomTable *atable)
atable->size = 0;
} // FreeAtomTable
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// End of atom.c ///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
} // end namespace glslang
......@@ -81,6 +81,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PpContext.h"
namespace glslang {
TPpContext::TPpContext(TParseContext& pc) :
parseContext(pc), preamble(0), strings(0), notAVersionToken(false),
ScopeList(0), CurrentScope(0), GlobalScope(0)
......@@ -124,3 +126,5 @@ void TPpContext::setShaderStrings(char* s[], int l[], int n)
currentString = 0;
}
}
} // end namespace glslang
......@@ -80,6 +80,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../ParseHelper.h"
namespace glslang {
class TPpToken {
public:
static const int maxTokenLength = 1024;
......@@ -386,5 +388,6 @@ protected:
int mem_AddCleanup(MemoryPool *p, void (*fn)(void *, void*), void *arg1, void* arg2);
};
#endif // PPCONTEXT_H
} // end namespace glslang
#endif // PPCONTEXT_H
......@@ -91,6 +91,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef malloc
#undef free
namespace glslang {
struct chunk {
struct chunk *next;
};
......@@ -184,3 +186,5 @@ int TPpContext::mem_AddCleanup(MemoryPool *pool, void (*fn)(void *, void*), void
pool->cleanup = cleanup;
return 0;
}
} // end namespace glslang
......@@ -89,13 +89,24 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PpContext.h"
#include "PpTokens.h"
static int eof_scan(TPpContext*, TPpContext::InputSrc*, TPpToken*)
namespace {
using namespace glslang;
int eof_scan(TPpContext*, TPpContext::InputSrc*, TPpToken*)
{
return EOF;
} // eof_scan
}
void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp)
{
}
static void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp) {}
static TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
} // end anonymous namespace
namespace glslang {
int TPpContext::InitScanner(TPpContext *cpp)
{
......@@ -831,7 +842,4 @@ int TPpContext::check_EOF(int token)
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// End of scanner.c //////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
} // end namespace glslang
......@@ -90,7 +90,11 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
static void unlinkScope(void *_scope, void* scopeList)
namespace {
using namespace glslang;
void unlinkScope(void *_scope, void* scopeList)
{
TPpContext::Scope *scope = (TPpContext::Scope*)_scope;
......@@ -102,6 +106,10 @@ static void unlinkScope(void *_scope, void* scopeList)
*(TPpContext::Scope**)scopeList = scope->next;
}
} // end anonymous namespace
namespace glslang {
/*
* NewScope()
*
......@@ -315,3 +323,4 @@ TPpContext::Symbol* TPpContext::LookUpSymbol(Scope *fScope, int atom)
return NULL;
} // LookUpSymbol
} // end namespace glslang
......@@ -92,6 +92,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PpContext.h"
#include "PpTokens.h"
namespace glslang {
///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
......@@ -488,6 +490,4 @@ void TPpContext::DumpTokenStream(FILE *fp, TokenStream *s, TPpToken * yylvalpp)
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// End of tokens.c ///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
} // end namespace glslang
......@@ -46,6 +46,7 @@
#define _vsnprintf vsnprintf
namespace glslang {
void DetachThreadLinux(void *);
......@@ -60,7 +61,7 @@ bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
{
//
// This function should return 0 if nIndex is invalid.
......@@ -69,18 +70,18 @@ inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
return pthread_getspecific(nIndex);
}
namespace glslang {
void InitGlobalLock();
void GetGlobalLock();
void ReleaseGlobalLock();
void InitGlobalLock();
void GetGlobalLock();
void ReleaseGlobalLock();
typedef unsigned int (*TThreadEntrypoint)(void*);
void* OS_CreateThread(TThreadEntrypoint);
void OS_WaitForAllThreads(void* threads, int numThreads);
typedef unsigned int (*TThreadEntrypoint)(void*);
void* OS_CreateThread(TThreadEntrypoint);
void OS_WaitForAllThreads(void* threads, int numThreads);
void OS_Sleep(int milliseconds);
void OS_Sleep(int milliseconds);
void OS_DumpMemoryCounters();
void OS_DumpMemoryCounters();
};
} // end namespace glslang
#endif // __OSINCLUDE_H
......@@ -38,6 +38,8 @@
#include "osinclude.h"
#include "InitializeDll.h"
namespace glslang {
//
// Thread cleanup
//
......@@ -135,25 +137,25 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
return false;
}
namespace glslang {
// TODO: if we need these on linux, flesh them out
void InitGlobalLock() { }
void GetGlobalLock() { }
void ReleaseGlobalLock() { }
// TODO: if we need these on linux, flesh them out
void InitGlobalLock() { }
void GetGlobalLock() { }
void ReleaseGlobalLock() { }
void* OS_CreateThread(TThreadEntrypoint entry)
{
}
void* OS_CreateThread(TThreadEntrypoint entry)
{
}
void OS_WaitForAllThreads(void* threads, int numThreads)
{
}
void OS_WaitForAllThreads(void* threads, int numThreads)
{
}
void OS_Sleep(int milliseconds)
{
}
void OS_Sleep(int milliseconds)
{
}
void OS_DumpMemoryCounters()
{
}
};
void OS_DumpMemoryCounters()
{
}
} // end namespace glslang
......@@ -45,24 +45,24 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
case DLL_PROCESS_ATTACH:
if (!InitProcess())
if (! glslang::InitProcess())
return FALSE;
break;
case DLL_THREAD_ATTACH:
if (!InitThread())
if (! glslang::InitThread())
return FALSE;
break;
case DLL_THREAD_DETACH:
if (!DetachThread())
if (! glslang::DetachThread())
return FALSE;
break;
case DLL_PROCESS_DETACH:
DetachProcess();
glslang::DetachProcess();
break;
default:
......
......@@ -44,6 +44,8 @@
#error Trying to include a windows specific file in a non windows build.
#endif
namespace glslang {
//
// Thread Local Storage Operations
//
......@@ -56,18 +58,18 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
void* OS_GetTLSValue(OS_TLSIndex nIndex);
namespace glslang {
void InitGlobalLock();
void GetGlobalLock();
void ReleaseGlobalLock();
void InitGlobalLock();
void GetGlobalLock();
void ReleaseGlobalLock();
typedef unsigned int (__stdcall *TThreadEntrypoint)(void*);
void* OS_CreateThread(TThreadEntrypoint);
void OS_WaitForAllThreads(void* threads, int numThreads);
typedef unsigned int (__stdcall *TThreadEntrypoint)(void*);
void* OS_CreateThread(TThreadEntrypoint);
void OS_WaitForAllThreads(void* threads, int numThreads);
void OS_Sleep(int milliseconds);
void OS_Sleep(int milliseconds);
void OS_DumpMemoryCounters();
void OS_DumpMemoryCounters();
};
} // end namespace glslang
#endif // __OSINCLUDE_H
......@@ -50,6 +50,8 @@
#error Trying to build a windows specific file in a non windows build.
#endif
namespace glslang {
//
// Thread Local Storage Operations
//
......@@ -97,44 +99,44 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
return false;
}
namespace glslang {
HANDLE GlobalLock;
HANDLE GlobalLock;
void InitGlobalLock()
{
void InitGlobalLock()
{
GlobalLock = CreateMutex(0, false, 0);
}
}
void GetGlobalLock()
{
void GetGlobalLock()
{
WaitForSingleObject(GlobalLock, INFINITE);
}
}
void ReleaseGlobalLock()
{
void ReleaseGlobalLock()
{
ReleaseMutex(GlobalLock);
}
}
void* OS_CreateThread(TThreadEntrypoint entry)
{
void* OS_CreateThread(TThreadEntrypoint entry)
{
return (void*)_beginthreadex(0, 0, entry, 0, 0, 0);
//return CreateThread(0, 0, entry, 0, 0, 0);
}
}
void OS_WaitForAllThreads(void* threads, int numThreads)
{
void OS_WaitForAllThreads(void* threads, int numThreads)
{
WaitForMultipleObjects(numThreads, (HANDLE*)threads, true, INFINITE);
}
}
void OS_Sleep(int milliseconds)
{
void OS_Sleep(int milliseconds)
{
Sleep(milliseconds);
}
}
void OS_DumpMemoryCounters()
{
void OS_DumpMemoryCounters()
{
PROCESS_MEMORY_COUNTERS counters;
GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters));
printf("Working set size: %d\n", counters.WorkingSetSize);
}
};
}
} // namespace glslang
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