summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-01-11 14:39:32 -0800
committerPaul Berry <[email protected]>2013-01-24 16:30:30 -0800
commit42a29d89fd85c86387f0d119950e243b6de76d79 (patch)
tree9eee8f2d609855dc9c6813aac84f5fdcd6786a54 /src/mesa
parent7d51ead56e2b97d313c6a0fda22cc930b5c41e9d (diff)
glsl: Eliminate ambiguity between function ins/outs and shader ins/outs
This patch replaces the three ir_variable_mode enums: - ir_var_in - ir_var_out - ir_var_inout with the following five: - ir_var_shader_in - ir_var_shader_out - ir_var_function_in - ir_var_function_out - ir_var_function_inout This eliminates a frustrating ambiguity: it used to be impossible to tell whether an ir_var_{in,out} variable was a shader in/out or a function in/out without seeing where the variable was declared in the IR. This complicated some optimization and lowering passes, and would have become a problem for implementing varying structs. In the lisp-style serialization of GLSL IR to strings performed by ir_print_visitor.cpp and ir_reader.cpp, I've retained the names "in", "out", and "inout" for function parameters, to avoid introducing code churn to the src/glsl/builtins/ir/ directory. Note: a couple of comments in the code seemed to indicate that we were planning for a possible future in which geometry shaders could have shader-scope inout variables. Our GLSL grammar rejects shader-scope inout variables, and I've been unable to find any evidence in the GLSL standards documents (or extensions) that this will ever be allowed, so I've eliminated these comments. Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_fp.cpp2
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp10
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_visitor.cpp4
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp4
-rw-r--r--src/mesa/main/shader_query.cpp12
-rw-r--r--src/mesa/program/ir_to_mesa.cpp7
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp17
7 files changed, 26 insertions, 30 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
index 9ca082a0fc9..5f5f6a9ba76 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
@@ -610,7 +610,7 @@ fs_visitor::setup_fp_regs()
*/
ir_variable *ir = new(mem_ctx) ir_variable(glsl_type::vec4_type,
"fp_input",
- ir_var_in);
+ ir_var_shader_in);
ir->location = i;
this->current_annotation = ralloc_asprintf(ctx, "interpolate input %d",
diff --git a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp
index 7a12e084ff8..b9487532c59 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp
@@ -110,11 +110,13 @@ ir_vector_reference_visitor::get_variable_entry(ir_variable *var)
switch (var->mode) {
case ir_var_uniform:
- case ir_var_in:
- case ir_var_out:
- case ir_var_inout:
+ case ir_var_shader_in:
+ case ir_var_shader_out:
+ case ir_var_function_in:
+ case ir_var_function_out:
+ case ir_var_function_inout:
/* Can't split varyings or uniforms. Function in/outs won't get split
- * either, so don't care about the ambiguity.
+ * either.
*/
return NULL;
case ir_var_auto:
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 5885989e76e..ebb37fd3113 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -57,7 +57,7 @@ fs_visitor::visit(ir_variable *ir)
if (variable_storage(ir))
return;
- if (ir->mode == ir_var_in) {
+ if (ir->mode == ir_var_shader_in) {
if (!strcmp(ir->name, "gl_FragCoord")) {
reg = emit_fragcoord_interpolation(ir);
} else if (!strcmp(ir->name, "gl_FrontFacing")) {
@@ -68,7 +68,7 @@ fs_visitor::visit(ir_variable *ir)
assert(reg);
hash_table_insert(this->variable_ht, reg, ir);
return;
- } else if (ir->mode == ir_var_out) {
+ } else if (ir->mode == ir_var_shader_out) {
reg = new(this->mem_ctx) fs_reg(this, ir->type);
if (ir->index > 0) {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index d9ff869f2da..cff04ba887c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -905,11 +905,11 @@ vec4_visitor::visit(ir_variable *ir)
return;
switch (ir->mode) {
- case ir_var_in:
+ case ir_var_shader_in:
reg = new(mem_ctx) dst_reg(ATTR, ir->location);
break;
- case ir_var_out:
+ case ir_var_shader_out:
reg = new(mem_ctx) dst_reg(this, ir->type);
for (int i = 0; i < type_size(ir->type); i++) {
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 27b1b8f5688..3014a97785d 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -106,7 +106,7 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL
- || var->mode != ir_var_in
+ || var->mode != ir_var_shader_in
|| var->location == -1)
continue;
@@ -169,7 +169,7 @@ _mesa_GetAttribLocation(GLhandleARB program, const GLcharARB * name)
* attribute, or if an error occurs, -1 will be returned."
*/
if (var == NULL
- || var->mode != ir_var_in
+ || var->mode != ir_var_shader_in
|| var->location == -1
|| var->location < VERT_ATTRIB_GENERIC0)
continue;
@@ -197,7 +197,7 @@ _mesa_count_active_attribs(struct gl_shader_program *shProg)
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL
- || var->mode != ir_var_in
+ || var->mode != ir_var_shader_in
|| var->location == -1)
continue;
@@ -223,7 +223,7 @@ _mesa_longest_attribute_name_length(struct gl_shader_program *shProg)
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL
- || var->mode != ir_var_in
+ || var->mode != ir_var_shader_in
|| var->location == -1)
continue;
@@ -333,7 +333,7 @@ _mesa_GetFragDataIndex(GLuint program, const GLchar *name)
* attribute, or if an error occurs, -1 will be returned."
*/
if (var == NULL
- || var->mode != ir_var_out
+ || var->mode != ir_var_shader_out
|| var->location == -1
|| var->location < FRAG_RESULT_DATA0)
continue;
@@ -389,7 +389,7 @@ _mesa_GetFragDataLocation(GLuint program, const GLchar *name)
* attribute, or if an error occurs, -1 will be returned."
*/
if (var == NULL
- || var->mode != ir_var_out
+ || var->mode != ir_var_shader_out
|| var->location == -1
|| var->location < FRAG_RESULT_DATA0)
continue;
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 0f7439b3b06..4723ec3578b 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1529,21 +1529,18 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
var->location);
this->variables.push_tail(entry);
break;
- case ir_var_in:
- case ir_var_inout:
+ case ir_var_shader_in:
/* The linker assigns locations for varyings and attributes,
* including deprecated builtins (like gl_Color),
* user-assigned generic attributes (glBindVertexLocation),
* and user-defined varyings.
- *
- * FINISHME: We would hit this path for function arguments. Fix!
*/
assert(var->location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_INPUT,
var->location);
break;
- case ir_var_out:
+ case ir_var_shader_out:
assert(var->location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_OUTPUT,
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 1d96e905c1e..575636e6e57 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2001,21 +2001,18 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
var->location);
this->variables.push_tail(entry);
break;
- case ir_var_in:
- case ir_var_inout:
+ case ir_var_shader_in:
/* The linker assigns locations for varyings and attributes,
* including deprecated builtins (like gl_Color), user-assign
* generic attributes (glBindVertexLocation), and
* user-defined varyings.
- *
- * FINISHME: We would hit this path for function arguments. Fix!
*/
assert(var->location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_INPUT,
var->location);
break;
- case ir_var_out:
+ case ir_var_shader_out:
assert(var->location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_OUTPUT,
@@ -2304,7 +2301,7 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
assert(!ir->lhs->type->is_scalar() && !ir->lhs->type->is_vector());
l.writemask = WRITEMASK_XYZW;
} else if (ir->lhs->type->is_scalar() &&
- ir->lhs->variable_referenced()->mode == ir_var_out) {
+ ir->lhs->variable_referenced()->mode == ir_var_shader_out) {
/* FINISHME: This hack makes writing to gl_FragDepth, which lives in the
* FINISHME: W component of fragment shader output zero, work correctly.
*/
@@ -2581,8 +2578,8 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
ir_rvalue *param_rval = (ir_rvalue *)iter.get();
ir_variable *param = (ir_variable *)sig_iter.get();
- if (param->mode == ir_var_in ||
- param->mode == ir_var_inout) {
+ if (param->mode == ir_var_function_in ||
+ param->mode == ir_var_function_inout) {
variable_storage *storage = find_variable_storage(param);
assert(storage);
@@ -2617,8 +2614,8 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
ir_rvalue *param_rval = (ir_rvalue *)iter.get();
ir_variable *param = (ir_variable *)sig_iter.get();
- if (param->mode == ir_var_out ||
- param->mode == ir_var_inout) {
+ if (param->mode == ir_var_function_out ||
+ param->mode == ir_var_function_inout) {
variable_storage *storage = find_variable_storage(param);
assert(storage);