glsl/mesa: add reference to gl_shader_program_data from gl_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Tue, 20 Dec 2016 10:37:25 +0000 (21:37 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Fri, 30 Dec 2016 22:48:51 +0000 (09:48 +1100)
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.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/compiler/glsl/linker.cpp
src/compiler/glsl/standalone_scaffolding.cpp
src/compiler/glsl/standalone_scaffolding.h
src/mesa/main/mtypes.h
src/mesa/program/program.c

index c6bf3b1673618540021585491159ab98a7e27f27..f4f918a34e7e467a421b2ca6704634ecaf006b76 100644 (file)
@@ -2208,6 +2208,8 @@ link_intrastage_shaders(void *mem_ctx,
       return NULL;
    }
 
+   _mesa_reference_shader_program_data(ctx, &gl_prog->sh.data, prog->data);
+
    /* Don't use _mesa_reference_program() just take ownership */
    linked->Program = gl_prog;
 
index 9160ba03e9072c80c7d2f849179a38757502627a..546ba722ed3803ee3eda6a106e0425af8f5f8cb1 100644 (file)
@@ -53,6 +53,15 @@ _mesa_warning(struct gl_context *ctx, const char *fmt, ...)
     va_end(vargs);
 }
 
+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)
index 790ff4a251c8387b26b49f85432340aedfba1fa4..5d179191fbf34416e2cded82254c98a15632ede9 100644 (file)
 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);
index 39ae6674614e7090592fd19abf6c1a47a2add3f3..c7535a3776187aaae654f026d01535b015c39d11 100644 (file)
@@ -1952,6 +1952,9 @@ struct gl_program
    struct {
       /** 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. */
index 27ae1c6d0eed9ac4f09af2988c4ad8ebee8a4dc8..b728d862e54a966a252e7952d83450bbffee5916 100644 (file)
@@ -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"
@@ -313,6 +314,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);
       }