diff options
Diffstat (limited to 'src/mesa/shader/slang/Include')
-rwxr-xr-x | src/mesa/shader/slang/Include/BaseTypes.h | 2 | ||||
-rwxr-xr-x | src/mesa/shader/slang/Include/Common.h | 22 | ||||
-rwxr-xr-x | src/mesa/shader/slang/Include/ConstantUnion.h | 2 | ||||
-rwxr-xr-x | src/mesa/shader/slang/Include/InfoSink.h | 2 | ||||
-rwxr-xr-x | src/mesa/shader/slang/Include/InitializeGlobals.h | 2 | ||||
-rwxr-xr-x | src/mesa/shader/slang/Include/InitializeParseContext.h | 2 | ||||
-rwxr-xr-x | src/mesa/shader/slang/Include/PoolAlloc.h | 26 | ||||
-rwxr-xr-x | src/mesa/shader/slang/Include/ResourceLimits.h | 11 | ||||
-rwxr-xr-x | src/mesa/shader/slang/Include/ShHandle.h | 26 | ||||
-rwxr-xr-x | src/mesa/shader/slang/Include/Types.h | 125 | ||||
-rwxr-xr-x | src/mesa/shader/slang/Include/intermediate.h | 25 |
11 files changed, 154 insertions, 91 deletions
diff --git a/src/mesa/shader/slang/Include/BaseTypes.h b/src/mesa/shader/slang/Include/BaseTypes.h index d79d9674a2c..c5bf8de17fe 100755 --- a/src/mesa/shader/slang/Include/BaseTypes.h +++ b/src/mesa/shader/slang/Include/BaseTypes.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
diff --git a/src/mesa/shader/slang/Include/Common.h b/src/mesa/shader/slang/Include/Common.h index ea37ccd3889..bd1aaa8fcf4 100755 --- a/src/mesa/shader/slang/Include/Common.h +++ b/src/mesa/shader/slang/Include/Common.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
@@ -45,8 +45,6 @@ #define UINT_PTR uintptr_t
#endif
-#include <assert.h>
-
/* windows only pragma */
#ifdef _MSC_VER
#pragma warning(disable : 4786) // Don't warn about too long identifiers
@@ -73,6 +71,7 @@ typedef int TSourceLoc;
+#include <assert.h>
#include "PoolAlloc.h"
//
@@ -194,7 +193,7 @@ public : //
typedef pool_allocator<char> TStringAllocator;
typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString;
-inline TString* NewPoolTString(char* s)
+inline TString* NewPoolTString(const char* s)
{
void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
return new(memory) TString(s);
@@ -253,13 +252,12 @@ inline const TString String(const int i, const int base = 10) {
char text[16]; // 32 bit ints are at most 10 digits in base 10
- // we assume base 10 or 16 for all cases
- if (base == 10)
- sprintf(text, "%d", i);
- else if (base == 16)
- sprintf(text, "%x", i);
- else
- assert (!"String(int): unsupported base");
+ #ifdef _WIN32
+ itoa(i, text, base);
+ #else
+ // we assume base 10 for all cases
+ sprintf(text, "%d", i);
+ #endif
return text;
}
@@ -281,5 +279,7 @@ __inline TPersistString FormatSourceLoc(const TSourceLoc loc) return TPersistString(locText);
}
+typedef TMap<TString, TString> TPragmaTable;
+typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
#endif // _COMMON_INCLUDED_
diff --git a/src/mesa/shader/slang/Include/ConstantUnion.h b/src/mesa/shader/slang/Include/ConstantUnion.h index 56059ea1ec0..a60ae114f68 100755 --- a/src/mesa/shader/slang/Include/ConstantUnion.h +++ b/src/mesa/shader/slang/Include/ConstantUnion.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
diff --git a/src/mesa/shader/slang/Include/InfoSink.h b/src/mesa/shader/slang/Include/InfoSink.h index eb02891291c..14d44a34adc 100755 --- a/src/mesa/shader/slang/Include/InfoSink.h +++ b/src/mesa/shader/slang/Include/InfoSink.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
diff --git a/src/mesa/shader/slang/Include/InitializeGlobals.h b/src/mesa/shader/slang/Include/InitializeGlobals.h index 7620c39d8b1..3d9a42a2b5f 100755 --- a/src/mesa/shader/slang/Include/InitializeGlobals.h +++ b/src/mesa/shader/slang/Include/InitializeGlobals.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
diff --git a/src/mesa/shader/slang/Include/InitializeParseContext.h b/src/mesa/shader/slang/Include/InitializeParseContext.h index ee6e8cefe6c..7d565b31321 100755 --- a/src/mesa/shader/slang/Include/InitializeParseContext.h +++ b/src/mesa/shader/slang/Include/InitializeParseContext.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
diff --git a/src/mesa/shader/slang/Include/PoolAlloc.h b/src/mesa/shader/slang/Include/PoolAlloc.h index 317ce0447d6..3649981ef2c 100755 --- a/src/mesa/shader/slang/Include/PoolAlloc.h +++ b/src/mesa/shader/slang/Include/PoolAlloc.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
@@ -84,8 +84,8 @@ public: }
void check() const {
- checkGuardBlock(preGuard(), (unsigned char) (guardBlockBeginVal), "before");
- checkGuardBlock(postGuard(), (unsigned char) (guardBlockEndVal), "after");
+ checkGuardBlock(preGuard(), guardBlockBeginVal, "before");
+ checkGuardBlock(postGuard(), guardBlockEndVal, "after");
}
void checkAllocList() const;
@@ -113,21 +113,16 @@ private: unsigned char* mem; // beginning of our allocation (pts to header)
TAllocation* prevAlloc; // prior allocation in the chain
- enum {
- guardBlockBeginVal = 0xfb,
- guardBlockEndVal = 0xfe,
- userDataFill = 0xcd
- };
+ // Support MSVC++ 6.0
+ const static unsigned char guardBlockBeginVal;
+ const static unsigned char guardBlockEndVal;
+ const static unsigned char userDataFill;
# ifdef GUARD_BLOCKS
- enum {
- guardBlockSize = 16
- };
+ const static size_t guardBlockSize;
inline static size_t headerSize() { return sizeof(TAllocation); }
# else
- enum {
- guardBlockSize = 0
- };
+ const static size_t guardBlockSize;
inline static size_t headerSize() { return 0; }
# endif
};
@@ -254,13 +249,10 @@ private: //
typedef TPoolAllocator* PoolAllocatorPointer;
extern TPoolAllocator& GetGlobalPoolAllocator();
-extern PoolAllocatorPointer& GetCompilerPoolAllocator();
#define GlobalPoolAllocator GetGlobalPoolAllocator()
-#define CompilerPoolAllocator GetCompilerPoolAllocator()
struct TThreadGlobalPools
{
TPoolAllocator* globalPoolAllocator;
- TPoolAllocator* compilerPoolAllocator;
};
//
diff --git a/src/mesa/shader/slang/Include/ResourceLimits.h b/src/mesa/shader/slang/Include/ResourceLimits.h index ec7277d890b..4ba0b07d07e 100755 --- a/src/mesa/shader/slang/Include/ResourceLimits.h +++ b/src/mesa/shader/slang/Include/ResourceLimits.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,10 @@ #ifndef _RESOURCE_LIMITS_INCLUDED_
#define _RESOURCE_LIMITS_INCLUDED_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct TBuiltInResource {
int maxLights;
int maxClipPlanes;
@@ -49,4 +53,9 @@ struct TBuiltInResource { int maxFragmentUniformComponents;
int maxDrawBuffers;
};
+
+#ifdef __cplusplus
+}
+#endif
+
#endif // _RESOURCE_LIMITS_INCLUDED_
diff --git a/src/mesa/shader/slang/Include/ShHandle.h b/src/mesa/shader/slang/Include/ShHandle.h index e7cb53b9cd4..6c654bdde2f 100755 --- a/src/mesa/shader/slang/Include/ShHandle.h +++ b/src/mesa/shader/slang/Include/ShHandle.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
@@ -101,32 +101,10 @@ public: virtual TCompiler* getAsCompiler() { return this; }
virtual bool linkable() { return haveValidObjectCode; }
- // Initialize our private pool for a new compilation, and
- // return it.
- virtual TPoolAllocator& getNewCompilationAllocator()
- {
- // We do a pop and push on the compiler pool, because compile can
- // be called repeatedly on the same compiler handle. Each time,
- // we want to pop away the results of any previous compile. We
- // could do that with popAll, but this is a somewhat smaller
- // hammer.
- compilerPool.pop();
- compilerPool.push();
-
- return compilerPool;
- }
-
- TPoolAllocator& getCompilerPoolAllocator() { return compilerPool; }
-
TInfoSink& infoSink;
protected:
EShLanguage language;
- bool haveValidObjectCode;
-
- // This is a per-compiler-object pool allocator. Allocations
- // who's lifetime need not extend beyond the lifetime of the
- // compiler itself can use this private pool.
- TPoolAllocator compilerPool;
+ bool haveValidObjectCode;
};
//
diff --git a/src/mesa/shader/slang/Include/Types.h b/src/mesa/shader/slang/Include/Types.h index 368b140342a..cd5a8617cb7 100755 --- a/src/mesa/shader/slang/Include/Types.h +++ b/src/mesa/shader/slang/Include/Types.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
@@ -74,6 +74,8 @@ public: int line;
};
+typedef std::map<TTypeList*, TTypeList*> TStructureMap;
+typedef std::map<TTypeList*, TTypeList*>::iterator TStructureMapIterator;
//
// Base class for things that have a type.
//
@@ -82,33 +84,91 @@ public: POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
explicit TType(TBasicType t, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
type(t), qualifier(q), size(s), matrix(m), array(a), arraySize(0),
- structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0)
+ structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), typeName(0), mangled(0), fieldName(0)
{ }
explicit TType(TPublicType p) :
type(p.type), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(0),
- structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0)
+ structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0)
{
if (p.userDef) {
structure = p.userDef->getStruct();
structureSize = setStructSize(p.userDef->getStruct());
- typeName = p.userDef->getTypeName();
+ typeName = NewPoolTString(p.userDef->getTypeName().c_str());
}
}
explicit TType(TTypeList* userDef, TString n) :
type(EbtStruct), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),
- structure(userDef), typeName(n), maxArraySize(0), arrayInformationType(0) {
+ structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0) {
structureSize = setStructSize(userDef);
+ typeName = NewPoolTString(n.c_str());
}
-
+ explicit TType() {}
virtual ~TType() {}
+
TType (const TType& type) { *this = type; }
+ void copyType(const TType& copyOf, TStructureMap& remapper)
+ {
+ type = copyOf.type;
+ qualifier = copyOf.qualifier;
+ size = copyOf.size;
+ matrix = copyOf.matrix;
+ array = copyOf.array;
+ arraySize = copyOf.arraySize;
+
+ TStructureMapIterator iter;
+ if (copyOf.structure) {
+ if ((iter = remapper.find(structure)) == remapper.end()) {
+ // create the new structure here
+ structure = NewPoolTTypeList();
+ for (unsigned int i = 0; i < copyOf.structure->size(); ++i) {
+ TTypeLine typeLine;
+ typeLine.line = (*copyOf.structure)[i].line;
+ typeLine.type = (*copyOf.structure)[i].type->clone(remapper);
+ structure->push_back(typeLine);
+ }
+ } else {
+ structure = iter->second;
+ }
+ } else
+ structure = 0;
+
+ fieldName = 0;
+ if (copyOf.fieldName)
+ fieldName = NewPoolTString(copyOf.fieldName->c_str());
+ typeName = 0;
+ if (copyOf.typeName)
+ typeName = NewPoolTString(copyOf.typeName->c_str());
+
+ mangled = 0;
+ if (copyOf.mangled)
+ mangled = NewPoolTString(copyOf.mangled->c_str());
+
+ structureSize = copyOf.structureSize;
+ maxArraySize = copyOf.maxArraySize;
+ assert (copyOf.arrayInformationType == 0);
+ arrayInformationType = 0; // arrayInformationType should not be set for builtIn symbol table level
+ }
+
+ TType* clone(TStructureMap& remapper)
+ {
+ TType *newType = new TType();
+ newType->copyType(*this, remapper);
+
+ return newType;
+ }
+
int setStructSize(TTypeList* userDef)
{
int stSize = 0;
for (TTypeList::iterator tl = userDef->begin(); tl != userDef->end(); tl++) {
if (((*tl).type)->isArray()) {
+ if (((*tl).type)->getStruct()) {
+ int structSize = setStructSize(((*tl).type)->getStruct());
+ stSize += structSize * ((*tl).type)->getArraySize();
+ } else {
stSize += ((*tl).type)->getInstanceSize() * ((*tl).type)->getArraySize();
+ }
} else if (((*tl).type)->isMatrix() || ((*tl).type)->isVector()){
stSize += ((*tl).type)->getInstanceSize();
} else if (((*tl).type)->getStruct()) {
@@ -132,10 +192,20 @@ public: structure = userDef->getStruct();
// leave array information intact.
}
- virtual void setTypeName(const TString& n) { typeName = n; }
- virtual void setFieldName(const TString& n) { fieldName = n; }
- virtual const TString& getTypeName() const { return typeName; }
- virtual const TString& getFieldName() const { return fieldName; }
+ virtual void setTypeName(const TString& n) { typeName = NewPoolTString(n.c_str()); }
+ virtual void setFieldName(const TString& n) { fieldName = NewPoolTString(n.c_str()); }
+ virtual const TString& getTypeName() const
+ {
+ assert (typeName);
+ return *typeName;
+ }
+
+ virtual const TString& getFieldName() const
+ {
+ assert (fieldName);
+ return *fieldName;
+ }
+
virtual TBasicType getBasicType() const { return type; }
virtual TQualifier getQualifier() const { return qualifier; }
virtual void changeQualifier(TQualifier q) { qualifier = q; }
@@ -152,8 +222,8 @@ public: return size;
}
- virtual bool isMatrix() const { return matrix; }
- virtual bool isArray() const { return array; }
+ virtual bool isMatrix() const { return matrix ? true : false; }
+ virtual bool isArray() const { return array ? true : false; }
int getArraySize() const { return arraySize; }
void setArraySize(int s) { array = true; arraySize = s; }
void setMaxArraySize (int s) { maxArraySize = s; }
@@ -180,14 +250,16 @@ public: const char* getBasicString() const { return TType::getBasicString(type); }
const char* getQualifierString() const { return ::getQualifierString(qualifier); }
TTypeList* getStruct() { return structure; }
- int getStructSize() { return structureSize; }
+ int getStructSize() const { return structureSize; }
TTypeList* getStruct() const { return structure; }
TString& getMangledName() {
- if (mangled.size() == 0) {
- buildMangledName(mangled);
- mangled+=';';
+ if (!mangled) {
+ mangled = NewPoolTString("");
+ buildMangledName(*mangled);
+ *mangled+=';';
}
- return mangled;
+
+ return *mangled;
}
bool operator==(const TType& right) const {
return type == right.type &&
@@ -203,21 +275,22 @@ public: TString getCompleteString() const;
protected:
- TBasicType type;
- TQualifier qualifier;
- int size; // size of vector or matrix, not size of array
- bool matrix;
- bool array;
+ void buildMangledName(TString&);
+
int arraySize;
TTypeList* structure; // 0 unless this is a struct
- TString fieldName; // for structure field names
- TString typeName; // for structure field type name
- TString mangled;
+ TString *fieldName; // for structure field names
+ TString *typeName; // for structure field type name
+ TString *mangled;
int structureSize;
int maxArraySize;
TType* arrayInformationType;
- void buildMangledName(TString&);
+ TQualifier qualifier : 7;
+ TBasicType type : 6;
+ int size : 8; // size of vector or matrix, not size of array
+ unsigned int matrix : 1;
+ unsigned int array : 1;
};
#endif // _TYPES_INCLUDED_
diff --git a/src/mesa/shader/slang/Include/intermediate.h b/src/mesa/shader/slang/Include/intermediate.h index 0c7d95ded2a..13e22c2749a 100755 --- a/src/mesa/shader/slang/Include/intermediate.h +++ b/src/mesa/shader/slang/Include/intermediate.h @@ -1,5 +1,5 @@ //
-//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,6 @@ //
// Operators used by the high-level (parse tree) representation.
//
-
enum TOperator {
EOpNull, // if in a node, should only mean a node is still being built
EOpSequence, // denotes a list of statements, or parameters, etc.
@@ -379,7 +378,7 @@ public: virtual bool promote(TInfoSink&) { return true; }
protected:
TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat)), op(o) {}
- TIntermOperator(TOperator o, TType t) : TIntermTyped(t), op(o) {}
+ TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {}
TOperator op;
};
@@ -406,7 +405,7 @@ protected: //
class TIntermUnary : public TIntermOperator {
public:
- TIntermUnary(TOperator o, TType t) : TIntermOperator(o, t), operand(0) {}
+ TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {}
TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {}
virtual void traverse(TIntermTraverser*);
virtual void setOperand(TIntermTyped* o) { operand = o; }
@@ -423,8 +422,9 @@ typedef TVector<int> TQualifierList; //
class TIntermAggregate : public TIntermOperator {
public:
- TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false) { }
- TIntermAggregate(TOperator o) : TIntermOperator(o) { }
+ TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false), pragmaTable(0) { }
+ TIntermAggregate(TOperator o) : TIntermOperator(o), pragmaTable(0) { }
+ ~TIntermAggregate() { delete pragmaTable; }
virtual TIntermAggregate* getAsAggregate() { return this; }
virtual void setOperator(TOperator o) { op = o; }
virtual TIntermSequence& getSequence() { return sequence; }
@@ -434,11 +434,22 @@ public: virtual void setUserDefined() { userDefined = true; }
virtual bool isUserDefined() { return userDefined; }
virtual TQualifierList& getQualifier() { return qualifier; }
+ void setOptimize(bool o) { optimize = o; }
+ void setDebug(bool d) { debug = d; }
+ bool getOptimize() { return optimize; }
+ bool getDebug() { return debug; }
+ void addToPragmaTable(const TPragmaTable& pTable);
+ const TPragmaTable& getPragmaTable() const { return *pragmaTable; }
protected:
+ TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
+ TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
TIntermSequence sequence;
TQualifierList qualifier;
TString name;
bool userDefined; // used for user defined function names
+ bool optimize;
+ bool debug;
+ TPragmaTable *pragmaTable;
};
//
@@ -448,7 +459,7 @@ class TIntermSelection : public TIntermTyped { public:
TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB) :
TIntermTyped(TType(EbtVoid)), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
- TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, TType type) :
+ TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, const TType& type) :
TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
virtual void traverse(TIntermTraverser*);
virtual TIntermNode* getCondition() const { return condition; }
|