opengles emulator: object name manager name generation

genName in the globalNameSpace now calls the glGen* function of opengl
to generate a global name instead of inventing one.
this is to overcome a bug in intel driver which raises glError when
binding a framebuffer/renderbuffer with a name that was not generated
by opengl.

Change-Id: Ia0c2fefbf3538c185c380ba62d74eb94f2b28254
This commit is contained in:
Yochai Shefi Simchon
2011-08-03 17:32:56 +03:00
committed by David 'Digit' Turner
parent 3127d80bd8
commit aaac179eb5
2 changed files with 49 additions and 39 deletions

View File

@@ -15,6 +15,7 @@
*/ */
#include <map> #include <map>
#include <GLcommon/objectNameManager.h> #include <GLcommon/objectNameManager.h>
#include <GLcommon/GLEScontext.h>
NameSpace::NameSpace(NamedObjectType p_type, GlobalNameSpace *globalNameSpace) : NameSpace::NameSpace(NamedObjectType p_type, GlobalNameSpace *globalNameSpace) :
@@ -105,6 +106,50 @@ NameSpace::replaceGlobalName(ObjectLocalName p_localName, unsigned int p_globalN
} }
} }
GlobalNameSpace::GlobalNameSpace()
{
mutex_init(&m_lock);
}
GlobalNameSpace::~GlobalNameSpace()
{
mutex_destroy(&m_lock);
}
unsigned int
GlobalNameSpace::genName(NamedObjectType p_type)
{
if ( p_type >= NUM_OBJECT_TYPES ) return 0;
unsigned int name = 0;
mutex_lock(&m_lock);
switch (p_type) {
case VERTEXBUFFER:
GLEScontext::dispatcher().glGenBuffers(1,&name);
break;
case TEXTURE:
GLEScontext::dispatcher().glGenTextures(1,&name);
break;
case RENDERBUFFER:
GLEScontext::dispatcher().glGenRenderbuffersEXT(1,&name);
break;
case FRAMEBUFFER:
GLEScontext::dispatcher().glGenFramebuffersEXT(1,&name);
break;
case SHADER: //objects in shader namepace are not handled
default:
name = 0;
}
mutex_unlock(&m_lock);
return name;
}
void
GlobalNameSpace::deleteName(NamedObjectType p_type, unsigned int p_name)
{
}
typedef std::pair<NamedObjectType, ObjectLocalName> ObjectIDPair; typedef std::pair<NamedObjectType, ObjectLocalName> ObjectIDPair;
typedef std::map<ObjectIDPair, ObjectDataPtr> ObjectDataMap; typedef std::map<ObjectIDPair, ObjectDataPtr> ObjectDataMap;

View File

@@ -118,48 +118,13 @@ private:
class GlobalNameSpace class GlobalNameSpace
{ {
public: public:
GlobalNameSpace() GlobalNameSpace();
{ ~GlobalNameSpace();
mutex_init(&m_lock); unsigned int genName(NamedObjectType p_type);
void deleteName(NamedObjectType p_type, unsigned int p_name);
for (int i=0; i<NUM_OBJECT_TYPES; i++) {
m_nameSpace[i] = new NameSpace((NamedObjectType)i, NULL);
}
}
~GlobalNameSpace()
{
mutex_lock(&m_lock);
for (int i=0; i<NUM_OBJECT_TYPES; i++) {
delete m_nameSpace[i];
}
mutex_unlock(&m_lock);
mutex_destroy(&m_lock);
}
unsigned int genName(NamedObjectType p_type)
{
if ( p_type >= NUM_OBJECT_TYPES ) return 0;
mutex_lock(&m_lock);
unsigned int name = m_nameSpace[p_type]->genName(0, false,true);
mutex_unlock(&m_lock);
return name;
}
void deleteName(NamedObjectType p_type, unsigned int p_name)
{
if ( p_type >= NUM_OBJECT_TYPES ) return;
mutex_lock(&m_lock);
m_nameSpace[p_type]->deleteName(p_name);
mutex_unlock(&m_lock);
}
private: private:
mutex_t m_lock; mutex_t m_lock;
NameSpace *m_nameSpace[NUM_OBJECT_TYPES];
}; };
// //