From e6daa62a48c62071d9fda8000f9d58b86a8b037d Mon Sep 17 00:00:00 2001 From: George Kyriazis Date: Sun, 15 Apr 2018 11:57:47 -0500 Subject: swr/rast: Add support for TexelMask evaluation Reviewed-by: Bruce Cherniak --- .../drivers/swr/rasterizer/jitter/builder.cpp | 42 ++++++++++++++++++++++ .../drivers/swr/rasterizer/jitter/builder.h | 2 ++ 2 files changed, 44 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp b/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp index bd815606fba..32487353f86 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/builder.cpp @@ -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(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(u.get()); + if (srcInst) + { + if (SetTexelMaskEvaluate(srcInst)) + { + return true; + } + } + } + } + + return false; + } + + bool Builder::IsTexelMaskEvaluate(Instruction* genSampleOrLoadIntrinsic) + { + CallInst* pGenIntrin = dyn_cast(genSampleOrLoadIntrinsic); + + if (!pGenIntrin) + { + return false; + } + + return (pGenIntrin->getMetadata("is_evaluate") != nullptr); + } + } diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder.h b/src/gallium/drivers/swr/rasterizer/jitter/builder.h index e2ad1e8b035..82c5f8cde2a 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/builder.h +++ b/src/gallium/drivers/swr/rasterizer/jitter/builder.h @@ -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" -- cgit v1.2.3