Commit 7a8ccc48 by Nicolas Capens

Eliminate TShHandleBase.

Bug 19331817 Change-Id: I3dc11a3e4eaea734ae86e2722d2565ce136fe335 Reviewed-on: https://swiftshader-review.googlesource.com/2151Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent d8cbf397
......@@ -31,25 +31,19 @@ private:
};
} // namespace
TShHandleBase::TShHandleBase() {
allocator.push();
SetGlobalPoolAllocator(&allocator);
}
TShHandleBase::~TShHandleBase() {
SetGlobalPoolAllocator(NULL);
allocator.popAll();
}
TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
: shaderType(type),
shaderSpec(spec),
maxCallStackDepth(UINT_MAX)
{
allocator.push();
SetGlobalPoolAllocator(&allocator);
}
TCompiler::~TCompiler()
{
SetGlobalPoolAllocator(NULL);
allocator.popAll();
}
bool TCompiler::Init(const ShBuiltInResources& resources)
......
......@@ -20,28 +20,12 @@
#include "InfoSink.h"
#include "SymbolTable.h"
class TCompiler;
//
// The base class used to back handles returned to the driver.
//
class TShHandleBase {
public:
TShHandleBase();
virtual ~TShHandleBase();
virtual TCompiler* getAsCompiler() { return 0; }
protected:
// Memory allocator. Allocates and tracks memory required by the compiler.
// Deallocates all memory when compiler is destructed.
TPoolAllocator allocator;
};
//
// The base class for the machine dependent compiler to derive from
// for managing object code from the compile.
//
class TCompiler : public TShHandleBase {
class TCompiler
{
public:
TCompiler(ShShaderType type, ShShaderSpec spec);
virtual ~TCompiler();
......@@ -86,6 +70,10 @@ private:
// Results of compilation.
TInfoSink infoSink; // Output sink.
// Memory allocator. Allocates and tracks memory required by the compiler.
// Deallocates all memory when compiler is destructed.
TPoolAllocator allocator;
};
//
......
......@@ -64,7 +64,7 @@ void ShInitBuiltInResources(ShBuiltInResources* resources)
ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec,
const ShBuiltInResources* resources)
{
TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec));
TCompiler* base = ConstructCompiler(type, spec);
TCompiler* compiler = base->getAsCompiler();
if (compiler == 0)
return 0;
......@@ -83,7 +83,7 @@ void ShDestruct(ShHandle handle)
if (handle == 0)
return;
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
TCompiler* base = static_cast<TCompiler*>(handle);
if (base->getAsCompiler())
DeleteCompiler(base->getAsCompiler());
......@@ -105,7 +105,7 @@ int ShCompile(
if (handle == 0)
return 0;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
TCompiler* base = reinterpret_cast<TCompiler*>(handle);
TCompiler* compiler = base->getAsCompiler();
if (compiler == 0)
return 0;
......@@ -119,7 +119,7 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params)
if (!handle || !params)
return;
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
TCompiler* base = static_cast<TCompiler*>(handle);
TCompiler* compiler = base->getAsCompiler();
if (!compiler) return;
......@@ -149,7 +149,7 @@ void ShGetInfoLog(const ShHandle handle, char* infoLog)
if (!handle || !infoLog)
return;
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
TCompiler* base = static_cast<TCompiler*>(handle);
TCompiler* compiler = base->getAsCompiler();
if (!compiler) return;
......@@ -165,7 +165,7 @@ void ShGetObjectCode(const ShHandle handle, char* objCode)
if (!handle || !objCode)
return;
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
TCompiler* base = static_cast<TCompiler*>(handle);
TCompiler* compiler = base->getAsCompiler();
if (!compiler) return;
......
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