swr/rast: Add support for TexelMask evaluation
authorGeorge Kyriazis <george.kyriazis@intel.com>
Sun, 15 Apr 2018 16:57:47 +0000 (11:57 -0500)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 27 Apr 2018 19:36:41 +0000 (14:36 -0500)
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/jitter/builder.cpp
src/gallium/drivers/swr/rasterizer/jitter/builder.h

index bd81560..3248735 100644 (file)
@@ -128,4 +128,46 @@ namespace SwrJit
 
         return (pAlloca->getMetadata("is_temp_alloca") != nullptr);
     }
+
+    // Returns true if able to find an intrinsic to mark
+    bool Builder::SetTexelMaskEvaluate(Instruction* inst)
+    {
+        CallInst* pGenIntrin = dyn_cast<CallInst>(inst);
+        if (pGenIntrin)
+        {
+            MDNode* N = MDNode::get(JM()->mContext, MDString::get(JM()->mContext, "is_evaluate"));
+            pGenIntrin->setMetadata("is_evaluate", N);
+            return true;
+        }
+        else
+        {
+            // Follow use def chain back up
+            for (Use& u : inst->operands())
+            {
+                Instruction* srcInst = dyn_cast<Instruction>(u.get());
+                if (srcInst)
+                {
+                    if (SetTexelMaskEvaluate(srcInst))
+                    {
+                        return true;
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+
+    bool Builder::IsTexelMaskEvaluate(Instruction* genSampleOrLoadIntrinsic)
+    {
+        CallInst* pGenIntrin = dyn_cast<CallInst>(genSampleOrLoadIntrinsic);
+
+        if (!pGenIntrin)
+        {
+            return false;
+        }
+
+        return (pGenIntrin->getMetadata("is_evaluate") != nullptr);
+    }
+
 }
index e2ad1e8..82c5f8c 100644 (file)
@@ -121,6 +121,8 @@ namespace SwrJit
         void SetTargetWidth(uint32_t width);
         void SetTempAlloca(Value* inst);
         bool IsTempAlloca(Value* inst);
+        bool SetTexelMaskEvaluate(Instruction* inst);
+        bool IsTexelMaskEvaluate(Instruction* inst);
 
 #include "gen_builder.hpp"
 #include "gen_builder_meta.hpp"