[Mesa-dev] [PATCH 08/17] i965/fs: make rescale_texcoord() not use ir_texture.

Kenneth Graunke kenneth at whitecape.org
Mon Oct 13 21:54:38 PDT 2014


From: Connor Abbott <connor.abbott at intel.com>

Our new IR won't have ir_texture objects, but using glsl_type is fine.

v2 (Ken): Drop redundant ir->coordinate NULL check; rebase.

Signed-off-by: Connor Abbott <connor.abbott at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_fs.h           |  2 +-
 src/mesa/drivers/dri/i965/brw_fs_fp.cpp      |  2 +-
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 12 ++++++------
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 137f036..458ea1e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -468,7 +468,7 @@ public:
    void emit_interpolation_setup_gen4();
    void emit_interpolation_setup_gen6();
    void compute_sample_position(fs_reg dst, fs_reg int_sample_pos);
-   fs_reg rescale_texcoord(ir_texture *ir, fs_reg coordinate,
+   fs_reg rescale_texcoord(fs_reg coordinate, const glsl_type *coord_type,
                            bool is_rect, uint32_t sampler, int texunit);
    fs_inst *emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate,
                               fs_reg shadow_comp, fs_reg lod, fs_reg lod2,
diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
index b1745dd..571fb66 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp
@@ -482,7 +482,7 @@ fs_visitor::emit_fragment_program_code()
          if (fpi->TexShadow)
             shadow_c = offset(coordinate, 2);
 
-         coordinate = rescale_texcoord(ir, coordinate,
+         coordinate = rescale_texcoord(coordinate, coordinate_type,
                                        fpi->TexSrcTarget == TEXTURE_RECT_INDEX,
                                        fpi->TexSrcUnit, fpi->TexSrcUnit);
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index c1ad969..baa94ce 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1689,7 +1689,7 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
 }
 
 fs_reg
-fs_visitor::rescale_texcoord(ir_texture *ir, fs_reg coordinate,
+fs_visitor::rescale_texcoord(fs_reg coordinate, const glsl_type *coord_type,
                              bool is_rect, uint32_t sampler, int texunit)
 {
    fs_inst *inst = NULL;
@@ -1751,7 +1751,7 @@ fs_visitor::rescale_texcoord(ir_texture *ir, fs_reg coordinate,
     * tracking to get the scaling factor.
     */
    if (brw->gen < 6 && is_rect) {
-      fs_reg dst = fs_reg(this, ir->coordinate->type);
+      fs_reg dst = fs_reg(this, coord_type);
       fs_reg src = coordinate;
       coordinate = dst;
 
@@ -1791,9 +1791,8 @@ fs_visitor::rescale_texcoord(ir_texture *ir, fs_reg coordinate,
       }
    }
 
-   if (ir->coordinate && needs_gl_clamp) {
-      for (unsigned int i = 0;
-	   i < MIN2(ir->coordinate->type->vector_elements, 3); i++) {
+   if (coord_type && needs_gl_clamp) {
+      for (unsigned int i = 0; i < MIN2(coord_type->vector_elements, 3); i++) {
 	 if (tex->gl_clamp_mask[i] & (1 << sampler)) {
 	    fs_reg chan = coordinate;
 	    chan = offset(chan, i);
@@ -1923,7 +1922,8 @@ fs_visitor::visit(ir_texture *ir)
    if (ir->coordinate) {
       ir->coordinate->accept(this);
 
-      coordinate = rescale_texcoord(ir, this->result,
+      coordinate = rescale_texcoord(this->result,
+                                    ir->coordinate->type,
                                     ir->sampler->type->sampler_dimensionality ==
                                     GLSL_SAMPLER_DIM_RECT,
                                     sampler, texunit);
-- 
2.1.2



More information about the mesa-dev mailing list