summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2011-11-04 16:08:52 -0700
committerIan Romanick <[email protected]>2011-11-08 11:10:11 -0800
commitb12b5d9ab5c0153c93ca5ad9cd93cb36e41be4eb (patch)
tree774cdb05ed2b05230cf54f0e5aadf1a3d836c2e8 /src/mesa
parent4464a4b27b66f832acbe52b0a002c04415924c14 (diff)
linker: Use app-specified fragment data location during linking
Fixes piglit's bindfragdata-link-error. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/mtypes.h9
-rw-r--r--src/mesa/main/shader_query.cpp2
-rw-r--r--src/mesa/main/shaderobj.c6
3 files changed, 16 insertions, 1 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5f2456cd0ab..ae6a33e0438 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2185,6 +2185,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 0694b48aeb1..23667a13328 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 9abf606f00f..454007f8353 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -240,6 +240,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;
@@ -316,6 +317,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);