Commit 53b76107 by Jamie Madill

Revert "Cache TTypes."

Unused variable warning in Release: warning C4189: 'MaxEnumValue' : local variable is initialized but not referenced I'll handle fixing this. BUG=492725 This reverts commit b25d14e4. Change-Id: I502fc5288d5d3c48ecd43f84acdf66b7e300ad22 Reviewed-on: https://chromium-review.googlesource.com/284863Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c70e1208
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
'compiler/translator/BuiltInFunctionEmulator.h', 'compiler/translator/BuiltInFunctionEmulator.h',
'compiler/translator/BuiltInFunctionEmulatorGLSL.cpp', 'compiler/translator/BuiltInFunctionEmulatorGLSL.cpp',
'compiler/translator/BuiltInFunctionEmulatorGLSL.h', 'compiler/translator/BuiltInFunctionEmulatorGLSL.h',
'compiler/translator/Cache.cpp',
'compiler/translator/Cache.h',
'compiler/translator/CallDAG.cpp', 'compiler/translator/CallDAG.cpp',
'compiler/translator/CallDAG.h', 'compiler/translator/CallDAG.h',
'compiler/translator/CodeGen.cpp', 'compiler/translator/CodeGen.cpp',
......
...@@ -18,10 +18,7 @@ enum TPrecision ...@@ -18,10 +18,7 @@ enum TPrecision
EbpUndefined, EbpUndefined,
EbpLow, EbpLow,
EbpMedium, EbpMedium,
EbpHigh, EbpHigh
// end of list
EbpLast
}; };
inline const char* getPrecisionString(TPrecision p) inline const char* getPrecisionString(TPrecision p)
...@@ -80,9 +77,6 @@ enum TBasicType ...@@ -80,9 +77,6 @@ enum TBasicType
EbtStruct, EbtStruct,
EbtInterfaceBlock, EbtInterfaceBlock,
EbtAddress, // should be deprecated?? EbtAddress, // should be deprecated??
// end of list
EbtLast
}; };
const char* getBasicString(TBasicType t); const char* getBasicString(TBasicType t);
......
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Cache.cpp: Implements a cache for various commonly created objects.
#include <limits>
#include "common/angleutils.h"
#include "common/debug.h"
#include "compiler/translator/Cache.h"
namespace
{
class TScopedAllocator : angle::NonCopyable
{
public:
TScopedAllocator(TPoolAllocator *allocator)
: mPreviousAllocator(GetGlobalPoolAllocator())
{
SetGlobalPoolAllocator(allocator);
}
~TScopedAllocator()
{
SetGlobalPoolAllocator(mPreviousAllocator);
}
private:
TPoolAllocator *mPreviousAllocator;
};
} // namespace
TCache::TypeKey::TypeKey(TBasicType basicType,
TPrecision precision,
TQualifier qualifier,
unsigned char primarySize,
unsigned char secondarySize)
{
static_assert(sizeof(components) <= sizeof(value),
"TypeKey::value is too small");
const size_t MaxEnumValue = std::numeric_limits<EnumComponentType>::max();
// TODO: change to static_assert() once we deprecate MSVC 2013 support
ASSERT(MaxEnumValue >= EbtLast &&
MaxEnumValue >= EbpLast &&
MaxEnumValue >= EvqLast &&
"TypeKey::EnumComponentType is too small");
value = 0;
components.basicType = static_cast<EnumComponentType>(basicType);
components.precision = static_cast<EnumComponentType>(precision);
components.qualifier = static_cast<EnumComponentType>(qualifier);
components.primarySize = primarySize;
components.secondarySize = secondarySize;
}
TCache *TCache::sCache = nullptr;
void TCache::initialize()
{
if (sCache == nullptr)
{
sCache = new TCache();
}
}
void TCache::destroy()
{
SafeDelete(sCache);
}
const TType *TCache::getType(TBasicType basicType,
TPrecision precision,
TQualifier qualifier,
unsigned char primarySize,
unsigned char secondarySize)
{
TypeKey key(basicType, precision, qualifier,
primarySize, secondarySize);
auto it = sCache->mTypes.find(key);
if (it != sCache->mTypes.end())
{
return it->second;
}
TScopedAllocator scopedAllocator(&sCache->mAllocator);
TType *type = new TType(basicType, precision, qualifier,
primarySize, secondarySize);
type->realize();
sCache->mTypes.insert(std::make_pair(key, type));
return type;
}
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Cache.h: Implements a cache for various commonly created objects.
#ifndef COMPILER_TRANSLATOR_CACHE_H_
#define COMPILER_TRANSLATOR_CACHE_H_
#include <stdint.h>
#include <string.h>
#include <map>
#include "compiler/translator/Types.h"
#include "compiler/translator/PoolAlloc.h"
class TCache
{
public:
static void initialize();
static void destroy();
static const TType *getType(TBasicType basicType,
TPrecision precision)
{
return getType(basicType, precision, EvqTemporary,
1, 1);
}
static const TType *getType(TBasicType basicType,
unsigned char primarySize = 1,
unsigned char secondarySize = 1)
{
return getType(basicType, EbpUndefined, EvqGlobal,
primarySize, secondarySize);
}
static const TType *getType(TBasicType basicType,
TQualifier qualifier,
unsigned char primarySize = 1,
unsigned char secondarySize = 1)
{
return getType(basicType, EbpUndefined, qualifier,
primarySize, secondarySize);
}
static const TType *getType(TBasicType basicType,
TPrecision precision,
TQualifier qualifier,
unsigned char primarySize,
unsigned char secondarySize);
private:
TCache()
{
}
union TypeKey
{
TypeKey(TBasicType basicType,
TPrecision precision,
TQualifier qualifier,
unsigned char primarySize,
unsigned char secondarySize);
typedef uint8_t EnumComponentType;
struct
{
EnumComponentType basicType;
EnumComponentType precision;
EnumComponentType qualifier;
unsigned char primarySize;
unsigned char secondarySize;
} components;
uint64_t value;
bool operator < (const TypeKey &other) const
{
return value < other.value;
}
};
typedef std::map<TypeKey, const TType*> TypeMap;
TypeMap mTypes;
TPoolAllocator mAllocator;
static TCache *sCache;
};
#endif // COMPILER_TRANSLATOR_CACHE_H_
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
#include "compiler/translator/Cache.h"
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
#include "compiler/translator/CallDAG.h" #include "compiler/translator/CallDAG.h"
#include "compiler/translator/ForLoopUnroll.h" #include "compiler/translator/ForLoopUnroll.h"
......
...@@ -11,26 +11,25 @@ ...@@ -11,26 +11,25 @@
// //
#include "compiler/translator/Initialize.h" #include "compiler/translator/Initialize.h"
#include "compiler/translator/Cache.h"
#include "compiler/translator/IntermNode.h" #include "compiler/translator/IntermNode.h"
#include "angle_gl.h" #include "angle_gl.h"
void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable) void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable)
{ {
const TType *float1 = TCache::getType(EbtFloat); TType *float1 = new TType(EbtFloat);
const TType *float2 = TCache::getType(EbtFloat, 2); TType *float2 = new TType(EbtFloat, 2);
const TType *float3 = TCache::getType(EbtFloat, 3); TType *float3 = new TType(EbtFloat, 3);
const TType *float4 = TCache::getType(EbtFloat, 4); TType *float4 = new TType(EbtFloat, 4);
const TType *int1 = TCache::getType(EbtInt); TType *int1 = new TType(EbtInt);
const TType *int2 = TCache::getType(EbtInt, 2); TType *int2 = new TType(EbtInt, 2);
const TType *int3 = TCache::getType(EbtInt, 3); TType *int3 = new TType(EbtInt, 3);
const TType *uint1 = TCache::getType(EbtUInt); TType *uint1 = new TType(EbtUInt);
const TType *bool1 = TCache::getType(EbtBool); TType *bool1 = new TType(EbtBool);
const TType *genType = TCache::getType(EbtGenType); TType *genType = new TType(EbtGenType);
const TType *genIType = TCache::getType(EbtGenIType); TType *genIType = new TType(EbtGenIType);
const TType *genUType = TCache::getType(EbtGenUType); TType *genUType = new TType(EbtGenUType);
const TType *genBType = TCache::getType(EbtGenBType); TType *genBType = new TType(EbtGenBType);
// //
// Angle and Trigonometric Functions. // Angle and Trigonometric Functions.
...@@ -103,10 +102,14 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR ...@@ -103,10 +102,14 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", genType, genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", genType, genType, genType);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", float1, float1, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", float1, float1, genType);
const TType *outFloat1 = TCache::getType(EbtFloat, EvqOut); TType *outFloat1 = new TType(EbtFloat);
const TType *outFloat2 = TCache::getType(EbtFloat, EvqOut, 2); TType *outFloat2 = new TType(EbtFloat, 2);
const TType *outFloat3 = TCache::getType(EbtFloat, EvqOut, 3); TType *outFloat3 = new TType(EbtFloat, 3);
const TType *outFloat4 = TCache::getType(EbtFloat, EvqOut, 4); TType *outFloat4 = new TType(EbtFloat, 4);
outFloat1->setQualifier(EvqOut);
outFloat2->setQualifier(EvqOut);
outFloat3->setQualifier(EvqOut);
outFloat4->setQualifier(EvqOut);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float1, "modf", float1, outFloat1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float1, "modf", float1, outFloat1);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float2, "modf", float2, outFloat2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float2, "modf", float2, outFloat2);
...@@ -139,15 +142,15 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR ...@@ -139,15 +142,15 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpReflect, genType, "reflect", genType, genType); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpReflect, genType, "reflect", genType, genType);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRefract, genType, "refract", genType, genType, float1); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRefract, genType, "refract", genType, genType, float1);
const TType *mat2 = TCache::getType(EbtFloat, 2, 2); TType *mat2 = new TType(EbtFloat, 2, 2);
const TType *mat3 = TCache::getType(EbtFloat, 3, 3); TType *mat3 = new TType(EbtFloat, 3, 3);
const TType *mat4 = TCache::getType(EbtFloat, 4, 4); TType *mat4 = new TType(EbtFloat, 4, 4);
const TType *mat2x3 = TCache::getType(EbtFloat, 2, 3); TType *mat2x3 = new TType(EbtFloat, 2, 3);
const TType *mat3x2 = TCache::getType(EbtFloat, 3, 2); TType *mat3x2 = new TType(EbtFloat, 3, 2);
const TType *mat2x4 = TCache::getType(EbtFloat, 2, 4); TType *mat2x4 = new TType(EbtFloat, 2, 4);
const TType *mat4x2 = TCache::getType(EbtFloat, 4, 2); TType *mat4x2 = new TType(EbtFloat, 4, 2);
const TType *mat3x4 = TCache::getType(EbtFloat, 3, 4); TType *mat3x4 = new TType(EbtFloat, 3, 4);
const TType *mat4x3 = TCache::getType(EbtFloat, 4, 3); TType *mat4x3 = new TType(EbtFloat, 4, 3);
// //
// Matrix Functions. // Matrix Functions.
...@@ -190,10 +193,10 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR ...@@ -190,10 +193,10 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat3, "inverse", mat3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat3, "inverse", mat3);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat4, "inverse", mat4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat4, "inverse", mat4);
const TType *vec = TCache::getType(EbtVec); TType *vec = new TType(EbtVec);
const TType *ivec = TCache::getType(EbtIVec); TType *ivec = new TType(EbtIVec);
const TType *uvec = TCache::getType(EbtUVec); TType *uvec = new TType(EbtUVec);
const TType *bvec = TCache::getType(EbtBVec); TType *bvec = new TType(EbtBVec);
// //
// Vector relational functions. // Vector relational functions.
...@@ -222,8 +225,8 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR ...@@ -222,8 +225,8 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAll, bool1, "all", bvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAll, bool1, "all", bvec);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorLogicalNot, bvec, "not", bvec); symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorLogicalNot, bvec, "not", bvec);
const TType *sampler2D = TCache::getType(EbtSampler2D); TType *sampler2D = new TType(EbtSampler2D);
const TType *samplerCube = TCache::getType(EbtSamplerCube); TType *samplerCube = new TType(EbtSamplerCube);
// //
// Texture Functions for GLSL ES 1.0 // Texture Functions for GLSL ES 1.0
...@@ -235,7 +238,7 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR ...@@ -235,7 +238,7 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR
if (resources.OES_EGL_image_external) if (resources.OES_EGL_image_external)
{ {
const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES); TType *samplerExternalOES = new TType(EbtSamplerExternalOES);
symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, float2); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, float2);
symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float3); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float3);
...@@ -244,7 +247,7 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR ...@@ -244,7 +247,7 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR
if (resources.ARB_texture_rectangle) if (resources.ARB_texture_rectangle)
{ {
const TType *sampler2DRect = TCache::getType(EbtSampler2DRect); TType *sampler2DRect = new TType(EbtSampler2DRect);
symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, float2); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, float2);
symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float3); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float3);
...@@ -293,12 +296,12 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR ...@@ -293,12 +296,12 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR
symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, float3, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, float3, float1);
} }
const TType *gvec4 = TCache::getType(EbtGVec4); TType *gvec4 = new TType(EbtGVec4);
const TType *gsampler2D = TCache::getType(EbtGSampler2D); TType *gsampler2D = new TType(EbtGSampler2D);
const TType *gsamplerCube = TCache::getType(EbtGSamplerCube); TType *gsamplerCube = new TType(EbtGSamplerCube);
const TType *gsampler3D = TCache::getType(EbtGSampler3D); TType *gsampler3D = new TType(EbtGSampler3D);
const TType *gsampler2DArray = TCache::getType(EbtGSampler2DArray); TType *gsampler2DArray = new TType(EbtGSampler2DArray);
// //
// Texture Functions for GLSL ES 3.0 // Texture Functions for GLSL ES 3.0
...@@ -326,9 +329,9 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR ...@@ -326,9 +329,9 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR
symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4, float1);
} }
const TType *sampler2DShadow = TCache::getType(EbtSampler2DShadow); TType *sampler2DShadow = new TType(EbtSampler2DShadow);
const TType *samplerCubeShadow = TCache::getType(EbtSamplerCubeShadow); TType *samplerCubeShadow = new TType(EbtSamplerCubeShadow);
const TType *sampler2DArrayShadow = TCache::getType(EbtSampler2DArrayShadow); TType *sampler2DArrayShadow = new TType(EbtSampler2DArrayShadow);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3);
symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4);
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
#include "compiler/translator/Cache.h"
#include "compiler/translator/InitializeDll.h" #include "compiler/translator/InitializeDll.h"
#include "compiler/translator/InitializeGlobals.h" #include "compiler/translator/InitializeGlobals.h"
#include "compiler/translator/InitializeParseContext.h" #include "compiler/translator/InitializeParseContext.h"
...@@ -25,8 +24,6 @@ bool InitProcess() ...@@ -25,8 +24,6 @@ bool InitProcess()
return false; return false;
} }
TCache::initialize();
return true; return true;
} }
...@@ -34,5 +31,4 @@ void DetachProcess() ...@@ -34,5 +31,4 @@ void DetachProcess()
{ {
FreeParseContextIndex(); FreeParseContextIndex();
FreePoolIndex(); FreePoolIndex();
TCache::destroy();
} }
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <stdio.h> #include <stdio.h>
#include "compiler/preprocessor/SourceLocation.h" #include "compiler/preprocessor/SourceLocation.h"
#include "compiler/translator/Cache.h"
#include "compiler/translator/glslang.h" #include "compiler/translator/glslang.h"
#include "compiler/translator/ValidateSwitch.h" #include "compiler/translator/ValidateSwitch.h"
#include "compiler/translator/ValidateGlobalInitializer.h" #include "compiler/translator/ValidateGlobalInitializer.h"
......
...@@ -247,13 +247,18 @@ public: ...@@ -247,13 +247,18 @@ public:
pointer address(reference x) const { return &x; } pointer address(reference x) const { return &x; }
const_pointer address(const_reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; }
pool_allocator() { } pool_allocator() : allocator(GetGlobalPoolAllocator()) { }
pool_allocator(TPoolAllocator& a) : allocator(&a) { }
template<class Other> pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }
pool_allocator(const pool_allocator<Other>& p) { }
template <class Other> template <class Other>
pool_allocator<T>& operator=(const pool_allocator<Other>& p) { return *this; } pool_allocator<T>& operator=(const pool_allocator<Other>& p) {
allocator = p.allocator;
return *this;
}
template<class Other>
pool_allocator(const pool_allocator<Other>& p) : allocator(&p.getAllocator()) { }
#if defined(__SUNPRO_CC) && !defined(_RWSTD_ALLOCATOR) #if defined(__SUNPRO_CC) && !defined(_RWSTD_ALLOCATOR)
// libCStd on some platforms have a different allocate/deallocate interface. // libCStd on some platforms have a different allocate/deallocate interface.
...@@ -279,13 +284,17 @@ public: ...@@ -279,13 +284,17 @@ public:
void construct(pointer p, const T& val) { new ((void *)p) T(val); } void construct(pointer p, const T& val) { new ((void *)p) T(val); }
void destroy(pointer p) { p->T::~T(); } void destroy(pointer p) { p->T::~T(); }
bool operator==(const pool_allocator& rhs) const { return true; } bool operator==(const pool_allocator& rhs) const { return &getAllocator() == &rhs.getAllocator(); }
bool operator!=(const pool_allocator& rhs) const { return false; } bool operator!=(const pool_allocator& rhs) const { return &getAllocator() != &rhs.getAllocator(); }
size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); } size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); }
size_type max_size(int size) const { return static_cast<size_type>(-1) / size; } size_type max_size(int size) const { return static_cast<size_type>(-1) / size; }
TPoolAllocator& getAllocator() const { return *GetGlobalPoolAllocator(); } void setAllocator(TPoolAllocator* a) { allocator = a; }
TPoolAllocator& getAllocator() const { return *allocator; }
protected:
TPoolAllocator* allocator;
}; };
#endif // COMPILER_TRANSLATOR_POOLALLOC_H_ #endif // COMPILER_TRANSLATOR_POOLALLOC_H_
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#endif #endif
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
#include "compiler/translator/Cache.h"
#include <stdio.h> #include <stdio.h>
#include <algorithm> #include <algorithm>
...@@ -165,10 +164,10 @@ const TType *SpecificType(const TType *type, int size) ...@@ -165,10 +164,10 @@ const TType *SpecificType(const TType *type, int size)
switch(type->getBasicType()) switch(type->getBasicType())
{ {
case EbtGenType: return TCache::getType(EbtFloat, static_cast<unsigned char>(size)); case EbtGenType: return new TType(EbtFloat, static_cast<unsigned char>(size));
case EbtGenIType: return TCache::getType(EbtInt, static_cast<unsigned char>(size)); case EbtGenIType: return new TType(EbtInt, static_cast<unsigned char>(size));
case EbtGenUType: return TCache::getType(EbtUInt, static_cast<unsigned char>(size)); case EbtGenUType: return new TType(EbtUInt, static_cast<unsigned char>(size));
case EbtGenBType: return TCache::getType(EbtBool, static_cast<unsigned char>(size)); case EbtGenBType: return new TType(EbtBool, static_cast<unsigned char>(size));
default: return type; default: return type;
} }
} }
...@@ -186,10 +185,10 @@ const TType *VectorType(const TType *type, int size) ...@@ -186,10 +185,10 @@ const TType *VectorType(const TType *type, int size)
switch(type->getBasicType()) switch(type->getBasicType())
{ {
case EbtVec: return TCache::getType(EbtFloat, static_cast<unsigned char>(size)); case EbtVec: return new TType(EbtFloat, static_cast<unsigned char>(size));
case EbtIVec: return TCache::getType(EbtInt, static_cast<unsigned char>(size)); case EbtIVec: return new TType(EbtInt, static_cast<unsigned char>(size));
case EbtUVec: return TCache::getType(EbtUInt, static_cast<unsigned char>(size)); case EbtUVec: return new TType(EbtUInt, static_cast<unsigned char>(size));
case EbtBVec: return TCache::getType(EbtBool, static_cast<unsigned char>(size)); case EbtBVec: return new TType(EbtBool, static_cast<unsigned char>(size));
default: return type; default: return type;
} }
} }
...@@ -200,30 +199,30 @@ void TSymbolTable::insertBuiltIn(ESymbolLevel level, TOperator op, const char *e ...@@ -200,30 +199,30 @@ void TSymbolTable::insertBuiltIn(ESymbolLevel level, TOperator op, const char *e
if (ptype1->getBasicType() == EbtGSampler2D) if (ptype1->getBasicType() == EbtGSampler2D)
{ {
bool gvec4 = (rvalue->getBasicType() == EbtGVec4); bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtFloat, 4) : rvalue, name, TCache::getType(EbtSampler2D), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2D), ptype2, ptype3, ptype4, ptype5);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtInt, 4) : rvalue, name, TCache::getType(EbtISampler2D), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler2D), ptype2, ptype3, ptype4, ptype5);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtUInt, 4) : rvalue, name, TCache::getType(EbtUSampler2D), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler2D), ptype2, ptype3, ptype4, ptype5);
} }
else if (ptype1->getBasicType() == EbtGSampler3D) else if (ptype1->getBasicType() == EbtGSampler3D)
{ {
bool gvec4 = (rvalue->getBasicType() == EbtGVec4); bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtFloat, 4) : rvalue, name, TCache::getType(EbtSampler3D), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler3D), ptype2, ptype3, ptype4, ptype5);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtInt, 4) : rvalue, name, TCache::getType(EbtISampler3D), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler3D), ptype2, ptype3, ptype4, ptype5);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtUInt, 4) : rvalue, name, TCache::getType(EbtUSampler3D), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler3D), ptype2, ptype3, ptype4, ptype5);
} }
else if (ptype1->getBasicType() == EbtGSamplerCube) else if (ptype1->getBasicType() == EbtGSamplerCube)
{ {
bool gvec4 = (rvalue->getBasicType() == EbtGVec4); bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtFloat, 4) : rvalue, name, TCache::getType(EbtSamplerCube), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSamplerCube), ptype2, ptype3, ptype4, ptype5);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtInt, 4) : rvalue, name, TCache::getType(EbtISamplerCube), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISamplerCube), ptype2, ptype3, ptype4, ptype5);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtUInt, 4) : rvalue, name, TCache::getType(EbtUSamplerCube), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSamplerCube), ptype2, ptype3, ptype4, ptype5);
} }
else if (ptype1->getBasicType() == EbtGSampler2DArray) else if (ptype1->getBasicType() == EbtGSampler2DArray)
{ {
bool gvec4 = (rvalue->getBasicType() == EbtGVec4); bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtFloat, 4) : rvalue, name, TCache::getType(EbtSampler2DArray), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2DArray), ptype2, ptype3, ptype4, ptype5);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtInt, 4) : rvalue, name, TCache::getType(EbtISampler2DArray), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler2DArray), ptype2, ptype3, ptype4, ptype5);
insertBuiltIn(level, gvec4 ? TCache::getType(EbtUInt, 4) : rvalue, name, TCache::getType(EbtUSampler2DArray), ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler2DArray), ptype2, ptype3, ptype4, ptype5);
} }
else if (IsGenType(rvalue) || IsGenType(ptype1) || IsGenType(ptype2) || IsGenType(ptype3)) else if (IsGenType(rvalue) || IsGenType(ptype1) || IsGenType(ptype2) || IsGenType(ptype3))
{ {
......
...@@ -142,8 +142,7 @@ TString TType::buildMangledName() const ...@@ -142,8 +142,7 @@ TString TType::buildMangledName() const
mangledName += interfaceBlock->mangledName(); mangledName += interfaceBlock->mangledName();
break; break;
default: default:
// EbtVoid, EbtAddress and non types UNREACHABLE();
break;
} }
if (isMatrix()) if (isMatrix())
......
...@@ -491,15 +491,10 @@ class TType ...@@ -491,15 +491,10 @@ class TType
return structure ? structure->containsSamplers() : false; return structure ? structure->containsSamplers() : false;
} }
// Initializes all lazily-initialized members.
void realize()
{
getMangledName();
}
protected: protected:
TString buildMangledName() const; TString buildMangledName() const;
size_t getStructSize() const; size_t getStructSize() const;
void computeDeepestStructNesting();
TBasicType type; TBasicType type;
TPrecision precision; TPrecision precision;
......
...@@ -37,7 +37,6 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h). ...@@ -37,7 +37,6 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
#endif #endif
#include "angle_gl.h" #include "angle_gl.h"
#include "compiler/translator/Cache.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
#include "compiler/translator/ParseContext.h" #include "compiler/translator/ParseContext.h"
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
...@@ -370,14 +369,14 @@ function_identifier ...@@ -370,14 +369,14 @@ function_identifier
| IDENTIFIER { | IDENTIFIER {
if (context->reservedErrorCheck(@1, *$1.string)) if (context->reservedErrorCheck(@1, *$1.string))
context->recover(); context->recover();
const TType *type = TCache::getType(EbtVoid, EbpUndefined); const TType *type = new TType(EbtVoid, EbpUndefined);
TFunction *function = new TFunction($1.string, type); TFunction *function = new TFunction($1.string, type);
$$ = function; $$ = function;
} }
| FIELD_SELECTION { | FIELD_SELECTION {
if (context->reservedErrorCheck(@1, *$1.string)) if (context->reservedErrorCheck(@1, *$1.string))
context->recover(); context->recover();
const TType *type = TCache::getType(EbtVoid, EbpUndefined); const TType *type = new TType(EbtVoid, EbpUndefined);
TFunction *function = new TFunction($1.string, type); TFunction *function = new TFunction($1.string, type);
$$ = function; $$ = function;
} }
......
...@@ -87,7 +87,6 @@ ...@@ -87,7 +87,6 @@
#endif #endif
#include "angle_gl.h" #include "angle_gl.h"
#include "compiler/translator/Cache.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
#include "compiler/translator/ParseContext.h" #include "compiler/translator/ParseContext.h"
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
...@@ -2604,7 +2603,7 @@ yyreduce: ...@@ -2604,7 +2603,7 @@ yyreduce:
{ {
if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string)) if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string))
context->recover(); context->recover();
const TType *type = TCache::getType(EbtVoid, EbpUndefined); const TType *type = new TType(EbtVoid, EbpUndefined);
TFunction *function = new TFunction((yyvsp[0].lex).string, type); TFunction *function = new TFunction((yyvsp[0].lex).string, type);
(yyval.interm.function) = function; (yyval.interm.function) = function;
} }
...@@ -2616,7 +2615,7 @@ yyreduce: ...@@ -2616,7 +2615,7 @@ yyreduce:
{ {
if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string)) if (context->reservedErrorCheck((yylsp[0]), *(yyvsp[0].lex).string))
context->recover(); context->recover();
const TType *type = TCache::getType(EbtVoid, EbpUndefined); const TType *type = new TType(EbtVoid, EbpUndefined);
TFunction *function = new TFunction((yyvsp[0].lex).string, type); TFunction *function = new TFunction((yyvsp[0].lex).string, type);
(yyval.interm.function) = function; (yyval.interm.function) = function;
} }
......
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