#include "imports.h"
#include "mtypes.h"
#include "hash.h"
-#include "hash_table.h"
#include "atifragshader.h"
#include "bufferobj.h"
#include "shared.h"
#include "program/program.h"
#include "dlist.h"
#include "samplerobj.h"
-#include "set.h"
#include "shaderapi.h"
#include "shaderobj.h"
#include "syncobj.h"
+#include "util/hash_table.h"
+#include "util/set.h"
/**
* Allocate and initialize a shared context state structure.
mtx_init(&shared->Mutex, mtx_plain);
shared->DisplayList = _mesa_NewHashTable();
+ shared->BitmapAtlas = _mesa_NewHashTable();
shared->TexObjects = _mesa_NewHashTable();
shared->Programs = _mesa_NewHashTable();
shared->SamplerObjects = _mesa_NewHashTable();
/* Allocate the default buffer object */
- shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0);
+ shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0);
/* Create default texture objects */
for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
GL_TEXTURE_2D,
GL_TEXTURE_1D
};
- STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS);
+ STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS);
shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]);
+ /* Need to explicitly set/overwrite the TargetIndex field here since
+ * the call to _mesa_tex_target_to_index() in NewTextureObject() may
+ * fail if the texture target is not supported.
+ */
+ shared->DefaultTex[i]->TargetIndex = i;
}
/* sanity check */
assert(shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount == 1);
/* Mutex and timestamp for texobj state validation */
- mtx_init(&shared->TexMutex, mtx_plain);
+ mtx_init(&shared->TexMutex, mtx_recursive);
shared->TextureStateStamp = 0;
shared->FrameBuffers = _mesa_NewHashTable();
shared->RenderBuffers = _mesa_NewHashTable();
- shared->SyncObjects = _mesa_set_create(NULL, _mesa_key_pointer_equal);
+ shared->SyncObjects = _mesa_set_create(NULL, _mesa_hash_pointer,
+ _mesa_key_pointer_equal);
return shared;
}
}
+/**
+ * Callback for deleting a bitmap atlas. Called by _mesa_HashDeleteAll().
+ */
+static void
+delete_bitmap_atlas_cb(GLuint id, void *data, void *userData)
+{
+ struct gl_bitmap_atlas *atlas = (struct gl_bitmap_atlas *) data;
+ struct gl_context *ctx = (struct gl_context *) userData;
+ _mesa_delete_bitmap_atlas(ctx, atlas);
+}
+
+
/**
* Callback for deleting a texture object. Called by _mesa_HashDeleteAll().
*/
struct gl_program *prog = (struct gl_program *) data;
struct gl_context *ctx = (struct gl_context *) userData;
if(prog != &_mesa_DummyProgram) {
- ASSERT(prog->RefCount == 1); /* should only be referenced by hash table */
+ assert(prog->RefCount == 1); /* should only be referenced by hash table */
prog->RefCount = 0; /* now going away */
ctx->Driver.DeleteProgram(ctx, prog);
}
struct gl_context *ctx = (struct gl_context *) userData;
struct gl_shader *sh = (struct gl_shader *) data;
if (_mesa_validate_shader_target(ctx, sh->Type)) {
- ctx->Driver.DeleteShader(ctx, sh);
+ _mesa_delete_shader(ctx, sh);
}
else {
struct gl_shader_program *shProg = (struct gl_shader_program *) data;
- ASSERT(shProg->Type == GL_SHADER_PROGRAM_MESA);
- ctx->Driver.DeleteShaderProgram(ctx, shProg);
+ assert(shProg->Type == GL_SHADER_PROGRAM_MESA);
+ _mesa_delete_shader_program(ctx, shProg);
}
}
*/
_mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx);
_mesa_DeleteHashTable(shared->DisplayList);
+ _mesa_HashDeleteAll(shared->BitmapAtlas, delete_bitmap_atlas_cb, ctx);
+ _mesa_DeleteHashTable(shared->BitmapAtlas);
_mesa_HashWalk(shared->ShaderObjects, free_shader_program_data_cb, ctx);
_mesa_HashDeleteAll(shared->ShaderObjects, delete_shader_cb, ctx);
struct set_entry *entry;
set_foreach(shared->SyncObjects, entry) {
- _mesa_unref_sync_object(ctx, (struct gl_sync_object *) entry->key);
+ _mesa_unref_sync_object(ctx, (struct gl_sync_object *) entry->key, 1);
}
}
_mesa_set_destroy(shared->SyncObjects, NULL);
* Free texture objects (after FBOs since some textures might have
* been bound to FBOs).
*/
- ASSERT(ctx->Driver.DeleteTexture);
+ assert(ctx->Driver.DeleteTexture);
/* the default textures */
for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]);