[Mesa-dev] [PATCH 2/4] mesa: Keep track of user settings for fragment data locations

Ian Romanick idr at freedesktop.org
Fri Nov 4 16:40:58 PDT 2011


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/mtypes.h         |    9 +++++++++
 src/mesa/main/shader_query.cpp |    2 +-
 src/mesa/main/shaderobj.c      |    6 ++++++
 3 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 6190972..5862f93 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2184,6 +2184,15 @@ struct gl_shader_program
     */
    struct string_to_uint_map *AttributeBindings;
 
+   /**
+    * User-defined fragment data bindings
+    *
+    * These are set via \c glBindFragDataLocation and are used to direct the
+    * GLSL linker.  These are \b not the values used in the compiled shader,
+    * and they are \b not the values returned by \c glGetFragDataLocation.
+    */
+   struct string_to_uint_map *FragDataBindings;
+
    /** Transform feedback varyings */
    struct {
       GLenum BufferMode;
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 0694b48..23667a1 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -267,7 +267,7 @@ _mesa_BindFragDataLocation(GLuint program, GLuint colorNumber,
     * FRAG_RESULT_DATA0 because that's how the linker differentiates
     * between built-in attributes and user-defined attributes.
     */
-
+   shProg->FragDataBindings->put(colorNumber + FRAG_RESULT_DATA0, name);
 
    /*
     * Note that this binding won't go into effect until
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index ccf7efd..5efc651 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -241,6 +241,7 @@ _mesa_init_shader_program(struct gl_context *ctx, struct gl_shader_program *prog
    prog->RefCount = 1;
 
    prog->AttributeBindings = string_to_uint_map_ctor();
+   prog->FragDataBindings = string_to_uint_map_ctor();
 
 #if FEATURE_ARB_geometry_shader4
    prog->Geom.VerticesOut = 0;
@@ -311,6 +312,11 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
       shProg->AttributeBindings = NULL;
    }
 
+   if (shProg->FragDataBindings) {
+      string_to_uint_map_dtor(shProg->FragDataBindings);
+      shProg->FragDataBindings = NULL;
+   }
+
    /* detach shaders */
    for (i = 0; i < shProg->NumShaders; i++) {
       _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL);
-- 
1.7.6.4



More information about the mesa-dev mailing list