[Mesa-dev] [PATCH 039/133] i965/fs: Don't take an ir_variable for emit_general_interpolation
Jason Ekstrand
jason at jlekstrand.net
Mon Dec 15 22:04:49 PST 2014
Previously, emit_general_interpolation took an ir_variable and pulled the
information it needed from that. This meant that in fs_fp, we were
constructing a dummy ir_variable just to pass into it. This commit makes
emit_general_interpolation take only the information it needs and gets rid
of the fs_fp cruft.
---
src/mesa/drivers/dri/i965/brw_fs.cpp | 48 +++++++++++++++-------------
src/mesa/drivers/dri/i965/brw_fs.h | 6 +++-
src/mesa/drivers/dri/i965/brw_fs_fp.cpp | 16 +++-------
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 6 +++-
4 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 4c587f3..b0e2cb4 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1279,35 +1279,41 @@ fs_visitor::emit_linterp(const fs_reg &attr, const fs_reg &interp,
this->delta_y[barycoord_mode], interp);
}
-fs_reg *
-fs_visitor::emit_general_interpolation(ir_variable *ir)
+void
+fs_visitor::emit_general_interpolation(fs_reg attr, const char *name,
+ const glsl_type *type,
+ glsl_interp_qualifier interpolation_mode,
+ int location, bool mod_centroid,
+ bool mod_sample)
{
- fs_reg *reg = new(this->mem_ctx) fs_reg(this, ir->type);
- reg->type = brw_type_for_base_type(ir->type->get_scalar_type());
- fs_reg attr = *reg;
+ attr.type = brw_type_for_base_type(type->get_scalar_type());
assert(stage == MESA_SHADER_FRAGMENT);
brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data;
brw_wm_prog_key *key = (brw_wm_prog_key*) this->key;
unsigned int array_elements;
- const glsl_type *type;
- if (ir->type->is_array()) {
- array_elements = ir->type->length;
+ if (type->is_array()) {
+ array_elements = type->length;
if (array_elements == 0) {
- fail("dereferenced array '%s' has length 0\n", ir->name);
+ fail("dereferenced array '%s' has length 0\n", name);
}
- type = ir->type->fields.array;
+ type = type->fields.array;
} else {
array_elements = 1;
- type = ir->type;
}
- glsl_interp_qualifier interpolation_mode =
- ir->determine_interpolation_mode(key->flat_shade);
+ if (interpolation_mode == INTERP_QUALIFIER_NONE) {
+ bool is_gl_Color =
+ location == VARYING_SLOT_COL0 || location == VARYING_SLOT_COL1;
+ if (key->flat_shade && is_gl_Color) {
+ interpolation_mode = INTERP_QUALIFIER_FLAT;
+ } else {
+ interpolation_mode = INTERP_QUALIFIER_SMOOTH;
+ }
+ }
- int location = ir->data.location;
for (unsigned int i = 0; i < array_elements; i++) {
for (unsigned int j = 0; j < type->matrix_columns; j++) {
if (prog_data->urb_setup[location] == -1) {
@@ -1327,7 +1333,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
for (unsigned int k = 0; k < type->vector_elements; k++) {
struct brw_reg interp = interp_reg(location, k);
interp = suboffset(interp, 3);
- interp.type = reg->type;
+ interp.type = attr.type;
emit(FS_OPCODE_CINTERP, attr, fs_reg(interp));
attr = offset(attr, 1);
}
@@ -1335,7 +1341,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
/* Smooth/noperspective interpolation case. */
for (unsigned int k = 0; k < type->vector_elements; k++) {
struct brw_reg interp = interp_reg(location, k);
- if (brw->needs_unlit_centroid_workaround && ir->data.centroid) {
+ if (brw->needs_unlit_centroid_workaround && mod_centroid) {
/* Get the pixel/sample mask into f0 so that we know
* which pixels are lit. Then, for each channel that is
* unlit, replace the centroid data with non-centroid
@@ -1352,8 +1358,8 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
inst->no_dd_clear = true;
inst = emit_linterp(attr, fs_reg(interp), interpolation_mode,
- ir->data.centroid && !key->persample_shading,
- ir->data.sample || key->persample_shading);
+ mod_centroid && !key->persample_shading,
+ mod_sample || key->persample_shading);
inst->predicate = BRW_PREDICATE_NORMAL;
inst->predicate_inverse = false;
if (brw->has_pln)
@@ -1361,8 +1367,8 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
} else {
emit_linterp(attr, fs_reg(interp), interpolation_mode,
- ir->data.centroid && !key->persample_shading,
- ir->data.sample || key->persample_shading);
+ mod_centroid && !key->persample_shading,
+ mod_sample || key->persample_shading);
}
if (brw->gen < 6 && interpolation_mode == INTERP_QUALIFIER_SMOOTH) {
emit(BRW_OPCODE_MUL, attr, attr, this->pixel_w);
@@ -1374,8 +1380,6 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
location++;
}
}
-
- return reg;
}
fs_reg *
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 918008d..95dfe95 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -480,7 +480,11 @@ public:
fs_reg *emit_frontfacing_interpolation();
fs_reg *emit_samplepos_setup();
fs_reg *emit_sampleid_setup();
- fs_reg *emit_general_interpolation(ir_variable *ir);
+ void emit_general_interpolation(fs_reg attr, const char *name,
+ const glsl_type *type,
+ glsl_interp_qualifier interpolation_mode,
+ int location, bool mod_centroid,
+ bool mod_sample);
fs_reg *emit_vs_system_value(enum brw_reg_type type, int location);
void emit_interpolation_setup_gen4();
void emit_interpolation_setup_gen6();
diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
index 0454014..e57b252 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
@@ -568,14 +568,6 @@ fs_visitor::setup_fp_regs()
fp_input_regs = rzalloc_array(mem_ctx, fs_reg, VARYING_SLOT_MAX);
for (int i = 0; i < VARYING_SLOT_MAX; i++) {
if (prog->InputsRead & BITFIELD64_BIT(i)) {
- /* Make up a dummy instruction to reuse code for emitting
- * interpolation.
- */
- ir_variable *ir = new(mem_ctx) ir_variable(glsl_type::vec4_type,
- "fp_input",
- ir_var_shader_in);
- ir->data.location = i;
-
this->current_annotation = ralloc_asprintf(ctx, "interpolate input %d",
i);
@@ -584,8 +576,6 @@ fs_visitor::setup_fp_regs()
{
assert(stage == MESA_SHADER_FRAGMENT);
gl_fragment_program *fp = (gl_fragment_program*) prog;
- ir->data.pixel_center_integer = fp->PixelCenterInteger;
- ir->data.origin_upper_left = fp->OriginUpperLeft;
fp_input_regs[i] =
*emit_fragcoord_interpolation(fp->PixelCenterInteger,
fp->OriginUpperLeft);
@@ -595,7 +585,11 @@ fs_visitor::setup_fp_regs()
fp_input_regs[i] = *emit_frontfacing_interpolation();
break;
default:
- fp_input_regs[i] = *emit_general_interpolation(ir);
+ fp_input_regs[i] = fs_reg(this, glsl_type::vec4_type);
+ emit_general_interpolation(fp_input_regs[i], "fp_input",
+ glsl_type::vec4_type,
+ INTERP_QUALIFIER_NONE,
+ i, false, false);
if (i == VARYING_SLOT_FOGC) {
emit(MOV(offset(fp_input_regs[i], 1), fs_reg(0.0f)));
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 3e447b8..fd7dd43 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -97,7 +97,11 @@ fs_visitor::visit(ir_variable *ir)
} else if (!strcmp(ir->name, "gl_FrontFacing")) {
reg = emit_frontfacing_interpolation();
} else {
- reg = emit_general_interpolation(ir);
+ reg = new(this->mem_ctx) fs_reg(this, ir->type);
+ emit_general_interpolation(*reg, ir->name, ir->type,
+ (glsl_interp_qualifier) ir->data.interpolation,
+ ir->data.location, ir->data.centroid,
+ ir->data.sample);
}
assert(reg);
hash_table_insert(this->variable_ht, reg, ir);
--
2.2.0
More information about the mesa-dev
mailing list