[Mesa-dev] [PATCH 16/22] nvir/nir: parse NIR shader info

Karol Herbst kherbst at redhat.com
Thu Dec 21 15:51:34 UTC 2017


TODO: this is far from being complete, but at least this let the basics things
work already.

Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 .../drivers/nouveau/codegen/nv50_ir_from_nir.cpp   | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
index d114fe28dd..cf324a3e8f 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -68,6 +68,7 @@ public:
                        decltype(nir_variable().data.interpolation),
                        unsigned semantics);
    bool assignSlots();
+   bool parseNIR();
 
    bool visit(nir_alu_instr *);
    bool visit(nir_block *);
@@ -893,6 +894,26 @@ bool Converter::assignSlots() {
    return info->assignSlots(info) == 0;
 }
 
+bool
+Converter::parseNIR()
+{
+   info->io.clipDistances = nir->info.clip_distance_array_size;
+   info->io.cullDistances = nir->info.cull_distance_array_size;
+
+   switch(prog->getType()) {
+   case Program::TYPE_FRAGMENT:
+      info->prop.fp.usesDiscard = nir->info.fs.uses_discard;
+      break;
+   case Program::TYPE_GEOMETRY:
+      info->prop.gp.instanceCount = nir->info.gs.invocations;
+      break;
+   default:
+      break;
+   }
+
+   return true;
+}
+
 bool
 Converter::visit(nir_function *function)
 {
@@ -1631,6 +1652,11 @@ Converter::run()
    if (prog->dbgFlags & NV50_IR_DEBUG_BASIC)
       nir_print_shader(nir, stderr);
 
+   if (!parseNIR()) {
+      ERROR("Couldn't prase NIR!\n");
+      return false;
+   }
+
    if (!assignSlots()) {
       ERROR("Couldn't assign slots!\n");
       return false;
-- 
2.14.3



More information about the mesa-dev mailing list