nv50/ir: add OP_BUFQ for buffers query
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sat, 9 Apr 2016 15:08:56 +0000 (17:08 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 26 Apr 2016 17:47:49 +0000 (19:47 +0200)
TGSI RESQ allows both images and buffers but we have to make a
distinction between these two type of resources in our lowering pass.
Introducing OP_BUFQ which is a fake operand will allow to implement
OP_SUQ for surfaces.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/nouveau/codegen/nv50_ir.h
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp
src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp

index 5141fc62e548c3dcd976689d3b5d509b72027d00..c52e86194633a40073bb1a8cde99431127a054c0 100644 (file)
@@ -162,6 +162,7 @@ enum operation
    OP_CCTL, // cache control
    OP_SHFL, // warp shuffle
    OP_VOTE,
+   OP_BUFQ, // buffer query
    OP_LAST
 };
 
index e57761fd0e2f01175895bda269c7914bfda97cd0..22a6ebc3ac18246c2203db3437f15405c21dfcd0 100644 (file)
@@ -3385,7 +3385,7 @@ Converter::handleInstruction(const struct tgsi_full_instruction *insn)
       handleATOM(dst0, dstTy, tgsi::opcodeToSubOp(tgsi.getOpcode()));
       break;
    case TGSI_OPCODE_RESQ:
-      geni = mkOp1(OP_SUQ, TYPE_U32, dst0[0],
+      geni = mkOp1(OP_BUFQ, TYPE_U32, dst0[0],
                    makeSym(TGSI_FILE_BUFFER, tgsi.getSrc(0).getIndex(0), -1, 0, 0));
       if (tgsi.getSrc(0).isIndirect(0))
          geni->setIndirect(0, 1, fetchSrc(tgsi.getSrc(0).getIndirect(0), 0, 0));
index a429ca4ebe43f7c90f70e01d1df155841bc8cbb3..7b07b09f65fbb2da6985e5f1a786d53b2030866e 100644 (file)
@@ -1070,13 +1070,13 @@ NVC0LoweringPass::handleTXLQ(TexInstruction *i)
 }
 
 bool
-NVC0LoweringPass::handleSUQ(Instruction *suq)
+NVC0LoweringPass::handleBUFQ(Instruction *bufq)
 {
-   suq->op = OP_MOV;
-   suq->setSrc(0, loadBufLength32(suq->getIndirect(0, 1),
-                                  suq->getSrc(0)->reg.fileIndex * 16));
-   suq->setIndirect(0, 0, NULL);
-   suq->setIndirect(0, 1, NULL);
+   bufq->op = OP_MOV;
+   bufq->setSrc(0, loadBufLength32(bufq->getIndirect(0, 1),
+                                   bufq->getSrc(0)->reg.fileIndex * 16));
+   bufq->setIndirect(0, 0, NULL);
+   bufq->setIndirect(0, 1, NULL);
    return true;
 }
 
@@ -1509,6 +1509,13 @@ static inline uint16_t getSuClampSubOp(const TexInstruction *su, int c)
    }
 }
 
+bool
+NVC0LoweringPass::handleSUQ(Instruction *suq)
+{
+   /* TODO: will be updated in the next commit. */
+   return true;
+}
+
 void
 NVC0LoweringPass::adjustCoordinatesMS(TexInstruction *tex)
 {
@@ -2260,6 +2267,9 @@ NVC0LoweringPass::visit(Instruction *i)
    case OP_SUQ:
       handleSUQ(i);
       break;
+   case OP_BUFQ:
+      handleBUFQ(i);
+      break;
    default:
       break;
    }
index d5c2cb5e7e162c118b2f287abe14e8a986ee2c2b..fd9f78012b751ddbc0e43ca80c224540e3b4928d 100644 (file)
@@ -108,6 +108,7 @@ protected:
    void handleSharedATOM(Instruction *);
    void handleSharedATOMNVE4(Instruction *);
    void handleLDST(Instruction *);
+   bool handleBUFQ(Instruction *);
 
    void checkPredicate(Instruction *);
 
index 39121a3a542f6953a51df83d947f4087e5eaa286..7fdbafa8c700fc0cdce1e7c5c18272b3d2d7a7e3 100644 (file)
@@ -191,6 +191,7 @@ const char *operationStr[OP_LAST + 1] =
    "cctl",
    "shfl",
    "vote",
+   "bufq",
    "(invalid)"
 };
 
index 160e36fd7b1983805feb0c7a8c2ec678ee492481..b5541005f5eeb2295b2202306945a4e52780a346 100644 (file)
@@ -56,6 +56,7 @@ const uint8_t Target::operationSrcNr[] =
    2, 2, 2, 1,             // VSHR, VSHL, VSEL, CCTL
    3,                      // SHFL
    1,                      // VOTE
+   1,                      // BUFQ
    0
 };
 
@@ -132,6 +133,8 @@ const OpClass Target::operationClass[] =
    OPCLASS_OTHER,
    // VOTE
    OPCLASS_OTHER,
+   // BUFQ
+   OPCLASS_OTHER,
    OPCLASS_PSEUDO // LAST
 };