Mesa (master): nvc0/ir: fix lowering of textureGrad

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Sun May 6 20:04:16 UTC 2012


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

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Sat May  5 13:30:03 2012 +0200

nvc0/ir: fix lowering of textureGrad

---

 src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp    |    8 ++++----
 .../drivers/nvc0/codegen/nv50_ir_emit_nvc0.cpp     |    2 +-
 .../drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp |   15 ++++++++-------
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp
index 77edaa6..726331e 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp
@@ -1819,8 +1819,8 @@ RegAlloc::InsertConstraintsPass::texConstraintNVE0(TexInstruction *tex)
    int n = tex->srcCount(0xff, true);
    if (n > 4) {
       condenseSrcs(tex, 0, 3);
-      if (n > 5)
-         condenseSrcs(tex, 4, n - 1);
+      if (n > 5) // NOTE: first call modified positions already
+         condenseSrcs(tex, 4 - (4 - 1), n - 1 - (4 - 1));
    } else
    if (n > 1) {
       condenseSrcs(tex, 0, n - 1);
@@ -1850,8 +1850,8 @@ RegAlloc::InsertConstraintsPass::texConstraintNVC0(TexInstruction *tex)
 
    if (s > 1)
       condenseSrcs(tex, 0, s - 1);
-   if (n > 1)
-      condenseSrcs(tex, s, s + (n - 1));
+   if (n > 1) // NOTE: first call modified positions already
+      condenseSrcs(tex, 1, n);
 
    condenseDefs(tex);
 }
diff --git a/src/gallium/drivers/nvc0/codegen/nv50_ir_emit_nvc0.cpp b/src/gallium/drivers/nvc0/codegen/nv50_ir_emit_nvc0.cpp
index 2ca4979..fbd1aa5 100644
--- a/src/gallium/drivers/nvc0/codegen/nv50_ir_emit_nvc0.cpp
+++ b/src/gallium/drivers/nvc0/codegen/nv50_ir_emit_nvc0.cpp
@@ -1020,7 +1020,7 @@ CodeEmitterNVC0::emitTEX(const TexInstruction *i)
       code[1] |= 0x02000000;
    }
 
-   if (i->tex.derivAll)
+   if (i->op != OP_TXD && i->tex.derivAll)
       code[1] |= 1 << 13;
 
    defId(i->def(0), 14);
diff --git a/src/gallium/drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp
index 02ae9fd..900e998 100644
--- a/src/gallium/drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp
+++ b/src/gallium/drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp
@@ -749,21 +749,22 @@ bool
 NVC0LoweringPass::handleTXD(TexInstruction *txd)
 {
    int dim = txd->tex.target.getDim();
-   int arg = txd->tex.target.getDim() + txd->tex.target.isArray();
+   int arg = txd->tex.target.getArgCount();
 
    handleTEX(txd);
-   while (txd->src(arg).exists())
+   while (txd->srcExists(arg))
       ++arg;
 
    txd->tex.derivAll = true;
-   if (dim > 2 || txd->tex.target.isShadow())
+   if (dim > 2 ||
+       txd->tex.target.isCube() ||
+       arg > 4 ||
+       txd->tex.target.isShadow())
       return handleManualTXD(txd);
 
-   assert(arg <= 4); // at most s/t/array, x, y, offset
-
    for (int c = 0; c < dim; ++c) {
-      txd->src(arg + c * 2 + 0).set(txd->dPdx[c]);
-      txd->src(arg + c * 2 + 1).set(txd->dPdy[c]);
+      txd->setSrc(arg + c * 2 + 0, txd->dPdx[c]);
+      txd->setSrc(arg + c * 2 + 1, txd->dPdy[c]);
       txd->dPdx[c].set(NULL);
       txd->dPdy[c].set(NULL);
    }




More information about the mesa-commit mailing list