aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl
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/glsl
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/glsl')
-rw-r--r--src/glsl/linker.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index d2f68cba72b..0306b7a1b5f 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1139,12 +1139,6 @@ find_available_slots(unsigned used_mask, unsigned needed_count)
* \return
* If locations are successfully assigned, true is returned. Otherwise an
* error is emitted to the shader link log and false is returned.
- *
- * \bug
- * Locations set via \c glBindFragDataLocation are not currently supported.
- * Only locations assigned automatically by the linker, explicitly set by a
- * layout qualifier, or explicitly set by a built-in variable (e.g., \c
- * gl_FragColor) are supported for fragment shaders.
*/
bool
assign_attribute_or_color_locations(gl_shader_program *prog,
@@ -1168,7 +1162,8 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
* 1. Invalidate the location assignments for all vertex shader inputs.
*
* 2. Assign locations for inputs that have user-defined (via
- * glBindVertexAttribLocation) locations.
+ * glBindVertexAttribLocation) locations and outputs that have
+ * user-defined locations (via glBindFragDataLocation).
*
* 3. Sort the attributes without assigned locations by number of slots
* required in decreasing order. Fragmentation caused by attribute
@@ -1229,6 +1224,13 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
assert(binding >= VERT_ATTRIB_GENERIC0);
var->location = binding;
}
+ } else if (target_index == MESA_SHADER_FRAGMENT) {
+ unsigned binding;
+
+ if (prog->FragDataBindings->get(binding, var->name)) {
+ assert(binding >= FRAG_RESULT_DATA0);
+ var->location = binding;
+ }
}
/* If the variable is not a built-in and has a location statically