Module: Mesa
Branch: master
Commit: d5d6ec884321ceaabe18ec4d33e9a27758696ef9
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d5d6ec884321ceaabe18ec4d33e9a27758696ef9

Author: Rob Clark <[email protected]>
Date:   Wed Apr 24 10:48:59 2013 -0400

freedreno: fix texture fetch type

There is a bit we need to set for 2D vs 3D fetch, to tell the hw whether
there are two or there valid input components.

Signed-off-by: Rob Clark <[email protected]>

---

 src/gallium/drivers/freedreno/freedreno_compiler.c |    5 +++++
 src/gallium/drivers/freedreno/instr-a2xx.h         |    2 +-
 src/gallium/drivers/freedreno/ir-a2xx.c            |    1 +
 src/gallium/drivers/freedreno/ir-a2xx.h            |    4 +++-
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_compiler.c 
b/src/gallium/drivers/freedreno/freedreno_compiler.c
index a26f8cf..b9cac8f 100644
--- a/src/gallium/drivers/freedreno/freedreno_compiler.c
+++ b/src/gallium/drivers/freedreno/freedreno_compiler.c
@@ -810,6 +810,7 @@ translate_tex(struct fd_compile_context *ctx,
 
        instr = ir2_instr_create(next_exec_cf(ctx), IR2_FETCH);
        instr->fetch.opc = TEX_FETCH;
+       instr->fetch.is_cube = (inst->Texture.Texture == TGSI_TEXTURE_3D);
        assert(inst->Texture.NumOffsets <= 1); // TODO what to do in other 
cases?
 
        /* save off the tex fetch to be patched later with correct const_idx: */
@@ -820,6 +821,10 @@ translate_tex(struct fd_compile_context *ctx,
        add_dst_reg(ctx, instr, using_temp ? &tmp_dst : &inst->Dst[0].Register);
        reg = add_src_reg(ctx, instr, coord);
 
+       /* blob compiler always sets 3rd component to same as 1st for 2d: */
+       if (inst->Texture.Texture == TGSI_TEXTURE_2D)
+               reg->swizzle[2] = reg->swizzle[0];
+
        /* dst register needs to be marked for sync: */
        ctx->need_sync |= 1 << instr->regs[0]->num;
 
diff --git a/src/gallium/drivers/freedreno/instr-a2xx.h 
b/src/gallium/drivers/freedreno/instr-a2xx.h
index cecc7a9..e1e897e 100644
--- a/src/gallium/drivers/freedreno/instr-a2xx.h
+++ b/src/gallium/drivers/freedreno/instr-a2xx.h
@@ -327,7 +327,7 @@ typedef struct PACKED {
        instr_tex_filter_t  vol_mag_filter           : 2;
        instr_tex_filter_t  vol_min_filter           : 2;
        uint8_t             use_comp_lod             : 1;
-       uint8_t             use_reg_lod              : 2;
+       uint8_t             use_reg_lod              : 2;  /* 0 for cube, 1 for 
2d */
        uint8_t             pred_select              : 1;
        /* dword2: */
        uint8_t             use_reg_gradients        : 1;
diff --git a/src/gallium/drivers/freedreno/ir-a2xx.c 
b/src/gallium/drivers/freedreno/ir-a2xx.c
index 2448a78..18afba8 100644
--- a/src/gallium/drivers/freedreno/ir-a2xx.c
+++ b/src/gallium/drivers/freedreno/ir-a2xx.c
@@ -339,6 +339,7 @@ static int instr_emit_fetch(struct ir2_instruction *instr,
                tex->vol_mag_filter = TEX_FILTER_USE_FETCH_CONST;
                tex->vol_min_filter = TEX_FILTER_USE_FETCH_CONST;
                tex->use_comp_lod = 1;
+               tex->use_reg_lod = !instr->fetch.is_cube;
                tex->sample_location = SAMPLE_CENTER;
 
                if (instr->pred != IR2_PRED_NONE) {
diff --git a/src/gallium/drivers/freedreno/ir-a2xx.h 
b/src/gallium/drivers/freedreno/ir-a2xx.h
index e2c7eff..822e5ec 100644
--- a/src/gallium/drivers/freedreno/ir-a2xx.h
+++ b/src/gallium/drivers/freedreno/ir-a2xx.h
@@ -72,7 +72,9 @@ struct ir2_instruction {
                struct {
                        instr_fetch_opc_t opc;
                        unsigned const_idx;
-                       /* maybe vertex fetch specific: */
+                       /* texture fetch specific: */
+                       bool is_cube : 1;
+                       /* vertex fetch specific: */
                        unsigned const_idx_sel;
                        enum a2xx_sq_surfaceformat fmt;
                        bool is_signed : 1;

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to