mesa: support for GL_ARB_instanced_arrays
[mesa.git] / src / mesa / main / shared.c
index f9d10f3bbea001d3045613c5fd4210eabb19bc69..ce9fc4de327474b61e8f5f0b8d5e41b02532670f 100644 (file)
@@ -30,9 +30,9 @@
 
 
 #include "imports.h"
+#include "mfeatures.h"
 #include "mtypes.h"
 #include "hash.h"
-#include "arrayobj.h"
 #if FEATURE_ATI_fragment_shader
 #include "atifragshader.h"
 #endif
@@ -41,9 +41,7 @@
 #include "program/program.h"
 #include "dlist.h"
 #include "shaderobj.h"
-#if FEATURE_ARB_sync
 #include "syncobj.h"
-#endif
 
 /**
  * Allocate and initialize a shared context state structure.
@@ -55,7 +53,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;
@@ -123,9 +121,7 @@ _mesa_alloc_shared_state(GLcontext *ctx)
    shared->RenderBuffers = _mesa_NewHashTable();
 #endif
 
-#if FEATURE_ARB_sync
    make_empty_list(& shared->SyncObjects);
-#endif
 
    return shared;
 }
@@ -138,7 +134,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);
 }
 
@@ -150,7 +146,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);
 }
 
@@ -162,7 +158,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 */
@@ -180,7 +176,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
@@ -193,7 +189,7 @@ 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);
       bufObj->Pointer = NULL;
@@ -209,7 +205,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) {
@@ -225,7 +221,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);
@@ -285,10 +281,14 @@ 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;
 
+   /* Free the dummy/fallback texture object */
+   if (shared->FallbackTex)
+      ctx->Driver.DeleteTexture(ctx, shared->FallbackTex);
+
    /*
     * Free display lists
     */
@@ -334,7 +334,6 @@ free_shared_state(GLcontext *ctx, struct gl_shared_state *shared)
    _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL);
 #endif
 
-#if FEATURE_ARB_sync
    {
       struct simple_node *node;
       struct simple_node *temp;
@@ -343,7 +342,6 @@ free_shared_state(GLcontext *ctx, struct gl_shared_state *shared)
         _mesa_unref_sync_object(ctx, (struct gl_sync_object *) node);
       }
    }
-#endif
 
    /*
     * Free texture objects (after FBOs since some textures might have
@@ -376,7 +374,7 @@ 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;