Commit faef5e4e by Nicolas Capens Committed by Nicolas Capens

Eliminate GL handle allocator.

Bug 18591036 Change-Id: Ic0d5183a3c5bcfb32802bf5a94253915f9113c2e Reviewed-on: https://swiftshader-review.googlesource.com/1553Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 490cdca4
......@@ -39,8 +39,6 @@ Context::Context(const egl::Config *config, const Context *shareContext) : mConf
sw::Context *context = new sw::Context();
device = new es2::Device(context);
mFenceHandleAllocator.setBaseHandle(0);
setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
mState.depthClearValue = 1.0f;
......
......@@ -16,7 +16,6 @@
#define LIBGLESV2_CONTEXT_H_
#include "libEGL/Context.hpp"
#include "HandleAllocator.h"
#include "RefCountObject.h"
#include "Image.hpp"
#include "Renderer/Sampler.hpp"
......@@ -347,18 +346,6 @@ public:
State mState;
typedef std::map<GLint, Framebuffer*> FramebufferMap;
FramebufferMap mFramebufferMap;
HandleAllocator mFramebufferHandleAllocator;
typedef std::map<GLint, Fence*> FenceMap;
FenceMap mFenceMap;
HandleAllocator mFenceHandleAllocator;
typedef std::map<GLint, Query*> QueryMap;
QueryMap mQueryMap;
HandleAllocator mQueryHandleAllocator;
// Recorded errors
bool mInvalidEnum;
bool mInvalidValue;
......
// 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);
}
}
}
}
// 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_
......@@ -164,7 +164,6 @@ copy "$(OutDir)libRAD.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
<ClCompile Include="..\common\debug.cpp" />
<ClCompile Include="Device.cpp" />
<ClCompile Include="Fence.cpp" />
<ClCompile Include="HandleAllocator.cpp" />
<ClCompile Include="Image.cpp" />
<ClCompile Include="libRAD.cpp" />
<ClCompile Include="main.cpp" />
......@@ -184,7 +183,6 @@ copy "$(OutDir)libRAD.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
<ClInclude Include="Context.h" />
<ClInclude Include="Device.hpp" />
<ClInclude Include="Fence.h" />
<ClInclude Include="HandleAllocator.h" />
<ClInclude Include="Image.hpp" />
<ClInclude Include="main.h" />
<ClInclude Include="mathutil.h" />
......
......@@ -20,9 +20,6 @@
<ClCompile Include="Fence.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HandleAllocator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="libRAD.cpp">
<Filter>Source Files</Filter>
</ClCompile>
......@@ -64,9 +61,6 @@
<ClInclude Include="Fence.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HandleAllocator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>Header Files</Filter>
</ClInclude>
......
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