[Mesa-dev] [PATCH 33/70] glsl/mesa: add reference to gl_shader_program_data from gl_program

Timothy Arceri timothy.arceri at collabora.com
Fri Nov 11 00:46:15 UTC 2016


We also add the stubs for the standalone compiler in this change.

By adding a reference here we can now refactor some code to use
gl_program where we were previously awkwardly using gl_shader_program.
---
 src/compiler/glsl/linker.cpp                 | 1 +
 src/compiler/glsl/standalone_scaffolding.cpp | 9 +++++++++
 src/compiler/glsl/standalone_scaffolding.h   | 5 +++++
 src/mesa/main/mtypes.h                       | 3 +++
 src/mesa/program/program.c                   | 2 ++
 5 files changed, 20 insertions(+)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 6ce4e04..d82c41c 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -2196,6 +2196,7 @@ link_intrastage_shaders(void *mem_ctx,
       return NULL;
    }
 
+   _mesa_reference_shader_program_data(ctx, &gl_prog->sh.data, prog->data);
    _mesa_reference_program(ctx, &linked->Program, gl_prog);
 
    linked->ir = new(linked) exec_list;
diff --git a/src/compiler/glsl/standalone_scaffolding.cpp b/src/compiler/glsl/standalone_scaffolding.cpp
index 9160ba0..546ba72 100644
--- a/src/compiler/glsl/standalone_scaffolding.cpp
+++ b/src/compiler/glsl/standalone_scaffolding.cpp
@@ -54,6 +54,15 @@ _mesa_warning(struct gl_context *ctx, const char *fmt, ...)
 }
 
 void
+_mesa_reference_shader_program_data(struct gl_context *ctx,
+                                    struct gl_shader_program_data **ptr,
+                                    struct gl_shader_program_data *data)
+{
+   (void) ctx;
+   *ptr = data;
+}
+
+void
 _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
                        struct gl_shader *sh)
 {
diff --git a/src/compiler/glsl/standalone_scaffolding.h b/src/compiler/glsl/standalone_scaffolding.h
index 790ff4a..5d17919 100644
--- a/src/compiler/glsl/standalone_scaffolding.h
+++ b/src/compiler/glsl/standalone_scaffolding.h
@@ -39,6 +39,11 @@ extern "C" void
 _mesa_warning(struct gl_context *ctx, const char *fmtString, ... );
 
 extern "C" void
+_mesa_reference_shader_program_data(struct gl_context *ctx,
+                                    struct gl_shader_program_data **ptr,
+                                    struct gl_shader_program_data *data);
+
+extern "C" void
 _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
                        struct gl_shader *sh);
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index cf83548..e2d6869 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1948,6 +1948,9 @@ struct gl_program
    union {
       /** Fields used by GLSL programs */
       struct {
+         /** Data shared by gl_program and gl_shader_program */
+         struct gl_shader_program_data *data;
+
          struct gl_active_atomic_buffer **AtomicBuffers;
 
          /** Post-link transform feedback info. */
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index 1248da4..c6949ba 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -34,6 +34,7 @@
 #include "main/framebuffer.h"
 #include "main/hash.h"
 #include "main/macros.h"
+#include "main/shaderobj.h"
 #include "program.h"
 #include "prog_cache.h"
 #include "prog_parameter.h"
@@ -312,6 +313,7 @@ _mesa_reference_program_(struct gl_context *ctx,
 
       if (deleteFlag) {
          assert(ctx);
+         _mesa_reference_shader_program_data(ctx, &oldProg->sh.data, NULL);
          ctx->Driver.DeleteProgram(ctx, oldProg);
       }
 
-- 
2.7.4



More information about the mesa-dev mailing list