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 bd815606fbad51e7cbafa5b84f6def2df57443b1..32487353f864aa8a932657d789f33b5c5f88e840 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 e2ad1e8b035490d4a173701c34484f2038f1a252..82c5f8cde2a868772cbcbd31651adaf2c81c488c 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"