diff options
author | Tapani Pälli <tapani.palli@intel.com> | 2013-12-12 13:51:01 +0200 |
---|---|---|
committer | Tapani Pälli <tapani.palli@intel.com> | 2013-12-12 17:28:08 +0200 |
commit | 33ee2c67c0a4e8f2fefbf37dacabd14918060af5 (patch) | |
tree | 4432c7acd7722bb635e1f34074278d669a0b74da | |
parent | c1d3080ee86cd3d914712ffe0bb533c5d6a6b271 (diff) | |
download | external_mesa3d-33ee2c67c0a4e8f2fefbf37dacabd14918060af5.zip external_mesa3d-33ee2c67c0a4e8f2fefbf37dacabd14918060af5.tar.gz external_mesa3d-33ee2c67c0a4e8f2fefbf37dacabd14918060af5.tar.bz2 |
glsl: move variables in to ir_variable::data, part I
This patch moves following bitfields in to the data structure:
used, assigned, how_declared, mode, interpolation,
origin_upper_left, pixel_center_integer
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
46 files changed, 308 insertions, 307 deletions
diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp index f7b5e83..2fe838d 100644 --- a/src/glsl/ast_array_index.cpp +++ b/src/glsl/ast_array_index.cpp @@ -168,7 +168,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx, if (array->type->is_unsized_array()) { _mesa_glsl_error(&loc, state, "unsized array index must be constant"); } else if (array->type->fields.array->is_interface() - && array->variable_referenced()->mode == ir_var_uniform) { + && array->variable_referenced()->data.mode == ir_var_uniform) { /* Page 46 in section 4.3.7 of the OpenGL ES 3.00 spec says: * * "All indexes used to index a uniform block array must be diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 8202116..9dbc0d0 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -123,7 +123,7 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, YYLTYPE loc = actual_ast->get_location(); /* Verify that 'const_in' parameters are ir_constants. */ - if (formal->mode == ir_var_const_in && + if (formal->data.mode == ir_var_const_in && actual->ir_type != ir_type_constant) { _mesa_glsl_error(&loc, state, "parameter `in %s' must be a constant expression", @@ -132,10 +132,10 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, } /* Verify that 'out' and 'inout' actual parameters are lvalues. */ - if (formal->mode == ir_var_function_out - || formal->mode == ir_var_function_inout) { + if (formal->data.mode == ir_var_function_out + || formal->data.mode == ir_var_function_inout) { const char *mode = NULL; - switch (formal->mode) { + switch (formal->data.mode) { case ir_var_function_out: mode = "out"; break; case ir_var_function_inout: mode = "inout"; break; default: assert(false); break; @@ -155,7 +155,7 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, ir_variable *var = actual->variable_referenced(); if (var) - var->assigned = true; + var->data.assigned = true; if (var && var->data.read_only) { _mesa_glsl_error(&loc, state, @@ -304,7 +304,7 @@ generate_call(exec_list *instructions, ir_function_signature *sig, assert(formal != NULL); if (formal->type->is_numeric() || formal->type->is_boolean()) { - switch (formal->mode) { + switch (formal->data.mode) { case ir_var_const_in: case ir_var_function_in: { ir_rvalue *converted @@ -316,7 +316,7 @@ generate_call(exec_list *instructions, ir_function_signature *sig, case ir_var_function_inout: fix_parameter(ctx, actual, formal->type, instructions, &post_call_conversions, - formal->mode == ir_var_function_inout); + formal->data.mode == ir_var_function_inout); break; default: assert (!"Illegal formal parameter mode"); diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 0278f97..2302277 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -767,7 +767,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, ir_variable *lhs_var = lhs->variable_referenced(); if (lhs_var) - lhs_var->assigned = true; + lhs_var->data.assigned = true; if (!error_emitted) { if (non_lvalue_description != NULL) { @@ -866,7 +866,7 @@ get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp", ir_var_temporary); instructions->push_tail(var); - var->mode = ir_var_auto; + var->data.mode = ir_var_auto; instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), lvalue)); @@ -1639,7 +1639,7 @@ ast_expression::hir(exec_list *instructions, state->symbols->get_variable(this->primary_expression.identifier); if (var != NULL) { - var->used = true; + var->data.used = true; result = new(ctx) ir_dereference_variable(var); } else { _mesa_glsl_error(& loc, state, "`%s' undeclared", @@ -1886,11 +1886,11 @@ is_varying_var(ir_variable *var, _mesa_glsl_parser_targets target) { switch (target) { case vertex_shader: - return var->mode == ir_var_shader_out; + return var->data.mode == ir_var_shader_out; case fragment_shader: - return var->mode == ir_var_shader_in; + return var->data.mode == ir_var_shader_in; default: - return var->mode == ir_var_shader_out || var->mode == ir_var_shader_in; + return var->data.mode == ir_var_shader_out || var->data.mode == ir_var_shader_in; } } @@ -1941,7 +1941,7 @@ validate_binding_qualifier(struct _mesa_glsl_parse_state *state, ir_variable *var, const ast_type_qualifier *qual) { - if (var->mode != ir_var_uniform) { + if (var->data.mode != ir_var_uniform) { _mesa_glsl_error(loc, state, "the \"binding\" qualifier only applies to uniforms"); return false; @@ -2078,7 +2078,7 @@ validate_explicit_location(const struct ast_type_qualifier *qual, */ switch (state->target) { case vertex_shader: - if (var->mode == ir_var_shader_in) { + if (var->data.mode == ir_var_shader_in) { if (!state->check_explicit_attrib_location_allowed(loc, var)) return; @@ -2095,7 +2095,7 @@ validate_explicit_location(const struct ast_type_qualifier *qual, return; case fragment_shader: - if (var->mode == ir_var_shader_out) { + if (var->data.mode == ir_var_shader_out) { if (!state->check_explicit_attrib_location_allowed(loc, var)) return; @@ -2162,7 +2162,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, STATIC_ASSERT(sizeof(qual->flags.q) <= sizeof(qual->flags.i)); if (qual->flags.q.invariant) { - if (var->used) { + if (var->data.used) { _mesa_glsl_error(loc, state, "variable `%s' may not be redeclared " "`invariant' after being used", @@ -2210,18 +2210,18 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, * the setting alone. */ if (qual->flags.q.in && qual->flags.q.out) - var->mode = ir_var_function_inout; + var->data.mode = ir_var_function_inout; else if (qual->flags.q.in) - var->mode = is_parameter ? ir_var_function_in : ir_var_shader_in; + var->data.mode = is_parameter ? ir_var_function_in : ir_var_shader_in; else if (qual->flags.q.attribute || (qual->flags.q.varying && (state->target == fragment_shader))) - var->mode = ir_var_shader_in; + var->data.mode = ir_var_shader_in; else if (qual->flags.q.out) - var->mode = is_parameter ? ir_var_function_out : ir_var_shader_out; + var->data.mode = is_parameter ? ir_var_function_out : ir_var_shader_out; else if (qual->flags.q.varying && (state->target == vertex_shader)) - var->mode = ir_var_shader_out; + var->data.mode = ir_var_shader_out; else if (qual->flags.q.uniform) - var->mode = ir_var_uniform; + var->data.mode = ir_var_uniform; if (!is_parameter && is_varying_var(var, state->target)) { /* This variable is being used to link data between shader stages (in @@ -2274,27 +2274,27 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, if (state->all_invariant && (state->current_function == NULL)) { switch (state->target) { case vertex_shader: - if (var->mode == ir_var_shader_out) + if (var->data.mode == ir_var_shader_out) var->data.invariant = true; break; case geometry_shader: - if ((var->mode == ir_var_shader_in) - || (var->mode == ir_var_shader_out)) + if ((var->data.mode == ir_var_shader_in) + || (var->data.mode == ir_var_shader_out)) var->data.invariant = true; break; case fragment_shader: - if (var->mode == ir_var_shader_in) + if (var->data.mode == ir_var_shader_in) var->data.invariant = true; break; } } - var->interpolation = - interpret_interpolation_qualifier(qual, (ir_variable_mode) var->mode, + var->data.interpolation = + interpret_interpolation_qualifier(qual, (ir_variable_mode) var->data.mode, state, loc); - var->pixel_center_integer = qual->flags.q.pixel_center_integer; - var->origin_upper_left = qual->flags.q.origin_upper_left; + var->data.pixel_center_integer = qual->flags.q.pixel_center_integer; + var->data.origin_upper_left = qual->flags.q.origin_upper_left; if ((qual->flags.q.origin_upper_left || qual->flags.q.pixel_center_integer) && (strcmp(var->name, "gl_FragCoord") != 0)) { const char *const qual_string = (qual->flags.q.origin_upper_left) @@ -2320,7 +2320,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, } if (var->type->contains_atomic()) { - if (var->mode == ir_var_uniform) { + if (var->data.mode == ir_var_uniform) { if (var->explicit_binding) { unsigned *offset = &state->atomic_counter_offsets[var->binding]; @@ -2335,7 +2335,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, _mesa_glsl_error(loc, state, "atomic counters require explicit binding point"); } - } else if (var->mode != ir_var_function_in) { + } else if (var->data.mode != ir_var_function_in) { _mesa_glsl_error(loc, state, "atomic counters may only be declared as " "function parameters or uniform-qualified " "global variables"); @@ -2491,12 +2491,12 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc, state->is_version(150, 0)) && strcmp(var->name, "gl_FragCoord") == 0 && earlier->type == var->type - && earlier->mode == var->mode) { + && earlier->data.mode == var->data.mode) { /* Allow redeclaration of gl_FragCoord for ARB_fcc layout * qualifiers. */ - earlier->origin_upper_left = var->origin_upper_left; - earlier->pixel_center_integer = var->pixel_center_integer; + earlier->data.origin_upper_left = var->data.origin_upper_left; + earlier->data.pixel_center_integer = var->data.pixel_center_integer; /* According to section 4.3.7 of the GLSL 1.30 spec, * the following built-in varaibles can be redeclared with an @@ -2516,21 +2516,21 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc, || strcmp(var->name, "gl_Color") == 0 || strcmp(var->name, "gl_SecondaryColor") == 0) && earlier->type == var->type - && earlier->mode == var->mode) { - earlier->interpolation = var->interpolation; + && earlier->data.mode == var->data.mode) { + earlier->data.interpolation = var->data.interpolation; /* Layout qualifiers for gl_FragDepth. */ } else if ((state->AMD_conservative_depth_enable || state->ARB_conservative_depth_enable) && strcmp(var->name, "gl_FragDepth") == 0 && earlier->type == var->type - && earlier->mode == var->mode) { + && earlier->data.mode == var->data.mode) { /** From the AMD_conservative_depth spec: * Within any shader, the first redeclarations of gl_FragDepth * must appear before any use of gl_FragDepth. */ - if (earlier->used) { + if (earlier->data.used) { _mesa_glsl_error(&loc, state, "the first redeclaration of gl_FragDepth " "must appear before any use of gl_FragDepth"); @@ -2550,7 +2550,7 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc, earlier->depth_layout = var->depth_layout; } else if (allow_all_redeclarations) { - if (earlier->mode != var->mode) { + if (earlier->data.mode != var->data.mode) { _mesa_glsl_error(&loc, state, "redeclaration of `%s' with incorrect qualifiers", var->name); @@ -2585,7 +2585,7 @@ process_initializer(ir_variable *var, ast_declaration *decl, * directly by an application via API commands, or indirectly by * OpenGL." */ - if (var->mode == ir_var_uniform) { + if (var->data.mode == ir_var_uniform) { state->check_version(120, 0, &initializer_loc, "cannot initialize uniforms"); } @@ -2595,7 +2595,7 @@ process_initializer(ir_variable *var, ast_declaration *decl, "cannot initialize samplers"); } - if ((var->mode == ir_var_shader_in) && (state->current_function == NULL)) { + if ((var->data.mode == ir_var_shader_in) && (state->current_function == NULL)) { _mesa_glsl_error(& initializer_loc, state, "cannot initialize %s shader input / %s", _mesa_glsl_shader_target_name(state->target), @@ -2844,16 +2844,16 @@ ast_declarator_list::hir(exec_list *instructions, "undeclared variable `%s' cannot be marked " "invariant", decl->identifier); } else if ((state->target == vertex_shader) - && (earlier->mode != ir_var_shader_out)) { + && (earlier->data.mode != ir_var_shader_out)) { _mesa_glsl_error(& loc, state, "`%s' cannot be marked invariant, vertex shader " "outputs only", decl->identifier); } else if ((state->target == fragment_shader) - && (earlier->mode != ir_var_shader_in)) { + && (earlier->data.mode != ir_var_shader_in)) { _mesa_glsl_error(& loc, state, "`%s' cannot be marked invariant, fragment shader " "inputs only", decl->identifier); - } else if (earlier->used) { + } else if (earlier->data.used) { _mesa_glsl_error(& loc, state, "variable `%s' may not be redeclared " "`invariant' after being used", @@ -3034,12 +3034,12 @@ ast_declarator_list::hir(exec_list *instructions, if (this->type->qualifier.flags.q.invariant) { if ((state->target == vertex_shader) && - var->mode != ir_var_shader_out) { + var->data.mode != ir_var_shader_out) { _mesa_glsl_error(& loc, state, "`%s' cannot be marked invariant, vertex shader " "outputs only", var->name); } else if ((state->target == fragment_shader) && - var->mode != ir_var_shader_in) { + var->data.mode != ir_var_shader_in) { /* FINISHME: Note that this doesn't work for invariant on * a function signature inval */ @@ -3076,7 +3076,7 @@ ast_declarator_list::hir(exec_list *instructions, "global scope%s", mode, var->name, extra); } - } else if (var->mode == ir_var_shader_in) { + } else if (var->data.mode == ir_var_shader_in) { var->data.read_only = true; if (state->target == vertex_shader) { @@ -3183,9 +3183,9 @@ ast_declarator_list::hir(exec_list *instructions, */ if (state->is_version(130, 300) && var->type->contains_integer() && - var->interpolation != INTERP_QUALIFIER_FLAT && - ((state->target == fragment_shader && var->mode == ir_var_shader_in) - || (state->target == vertex_shader && var->mode == ir_var_shader_out + var->data.interpolation != INTERP_QUALIFIER_FLAT && + ((state->target == fragment_shader && var->data.mode == ir_var_shader_in) + || (state->target == vertex_shader && var->data.mode == ir_var_shader_out && state->es_shader))) { const char *var_type = (state->target == vertex_shader) ? "vertex output" : "fragment input"; @@ -3374,12 +3374,12 @@ ast_declarator_list::hir(exec_list *instructions, false /* allow_all_redeclarations */); if (earlier != NULL) { if (strncmp(var->name, "gl_", 3) == 0 && - earlier->how_declared == ir_var_declared_in_block) { + earlier->data.how_declared == ir_var_declared_in_block) { _mesa_glsl_error(&loc, state, "`%s' has already been redeclared using " "gl_PerVertex", var->name); } - earlier->how_declared = ir_var_declared_normally; + earlier->data.how_declared = ir_var_declared_normally; } if (decl->initializer != NULL) { @@ -3559,7 +3559,7 @@ ast_parameter_declarator::hir(exec_list *instructions, * as out or inout function parameters, nor can they be assigned * into." */ - if ((var->mode == ir_var_function_inout || var->mode == ir_var_function_out) + if ((var->data.mode == ir_var_function_inout || var->data.mode == ir_var_function_out) && type->contains_sampler()) { _mesa_glsl_error(&loc, state, "out and inout parameters cannot contain samplers"); type = glsl_type::error_type; @@ -3579,7 +3579,7 @@ ast_parameter_declarator::hir(exec_list *instructions, * So for GLSL 1.10, passing an array as an out or inout parameter is not * allowed. This restriction is removed in GLSL 1.20, and in GLSL ES. */ - if ((var->mode == ir_var_function_inout || var->mode == ir_var_function_out) + if ((var->data.mode == ir_var_function_inout || var->data.mode == ir_var_function_out) && type->is_array() && !state->check_version(120, 100, &loc, "arrays cannot be out or inout parameters")) { @@ -4794,7 +4794,7 @@ public: virtual ir_visitor_status visit(ir_dereference_variable *ir) { - if (ir->var->mode == mode && ir->var->get_interface_type() == block) { + if (ir->var->data.mode == mode && ir->var->get_interface_type() == block) { found = true; return visit_stop; } @@ -5077,7 +5077,7 @@ ast_interface_block::hir(exec_list *instructions, _mesa_glsl_error(&loc, state, "`%s' redeclared", this->instance_name); } - earlier->how_declared = ir_var_declared_normally; + earlier->data.how_declared = ir_var_declared_normally; earlier->type = var->type; earlier->reinit_interface_type(block_type); delete var; @@ -5096,7 +5096,7 @@ ast_interface_block::hir(exec_list *instructions, new(state) ir_variable(fields[i].type, ralloc_strdup(state, fields[i].name), var_mode); - var->interpolation = fields[i].interpolation; + var->data.interpolation = fields[i].interpolation; var->data.centroid = fields[i].centroid; var->data.sample = fields[i].sample; var->init_interface_type(block_type); @@ -5109,11 +5109,11 @@ ast_interface_block::hir(exec_list *instructions, _mesa_glsl_error(&loc, state, "redeclaration of gl_PerVertex can only " "include built-in variables"); - } else if (earlier->how_declared == ir_var_declared_normally) { + } else if (earlier->data.how_declared == ir_var_declared_normally) { _mesa_glsl_error(&loc, state, "`%s' has already been redeclared", var->name); } else { - earlier->how_declared = ir_var_declared_in_block; + earlier->data.how_declared = ir_var_declared_in_block; earlier->reinit_interface_type(block_type); } continue; @@ -5159,8 +5159,8 @@ ast_interface_block::hir(exec_list *instructions, ir_variable *const var = ((ir_instruction *) node)->as_variable(); if (var != NULL && var->get_interface_type() == earlier_per_vertex && - var->mode == var_mode) { - if (var->how_declared == ir_var_declared_normally) { + var->data.mode == var_mode) { + if (var->data.how_declared == ir_var_declared_normally) { _mesa_glsl_error(&loc, state, "redeclaration of gl_PerVertex cannot " "follow a redeclaration of `%s'", @@ -5215,7 +5215,7 @@ ast_gs_input_layout::hir(exec_list *instructions, */ foreach_list (node, instructions) { ir_variable *var = ((ir_instruction *) node)->as_variable(); - if (var == NULL || var->mode != ir_var_shader_in) + if (var == NULL || var->data.mode != ir_var_shader_in) continue; /* Note: gl_PrimitiveIDIn has mode ir_var_shader_in, but it's not an @@ -5256,7 +5256,7 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, foreach_list(node, instructions) { ir_variable *var = ((ir_instruction *)node)->as_variable(); - if (!var || !var->assigned) + if (!var || !var->data.assigned) continue; if (strcmp(var->name, "gl_FragColor") == 0) @@ -5265,7 +5265,7 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, gl_FragData_assigned = true; else if (strncmp(var->name, "gl_", 3) != 0) { if (state->target == fragment_shader && - var->mode == ir_var_shader_out) { + var->data.mode == ir_var_shader_out) { user_defined_fs_output_assigned = true; user_defined_fs_output = var; } @@ -5346,7 +5346,7 @@ remove_per_vertex_blocks(exec_list *instructions, foreach_list_safe(node, instructions) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); if (var != NULL && var->get_interface_type() == per_vertex && - var->mode == mode) { + var->data.mode == mode) { state->symbols->disable_variable(var->name); var->remove(); } diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index 9cc11b7..2392437 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -435,9 +435,9 @@ builtin_variable_generator::add_variable(const char *name, enum ir_variable_mode mode, int slot) { ir_variable *var = new(symtab) ir_variable(type, name, mode); - var->how_declared = ir_var_declared_implicitly; + var->data.how_declared = ir_var_declared_implicitly; - switch (var->mode) { + switch (var->data.mode) { case ir_var_auto: case ir_var_shader_in: case ir_var_uniform: @@ -793,9 +793,9 @@ builtin_variable_generator::generate_gs_special_vars() */ ir_variable *var; var = add_input(VARYING_SLOT_PRIMITIVE_ID, int_t, "gl_PrimitiveIDIn"); - var->interpolation = INTERP_QUALIFIER_FLAT; + var->data.interpolation = INTERP_QUALIFIER_FLAT; var = add_output(VARYING_SLOT_PRIMITIVE_ID, int_t, "gl_PrimitiveID"); - var->interpolation = INTERP_QUALIFIER_FLAT; + var->data.interpolation = INTERP_QUALIFIER_FLAT; } @@ -813,7 +813,7 @@ builtin_variable_generator::generate_fs_special_vars() if (state->is_version(150, 0)) { ir_variable *var = add_input(VARYING_SLOT_PRIMITIVE_ID, int_t, "gl_PrimitiveID"); - var->interpolation = INTERP_QUALIFIER_FLAT; + var->data.interpolation = INTERP_QUALIFIER_FLAT; } /* gl_FragColor and gl_FragData were deprecated starting in desktop GLSL @@ -936,7 +936,7 @@ builtin_variable_generator::generate_varyings() ir_variable *var = add_variable(fields[i].name, fields[i].type, ir_var_shader_out, fields[i].location); - var->interpolation = fields[i].interpolation; + var->data.interpolation = fields[i].interpolation; var->data.centroid = fields[i].centroid; var->data.sample = fields[i].sample; var->init_interface_type(per_vertex_out_type); diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index a3ca4ef..980c201 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1579,9 +1579,7 @@ ir_swizzle::variable_referenced() const ir_variable::ir_variable(const struct glsl_type *type, const char *name, ir_variable_mode mode) - : max_array_access(0), max_ifc_array_access(NULL), - how_declared(ir_var_declared_normally), mode(mode), - interpolation(INTERP_QUALIFIER_NONE), atomic() + : max_array_access(0), max_ifc_array_access(NULL), atomic() { this->ir_type = ir_type_variable; this->type = type; @@ -1593,14 +1591,17 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, this->warn_extension = NULL; this->constant_value = NULL; this->constant_initializer = NULL; - this->origin_upper_left = false; - this->pixel_center_integer = false; + this->data.origin_upper_left = false; + this->data.pixel_center_integer = false; this->depth_layout = ir_depth_layout_none; - this->used = false; + this->data.used = false; this->data.read_only = false; this->data.centroid = false; this->data.sample = false; this->data.invariant = false; + this->data.how_declared = ir_var_declared_normally; + this->data.mode = mode; + this->data.interpolation = INTERP_QUALIFIER_NONE; if (type != NULL) { if (type->base_type == GLSL_TYPE_SAMPLER) @@ -1632,8 +1633,8 @@ interpolation_string(unsigned interpolation) glsl_interp_qualifier ir_variable::determine_interpolation_mode(bool flat_shade) { - if (this->interpolation != INTERP_QUALIFIER_NONE) - return (glsl_interp_qualifier) this->interpolation; + if (this->data.interpolation != INTERP_QUALIFIER_NONE) + return (glsl_interp_qualifier) this->data.interpolation; int location = this->location; bool is_gl_Color = location == VARYING_SLOT_COL0 || location == VARYING_SLOT_COL1; @@ -1705,8 +1706,8 @@ ir_function_signature::qualifiers_match(exec_list *params) ir_variable *b = (ir_variable *)iter_b.get(); if (a->data.read_only != b->data.read_only || - !modes_match(a->mode, b->mode) || - a->interpolation != b->interpolation || + !modes_match(a->data.mode, b->data.mode) || + a->data.interpolation != b->data.interpolation || a->data.centroid != b->data.centroid || a->data.sample != b->data.sample) { @@ -1892,7 +1893,7 @@ vertices_per_prim(GLenum prim) const char * mode_string(const ir_variable *var) { - switch (var->mode) { + switch (var->data.mode) { case ir_var_auto: return (var->data.read_only) ? "global constant" : "global variable"; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index cdede59..e0fe059 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -403,7 +403,7 @@ public: */ inline bool is_in_uniform_block() const { - return this->mode == ir_var_uniform && this->interface_type != NULL; + return this->data.mode == ir_var_uniform && this->interface_type != NULL; } /** @@ -535,59 +535,59 @@ public: unsigned sample:1; unsigned invariant:1; - } data; + /** + * Has this variable been used for reading or writing? + * + * Several GLSL semantic checks require knowledge of whether or not a + * variable has been used. For example, it is an error to redeclare a + * variable as invariant after it has been used. + * + * This is only maintained in the ast_to_hir.cpp path, not in + * Mesa's fixed function or ARB program paths. + */ + unsigned used:1; - /** - * Has this variable been used for reading or writing? - * - * Several GLSL semantic checks require knowledge of whether or not a - * variable has been used. For example, it is an error to redeclare a - * variable as invariant after it has been used. - * - * This is only maintained in the ast_to_hir.cpp path, not in - * Mesa's fixed function or ARB program paths. - */ - unsigned used:1; + /** + * Has this variable been statically assigned? + * + * This answers whether the variable was assigned in any path of + * the shader during ast_to_hir. This doesn't answer whether it is + * still written after dead code removal, nor is it maintained in + * non-ast_to_hir.cpp (GLSL parsing) paths. + */ + unsigned assigned:1; - /** - * Has this variable been statically assigned? - * - * This answers whether the variable was assigned in any path of - * the shader during ast_to_hir. This doesn't answer whether it is - * still written after dead code removal, nor is it maintained in - * non-ast_to_hir.cpp (GLSL parsing) paths. - */ - unsigned assigned:1; + /** + * Enum indicating how the variable was declared. See + * ir_var_declaration_type. + * + * This is used to detect certain kinds of illegal variable redeclarations. + */ + unsigned how_declared:2; - /** - * Enum indicating how the variable was declared. See - * ir_var_declaration_type. - * - * This is used to detect certain kinds of illegal variable redeclarations. - */ - unsigned how_declared:2; + /** + * Storage class of the variable. + * + * \sa ir_variable_mode + */ + unsigned mode:4; - /** - * Storage class of the variable. - * - * \sa ir_variable_mode - */ - unsigned mode:4; + /** + * Interpolation mode for shader inputs / outputs + * + * \sa ir_variable_interpolation + */ + unsigned interpolation:2; - /** - * Interpolation mode for shader inputs / outputs - * - * \sa ir_variable_interpolation - */ - unsigned interpolation:2; + /** + * \name ARB_fragment_coord_conventions + * @{ + */ + unsigned origin_upper_left:1; + unsigned pixel_center_integer:1; + /*@}*/ - /** - * \name ARB_fragment_coord_conventions - * @{ - */ - unsigned origin_upper_left:1; - unsigned pixel_center_integer:1; - /*@}*/ + } data; /** * Was the location explicitly set in the shader? diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index a781cf0..56a6a57 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -41,7 +41,7 @@ ir_variable * ir_variable::clone(void *mem_ctx, struct hash_table *ht) const { ir_variable *var = new(mem_ctx) ir_variable(this->type, this->name, - (ir_variable_mode) this->mode); + (ir_variable_mode) this->data.mode); var->max_array_access = this->max_array_access; if (this->is_interface_instance()) { @@ -54,23 +54,23 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const var->data.centroid = this->data.centroid; var->data.sample = this->data.sample; var->data.invariant = this->data.invariant; - var->interpolation = this->interpolation; + var->data.interpolation = this->data.interpolation; var->location = this->location; var->index = this->index; var->binding = this->binding; var->atomic.buffer_index = this->atomic.buffer_index; var->atomic.offset = this->atomic.offset; var->warn_extension = this->warn_extension; - var->origin_upper_left = this->origin_upper_left; - var->pixel_center_integer = this->pixel_center_integer; + var->data.origin_upper_left = this->data.origin_upper_left; + var->data.pixel_center_integer = this->data.pixel_center_integer; var->explicit_location = this->explicit_location; var->explicit_index = this->explicit_index; var->explicit_binding = this->explicit_binding; var->has_initializer = this->has_initializer; var->depth_layout = this->depth_layout; - var->assigned = this->assigned; - var->how_declared = this->how_declared; - var->used = this->used; + var->data.assigned = this->data.assigned; + var->data.how_declared = this->data.how_declared; + var->data.used = this->data.used; var->num_state_slots = this->num_state_slots; if (this->state_slots) { diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 0efd1d5..7ca865e 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -1583,7 +1583,7 @@ ir_dereference_variable::constant_expression_value(struct hash_table *variable_c /* The constant_value of a uniform variable is its initializer, * not the lifetime constant value of the uniform. */ - if (var->mode == ir_var_uniform) + if (var->data.mode == ir_var_uniform) return NULL; if (!var->constant_value) diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp index 53cf469..bd5318d 100644 --- a/src/glsl/ir_function.cpp +++ b/src/glsl/ir_function.cpp @@ -66,7 +66,7 @@ parameter_lists_match(const exec_list *list_a, const exec_list *list_b) /* Try to find an implicit conversion from actual to param. */ inexact_match = true; - switch ((enum ir_variable_mode)(param->mode)) { + switch ((enum ir_variable_mode)(param->data.mode)) { case ir_var_auto: case ir_var_uniform: case ir_var_temporary: diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index ae5074b..01c5f7f 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -159,7 +159,7 @@ void ir_print_visitor::visit(ir_variable *ir) STATIC_ASSERT(ARRAY_SIZE(interp) == INTERP_QUALIFIER_COUNT); printf("(%s%s%s%s%s) ", - cent, samp, inv, mode[ir->mode], interp[ir->interpolation]); + cent, samp, inv, mode[ir->data.mode], interp[ir->data.interpolation]); print_type(ir->type); printf(" %s)", unique_name(ir)); diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 127358c..7970112 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -418,29 +418,29 @@ ir_reader::read_declaration(s_expression *expr) } else if (strcmp(qualifier->value(), "invariant") == 0) { var->data.invariant = 1; } else if (strcmp(qualifier->value(), "uniform") == 0) { - var->mode = ir_var_uniform; + var->data.mode = ir_var_uniform; } else if (strcmp(qualifier->value(), "auto") == 0) { - var->mode = ir_var_auto; + var->data.mode = ir_var_auto; } else if (strcmp(qualifier->value(), "in") == 0) { - var->mode = ir_var_function_in; + var->data.mode = ir_var_function_in; } else if (strcmp(qualifier->value(), "shader_in") == 0) { - var->mode = ir_var_shader_in; + var->data.mode = ir_var_shader_in; } else if (strcmp(qualifier->value(), "const_in") == 0) { - var->mode = ir_var_const_in; + var->data.mode = ir_var_const_in; } else if (strcmp(qualifier->value(), "out") == 0) { - var->mode = ir_var_function_out; + var->data.mode = ir_var_function_out; } else if (strcmp(qualifier->value(), "shader_out") == 0) { - var->mode = ir_var_shader_out; + var->data.mode = ir_var_shader_out; } else if (strcmp(qualifier->value(), "inout") == 0) { - var->mode = ir_var_function_inout; + var->data.mode = ir_var_function_inout; } else if (strcmp(qualifier->value(), "temporary") == 0) { - var->mode = ir_var_temporary; + var->data.mode = ir_var_temporary; } else if (strcmp(qualifier->value(), "smooth") == 0) { - var->interpolation = INTERP_QUALIFIER_SMOOTH; + var->data.interpolation = INTERP_QUALIFIER_SMOOTH; } else if (strcmp(qualifier->value(), "flat") == 0) { - var->interpolation = INTERP_QUALIFIER_FLAT; + var->data.interpolation = INTERP_QUALIFIER_FLAT; } else if (strcmp(qualifier->value(), "noperspective") == 0) { - var->interpolation = INTERP_QUALIFIER_NOPERSPECTIVE; + var->data.interpolation = INTERP_QUALIFIER_NOPERSPECTIVE; } else { ir_read_error(expr, "unknown qualifier: %s", qualifier->value()); return NULL; diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp index 2d82439..23bad98 100644 --- a/src/glsl/ir_set_program_inouts.cpp +++ b/src/glsl/ir_set_program_inouts.cpp @@ -75,9 +75,9 @@ private: static inline bool is_shader_inout(ir_variable *var) { - return var->mode == ir_var_shader_in || - var->mode == ir_var_shader_out || - var->mode == ir_var_system_value; + return var->data.mode == ir_var_shader_in || + var->data.mode == ir_var_shader_out || + var->data.mode == ir_var_system_value; } static void @@ -94,21 +94,21 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len, for (int i = 0; i < len; i++) { GLbitfield64 bitfield = BITFIELD64_BIT(var->location + var->index + offset + i); - if (var->mode == ir_var_shader_in) { + if (var->data.mode == ir_var_shader_in) { prog->InputsRead |= bitfield; if (is_fragment_shader) { gl_fragment_program *fprog = (gl_fragment_program *) prog; fprog->InterpQualifier[var->location + var->index + offset + i] = - (glsl_interp_qualifier) var->interpolation; + (glsl_interp_qualifier) var->data.interpolation; if (var->data.centroid) fprog->IsCentroid |= bitfield; if (var->data.sample) fprog->IsSample |= bitfield; } - } else if (var->mode == ir_var_system_value) { + } else if (var->data.mode == ir_var_system_value) { prog->SystemValuesRead |= bitfield; } else { - assert(var->mode == ir_var_shader_out); + assert(var->data.mode == ir_var_shader_out); prog->OutputsWritten |= bitfield; } } @@ -123,7 +123,7 @@ ir_set_program_inouts_visitor::mark_whole_variable(ir_variable *var) { const glsl_type *type = var->type; if (this->shader_type == GL_GEOMETRY_SHADER && - var->mode == ir_var_shader_in && type->is_array()) { + var->data.mode == ir_var_shader_in && type->is_array()) { type = type->fields.array; } @@ -162,7 +162,7 @@ ir_set_program_inouts_visitor::try_mark_partial_variable(ir_variable *var, const glsl_type *type = var->type; if (this->shader_type == GL_GEOMETRY_SHADER && - var->mode == ir_var_shader_in) { + var->data.mode == ir_var_shader_in) { /* The only geometry shader input that is not an array is * gl_PrimitiveIDIn, and in that case, this code will never be reached, * because gl_PrimitiveIDIn can't be indexed into in array fashion. @@ -244,7 +244,7 @@ ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir) if (ir_dereference_variable * const deref_var = inner_array->array->as_dereference_variable()) { if (this->shader_type == GL_GEOMETRY_SHADER && - deref_var->var->mode == ir_var_shader_in) { + deref_var->var->data.mode == ir_var_shader_in) { /* foo is a geometry shader input, so i is the vertex, and j the * part of the input we're accessing. */ @@ -263,7 +263,7 @@ ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir) ir->array->as_dereference_variable()) { /* ir => foo[i], where foo is a variable. */ if (this->shader_type == GL_GEOMETRY_SHADER && - deref_var->var->mode == ir_var_shader_in) { + deref_var->var->data.mode == ir_var_shader_in) { /* foo is a geometry shader input, so i is the vertex, and we're * accessing the entire input. */ diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 8e73229..4614cb7 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -752,8 +752,8 @@ ir_validate::visit_enter(ir_call *ir) printf("ir_call parameter type mismatch:\n"); goto dump_ir; } - if (formal_param->mode == ir_var_function_out - || formal_param->mode == ir_var_function_inout) { + if (formal_param->data.mode == ir_var_function_out + || formal_param->data.mode == ir_var_function_inout) { if (!actual_param->is_lvalue()) { printf("ir_call out/inout parameters must be lvalues:\n"); goto dump_ir; diff --git a/src/glsl/link_interface_blocks.cpp b/src/glsl/link_interface_blocks.cpp index 6900fa9..4769636 100644 --- a/src/glsl/link_interface_blocks.cpp +++ b/src/glsl/link_interface_blocks.cpp @@ -60,7 +60,7 @@ struct interface_block_definition if (var->type->is_array()) array_size = var->type->length; } - explicitly_declared = (var->how_declared != ir_var_declared_implicitly); + explicitly_declared = (var->data.how_declared != ir_var_declared_implicitly); } /** @@ -270,7 +270,7 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog, continue; interface_block_definitions *definitions; - switch (var->mode) { + switch (var->data.mode) { case ir_var_shader_in: definitions = &in_interfaces; break; @@ -298,7 +298,7 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog, */ definitions->store(def); } else if (!intrastage_match(prev_def, &def, - (ir_variable_mode) var->mode)) { + (ir_variable_mode) var->data.mode)) { linker_error(prog, "definitions of interface block `%s' do not" " match\n", iface_type->name); return; @@ -318,7 +318,7 @@ validate_interstage_inout_blocks(struct gl_shader_program *prog, /* Add input interfaces from the consumer to the symbol table. */ foreach_list(node, consumer->ir) { ir_variable *var = ((ir_instruction *) node)->as_variable(); - if (!var || !var->get_interface_type() || var->mode != ir_var_shader_in) + if (!var || !var->get_interface_type() || var->data.mode != ir_var_shader_in) continue; definitions.store(interface_block_definition(var)); @@ -327,7 +327,7 @@ validate_interstage_inout_blocks(struct gl_shader_program *prog, /* Verify that the producer's output interfaces match. */ foreach_list(node, producer->ir) { ir_variable *var = ((ir_instruction *) node)->as_variable(); - if (!var || !var->get_interface_type() || var->mode != ir_var_shader_out) + if (!var || !var->get_interface_type() || var->data.mode != ir_var_shader_out) continue; interface_block_definition *consumer_def = @@ -361,7 +361,7 @@ validate_interstage_uniform_blocks(struct gl_shader_program *prog, const gl_shader *stage = stages[i]; foreach_list(node, stage->ir) { ir_variable *var = ((ir_instruction *) node)->as_variable(); - if (!var || !var->get_interface_type() || var->mode != ir_var_uniform) + if (!var || !var->get_interface_type() || var->data.mode != ir_var_uniform) continue; interface_block_definition *old_def = diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp index 786aaf0..ef74607 100644 --- a/src/glsl/link_uniform_initializers.cpp +++ b/src/glsl/link_uniform_initializers.cpp @@ -224,7 +224,7 @@ link_set_uniform_initializers(struct gl_shader_program *prog) foreach_list(node, shader->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (!var || var->mode != ir_var_uniform) + if (!var || var->data.mode != ir_var_uniform) continue; if (!mem_ctx) diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 0a15739..632167e 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -637,7 +637,7 @@ link_update_uniform_buffer_variables(struct gl_shader *shader) if ((var == NULL) || !var->is_in_uniform_block()) continue; - assert(var->mode == ir_var_uniform); + assert(var->data.mode == ir_var_uniform); if (var->is_interface_instance()) { var->location = 0; @@ -767,7 +767,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog) foreach_list(node, sh->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if ((var == NULL) || (var->mode != ir_var_uniform)) + if ((var == NULL) || (var->data.mode != ir_var_uniform)) continue; /* FINISHME: Update code to process built-in uniforms! @@ -818,7 +818,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog) foreach_list(node, prog->_LinkedShaders[i]->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if ((var == NULL) || (var->mode != ir_var_uniform)) + if ((var == NULL) || (var->data.mode != ir_var_uniform)) continue; /* FINISHME: Update code to process built-in uniforms! diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp index 53a9d75..7c35892 100644 --- a/src/glsl/link_varyings.cpp +++ b/src/glsl/link_varyings.cpp @@ -129,7 +129,7 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog, return; } - if (input->interpolation != output->interpolation) { + if (input->data.interpolation != output->data.interpolation) { linker_error(prog, "%s shader output `%s' specifies %s " "interpolation qualifier, " @@ -137,9 +137,9 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog, "interpolation qualifier\n", _mesa_glsl_shader_target_name(producer_type), output->name, - interpolation_string(output->interpolation), + interpolation_string(output->data.interpolation), _mesa_glsl_shader_target_name(consumer_type), - interpolation_string(input->interpolation)); + interpolation_string(input->data.interpolation)); return; } } @@ -155,11 +155,11 @@ cross_validate_front_and_back_color(struct gl_shader_program *prog, GLenum consumer_type, GLenum producer_type) { - if (front_color != NULL && front_color->assigned) + if (front_color != NULL && front_color->data.assigned) cross_validate_types_and_qualifiers(prog, input, front_color, consumer_type, producer_type); - if (back_color != NULL && back_color->assigned) + if (back_color != NULL && back_color->data.assigned) cross_validate_types_and_qualifiers(prog, input, back_color, consumer_type, producer_type); } @@ -178,7 +178,7 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog, foreach_list(node, producer->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if ((var == NULL) || (var->mode != ir_var_shader_out)) + if ((var == NULL) || (var->data.mode != ir_var_shader_out)) continue; parameters.add_variable(var); @@ -196,10 +196,10 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog, foreach_list(node, consumer->ir) { ir_variable *const input = ((ir_instruction *) node)->as_variable(); - if ((input == NULL) || (input->mode != ir_var_shader_in)) + if ((input == NULL) || (input->data.mode != ir_var_shader_in)) continue; - if (strcmp(input->name, "gl_Color") == 0 && input->used) { + if (strcmp(input->name, "gl_Color") == 0 && input->data.used) { const ir_variable *const front_color = parameters.get_variable("gl_FrontColor"); @@ -209,7 +209,7 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog, cross_validate_front_and_back_color(prog, input, front_color, back_color, consumer->Type, producer->Type); - } else if (strcmp(input->name, "gl_SecondaryColor") == 0 && input->used) { + } else if (strcmp(input->name, "gl_SecondaryColor") == 0 && input->data.used) { const ir_variable *const front_color = parameters.get_variable("gl_FrontSecondaryColor"); @@ -766,12 +766,12 @@ varying_matches::record(ir_variable *producer_var, ir_variable *consumer_var) */ producer_var->data.centroid = false; producer_var->data.sample = false; - producer_var->interpolation = INTERP_QUALIFIER_FLAT; + producer_var->data.interpolation = INTERP_QUALIFIER_FLAT; if (consumer_var) { consumer_var->data.centroid = false; consumer_var->data.sample = false; - consumer_var->interpolation = INTERP_QUALIFIER_FLAT; + consumer_var->data.interpolation = INTERP_QUALIFIER_FLAT; } } @@ -889,7 +889,7 @@ varying_matches::compute_packing_class(ir_variable *var) */ unsigned packing_class = var->data.centroid | (var->data.sample << 1); packing_class *= 4; - packing_class += var->interpolation; + packing_class += var->data.interpolation; return packing_class; } @@ -947,7 +947,7 @@ is_varying_var(GLenum shaderType, const ir_variable *var) { /* Only fragment shaders will take a varying variable as an input */ if (shaderType == GL_FRAGMENT_SHADER && - var->mode == ir_var_shader_in) { + var->data.mode == ir_var_shader_in) { switch (var->location) { case VARYING_SLOT_POS: case VARYING_SLOT_FACE: @@ -1096,7 +1096,7 @@ assign_varying_locations(struct gl_context *ctx, ir_variable *const input_var = ((ir_instruction *) node)->as_variable(); - if ((input_var != NULL) && (input_var->mode == ir_var_shader_in)) { + if ((input_var != NULL) && (input_var->data.mode == ir_var_shader_in)) { if (input_var->get_interface_type() != NULL) { char *const iface_field_name = ralloc_asprintf(mem_ctx, "%s.%s", @@ -1115,7 +1115,7 @@ assign_varying_locations(struct gl_context *ctx, foreach_list(node, producer->ir) { ir_variable *const output_var = ((ir_instruction *) node)->as_variable(); - if ((output_var == NULL) || (output_var->mode != ir_var_shader_out)) + if ((output_var == NULL) || (output_var->data.mode != ir_var_shader_out)) continue; tfeedback_candidate_generator g(mem_ctx, tfeedback_candidates); @@ -1135,7 +1135,7 @@ assign_varying_locations(struct gl_context *ctx, (ir_variable *) hash_table_find(consumer_inputs, output_var->name); } - if (input_var && input_var->mode != ir_var_shader_in) + if (input_var && input_var->data.mode != ir_var_shader_in) input_var = NULL; if (input_var) { @@ -1199,7 +1199,7 @@ assign_varying_locations(struct gl_context *ctx, foreach_list(node, consumer->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var && var->mode == ir_var_shader_in && + if (var && var->data.mode == ir_var_shader_in && var->is_unmatched_generic_inout) { if (prog->Version <= 120) { /* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec: @@ -1225,7 +1225,7 @@ assign_varying_locations(struct gl_context *ctx, /* An 'in' variable is only really a shader input if its * value is written by the previous stage. */ - var->mode = ir_var_auto; + var->data.mode = ir_var_auto; } } } @@ -1243,7 +1243,7 @@ check_against_output_limit(struct gl_context *ctx, foreach_list(node, producer->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var && var->mode == ir_var_shader_out && + if (var && var->data.mode == ir_var_shader_out && is_varying_var(producer->Type, var)) { output_vectors += var->type->count_attribute_slots(); } @@ -1292,7 +1292,7 @@ check_against_input_limit(struct gl_context *ctx, foreach_list(node, consumer->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var && var->mode == ir_var_shader_in && + if (var && var->data.mode == ir_var_shader_in && is_varying_var(consumer->Type, var)) { input_vectors += var->type->count_attribute_slots(); } diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 38bf579..446e799 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -114,8 +114,8 @@ public: ir_rvalue *param_rval = (ir_rvalue *)iter.get(); ir_variable *sig_param = (ir_variable *)sig_iter.get(); - if (sig_param->mode == ir_var_function_out || - sig_param->mode == ir_var_function_inout) { + if (sig_param->data.mode == ir_var_function_out || + sig_param->data.mode == ir_var_function_inout) { ir_variable *var = param_rval->variable_referenced(); if (var && strcmp(name, var->name) == 0) { found = true; @@ -198,7 +198,7 @@ public: virtual ir_visitor_status visit(ir_variable *var) { - if (!var->type->is_array() || var->mode != ir_var_shader_in) + if (!var->type->is_array() || var->data.mode != ir_var_shader_in) return visit_continue; unsigned size = var->type->length; @@ -580,13 +580,13 @@ cross_validate_globals(struct gl_shader_program *prog, if (var == NULL) continue; - if (uniforms_only && (var->mode != ir_var_uniform)) + if (uniforms_only && (var->data.mode != ir_var_uniform)) continue; /* Don't cross validate temporaries that are at global scope. These * will eventually get pulled into the shaders 'main'. */ - if (var->mode == ir_var_temporary) + if (var->data.mode == ir_var_temporary) continue; /* If a global with this name has already been seen, verify that the @@ -682,7 +682,7 @@ cross_validate_globals(struct gl_shader_program *prog, "the same set of qualifiers."); } - if (var->used && layout_differs) { + if (var->data.used && layout_differs) { linker_error(prog, "If gl_FragDepth is redeclared with a layout " "qualifier in any fragment shader, it must be " @@ -890,7 +890,7 @@ remap_variables(ir_instruction *inst, struct gl_shader *target, virtual ir_visitor_status visit(ir_dereference_variable *ir) { - if (ir->var->mode == ir_var_temporary) { + if (ir->var->data.mode == ir_var_temporary) { ir_variable *var = (ir_variable *) hash_table_find(temps, ir->var); assert(var != NULL); @@ -964,13 +964,13 @@ move_non_declarations(exec_list *instructions, exec_node *last, continue; ir_variable *var = inst->as_variable(); - if ((var != NULL) && (var->mode != ir_var_temporary)) + if ((var != NULL) && (var->data.mode != ir_var_temporary)) continue; assert(inst->as_assignment() || inst->as_call() || inst->as_if() /* for initializers with the ?: operator */ - || ((var != NULL) && (var->mode == ir_var_temporary))); + || ((var != NULL) && (var->data.mode == ir_var_temporary))); if (make_copies) { inst = inst->clone(target, NULL); @@ -1494,7 +1494,7 @@ update_array_sizes(struct gl_shader_program *prog) foreach_list(node, prog->_LinkedShaders[i]->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if ((var == NULL) || (var->mode != ir_var_uniform) || + if ((var == NULL) || (var->data.mode != ir_var_uniform) || !var->type->is_array()) continue; @@ -1660,7 +1660,7 @@ assign_attribute_or_color_locations(gl_shader_program *prog, foreach_list(node, sh->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if ((var == NULL) || (var->mode != (unsigned) direction)) + if ((var == NULL) || (var->data.mode != (unsigned) direction)) continue; if (var->explicit_location) { @@ -1821,7 +1821,7 @@ demote_shader_inputs_and_outputs(gl_shader *sh, enum ir_variable_mode mode) foreach_list(node, sh->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if ((var == NULL) || (var->mode != int(mode))) + if ((var == NULL) || (var->data.mode != int(mode))) continue; /* A shader 'in' or 'out' variable is only really an input or output if @@ -1829,7 +1829,7 @@ demote_shader_inputs_and_outputs(gl_shader *sh, enum ir_variable_mode mode) * to have a location assigned. */ if (var->is_unmatched_generic_inout) { - var->mode = ir_var_auto; + var->data.mode = ir_var_auto; } } } @@ -1857,7 +1857,7 @@ store_fragdepth_layout(struct gl_shader_program *prog) foreach_list(node, ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var == NULL || var->mode != ir_var_shader_out) { + if (var == NULL || var->data.mode != ir_var_shader_out) { continue; } diff --git a/src/glsl/lower_clip_distance.cpp b/src/glsl/lower_clip_distance.cpp index 04fa6d4..33e480b 100644 --- a/src/glsl/lower_clip_distance.cpp +++ b/src/glsl/lower_clip_distance.cpp @@ -141,7 +141,7 @@ lower_clip_distance_visitor::visit(ir_variable *ir) ir->replace_with(this->new_clip_distance_1d_var); } else { /* 2D gl_ClipDistance (used for geometry input). */ - assert(ir->mode == ir_var_shader_in && + assert(ir->data.mode == ir_var_shader_in && this->shader_type == GL_GEOMETRY_SHADER_ARB); if (this->old_clip_distance_2d_var) return visit_continue; @@ -500,8 +500,8 @@ lower_clip_distance_visitor::visit_leave(ir_call *ir) this->base_ir->insert_before(temp_clip_distance); actual_param->replace_with( new(ctx) ir_dereference_variable(temp_clip_distance)); - if (formal_param->mode == ir_var_function_in - || formal_param->mode == ir_var_function_inout) { + if (formal_param->data.mode == ir_var_function_in + || formal_param->data.mode == ir_var_function_inout) { /* Copy from gl_ClipDistance to the temporary before the call. * Since we are going to insert this copy before the current * instruction, we need to visit it afterwards to make sure it @@ -513,8 +513,8 @@ lower_clip_distance_visitor::visit_leave(ir_call *ir) this->base_ir->insert_before(new_assignment); this->visit_new_assignment(new_assignment); } - if (formal_param->mode == ir_var_function_out - || formal_param->mode == ir_var_function_inout) { + if (formal_param->data.mode == ir_var_function_out + || formal_param->data.mode == ir_var_function_inout) { /* Copy from the temporary to gl_ClipDistance after the call. * Since visit_list_elements() has already decided which * instruction it's going to visit next, we need to visit diff --git a/src/glsl/lower_named_interface_blocks.cpp b/src/glsl/lower_named_interface_blocks.cpp index 0775375..2a1b351 100644 --- a/src/glsl/lower_named_interface_blocks.cpp +++ b/src/glsl/lower_named_interface_blocks.cpp @@ -108,7 +108,7 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions) * but, this will require changes to the other uniform block * support code. */ - if (var->mode == ir_var_uniform) + if (var->data.mode == ir_var_uniform) continue; const glsl_type * iface_t = var->type; @@ -139,7 +139,7 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions) new_var = new(mem_ctx) ir_variable(iface_t->fields.structure[i].type, var_name, - (ir_variable_mode) var->mode); + (ir_variable_mode) var->data.mode); new_var->from_named_ifc_block_nonarray = 1; } else { const glsl_type *new_array_type = @@ -149,12 +149,12 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions) new_var = new(mem_ctx) ir_variable(new_array_type, var_name, - (ir_variable_mode) var->mode); + (ir_variable_mode) var->data.mode); new_var->from_named_ifc_block_array = 1; } new_var->location = iface_t->fields.structure[i].location; new_var->explicit_location = (new_var->location >= 0); - new_var->interpolation = + new_var->data.interpolation = iface_t->fields.structure[i].interpolation; new_var->data.centroid = iface_t->fields.structure[i].centroid; new_var->data.sample = iface_t->fields.structure[i].sample; @@ -212,7 +212,7 @@ flatten_named_interface_blocks_declarations::handle_rvalue(ir_rvalue **rvalue) * but, this will require changes to the other uniform block * support code. */ - if (var->mode == ir_var_uniform) + if (var->data.mode == ir_var_uniform) return; if (var->get_interface_type() != NULL) { diff --git a/src/glsl/lower_output_reads.cpp b/src/glsl/lower_output_reads.cpp index 128b0b8..afe1776 100644 --- a/src/glsl/lower_output_reads.cpp +++ b/src/glsl/lower_output_reads.cpp @@ -91,7 +91,7 @@ output_read_remover::~output_read_remover() ir_visitor_status output_read_remover::visit(ir_dereference_variable *ir) { - if (ir->var->mode != ir_var_shader_out) + if (ir->var->data.mode != ir_var_shader_out) return visit_continue; ir_variable *temp = (ir_variable *) hash_table_find(replacements, ir->var); diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp index 498914e..ca7361f 100644 --- a/src/glsl/lower_packed_varyings.cpp +++ b/src/glsl/lower_packed_varyings.cpp @@ -258,7 +258,7 @@ lower_packed_varyings_visitor::run(exec_list *instructions) if (var == NULL) continue; - if (var->mode != this->mode || + if (var->data.mode != this->mode || var->location < (int) this->location_base || !this->needs_lowering(var)) continue; @@ -268,11 +268,11 @@ lower_packed_varyings_visitor::run(exec_list *instructions) * safe, caller should ensure that integral varyings always use flat * interpolation, even when this is not required by GLSL. */ - assert(var->interpolation == INTERP_QUALIFIER_FLAT || + assert(var->data.interpolation == INTERP_QUALIFIER_FLAT || !var->type->contains_integer()); /* Change the old varying into an ordinary global. */ - var->mode = ir_var_auto; + var->data.mode = ir_var_auto; /* Create a reference to the old varying. */ ir_dereference_variable *deref @@ -547,7 +547,7 @@ lower_packed_varyings_visitor::get_packed_varying_deref( if (this->packed_varyings[slot] == NULL) { char *packed_name = ralloc_asprintf(this->mem_ctx, "packed:%s", name); const glsl_type *packed_type; - if (unpacked_var->interpolation == INTERP_QUALIFIER_FLAT) + if (unpacked_var->data.interpolation == INTERP_QUALIFIER_FLAT) packed_type = glsl_type::ivec4_type; else packed_type = glsl_type::vec4_type; @@ -566,7 +566,7 @@ lower_packed_varyings_visitor::get_packed_varying_deref( } packed_var->data.centroid = unpacked_var->data.centroid; packed_var->data.sample = unpacked_var->data.sample; - packed_var->interpolation = unpacked_var->interpolation; + packed_var->data.interpolation = unpacked_var->data.interpolation; packed_var->location = location; unpacked_var->insert_before(packed_var); this->packed_varyings[slot] = packed_var; diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp b/src/glsl/lower_variable_index_to_cond_assign.cpp index 699fb39..7c5d80f 100644 --- a/src/glsl/lower_variable_index_to_cond_assign.cpp +++ b/src/glsl/lower_variable_index_to_cond_assign.cpp @@ -365,7 +365,7 @@ public: if (var == NULL) return this->lower_temps; - switch (var->mode) { + switch (var->data.mode) { case ir_var_auto: case ir_var_temporary: return this->lower_temps; diff --git a/src/glsl/opt_array_splitting.cpp b/src/glsl/opt_array_splitting.cpp index c7c5f67..e946e0a 100644 --- a/src/glsl/opt_array_splitting.cpp +++ b/src/glsl/opt_array_splitting.cpp @@ -122,8 +122,8 @@ ir_array_reference_visitor::get_variable_entry(ir_variable *var) { assert(var); - if (var->mode != ir_var_auto && - var->mode != ir_var_temporary) + if (var->data.mode != ir_var_auto && + var->data.mode != ir_var_temporary) return NULL; if (!(var->type->is_array() || var->type->is_matrix())) diff --git a/src/glsl/opt_constant_folding.cpp b/src/glsl/opt_constant_folding.cpp index 072fefe..08a47b9 100644 --- a/src/glsl/opt_constant_folding.cpp +++ b/src/glsl/opt_constant_folding.cpp @@ -127,8 +127,8 @@ ir_constant_folding_visitor::visit_enter(ir_call *ir) ir_rvalue *param_rval = (ir_rvalue *)iter.get(); ir_variable *sig_param = (ir_variable *)sig_iter.get(); - if (sig_param->mode == ir_var_function_in - || sig_param->mode == ir_var_const_in) { + if (sig_param->data.mode == ir_var_function_in + || sig_param->data.mode == ir_var_const_in) { ir_rvalue *new_param = param_rval; handle_rvalue(&new_param); diff --git a/src/glsl/opt_constant_propagation.cpp b/src/glsl/opt_constant_propagation.cpp index 2f65937..f1a6fbd 100644 --- a/src/glsl/opt_constant_propagation.cpp +++ b/src/glsl/opt_constant_propagation.cpp @@ -285,8 +285,8 @@ ir_constant_propagation_visitor::visit_enter(ir_call *ir) foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); ir_rvalue *param = (ir_rvalue *)iter.get(); - if (sig_param->mode != ir_var_function_out - && sig_param->mode != ir_var_function_inout) { + if (sig_param->data.mode != ir_var_function_out + && sig_param->data.mode != ir_var_function_inout) { ir_rvalue *new_param = param; handle_rvalue(&new_param); if (new_param != param) diff --git a/src/glsl/opt_constant_variable.cpp b/src/glsl/opt_constant_variable.cpp index cbe6450..a026c51 100644 --- a/src/glsl/opt_constant_variable.cpp +++ b/src/glsl/opt_constant_variable.cpp @@ -137,8 +137,8 @@ ir_constant_variable_visitor::visit_enter(ir_call *ir) ir_rvalue *param_rval = (ir_rvalue *)iter.get(); ir_variable *param = (ir_variable *)sig_iter.get(); - if (param->mode == ir_var_function_out || - param->mode == ir_var_function_inout) { + if (param->data.mode == ir_var_function_out || + param->data.mode == ir_var_function_inout) { ir_variable *var = param_rval->variable_referenced(); struct assignment_entry *entry; diff --git a/src/glsl/opt_copy_propagation.cpp b/src/glsl/opt_copy_propagation.cpp index 7282b61..db5dfc1 100644 --- a/src/glsl/opt_copy_propagation.cpp +++ b/src/glsl/opt_copy_propagation.cpp @@ -189,8 +189,8 @@ ir_copy_propagation_visitor::visit_enter(ir_call *ir) foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); ir_instruction *ir = (ir_instruction *)iter.get(); - if (sig_param->mode != ir_var_function_out - && sig_param->mode != ir_var_function_inout) { + if (sig_param->data.mode != ir_var_function_out + && sig_param->data.mode != ir_var_function_inout) { ir->accept(this); } sig_param_iter.next(); diff --git a/src/glsl/opt_copy_propagation_elements.cpp b/src/glsl/opt_copy_propagation_elements.cpp index 6a19da4..ba8a0f5 100644 --- a/src/glsl/opt_copy_propagation_elements.cpp +++ b/src/glsl/opt_copy_propagation_elements.cpp @@ -297,8 +297,8 @@ ir_copy_propagation_elements_visitor::visit_enter(ir_call *ir) foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); ir_instruction *ir = (ir_instruction *)iter.get(); - if (sig_param->mode != ir_var_function_out - && sig_param->mode != ir_var_function_inout) { + if (sig_param->data.mode != ir_var_function_out + && sig_param->data.mode != ir_var_function_inout) { ir->accept(this); } sig_param_iter.next(); diff --git a/src/glsl/opt_dead_builtin_varyings.cpp b/src/glsl/opt_dead_builtin_varyings.cpp index b336bc0..62b5f1e 100644 --- a/src/glsl/opt_dead_builtin_varyings.cpp +++ b/src/glsl/opt_dead_builtin_varyings.cpp @@ -85,7 +85,7 @@ public: { ir_variable *var = ir->variable_referenced(); - if (!var || var->mode != this->mode) + if (!var || var->data.mode != this->mode) return visit_continue; if (this->find_frag_outputs && var->location == FRAG_RESULT_DATA0) { @@ -130,7 +130,7 @@ public: { ir_variable *var = ir->variable_referenced(); - if (var->mode != this->mode || !var->type->is_array()) + if (var->data.mode != this->mode || !var->type->is_array()) return visit_continue; if (this->find_frag_outputs && var->location == FRAG_RESULT_DATA0) { @@ -152,7 +152,7 @@ public: virtual ir_visitor_status visit(ir_variable *var) { - if (var->mode != this->mode) + if (var->data.mode != this->mode) return visit_continue; /* Nothing to do here for fragment outputs. */ diff --git a/src/glsl/opt_dead_code.cpp b/src/glsl/opt_dead_code.cpp index b65e5c2..a8d8b4a 100644 --- a/src/glsl/opt_dead_code.cpp +++ b/src/glsl/opt_dead_code.cpp @@ -79,9 +79,9 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned) /* Remove a single dead assignment to the variable we found. * Don't do so if it's a shader or function output, though. */ - if (entry->var->mode != ir_var_function_out && - entry->var->mode != ir_var_function_inout && - entry->var->mode != ir_var_shader_out) { + if (entry->var->data.mode != ir_var_function_out && + entry->var->data.mode != ir_var_function_inout && + entry->var->data.mode != ir_var_shader_out) { entry->assign->remove(); progress = true; @@ -99,7 +99,7 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned) * stage. Also, once uniform locations have been assigned, the * declaration cannot be deleted. */ - if (entry->var->mode == ir_var_uniform && + if (entry->var->data.mode == ir_var_uniform && (uniform_locations_assigned || entry->var->constant_value)) continue; diff --git a/src/glsl/opt_dead_code_local.cpp b/src/glsl/opt_dead_code_local.cpp index 42a30b3..43a0166 100644 --- a/src/glsl/opt_dead_code_local.cpp +++ b/src/glsl/opt_dead_code_local.cpp @@ -121,7 +121,7 @@ public: */ foreach_iter(exec_list_iterator, iter, *this->assignments) { assignment_entry *entry = (assignment_entry *)iter.get(); - if (entry->lhs->mode == ir_var_shader_out) { + if (entry->lhs->data.mode == ir_var_shader_out) { if (debug) printf("kill %s\n", entry->lhs->name); entry->remove(); diff --git a/src/glsl/opt_function_inlining.cpp b/src/glsl/opt_function_inlining.cpp index 86d0fa3..c8f42a4 100644 --- a/src/glsl/opt_function_inlining.cpp +++ b/src/glsl/opt_function_inlining.cpp @@ -132,7 +132,7 @@ ir_call::generate_inline(ir_instruction *next_ir) parameters[i] = NULL; } else { parameters[i] = sig_param->clone(ctx, ht); - parameters[i]->mode = ir_var_auto; + parameters[i]->data.mode = ir_var_auto; /* Remove the read-only decoration becuase we're going to write * directly to this variable. If the cloned variable is left @@ -144,9 +144,9 @@ ir_call::generate_inline(ir_instruction *next_ir) } /* Move the actual param into our param variable if it's an 'in' type. */ - if (parameters[i] && (sig_param->mode == ir_var_function_in || - sig_param->mode == ir_var_const_in || - sig_param->mode == ir_var_function_inout)) { + if (parameters[i] && (sig_param->data.mode == ir_var_function_in || + sig_param->data.mode == ir_var_const_in || + sig_param->data.mode == ir_var_function_inout)) { ir_assignment *assign; assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]), @@ -202,8 +202,8 @@ ir_call::generate_inline(ir_instruction *next_ir) const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get(); /* Move our param variable into the actual param if it's an 'out' type. */ - if (parameters[i] && (sig_param->mode == ir_var_function_out || - sig_param->mode == ir_var_function_inout)) { + if (parameters[i] && (sig_param->data.mode == ir_var_function_out || + sig_param->data.mode == ir_var_function_inout)) { ir_assignment *assign; assign = new(ctx) ir_assignment(param->clone(ctx, NULL)->as_rvalue(), diff --git a/src/glsl/opt_structure_splitting.cpp b/src/glsl/opt_structure_splitting.cpp index 9f4b3dd..414f000 100644 --- a/src/glsl/opt_structure_splitting.cpp +++ b/src/glsl/opt_structure_splitting.cpp @@ -103,8 +103,8 @@ ir_structure_reference_visitor::get_variable_entry(ir_variable *var) { assert(var); - if (!var->type->is_record() || var->mode == ir_var_uniform - || var->mode == ir_var_shader_in || var->mode == ir_var_shader_out) + if (!var->type->is_record() || var->data.mode == ir_var_uniform + || var->data.mode == ir_var_shader_in || var->data.mode == ir_var_shader_out) return NULL; foreach_iter(exec_list_iterator, iter, this->variable_list) { diff --git a/src/glsl/opt_tree_grafting.cpp b/src/glsl/opt_tree_grafting.cpp index 46c06e6..6d75a15 100644 --- a/src/glsl/opt_tree_grafting.cpp +++ b/src/glsl/opt_tree_grafting.cpp @@ -211,8 +211,8 @@ ir_tree_grafting_visitor::visit_enter(ir_call *ir) ir_rvalue *ir = (ir_rvalue *)iter.get(); ir_rvalue *new_ir = ir; - if (sig_param->mode != ir_var_function_in - && sig_param->mode != ir_var_const_in) { + if (sig_param->data.mode != ir_var_function_in + && sig_param->data.mode != ir_var_const_in) { if (check_graft(ir, sig_param) == visit_stop) return visit_stop; continue; @@ -361,9 +361,9 @@ tree_grafting_basic_block(ir_instruction *bb_first, if (!lhs_var) continue; - if (lhs_var->mode == ir_var_function_out || - lhs_var->mode == ir_var_function_inout || - lhs_var->mode == ir_var_shader_out) + if (lhs_var->data.mode == ir_var_function_out || + lhs_var->data.mode == ir_var_function_inout || + lhs_var->data.mode == ir_var_shader_out) continue; ir_variable_refcount_entry *entry = info->refs->get_variable_entry(lhs_var); diff --git a/src/glsl/tests/builtin_variable_test.cpp b/src/glsl/tests/builtin_variable_test.cpp index accdd91..6164e10 100644 --- a/src/glsl/tests/builtin_variable_test.cpp +++ b/src/glsl/tests/builtin_variable_test.cpp @@ -110,7 +110,7 @@ common_builtin::uniforms_and_system_values_dont_have_explicit_location() foreach_list(node, &this->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var->mode != ir_var_uniform && var->mode != ir_var_system_value) + if (var->data.mode != ir_var_uniform && var->data.mode != ir_var_system_value) continue; EXPECT_FALSE(var->explicit_location); @@ -124,7 +124,7 @@ common_builtin::constants_are_constant() foreach_list(node, &this->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var->mode != ir_var_auto) + if (var->data.mode != ir_var_auto) continue; EXPECT_FALSE(var->explicit_location); @@ -139,7 +139,7 @@ common_builtin::no_invalid_variable_modes() foreach_list(node, &this->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - switch (var->mode) { + switch (var->data.mode) { case ir_var_auto: case ir_var_uniform: case ir_var_shader_in: @@ -149,7 +149,7 @@ common_builtin::no_invalid_variable_modes() default: ADD_FAILURE() << "Built-in variable " << var->name - << " has an invalid mode " << int(var->mode); + << " has an invalid mode " << int(var->data.mode); break; } } @@ -176,7 +176,7 @@ TEST_F(vertex_builtin, inputs_have_explicit_location) foreach_list(node, &this->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var->mode != ir_var_shader_in) + if (var->data.mode != ir_var_shader_in) continue; EXPECT_TRUE(var->explicit_location); @@ -191,7 +191,7 @@ TEST_F(vertex_builtin, outputs_have_explicit_location) foreach_list(node, &this->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var->mode != ir_var_shader_out) + if (var->data.mode != ir_var_shader_out) continue; EXPECT_TRUE(var->explicit_location); @@ -244,7 +244,7 @@ TEST_F(fragment_builtin, inputs_have_explicit_location) foreach_list(node, &this->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var->mode != ir_var_shader_in) + if (var->data.mode != ir_var_shader_in) continue; EXPECT_TRUE(var->explicit_location); @@ -264,7 +264,7 @@ TEST_F(fragment_builtin, outputs_have_explicit_location) foreach_list(node, &this->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var->mode != ir_var_shader_out) + if (var->data.mode != ir_var_shader_out) continue; EXPECT_TRUE(var->explicit_location); @@ -315,7 +315,7 @@ TEST_F(geometry_builtin, inputs_have_explicit_location) foreach_list(node, &this->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var->mode != ir_var_shader_in) + if (var->data.mode != ir_var_shader_in) continue; if (var->is_interface_instance()) { @@ -361,7 +361,7 @@ TEST_F(geometry_builtin, outputs_have_explicit_location) foreach_list(node, &this->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var->mode != ir_var_shader_out) + if (var->data.mode != ir_var_shader_out) continue; EXPECT_TRUE(var->explicit_location); diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 374801f..2819203 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -952,10 +952,10 @@ fs_visitor::emit_fragcoord_interpolation(ir_variable *ir) { fs_reg *reg = new(this->mem_ctx) fs_reg(this, ir->type); fs_reg wpos = *reg; - bool flip = !ir->origin_upper_left ^ c->key.render_to_fbo; + bool flip = !ir->data.origin_upper_left ^ c->key.render_to_fbo; /* gl_FragCoord.x */ - if (ir->pixel_center_integer) { + if (ir->data.pixel_center_integer) { emit(MOV(wpos, this->pixel_x)); } else { emit(ADD(wpos, this->pixel_x, fs_reg(0.5f))); @@ -963,11 +963,11 @@ fs_visitor::emit_fragcoord_interpolation(ir_variable *ir) wpos.reg_offset++; /* gl_FragCoord.y */ - if (!flip && ir->pixel_center_integer) { + if (!flip && ir->data.pixel_center_integer) { emit(MOV(wpos, this->pixel_y)); } else { fs_reg pixel_y = this->pixel_y; - float offset = (ir->pixel_center_integer ? 0.0 : 0.5); + float offset = (ir->data.pixel_center_integer ? 0.0 : 0.5); if (flip) { pixel_y.negate = true; diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp index 5aec757..dbf2017 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp @@ -615,8 +615,8 @@ fs_visitor::setup_fp_regs() switch (i) { case VARYING_SLOT_POS: - ir->pixel_center_integer = fp->PixelCenterInteger; - ir->origin_upper_left = fp->OriginUpperLeft; + ir->data.pixel_center_integer = fp->PixelCenterInteger; + ir->data.origin_upper_left = fp->OriginUpperLeft; fp_input_regs[i] = *emit_fragcoord_interpolation(ir); break; case VARYING_SLOT_FACE: 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 6284b59..ff7aa80 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp @@ -107,7 +107,7 @@ ir_vector_reference_visitor::get_variable_entry(ir_variable *var) if (!var->type->is_vector()) return NULL; - switch (var->mode) { + switch (var->data.mode) { case ir_var_uniform: case ir_var_shader_in: case ir_var_shader_out: diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 64ff899..763c0ae 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -56,7 +56,7 @@ fs_visitor::visit(ir_variable *ir) if (variable_storage(ir)) return; - if (ir->mode == ir_var_shader_in) { + if (ir->data.mode == ir_var_shader_in) { if (!strcmp(ir->name, "gl_FragCoord")) { reg = emit_fragcoord_interpolation(ir); } else if (!strcmp(ir->name, "gl_FrontFacing")) { @@ -67,7 +67,7 @@ fs_visitor::visit(ir_variable *ir) assert(reg); hash_table_insert(this->variable_ht, reg, ir); return; - } else if (ir->mode == ir_var_shader_out) { + } else if (ir->data.mode == ir_var_shader_out) { reg = new(this->mem_ctx) fs_reg(this, ir->type); if (ir->index > 0) { @@ -101,7 +101,7 @@ fs_visitor::visit(ir_variable *ir) this->output_components[output] = vector_elements; } } - } else if (ir->mode == ir_var_uniform) { + } else if (ir->data.mode == ir_var_uniform) { int param_index = c->prog_data.nr_params; /* Thanks to the lower_ubo_reference pass, we will see only @@ -131,7 +131,7 @@ fs_visitor::visit(ir_variable *ir) reg = new(this->mem_ctx) fs_reg(UNIFORM, param_index); reg->type = brw_type_for_base_type(ir->type); - } else if (ir->mode == ir_var_system_value) { + } else if (ir->data.mode == ir_var_system_value) { if (ir->location == SYSTEM_VALUE_SAMPLE_POS) { reg = emit_samplepos_setup(ir); } else if (ir->location == SYSTEM_VALUE_SAMPLE_ID) { diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index 88aa169..6f0ace8 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -223,7 +223,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg) foreach_list(node, shader->ir) { ir_variable *var = ((ir_instruction *) node)->as_variable(); - if ((var == NULL) || (var->mode != ir_var_uniform) + if ((var == NULL) || (var->data.mode != ir_var_uniform) || (strncmp(var->name, "gl_", 3) != 0)) continue; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp index adbb1cf..c93459d 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp @@ -283,7 +283,7 @@ vec4_gs_visitor::compute_array_stride(ir_dereference_array *ir) * setup_attributes() will remap our accesses to the actual input array. */ ir_dereference_variable *deref_var = ir->array->as_dereference_variable(); - if (deref_var && deref_var->var->mode == ir_var_shader_in) + if (deref_var && deref_var->var->data.mode == ir_var_shader_in) return BRW_VARYING_SLOT_COUNT; else return vec4_visitor::compute_array_stride(ir); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 81039ab..0d8135c 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -945,7 +945,7 @@ vec4_visitor::visit(ir_variable *ir) if (variable_storage(ir)) return; - switch (ir->mode) { + switch (ir->data.mode) { case ir_var_shader_in: reg = new(mem_ctx) dst_reg(ATTR, ir->location); break; @@ -1752,7 +1752,7 @@ vec4_visitor::visit(ir_dereference_variable *ir) this->result = src_reg(*reg); /* System values get their swizzle from the dst_reg writemask */ - if (ir->var->mode == ir_var_system_value) + if (ir->var->data.mode == ir_var_system_value) return; if (type->is_scalar() || type->is_vector() || type->is_matrix()) diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index 3014a97..6db29d8 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_shader_in + || var->data.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_shader_in + || var->data.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_shader_in + || var->data.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_shader_in + || var->data.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_shader_out + || var->data.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_shader_out + || var->data.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 ad6c242..1f841ef 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -681,11 +681,11 @@ ir_to_mesa_visitor::visit(ir_variable *ir) if (strcmp(ir->name, "gl_FragCoord") == 0) { struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog; - fp->OriginUpperLeft = ir->origin_upper_left; - fp->PixelCenterInteger = ir->pixel_center_integer; + fp->OriginUpperLeft = ir->data.origin_upper_left; + fp->PixelCenterInteger = ir->data.pixel_center_integer; } - if (ir->mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) { + if (ir->data.mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) { unsigned int i; const ir_state_slot *const slots = ir->state_slots; assert(ir->state_slots != NULL); @@ -1528,7 +1528,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) ir_variable *var = ir->var; if (!entry) { - switch (var->mode) { + switch (var->data.mode) { case ir_var_uniform: entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM, var->location); @@ -2499,7 +2499,7 @@ _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program foreach_list(node, sh->ir) { ir_variable *var = ((ir_instruction *) node)->as_variable(); - if ((var == NULL) || (var->mode != ir_var_uniform) + if ((var == NULL) || (var->data.mode != ir_var_uniform) || var->is_in_uniform_block() || (strncmp(var->name, "gl_", 3) == 0)) continue; diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index a1ee24f..befa6d4 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1056,11 +1056,11 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir) if (strcmp(ir->name, "gl_FragCoord") == 0) { struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog; - fp->OriginUpperLeft = ir->origin_upper_left; - fp->PixelCenterInteger = ir->pixel_center_integer; + fp->OriginUpperLeft = ir->data.origin_upper_left; + fp->PixelCenterInteger = ir->data.pixel_center_integer; } - if (ir->mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) { + if (ir->data.mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) { unsigned int i; const ir_state_slot *const slots = ir->state_slots; assert(ir->state_slots != NULL); @@ -2020,7 +2020,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir) ir_variable *var = ir->var; if (!entry) { - switch (var->mode) { + switch (var->data.mode) { case ir_var_uniform: entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM, var->location); @@ -2345,7 +2345,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_shader_out) { + ir->lhs->variable_referenced()->data.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. */ @@ -2621,8 +2621,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_function_in || - param->mode == ir_var_function_inout) { + if (param->data.mode == ir_var_function_in || + param->data.mode == ir_var_function_inout) { variable_storage *storage = find_variable_storage(param); assert(storage); @@ -2657,8 +2657,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_function_out || - param->mode == ir_var_function_inout) { + if (param->data.mode == ir_var_function_out || + param->data.mode == ir_var_function_inout) { variable_storage *storage = find_variable_storage(param); assert(storage); |