[Mesa-dev,03/23] mesa: remove Driver.DeleteShader

Submitted by Marek Olšák on Sept. 27, 2015, 10:20 p.m.

Details

Message ID 1443392452-668-4-git-send-email-maraeo@gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Marek Olšák Sept. 27, 2015, 10:20 p.m.
From: Marek Olšák <marek.olsak@amd.com>

Nothing overrides it.
---
 src/glsl/linker.cpp                 | 8 ++++----
 src/glsl/standalone_scaffolding.cpp | 8 ++++++++
 src/glsl/standalone_scaffolding.h   | 3 +++
 src/mesa/main/dd.h                  | 1 -
 src/mesa/main/shaderobj.c           | 8 +++-----
 src/mesa/main/shaderobj.h           | 3 +++
 src/mesa/main/shared.c              | 2 +-
 7 files changed, 22 insertions(+), 11 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 29ed1ce..eb9559c 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2132,7 +2132,7 @@  link_intrastage_shaders(void *mem_ctx,
 
 
    if (!ok) {
-      ctx->Driver.DeleteShader(ctx, linked);
+      _mesa_delete_shader(ctx, linked);
       return NULL;
    }
 
@@ -3674,7 +3674,7 @@  link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
 
    for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) {
       if (prog->_LinkedShaders[i] != NULL)
-	 ctx->Driver.DeleteShader(ctx, prog->_LinkedShaders[i]);
+	 _mesa_delete_shader(ctx, prog->_LinkedShaders[i]);
 
       prog->_LinkedShaders[i] = NULL;
    }
@@ -3689,7 +3689,7 @@  link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
 
          if (!prog->LinkStatus) {
             if (sh)
-               ctx->Driver.DeleteShader(ctx, sh);
+               _mesa_delete_shader(ctx, sh);
             goto done;
          }
 
@@ -3712,7 +3712,7 @@  link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
          }
          if (!prog->LinkStatus) {
             if (sh)
-               ctx->Driver.DeleteShader(ctx, sh);
+               _mesa_delete_shader(ctx, sh);
             goto done;
          }
 
diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp
index e52869f..0941149 100644
--- a/src/glsl/standalone_scaffolding.cpp
+++ b/src/glsl/standalone_scaffolding.cpp
@@ -86,6 +86,14 @@  _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
 }
 
 void
+_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
+{
+   free((void *)sh->Source);
+   free(sh->Label);
+   ralloc_free(sh);
+}
+
+void
 _mesa_clear_shader_program_data(struct gl_shader_program *shProg)
 {
    unsigned i;
diff --git a/src/glsl/standalone_scaffolding.h b/src/glsl/standalone_scaffolding.h
index dc6fb64..a9ca5e4 100644
--- a/src/glsl/standalone_scaffolding.h
+++ b/src/glsl/standalone_scaffolding.h
@@ -45,6 +45,9 @@  extern "C" struct gl_shader *
 _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type);
 
 extern "C" void
+_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh);
+
+extern "C" void
 _mesa_clear_shader_program_data(struct gl_shader_program *);
 
 extern "C" void
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 9d5104b..95831d1 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -783,7 +783,6 @@  struct dd_function_table {
     * \name GLSL-related functions (ARB extensions and OpenGL 2.x)
     */
    /*@{*/
-   void (*DeleteShader)(struct gl_context *ctx, struct gl_shader *shader);
    struct gl_shader_program *(*NewShaderProgram)(GLuint name);
    void (*DeleteShaderProgram)(struct gl_context *ctx,
                                struct gl_shader_program *shProg);
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index afacddc..885746c 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -74,7 +74,7 @@  _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
       if (deleteFlag) {
 	 if (old->Name != 0)
 	    _mesa_HashRemove(ctx->Shared->ShaderObjects, old->Name);
-         ctx->Driver.DeleteShader(ctx, old);
+         _mesa_delete_shader(ctx, old);
       }
 
       *ptr = NULL;
@@ -115,9 +115,8 @@  _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
 
 /**
  * Delete a shader object.
- * Called via ctx->Driver.DeleteShader().
  */
-static void
+void
 _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
 {
    free((void *)sh->Source);
@@ -361,7 +360,7 @@  _mesa_free_shader_program_data(struct gl_context *ctx,
 
    for (sh = 0; sh < MESA_SHADER_STAGES; sh++) {
       if (shProg->_LinkedShaders[sh] != NULL) {
-	 ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[sh]);
+	 _mesa_delete_shader(ctx, shProg->_LinkedShaders[sh]);
 	 shProg->_LinkedShaders[sh] = NULL;
       }
    }
@@ -437,7 +436,6 @@  _mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name,
 void
 _mesa_init_shader_object_functions(struct dd_function_table *driver)
 {
-   driver->DeleteShader = _mesa_delete_shader;
    driver->NewShaderProgram = _mesa_new_shader_program;
    driver->DeleteShaderProgram = _mesa_delete_shader_program;
    driver->LinkShader = _mesa_ir_link_shader;
diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
index 943044e..8add642 100644
--- a/src/mesa/main/shaderobj.h
+++ b/src/mesa/main/shaderobj.h
@@ -82,6 +82,9 @@  _mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader);
 extern struct gl_shader *
 _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type);
 
+extern void
+_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh);
+
 extern struct gl_shader_program *
 _mesa_lookup_shader_program(struct gl_context *ctx, GLuint name);
 
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index d5ac9f1..7ab89d0 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -219,7 +219,7 @@  delete_shader_cb(GLuint id, void *data, void *userData)
    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;