Share the name space implementation between all GL versions.
Bug 18962347
Change-Id: Ifd7ca4142d90798d0bbe2defa9337bac17e20daf
Reviewed-on: https://swiftshader-review.googlesource.com/1881
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/common/NameSpace.cpp b/src/OpenGL/common/NameSpace.cpp
new file mode 100644
index 0000000..3410233
--- /dev/null
+++ b/src/OpenGL/common/NameSpace.cpp
@@ -0,0 +1,70 @@
+// SwiftShader Software Renderer
+//
+// Copyright(c) 2005-2012 TransGaming Inc.
+//
+// All rights reserved. No part of this software may be copied, distributed, transmitted,
+// transcribed, stored in a retrieval system, translated into any human or computer
+// language by any means, or disclosed to third parties without the explicit written
+// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
+// or implied, including but not limited to any patent rights, are granted to you.
+//
+
+// NameSpace.cpp: Implements the NameSpace class, which is used
+// to allocate GL object names.
+
+#include "common/NameSpace.hpp"
+
+#include "debug.h"
+
+namespace gl
+{
+
+NameSpace::NameSpace() : baseValue(1), nextValue(1)
+{
+}
+
+NameSpace::~NameSpace()
+{
+}
+
+void NameSpace::setBaseHandle(GLuint value)
+{
+ ASSERT(baseValue == nextValue);
+ baseValue = value;
+ nextValue = value;
+}
+
+GLuint NameSpace::allocate()
+{
+ if(freeValues.size())
+ {
+ GLuint handle = freeValues.back();
+ freeValues.pop_back();
+
+ return handle;
+ }
+
+ return nextValue++;
+}
+
+void NameSpace::release(GLuint handle)
+{
+ if(handle == nextValue - 1)
+ {
+ // Don't drop below base value
+ if(nextValue > baseValue)
+ {
+ nextValue--;
+ }
+ }
+ else
+ {
+ // Only free handles that we own - don't drop below the base value
+ if(handle >= baseValue)
+ {
+ freeValues.push_back(handle);
+ }
+ }
+}
+
+}
diff --git a/src/OpenGL/libGL/HandleAllocator.h b/src/OpenGL/common/NameSpace.hpp
similarity index 63%
rename from src/OpenGL/libGL/HandleAllocator.h
rename to src/OpenGL/common/NameSpace.hpp
index b40fe97..5177676 100644
--- a/src/OpenGL/libGL/HandleAllocator.h
+++ b/src/OpenGL/common/NameSpace.hpp
@@ -9,38 +9,37 @@
// or implied, including but not limited to any patent rights, are granted to you.
//
-// HandleAllocator.h: Defines the HandleAllocator class, which is used to
-// allocate GL handles.
+// NameSpace.h: Defines the NameSpace class, which is used to
+// allocate GL object names.
-#ifndef LIBGL_HANDLEALLOCATOR_H_
-#define LIBGL_HANDLEALLOCATOR_H_
-
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#ifndef gl_NameSpace_hpp
+#define gl_NameSpace_hpp
#include <vector>
+typedef unsigned int GLuint;
+
namespace gl
{
-class HandleAllocator
+class NameSpace
{
public:
- HandleAllocator();
- virtual ~HandleAllocator();
+ NameSpace();
+ virtual ~NameSpace();
void setBaseHandle(GLuint value);
GLuint allocate();
void release(GLuint handle);
- private:
- GLuint mBaseValue;
- GLuint mNextValue;
+private:
+ GLuint baseValue;
+ GLuint nextValue;
typedef std::vector<GLuint> HandleList;
- HandleList mFreeValues;
+ HandleList freeValues;
};
}
-#endif // LIBGL_HANDLEALLOCATOR_H_
+#endif // gl_NameSpace_hpp
diff --git a/src/OpenGL/libGL/Context.cpp b/src/OpenGL/libGL/Context.cpp
index 3d4d477..850a001 100644
--- a/src/OpenGL/libGL/Context.cpp
+++ b/src/OpenGL/libGL/Context.cpp
@@ -44,7 +44,7 @@
sw::Context *context = new sw::Context();
device = new gl::Device(context);
- mFenceHandleAllocator.setBaseHandle(0);
+ mFenceNameSpace.setBaseHandle(0);
setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -773,7 +773,7 @@
// Returns an unused framebuffer name
GLuint Context::createFramebuffer()
{
- GLuint handle = mFramebufferHandleAllocator.allocate();
+ GLuint handle = mFramebufferNameSpace.allocate();
mFramebufferMap[handle] = NULL;
@@ -782,7 +782,7 @@
GLuint Context::createFence()
{
- GLuint handle = mFenceHandleAllocator.allocate();
+ GLuint handle = mFenceNameSpace.allocate();
mFenceMap[handle] = new Fence;
@@ -792,7 +792,7 @@
// Returns an unused query name
GLuint Context::createQuery()
{
- GLuint handle = mQueryHandleAllocator.allocate();
+ GLuint handle = mQueryNameSpace.allocate();
mQueryMap[handle] = NULL;
@@ -847,7 +847,7 @@
{
detachFramebuffer(framebuffer);
- mFramebufferHandleAllocator.release(framebufferObject->first);
+ mFramebufferNameSpace.release(framebufferObject->first);
delete framebufferObject->second;
mFramebufferMap.erase(framebufferObject);
}
@@ -859,7 +859,7 @@
if(fenceObject != mFenceMap.end())
{
- mFenceHandleAllocator.release(fenceObject->first);
+ mFenceNameSpace.release(fenceObject->first);
delete fenceObject->second;
mFenceMap.erase(fenceObject);
}
@@ -871,7 +871,7 @@
if(queryObject != mQueryMap.end())
{
- mQueryHandleAllocator.release(queryObject->first);
+ mQueryNameSpace.release(queryObject->first);
if(queryObject->second)
{
diff --git a/src/OpenGL/libGL/Context.h b/src/OpenGL/libGL/Context.h
index 5c7bd48..ec09a6e 100644
--- a/src/OpenGL/libGL/Context.h
+++ b/src/OpenGL/libGL/Context.h
@@ -17,7 +17,7 @@
#include "libEGL/Context.hpp"
#include "ResourceManager.h"
-#include "HandleAllocator.h"
+#include "common/NameSpace.hpp"
#include "common/Object.hpp"
#include "Image.hpp"
#include "Renderer/Sampler.hpp"
@@ -469,15 +469,15 @@
typedef std::map<GLint, Framebuffer*> FramebufferMap;
FramebufferMap mFramebufferMap;
- HandleAllocator mFramebufferHandleAllocator;
+ NameSpace mFramebufferNameSpace;
typedef std::map<GLint, Fence*> FenceMap;
FenceMap mFenceMap;
- HandleAllocator mFenceHandleAllocator;
+ NameSpace mFenceNameSpace;
typedef std::map<GLint, Query*> QueryMap;
QueryMap mQueryMap;
- HandleAllocator mQueryHandleAllocator;
+ NameSpace mQueryNameSpace;
VertexDataManager *mVertexDataManager;
IndexDataManager *mIndexDataManager;
diff --git a/src/OpenGL/libGL/HandleAllocator.cpp b/src/OpenGL/libGL/HandleAllocator.cpp
deleted file mode 100644
index 7db672a..0000000
--- a/src/OpenGL/libGL/HandleAllocator.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2012 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// HandleAllocator.cpp: Implements the HandleAllocator class, which is used
-// to allocate GL handles.
-
-#include "HandleAllocator.h"
-
-#include "main.h"
-
-namespace gl
-{
-
-HandleAllocator::HandleAllocator() : mBaseValue(1), mNextValue(1)
-{
-}
-
-HandleAllocator::~HandleAllocator()
-{
-}
-
-void HandleAllocator::setBaseHandle(GLuint value)
-{
- ASSERT(mBaseValue == mNextValue);
- mBaseValue = value;
- mNextValue = value;
-}
-
-GLuint HandleAllocator::allocate()
-{
- if(mFreeValues.size())
- {
- GLuint handle = mFreeValues.back();
- mFreeValues.pop_back();
- return handle;
- }
- return mNextValue++;
-}
-
-void HandleAllocator::release(GLuint handle)
-{
- if(handle == mNextValue - 1)
- {
- // Don't drop below base value
- if(mNextValue > mBaseValue)
- {
- mNextValue--;
- }
- }
- else
- {
- // Only free handles that we own - don't drop below the base value
- if(handle >= mBaseValue)
- {
- mFreeValues.push_back(handle);
- }
- }
-}
-
-}
diff --git a/src/OpenGL/libGL/ResourceManager.cpp b/src/OpenGL/libGL/ResourceManager.cpp
index a4c8998..37d1736 100644
--- a/src/OpenGL/libGL/ResourceManager.cpp
+++ b/src/OpenGL/libGL/ResourceManager.cpp
@@ -71,7 +71,7 @@
// Returns an unused buffer name
GLuint ResourceManager::createBuffer()
{
- GLuint handle = mBufferHandleAllocator.allocate();
+ GLuint handle = mBufferNameSpace.allocate();
mBufferMap[handle] = NULL;
@@ -81,7 +81,7 @@
// Returns an unused shader/program name
GLuint ResourceManager::createShader(GLenum type)
{
- GLuint handle = mProgramShaderHandleAllocator.allocate();
+ GLuint handle = mProgramShaderNameSpace.allocate();
if(type == GL_VERTEX_SHADER)
{
@@ -99,7 +99,7 @@
// Returns an unused program/shader name
GLuint ResourceManager::createProgram()
{
- GLuint handle = mProgramShaderHandleAllocator.allocate();
+ GLuint handle = mProgramShaderNameSpace.allocate();
mProgramMap[handle] = new Program(this, handle);
@@ -109,7 +109,7 @@
// Returns an unused texture name
GLuint ResourceManager::createTexture()
{
- GLuint handle = mTextureHandleAllocator.allocate();
+ GLuint handle = mTextureNameSpace.allocate();
mTextureMap[handle] = NULL;
@@ -119,7 +119,7 @@
// Returns an unused renderbuffer name
GLuint ResourceManager::createRenderbuffer()
{
- GLuint handle = mRenderbufferHandleAllocator.allocate();
+ GLuint handle = mRenderbufferNameSpace.allocate();
mRenderbufferMap[handle] = NULL;
@@ -132,7 +132,7 @@
if(bufferObject != mBufferMap.end())
{
- mBufferHandleAllocator.release(bufferObject->first);
+ mBufferNameSpace.release(bufferObject->first);
if(bufferObject->second) bufferObject->second->release();
mBufferMap.erase(bufferObject);
}
@@ -146,7 +146,7 @@
{
if(shaderObject->second->getRefCount() == 0)
{
- mProgramShaderHandleAllocator.release(shaderObject->first);
+ mProgramShaderNameSpace.release(shaderObject->first);
delete shaderObject->second;
mShaderMap.erase(shaderObject);
}
@@ -165,7 +165,7 @@
{
if(programObject->second->getRefCount() == 0)
{
- mProgramShaderHandleAllocator.release(programObject->first);
+ mProgramShaderNameSpace.release(programObject->first);
delete programObject->second;
mProgramMap.erase(programObject);
}
@@ -182,7 +182,7 @@
if(textureObject != mTextureMap.end())
{
- mTextureHandleAllocator.release(textureObject->first);
+ mTextureNameSpace.release(textureObject->first);
if(textureObject->second) textureObject->second->release();
mTextureMap.erase(textureObject);
}
@@ -194,7 +194,7 @@
if(renderbufferObject != mRenderbufferMap.end())
{
- mRenderbufferHandleAllocator.release(renderbufferObject->first);
+ mRenderbufferNameSpace.release(renderbufferObject->first);
if(renderbufferObject->second) renderbufferObject->second->release();
mRenderbufferMap.erase(renderbufferObject);
}
diff --git a/src/OpenGL/libGL/ResourceManager.h b/src/OpenGL/libGL/ResourceManager.h
index 06d9aae..e48db2a 100644
--- a/src/OpenGL/libGL/ResourceManager.h
+++ b/src/OpenGL/libGL/ResourceManager.h
@@ -15,7 +15,7 @@
#ifndef LIBGL_RESOURCEMANAGER_H_
#define LIBGL_RESOURCEMANAGER_H_
-#include "HandleAllocator.h"
+#include "common/NameSpace.hpp"
#define GL_APICALL
#include <GLES2/gl2.h>
@@ -77,22 +77,22 @@
typedef std::map<GLint, Buffer*> BufferMap;
BufferMap mBufferMap;
- HandleAllocator mBufferHandleAllocator;
+ NameSpace mBufferNameSpace;
typedef std::map<GLint, Shader*> ShaderMap;
ShaderMap mShaderMap;
typedef std::map<GLint, Program*> ProgramMap;
ProgramMap mProgramMap;
- HandleAllocator mProgramShaderHandleAllocator;
+ NameSpace mProgramShaderNameSpace;
typedef std::map<GLint, Texture*> TextureMap;
TextureMap mTextureMap;
- HandleAllocator mTextureHandleAllocator;
+ NameSpace mTextureNameSpace;
typedef std::map<GLint, Renderbuffer*> RenderbufferMap;
RenderbufferMap mRenderbufferMap;
- HandleAllocator mRenderbufferHandleAllocator;
+ NameSpace mRenderbufferNameSpace;
};
}
diff --git a/src/OpenGL/libGL/libGL.vcxproj b/src/OpenGL/libGL/libGL.vcxproj
index 6f785fc..77cf943 100644
--- a/src/OpenGL/libGL/libGL.vcxproj
+++ b/src/OpenGL/libGL/libGL.vcxproj
@@ -318,6 +318,7 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="..\common\NameSpace.cpp" />
<ClCompile Include="..\common\Object.cpp" />
<ClCompile Include="Buffer.cpp" />
<ClCompile Include="Context.cpp" />
@@ -325,7 +326,6 @@
<ClCompile Include="Device.cpp" />
<ClCompile Include="Fence.cpp" />
<ClCompile Include="Framebuffer.cpp" />
- <ClCompile Include="HandleAllocator.cpp" />
<ClCompile Include="Image.cpp" />
<ClCompile Include="IndexDataManager.cpp" />
<ClCompile Include="libGL.cpp" />
@@ -341,6 +341,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\debug.h" />
+ <ClInclude Include="..\common\NameSpace.hpp" />
<ClInclude Include="..\common\Object.hpp" />
<ClInclude Include="..\include\GLES2\gl2.h" />
<ClInclude Include="..\include\GLES2\gl2ext.h" />
@@ -350,7 +351,6 @@
<ClInclude Include="Device.hpp" />
<ClInclude Include="Fence.h" />
<ClInclude Include="Framebuffer.h" />
- <ClInclude Include="HandleAllocator.h" />
<ClInclude Include="Image.hpp" />
<ClInclude Include="IndexDataManager.h" />
<ClInclude Include="main.h" />
diff --git a/src/OpenGL/libGL/libGL.vcxproj.filters b/src/OpenGL/libGL/libGL.vcxproj.filters
index 1fcf9a4..66b2d0f 100644
--- a/src/OpenGL/libGL/libGL.vcxproj.filters
+++ b/src/OpenGL/libGL/libGL.vcxproj.filters
@@ -26,9 +26,6 @@
<ClCompile Include="Framebuffer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="HandleAllocator.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="IndexDataManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -71,6 +68,9 @@
<ClCompile Include="..\common\Object.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\common\NameSpace.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Buffer.h">
@@ -85,9 +85,6 @@
<ClInclude Include="Framebuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="HandleAllocator.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="IndexDataManager.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -145,6 +142,9 @@
<ClInclude Include="..\common\Object.hpp">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\common\NameSpace.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="libGL.rc" />
diff --git a/src/OpenGL/libGLES_CM/Context.cpp b/src/OpenGL/libGLES_CM/Context.cpp
index f22dfaf..fbbe989 100644
--- a/src/OpenGL/libGLES_CM/Context.cpp
+++ b/src/OpenGL/libGLES_CM/Context.cpp
@@ -761,7 +761,7 @@
// Returns an unused framebuffer name
GLuint Context::createFramebuffer()
{
- GLuint handle = mFramebufferHandleAllocator.allocate();
+ GLuint handle = mFramebufferNameSpace.allocate();
mFramebufferMap[handle] = NULL;
@@ -806,7 +806,7 @@
{
detachFramebuffer(framebuffer);
- mFramebufferHandleAllocator.release(framebufferObject->first);
+ mFramebufferNameSpace.release(framebufferObject->first);
delete framebufferObject->second;
mFramebufferMap.erase(framebufferObject);
}
diff --git a/src/OpenGL/libGLES_CM/Context.h b/src/OpenGL/libGLES_CM/Context.h
index 9b22f8c..101b2f9 100644
--- a/src/OpenGL/libGLES_CM/Context.h
+++ b/src/OpenGL/libGLES_CM/Context.h
@@ -17,7 +17,7 @@
#include "libEGL/Context.hpp"
#include "ResourceManager.h"
-#include "HandleAllocator.h"
+#include "common/NameSpace.hpp"
#include "common/Object.hpp"
#include "Image.hpp"
#include "Renderer/Sampler.hpp"
@@ -472,7 +472,7 @@
typedef std::map<GLint, Framebuffer*> FramebufferMap;
FramebufferMap mFramebufferMap;
- HandleAllocator mFramebufferHandleAllocator;
+ gl::NameSpace mFramebufferNameSpace;
VertexDataManager *mVertexDataManager;
IndexDataManager *mIndexDataManager;
diff --git a/src/OpenGL/libGLES_CM/HandleAllocator.cpp b/src/OpenGL/libGLES_CM/HandleAllocator.cpp
deleted file mode 100644
index 52991c1..0000000
--- a/src/OpenGL/libGLES_CM/HandleAllocator.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2012 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// HandleAllocator.cpp: Implements the HandleAllocator class, which is used
-// to allocate GL handles.
-
-#include "HandleAllocator.h"
-
-#include "main.h"
-
-namespace es1
-{
-
-HandleAllocator::HandleAllocator() : mBaseValue(1), mNextValue(1)
-{
-}
-
-HandleAllocator::~HandleAllocator()
-{
-}
-
-void HandleAllocator::setBaseHandle(GLuint value)
-{
- ASSERT(mBaseValue == mNextValue);
- mBaseValue = value;
- mNextValue = value;
-}
-
-GLuint HandleAllocator::allocate()
-{
- if(mFreeValues.size())
- {
- GLuint handle = mFreeValues.back();
- mFreeValues.pop_back();
- return handle;
- }
- return mNextValue++;
-}
-
-void HandleAllocator::release(GLuint handle)
-{
- if(handle == mNextValue - 1)
- {
- // Don't drop below base value
- if(mNextValue > mBaseValue)
- {
- mNextValue--;
- }
- }
- else
- {
- // Only free handles that we own - don't drop below the base value
- if(handle >= mBaseValue)
- {
- mFreeValues.push_back(handle);
- }
- }
-}
-
-}
diff --git a/src/OpenGL/libGLES_CM/HandleAllocator.h b/src/OpenGL/libGLES_CM/HandleAllocator.h
deleted file mode 100644
index 448f82a..0000000
--- a/src/OpenGL/libGLES_CM/HandleAllocator.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2012 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// HandleAllocator.h: Defines the HandleAllocator class, which is used to
-// allocate GL handles.
-
-#ifndef LIBGLES_CM_HANDLEALLOCATOR_H_
-#define LIBGLES_CM_HANDLEALLOCATOR_H_
-
-#define GL_API
-#include <GLES/gl.h>
-
-#include <vector>
-
-namespace es1
-{
-
-class HandleAllocator
-{
- public:
- HandleAllocator();
- virtual ~HandleAllocator();
-
- void setBaseHandle(GLuint value);
-
- GLuint allocate();
- void release(GLuint handle);
-
- private:
- GLuint mBaseValue;
- GLuint mNextValue;
- typedef std::vector<GLuint> HandleList;
- HandleList mFreeValues;
-};
-
-}
-
-#endif // LIBGLES_CM_HANDLEALLOCATOR_H_
diff --git a/src/OpenGL/libGLES_CM/ResourceManager.cpp b/src/OpenGL/libGLES_CM/ResourceManager.cpp
index 9a7d74d..4e9f1bd 100644
--- a/src/OpenGL/libGLES_CM/ResourceManager.cpp
+++ b/src/OpenGL/libGLES_CM/ResourceManager.cpp
@@ -59,7 +59,7 @@
// Returns an unused buffer name
GLuint ResourceManager::createBuffer()
{
- GLuint handle = mBufferHandleAllocator.allocate();
+ GLuint handle = mBufferNameSpace.allocate();
mBufferMap[handle] = NULL;
@@ -69,7 +69,7 @@
// Returns an unused texture name
GLuint ResourceManager::createTexture()
{
- GLuint handle = mTextureHandleAllocator.allocate();
+ GLuint handle = mTextureNameSpace.allocate();
mTextureMap[handle] = NULL;
@@ -79,7 +79,7 @@
// Returns an unused renderbuffer name
GLuint ResourceManager::createRenderbuffer()
{
- GLuint handle = mRenderbufferHandleAllocator.allocate();
+ GLuint handle = mRenderbufferNameSpace.allocate();
mRenderbufferMap[handle] = NULL;
@@ -92,7 +92,7 @@
if(bufferObject != mBufferMap.end())
{
- mBufferHandleAllocator.release(bufferObject->first);
+ mBufferNameSpace.release(bufferObject->first);
if(bufferObject->second) bufferObject->second->release();
mBufferMap.erase(bufferObject);
}
@@ -104,7 +104,7 @@
if(textureObject != mTextureMap.end())
{
- mTextureHandleAllocator.release(textureObject->first);
+ mTextureNameSpace.release(textureObject->first);
if(textureObject->second) textureObject->second->release();
mTextureMap.erase(textureObject);
}
@@ -116,7 +116,7 @@
if(renderbufferObject != mRenderbufferMap.end())
{
- mRenderbufferHandleAllocator.release(renderbufferObject->first);
+ mRenderbufferNameSpace.release(renderbufferObject->first);
if(renderbufferObject->second) renderbufferObject->second->release();
mRenderbufferMap.erase(renderbufferObject);
}
diff --git a/src/OpenGL/libGLES_CM/ResourceManager.h b/src/OpenGL/libGLES_CM/ResourceManager.h
index 0e410b8..483ea1d 100644
--- a/src/OpenGL/libGLES_CM/ResourceManager.h
+++ b/src/OpenGL/libGLES_CM/ResourceManager.h
@@ -15,7 +15,7 @@
#ifndef LIBGLES_CM_RESOURCEMANAGER_H_
#define LIBGLES_CM_RESOURCEMANAGER_H_
-#include "HandleAllocator.h"
+#include "common/NameSpace.hpp"
#define GL_API
#include <GLES/gl.h>
@@ -69,15 +69,15 @@
typedef std::map<GLint, Buffer*> BufferMap;
BufferMap mBufferMap;
- HandleAllocator mBufferHandleAllocator;
+ gl::NameSpace mBufferNameSpace;
typedef std::map<GLint, Texture*> TextureMap;
TextureMap mTextureMap;
- HandleAllocator mTextureHandleAllocator;
+ gl::NameSpace mTextureNameSpace;
typedef std::map<GLint, Renderbuffer*> RenderbufferMap;
RenderbufferMap mRenderbufferMap;
- HandleAllocator mRenderbufferHandleAllocator;
+ gl::NameSpace mRenderbufferNameSpace;
};
}
diff --git a/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj b/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj
index bf5f423..3757f90 100644
--- a/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj
+++ b/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj
@@ -318,13 +318,13 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="..\common\NameSpace.cpp" />
<ClCompile Include="..\common\Object.cpp" />
<ClCompile Include="Buffer.cpp" />
<ClCompile Include="Context.cpp" />
<ClCompile Include="..\common\debug.cpp" />
<ClCompile Include="Device.cpp" />
<ClCompile Include="Framebuffer.cpp" />
- <ClCompile Include="HandleAllocator.cpp" />
<ClCompile Include="Image.cpp" />
<ClCompile Include="IndexDataManager.cpp" />
<ClCompile Include="libGLES_CM.cpp" />
@@ -338,6 +338,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\debug.h" />
+ <ClInclude Include="..\common\NameSpace.hpp" />
<ClInclude Include="..\common\Object.hpp" />
<ClInclude Include="..\include\GLES\egl.h" />
<ClInclude Include="..\include\GLES\gl.h" />
@@ -347,7 +348,6 @@
<ClInclude Include="Context.h" />
<ClInclude Include="Device.hpp" />
<ClInclude Include="Framebuffer.h" />
- <ClInclude Include="HandleAllocator.h" />
<ClInclude Include="Image.hpp" />
<ClInclude Include="IndexDataManager.h" />
<ClInclude Include="main.h" />
diff --git a/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj.filters b/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj.filters
index 5ccc748..47c405f 100644
--- a/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj.filters
+++ b/src/OpenGL/libGLES_CM/libGLES_CM.vcxproj.filters
@@ -23,9 +23,6 @@
<ClCompile Include="Framebuffer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="HandleAllocator.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="IndexDataManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -62,6 +59,9 @@
<ClCompile Include="..\common\Object.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\common\NameSpace.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Buffer.h">
@@ -73,9 +73,6 @@
<ClInclude Include="Framebuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="HandleAllocator.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="IndexDataManager.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -130,6 +127,9 @@
<ClInclude Include="..\common\Object.hpp">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\common\NameSpace.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="libGLES_CM.rc" />
diff --git a/src/OpenGL/libGLESv2/Context.cpp b/src/OpenGL/libGLESv2/Context.cpp
index 30a1d7e..a141b26 100644
--- a/src/OpenGL/libGLESv2/Context.cpp
+++ b/src/OpenGL/libGLESv2/Context.cpp
@@ -44,7 +44,7 @@
sw::Context *context = new sw::Context();
device = new es2::Device(context);
- mFenceHandleAllocator.setBaseHandle(0);
+ mFenceNameSpace.setBaseHandle(0);
setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -775,7 +775,7 @@
// Returns an unused framebuffer name
GLuint Context::createFramebuffer()
{
- GLuint handle = mFramebufferHandleAllocator.allocate();
+ GLuint handle = mFramebufferNameSpace.allocate();
mFramebufferMap[handle] = NULL;
@@ -784,7 +784,7 @@
GLuint Context::createFence()
{
- GLuint handle = mFenceHandleAllocator.allocate();
+ GLuint handle = mFenceNameSpace.allocate();
mFenceMap[handle] = new Fence;
@@ -794,7 +794,7 @@
// Returns an unused query name
GLuint Context::createQuery()
{
- GLuint handle = mQueryHandleAllocator.allocate();
+ GLuint handle = mQueryNameSpace.allocate();
mQueryMap[handle] = NULL;
@@ -849,7 +849,7 @@
{
detachFramebuffer(framebuffer);
- mFramebufferHandleAllocator.release(framebufferObject->first);
+ mFramebufferNameSpace.release(framebufferObject->first);
delete framebufferObject->second;
mFramebufferMap.erase(framebufferObject);
}
@@ -861,7 +861,7 @@
if(fenceObject != mFenceMap.end())
{
- mFenceHandleAllocator.release(fenceObject->first);
+ mFenceNameSpace.release(fenceObject->first);
delete fenceObject->second;
mFenceMap.erase(fenceObject);
}
@@ -873,7 +873,7 @@
if(queryObject != mQueryMap.end())
{
- mQueryHandleAllocator.release(queryObject->first);
+ mQueryNameSpace.release(queryObject->first);
if(queryObject->second)
{
diff --git a/src/OpenGL/libGLESv2/Context.h b/src/OpenGL/libGLESv2/Context.h
index 9878cf6..5d25b40 100644
--- a/src/OpenGL/libGLESv2/Context.h
+++ b/src/OpenGL/libGLESv2/Context.h
@@ -17,7 +17,7 @@
#include "libEGL/Context.hpp"
#include "ResourceManager.h"
-#include "HandleAllocator.h"
+#include "common/NameSpace.hpp"
#include "common/Object.hpp"
#include "Image.hpp"
#include "Renderer/Sampler.hpp"
@@ -470,15 +470,15 @@
typedef std::map<GLint, Framebuffer*> FramebufferMap;
FramebufferMap mFramebufferMap;
- HandleAllocator mFramebufferHandleAllocator;
+ gl::NameSpace mFramebufferNameSpace;
typedef std::map<GLint, Fence*> FenceMap;
FenceMap mFenceMap;
- HandleAllocator mFenceHandleAllocator;
+ gl::NameSpace mFenceNameSpace;
typedef std::map<GLint, Query*> QueryMap;
QueryMap mQueryMap;
- HandleAllocator mQueryHandleAllocator;
+ gl::NameSpace mQueryNameSpace;
VertexDataManager *mVertexDataManager;
IndexDataManager *mIndexDataManager;
diff --git a/src/OpenGL/libGLESv2/HandleAllocator.cpp b/src/OpenGL/libGLESv2/HandleAllocator.cpp
deleted file mode 100644
index 85813f2..0000000
--- a/src/OpenGL/libGLESv2/HandleAllocator.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2012 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// HandleAllocator.cpp: Implements the HandleAllocator class, which is used
-// to allocate GL handles.
-
-#include "HandleAllocator.h"
-
-#include "main.h"
-
-namespace es2
-{
-
-HandleAllocator::HandleAllocator() : mBaseValue(1), mNextValue(1)
-{
-}
-
-HandleAllocator::~HandleAllocator()
-{
-}
-
-void HandleAllocator::setBaseHandle(GLuint value)
-{
- ASSERT(mBaseValue == mNextValue);
- mBaseValue = value;
- mNextValue = value;
-}
-
-GLuint HandleAllocator::allocate()
-{
- if(mFreeValues.size())
- {
- GLuint handle = mFreeValues.back();
- mFreeValues.pop_back();
- return handle;
- }
- return mNextValue++;
-}
-
-void HandleAllocator::release(GLuint handle)
-{
- if(handle == mNextValue - 1)
- {
- // Don't drop below base value
- if(mNextValue > mBaseValue)
- {
- mNextValue--;
- }
- }
- else
- {
- // Only free handles that we own - don't drop below the base value
- if(handle >= mBaseValue)
- {
- mFreeValues.push_back(handle);
- }
- }
-}
-
-}
diff --git a/src/OpenGL/libGLESv2/HandleAllocator.h b/src/OpenGL/libGLESv2/HandleAllocator.h
deleted file mode 100644
index 8079d12..0000000
--- a/src/OpenGL/libGLESv2/HandleAllocator.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2012 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// HandleAllocator.h: Defines the HandleAllocator class, which is used to
-// allocate GL handles.
-
-#ifndef LIBGLESV2_HANDLEALLOCATOR_H_
-#define LIBGLESV2_HANDLEALLOCATOR_H_
-
-#define GL_APICALL
-#include <GLES2/gl2.h>
-
-#include <vector>
-
-namespace es2
-{
-
-class HandleAllocator
-{
- public:
- HandleAllocator();
- virtual ~HandleAllocator();
-
- void setBaseHandle(GLuint value);
-
- GLuint allocate();
- void release(GLuint handle);
-
- private:
- GLuint mBaseValue;
- GLuint mNextValue;
- typedef std::vector<GLuint> HandleList;
- HandleList mFreeValues;
-};
-
-}
-
-#endif // LIBGLESV2_HANDLEALLOCATOR_H_
diff --git a/src/OpenGL/libGLESv2/ResourceManager.cpp b/src/OpenGL/libGLESv2/ResourceManager.cpp
index 2f6fd74..4f6b177 100644
--- a/src/OpenGL/libGLESv2/ResourceManager.cpp
+++ b/src/OpenGL/libGLESv2/ResourceManager.cpp
@@ -71,7 +71,7 @@
// Returns an unused buffer name
GLuint ResourceManager::createBuffer()
{
- GLuint handle = mBufferHandleAllocator.allocate();
+ GLuint handle = mBufferNameSpace.allocate();
mBufferMap[handle] = NULL;
@@ -81,7 +81,7 @@
// Returns an unused shader/program name
GLuint ResourceManager::createShader(GLenum type)
{
- GLuint handle = mProgramShaderHandleAllocator.allocate();
+ GLuint handle = mProgramShaderNameSpace.allocate();
if(type == GL_VERTEX_SHADER)
{
@@ -99,7 +99,7 @@
// Returns an unused program/shader name
GLuint ResourceManager::createProgram()
{
- GLuint handle = mProgramShaderHandleAllocator.allocate();
+ GLuint handle = mProgramShaderNameSpace.allocate();
mProgramMap[handle] = new Program(this, handle);
@@ -109,7 +109,7 @@
// Returns an unused texture name
GLuint ResourceManager::createTexture()
{
- GLuint handle = mTextureHandleAllocator.allocate();
+ GLuint handle = mTextureNameSpace.allocate();
mTextureMap[handle] = NULL;
@@ -119,7 +119,7 @@
// Returns an unused renderbuffer name
GLuint ResourceManager::createRenderbuffer()
{
- GLuint handle = mRenderbufferHandleAllocator.allocate();
+ GLuint handle = mRenderbufferNameSpace.allocate();
mRenderbufferMap[handle] = NULL;
@@ -132,7 +132,7 @@
if(bufferObject != mBufferMap.end())
{
- mBufferHandleAllocator.release(bufferObject->first);
+ mBufferNameSpace.release(bufferObject->first);
if(bufferObject->second) bufferObject->second->release();
mBufferMap.erase(bufferObject);
}
@@ -146,7 +146,7 @@
{
if(shaderObject->second->getRefCount() == 0)
{
- mProgramShaderHandleAllocator.release(shaderObject->first);
+ mProgramShaderNameSpace.release(shaderObject->first);
delete shaderObject->second;
mShaderMap.erase(shaderObject);
}
@@ -165,7 +165,7 @@
{
if(programObject->second->getRefCount() == 0)
{
- mProgramShaderHandleAllocator.release(programObject->first);
+ mProgramShaderNameSpace.release(programObject->first);
delete programObject->second;
mProgramMap.erase(programObject);
}
@@ -182,7 +182,7 @@
if(textureObject != mTextureMap.end())
{
- mTextureHandleAllocator.release(textureObject->first);
+ mTextureNameSpace.release(textureObject->first);
if(textureObject->second) textureObject->second->release();
mTextureMap.erase(textureObject);
}
@@ -194,7 +194,7 @@
if(renderbufferObject != mRenderbufferMap.end())
{
- mRenderbufferHandleAllocator.release(renderbufferObject->first);
+ mRenderbufferNameSpace.release(renderbufferObject->first);
if(renderbufferObject->second) renderbufferObject->second->release();
mRenderbufferMap.erase(renderbufferObject);
}
diff --git a/src/OpenGL/libGLESv2/ResourceManager.h b/src/OpenGL/libGLESv2/ResourceManager.h
index d7d626d..504563e 100644
--- a/src/OpenGL/libGLESv2/ResourceManager.h
+++ b/src/OpenGL/libGLESv2/ResourceManager.h
@@ -15,7 +15,7 @@
#ifndef LIBGLESV2_RESOURCEMANAGER_H_
#define LIBGLESV2_RESOURCEMANAGER_H_
-#include "HandleAllocator.h"
+#include "common/NameSpace.hpp"
#define GL_APICALL
#include <GLES2/gl2.h>
@@ -78,22 +78,22 @@
typedef std::map<GLint, Buffer*> BufferMap;
BufferMap mBufferMap;
- HandleAllocator mBufferHandleAllocator;
+ gl::NameSpace mBufferNameSpace;
typedef std::map<GLint, Shader*> ShaderMap;
ShaderMap mShaderMap;
typedef std::map<GLint, Program*> ProgramMap;
ProgramMap mProgramMap;
- HandleAllocator mProgramShaderHandleAllocator;
+ gl::NameSpace mProgramShaderNameSpace;
typedef std::map<GLint, Texture*> TextureMap;
TextureMap mTextureMap;
- HandleAllocator mTextureHandleAllocator;
+ gl::NameSpace mTextureNameSpace;
typedef std::map<GLint, Renderbuffer*> RenderbufferMap;
RenderbufferMap mRenderbufferMap;
- HandleAllocator mRenderbufferHandleAllocator;
+ gl::NameSpace mRenderbufferNameSpace;
};
}
diff --git a/src/OpenGL/libGLESv2/libGLESv2.vcxproj b/src/OpenGL/libGLESv2/libGLESv2.vcxproj
index aaa95be..58076d4 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.vcxproj
+++ b/src/OpenGL/libGLESv2/libGLESv2.vcxproj
@@ -318,6 +318,7 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="..\common\NameSpace.cpp" />
<ClCompile Include="..\common\Object.cpp" />
<ClCompile Include="Buffer.cpp" />
<ClCompile Include="Context.cpp" />
@@ -325,7 +326,6 @@
<ClCompile Include="Device.cpp" />
<ClCompile Include="Fence.cpp" />
<ClCompile Include="Framebuffer.cpp" />
- <ClCompile Include="HandleAllocator.cpp" />
<ClCompile Include="Image.cpp" />
<ClCompile Include="IndexDataManager.cpp" />
<ClCompile Include="libGLESv2.cpp" />
@@ -341,6 +341,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\debug.h" />
+ <ClInclude Include="..\common\NameSpace.hpp" />
<ClInclude Include="..\common\Object.hpp" />
<ClInclude Include="..\include\GLES2\gl2.h" />
<ClInclude Include="..\include\GLES2\gl2ext.h" />
@@ -350,7 +351,6 @@
<ClInclude Include="Device.hpp" />
<ClInclude Include="Fence.h" />
<ClInclude Include="Framebuffer.h" />
- <ClInclude Include="HandleAllocator.h" />
<ClInclude Include="Image.hpp" />
<ClInclude Include="IndexDataManager.h" />
<ClInclude Include="main.h" />
diff --git a/src/OpenGL/libGLESv2/libGLESv2.vcxproj.filters b/src/OpenGL/libGLESv2/libGLESv2.vcxproj.filters
index c67845b..c2501d5 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.vcxproj.filters
+++ b/src/OpenGL/libGLESv2/libGLESv2.vcxproj.filters
@@ -26,9 +26,6 @@
<ClCompile Include="Framebuffer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="HandleAllocator.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="IndexDataManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -71,6 +68,9 @@
<ClCompile Include="..\common\Object.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\common\NameSpace.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Buffer.h">
@@ -85,9 +85,6 @@
<ClInclude Include="Framebuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="HandleAllocator.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="IndexDataManager.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -145,6 +142,9 @@
<ClInclude Include="..\common\Object.hpp">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\common\NameSpace.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="libGLESv2.rc" />