From cee66dd2aa182ba30130bef3298444667753b051 Mon Sep 17 00:00:00 2001 From: Tim Rowley Date: Thu, 3 Nov 2016 13:33:13 -0500 Subject: swr: [rasterizer core/jitter] fix alpha test bug Alpha from render target 0 should always be used for alpha test for all render targets, according to GL and DX9 specs. Previously we were using alpha from the current render target. Reviewed-by: Bruce Cherniak --- src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/gallium/drivers/swr/rasterizer/jitter') diff --git a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp index 46ea4951e87..b5b21c0d332 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp @@ -443,10 +443,13 @@ struct BlendJit : public Builder } } - void AlphaTest(const BLEND_COMPILE_STATE& state, Value* pBlendState, Value* pAlpha, Value* ppMask) + void AlphaTest(const BLEND_COMPILE_STATE& state, Value* pBlendState, Value* ppAlpha, Value* ppMask) { // load uint32_t reference Value* pRef = VBROADCAST(LOAD(pBlendState, { 0, SWR_BLEND_STATE_alphaTestReference })); + + // load alpha + Value* pAlpha = LOAD(ppAlpha); Value* pTest = nullptr; if (state.alphaTestFormat == ALPHA_TEST_UNORM8) @@ -523,6 +526,7 @@ struct BlendJit : public Builder PointerType::get(Gen_SWR_BLEND_STATE(JM()), 0), // SWR_BLEND_STATE* PointerType::get(mSimdFP32Ty, 0), // simdvector& src PointerType::get(mSimdFP32Ty, 0), // simdvector& src1 + PointerType::get(mSimdFP32Ty, 0), // src0alpha Type::getInt32Ty(JM()->mContext), // sampleNum PointerType::get(mSimdFP32Ty, 0), // uint8_t* pDst PointerType::get(mSimdFP32Ty, 0), // simdvector& result @@ -545,6 +549,8 @@ struct BlendJit : public Builder pSrc->setName("src"); Value* pSrc1 = &*argitr++; pSrc1->setName("src1"); + Value* pSrc0Alpha = &*argitr++; + pSrc0Alpha->setName("src0alpha"); Value* sampleNum = &*argitr++; sampleNum->setName("sampleNum"); Value* pDst = &*argitr++; @@ -588,7 +594,7 @@ struct BlendJit : public Builder // alpha test if (state.desc.alphaTestEnable) { - AlphaTest(state, pBlendState, src[3], ppMask); + AlphaTest(state, pBlendState, pSrc0Alpha, ppMask); } // color blend -- cgit v1.2.3