X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fshared.c;h=8b7159db09cd507a946186509e73f8c480f4c9b5;hb=b79782cbedf8b23ea392d9a597eb4831a605bbe0;hp=a56c70fa7f65c847e1dbc61ac0001362deadeffc;hpb=695cc370a280a637f411f5ff3877b3fd1c05e424;p=mesa.git diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index a56c70fa7f6..8b7159db09c 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -27,9 +27,8 @@ * Shared-context state */ - - #include "imports.h" +#include "mfeatures.h" #include "mtypes.h" #include "hash.h" #if FEATURE_ATI_fragment_shader @@ -39,9 +38,13 @@ #include "shared.h" #include "program/program.h" #include "dlist.h" +#if FEATURE_ARB_sampler_objects +#include "samplerobj.h" +#endif #include "shaderobj.h" #include "syncobj.h" + /** * Allocate and initialize a shared context state structure. * Initializes the display list, texture objects and vertex programs hash @@ -52,7 +55,7 @@ * failure. */ struct gl_shared_state * -_mesa_alloc_shared_state(GLcontext *ctx) +_mesa_alloc_shared_state(struct gl_context *ctx) { struct gl_shared_state *shared; GLuint i; @@ -90,6 +93,11 @@ _mesa_alloc_shared_state(GLcontext *ctx) shared->BufferObjects = _mesa_NewHashTable(); #endif +#if FEATURE_ARB_sampler_objects + /* GL_ARB_sampler_objects */ + shared->SamplerObjects = _mesa_NewHashTable(); +#endif + /* Allocate the default buffer object */ shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0); @@ -97,6 +105,7 @@ _mesa_alloc_shared_state(GLcontext *ctx) for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { /* NOTE: the order of these enums matches the TEXTURE_x_INDEX values */ static const GLenum targets[NUM_TEXTURE_TARGETS] = { + GL_TEXTURE_BUFFER, GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_1D_ARRAY_EXT, GL_TEXTURE_CUBE_MAP, @@ -105,6 +114,7 @@ _mesa_alloc_shared_state(GLcontext *ctx) GL_TEXTURE_2D, GL_TEXTURE_1D }; + assert(Elements(targets) == NUM_TEXTURE_TARGETS); shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]); } @@ -133,7 +143,7 @@ static void delete_displaylist_cb(GLuint id, void *data, void *userData) { struct gl_display_list *list = (struct gl_display_list *) data; - GLcontext *ctx = (GLcontext *) userData; + struct gl_context *ctx = (struct gl_context *) userData; _mesa_delete_list(ctx, list); } @@ -145,7 +155,7 @@ static void delete_texture_cb(GLuint id, void *data, void *userData) { struct gl_texture_object *texObj = (struct gl_texture_object *) data; - GLcontext *ctx = (GLcontext *) userData; + struct gl_context *ctx = (struct gl_context *) userData; ctx->Driver.DeleteTexture(ctx, texObj); } @@ -157,7 +167,7 @@ static void delete_program_cb(GLuint id, void *data, void *userData) { struct gl_program *prog = (struct gl_program *) data; - GLcontext *ctx = (GLcontext *) userData; + struct gl_context *ctx = (struct gl_context *) userData; if(prog != &_mesa_DummyProgram) { ASSERT(prog->RefCount == 1); /* should only be referenced by hash table */ prog->RefCount = 0; /* now going away */ @@ -175,7 +185,7 @@ static void delete_fragshader_cb(GLuint id, void *data, void *userData) { struct ati_fragment_shader *shader = (struct ati_fragment_shader *) data; - GLcontext *ctx = (GLcontext *) userData; + struct gl_context *ctx = (struct gl_context *) userData; _mesa_delete_ati_fragment_shader(ctx, shader); } #endif @@ -188,9 +198,9 @@ static void delete_bufferobj_cb(GLuint id, void *data, void *userData) { struct gl_buffer_object *bufObj = (struct gl_buffer_object *) data; - GLcontext *ctx = (GLcontext *) userData; + struct gl_context *ctx = (struct gl_context *) userData; if (_mesa_bufferobj_mapped(bufObj)) { - ctx->Driver.UnmapBuffer(ctx, 0, bufObj); + ctx->Driver.UnmapBuffer(ctx, bufObj); bufObj->Pointer = NULL; } _mesa_reference_buffer_object(ctx, &bufObj, NULL); @@ -204,7 +214,7 @@ delete_bufferobj_cb(GLuint id, void *data, void *userData) static void free_shader_program_data_cb(GLuint id, void *data, void *userData) { - GLcontext *ctx = (GLcontext *) userData; + struct gl_context *ctx = (struct gl_context *) userData; struct gl_shader_program *shProg = (struct gl_shader_program *) data; if (shProg->Type == GL_SHADER_PROGRAM_MESA) { @@ -220,7 +230,7 @@ free_shader_program_data_cb(GLuint id, void *data, void *userData) static void delete_shader_cb(GLuint id, void *data, void *userData) { - GLcontext *ctx = (GLcontext *) userData; + struct gl_context *ctx = (struct gl_context *) userData; struct gl_shader *sh = (struct gl_shader *) data; if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER) { ctx->Driver.DeleteShader(ctx, sh); @@ -267,6 +277,20 @@ delete_renderbuffer_cb(GLuint id, void *data, void *userData) } +#if FEATURE_ARB_sampler_objects +/** + * Callback for deleting a sampler object. Called by _mesa_HashDeleteAll() + */ +static void +delete_sampler_object_cb(GLuint id, void *data, void *userData) +{ + struct gl_context *ctx = (struct gl_context *) userData; + struct gl_sampler_object *sampObj = (struct gl_sampler_object *) data; + _mesa_reference_sampler_object(ctx, &sampObj, NULL); +} +#endif + + /** * Deallocate a shared state object and all children structures. * @@ -280,7 +304,7 @@ delete_renderbuffer_cb(GLuint id, void *data, void *userData) * \sa alloc_shared_state(). */ static void -free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) +free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) { GLuint i; @@ -342,6 +366,11 @@ free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) } } +#if FEATURE_ARB_sampler_objects + _mesa_HashDeleteAll(shared->SamplerObjects, delete_sampler_object_cb, ctx); + _mesa_DeleteHashTable(shared->SamplerObjects); +#endif + /* * Free texture objects (after FBOs since some textures might have * been bound to FBOs). @@ -373,7 +402,8 @@ free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) * \sa free_shared_state(). */ void -_mesa_release_shared_state(GLcontext *ctx, struct gl_shared_state *shared) +_mesa_release_shared_state(struct gl_context *ctx, + struct gl_shared_state *shared) { GLint RefCount;