aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/linker.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-10-24 08:15:59 +0200
committermarha <marha@users.sourceforge.net>2013-10-24 08:15:59 +0200
commit285b1bd8933288fc56259cfb3de61207c8e35d9e (patch)
tree2107aaa7f683f16a9a1a73e5f6f2d7ba53710f32 /mesalib/src/glsl/linker.cpp
parentc665b6e88274f8bc603b0f14f92bf09d2023bd4d (diff)
parent4eb0b643ad978d94837e2d587a5d4358f974a25c (diff)
downloadvcxsrv-285b1bd8933288fc56259cfb3de61207c8e35d9e.tar.gz
vcxsrv-285b1bd8933288fc56259cfb3de61207c8e35d9e.tar.bz2
vcxsrv-285b1bd8933288fc56259cfb3de61207c8e35d9e.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig mesa xserver git update 24 oct 2013 Conflicts: xorg-server/glx/glxdricommon.c
Diffstat (limited to 'mesalib/src/glsl/linker.cpp')
-rw-r--r--mesalib/src/glsl/linker.cpp60
1 files changed, 28 insertions, 32 deletions
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 9095a4015..b23c31a16 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -366,35 +366,38 @@ parse_program_resource_name(const GLchar *name,
void
-link_invalidate_variable_locations(gl_shader *sh, int input_base,
- int output_base)
+link_invalidate_variable_locations(exec_list *ir)
{
- foreach_list(node, sh->ir) {
+ foreach_list(node, ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL)
continue;
- int base;
- switch (var->mode) {
- case ir_var_shader_in:
- base = input_base;
- break;
- case ir_var_shader_out:
- base = output_base;
- break;
- default:
- continue;
- }
-
- /* Only assign locations for generic attributes / varyings / etc.
+ /* Only assign locations for variables that lack an explicit location.
+ * Explicit locations are set for all built-in variables, generic vertex
+ * shader inputs (via layout(location=...)), and generic fragment shader
+ * outputs (also via layout(location=...)).
*/
- if ((var->location >= base) && !var->explicit_location)
+ if (!var->explicit_location) {
var->location = -1;
+ var->location_frac = 0;
+ }
- if ((var->location == -1) && !var->explicit_location) {
+ /* ir_variable::is_unmatched_generic_inout is used by the linker while
+ * connecting outputs from one stage to inputs of the next stage.
+ *
+ * There are two implicit assumptions here. First, we assume that any
+ * built-in variable (i.e., non-generic in or out) will have
+ * explicit_location set. Second, we assume that any generic in or out
+ * will not have explicit_location set.
+ *
+ * This second assumption will only be valid until
+ * GL_ARB_separate_shader_objects is supported. When that extension is
+ * implemented, this function will need some modifications.
+ */
+ if (!var->explicit_location) {
var->is_unmatched_generic_inout = 1;
- var->location_frac = 0;
} else {
var->is_unmatched_generic_inout = 0;
}
@@ -2057,14 +2060,10 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
}
}
- /* Previous to GLSL version 1.30, different compilation units could mix and
- * match shading language versions. With GLSL 1.30 and later, the versions
- * of all shaders must match.
- *
- * GLSL ES has never allowed mixing of shading language versions.
+ /* In desktop GLSL, different shader versions may be linked together. In
+ * GLSL ES, all shader versions must be the same.
*/
- if ((is_es_prog || max_version >= 130)
- && min_version != max_version) {
+ if (is_es_prog && min_version != max_version) {
linker_error(prog, "all shaders must use same shading "
"language version\n");
goto done;
@@ -2221,18 +2220,15 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
/* Mark all generic shader inputs and outputs as unpaired. */
if (prog->_LinkedShaders[MESA_SHADER_VERTEX] != NULL) {
link_invalidate_variable_locations(
- prog->_LinkedShaders[MESA_SHADER_VERTEX],
- VERT_ATTRIB_GENERIC0, VARYING_SLOT_VAR0);
+ prog->_LinkedShaders[MESA_SHADER_VERTEX]->ir);
}
if (prog->_LinkedShaders[MESA_SHADER_GEOMETRY] != NULL) {
link_invalidate_variable_locations(
- prog->_LinkedShaders[MESA_SHADER_GEOMETRY],
- VARYING_SLOT_VAR0, VARYING_SLOT_VAR0);
+ prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->ir);
}
if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] != NULL) {
link_invalidate_variable_locations(
- prog->_LinkedShaders[MESA_SHADER_FRAGMENT],
- VARYING_SLOT_VAR0, FRAG_RESULT_DATA0);
+ prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir);
}
/* FINISHME: The value of the max_attribute_index parameter is