Mesa (master): gv100/ir: implement sample shading

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 7 11:43:05 UTC 2020


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

Author: Karol Herbst <kherbst at redhat.com>
Date:   Sat Jul  4 22:12:10 2020 +0200

gv100/ir: implement sample shading

Fixes sample shading tests in the Khronos OpenGL(ES) CTS

Signed-off-by: Karol Herbst <kherbst at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5747>

---

 .../drivers/nouveau/codegen/nv50_ir_emit_gv100.cpp | 52 +++++++++++++++++++---
 1 file changed, 45 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gv100.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gv100.cpp
index dcd2fae5367..0b59f64f156 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gv100.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_gv100.cpp
@@ -910,6 +910,40 @@ CodeEmitterGV100::emitATOMS()
    emitGPR  (16, insn->def(0));
 }
 
+static void
+interpApply(const FixupEntry *entry, uint32_t *code, const FixupData& data)
+{
+   int ipa = entry->ipa;
+   int loc = entry->loc;
+
+   if (data.force_persample_interp &&
+       (ipa & NV50_IR_INTERP_SAMPLE_MASK) == NV50_IR_INTERP_DEFAULT &&
+       (ipa & NV50_IR_INTERP_MODE_MASK) != NV50_IR_INTERP_FLAT) {
+      ipa |= NV50_IR_INTERP_CENTROID;
+   }
+
+   int sample;
+   switch (ipa & NV50_IR_INTERP_SAMPLE_MASK) {
+   case NV50_IR_INTERP_DEFAULT : sample = 0; break;
+   case NV50_IR_INTERP_CENTROID: sample = 1; break;
+   case NV50_IR_INTERP_OFFSET  : sample = 2; break;
+   default: assert(!"invalid sample mode");
+   }
+
+   int interp;
+   switch (ipa & NV50_IR_INTERP_MODE_MASK) {
+   case NV50_IR_INTERP_LINEAR     :
+   case NV50_IR_INTERP_PERSPECTIVE: interp = 0; break;
+   case NV50_IR_INTERP_FLAT       : interp = 1; break;
+   case NV50_IR_INTERP_SC         : interp = 2; break;
+   default: assert(!"invalid ipa mode");
+   }
+
+   code[loc + 2] &= ~(0xf << 12);
+   code[loc + 2] |= sample << 12;
+   code[loc + 2] |= interp << 14;
+}
+
 void
 CodeEmitterGV100::emitIPA()
 {
@@ -926,17 +960,21 @@ CodeEmitterGV100::emitIPA()
       break;
    }
 
+   switch (insn->getSampleMode()) {
+   case NV50_IR_INTERP_DEFAULT : emitField(76, 2, 0); break;
+   case NV50_IR_INTERP_CENTROID: emitField(76, 2, 1); break;
+   case NV50_IR_INTERP_OFFSET  : emitField(76, 2, 2); break;
+   default:
+      assert(!"invalid sample mode");
+      break;
+   }
+
    if (insn->getSampleMode() != NV50_IR_INTERP_OFFSET) {
-      switch (insn->getSampleMode()) {
-      case NV50_IR_INTERP_DEFAULT : emitField(76, 2, 0); break;
-      case NV50_IR_INTERP_CENTROID: emitField(76, 2, 1); break;
-      default:
-         break;
-      }
       emitGPR  (32);
+      addInterp(insn->ipa, 0xff, interpApply);
    } else {
-      emitField(76, 2, 2);
       emitGPR  (32, insn->src(1));
+      addInterp(insn->ipa, insn->getSrc(1)->reg.data.id, interpApply);
    }
 
    assert(!insn->src(0).isIndirect(0));



More information about the mesa-commit mailing list