[Mesa-dev] [PATCH 08/14] swr: [rasterizer core/jitter] fix alpha test bug
Tim Rowley
timothy.o.rowley at intel.com
Thu Nov 10 03:18:42 UTC 2016
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.
---
src/gallium/drivers/swr/rasterizer/core/backend.h | 1 +
src/gallium/drivers/swr/rasterizer/core/state.h | 6 +++++-
src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp | 10 ++++++++--
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/swr/rasterizer/core/backend.h b/src/gallium/drivers/swr/rasterizer/core/backend.h
index dc0be90..a7018e0 100644
--- a/src/gallium/drivers/swr/rasterizer/core/backend.h
+++ b/src/gallium/drivers/swr/rasterizer/core/backend.h
@@ -714,6 +714,7 @@ INLINE void OutputMerger(SWR_PS_CONTEXT &psContext, uint8_t* (&pColorBase)[SWR_N
pBlendState,
psContext.shaded[rt],
psContext.shaded[1],
+ psContext.shaded[0].w,
sample,
pColorSample,
blendOut,
diff --git a/src/gallium/drivers/swr/rasterizer/core/state.h b/src/gallium/drivers/swr/rasterizer/core/state.h
index 5ee12e8..24927cd 100644
--- a/src/gallium/drivers/swr/rasterizer/core/state.h
+++ b/src/gallium/drivers/swr/rasterizer/core/state.h
@@ -805,9 +805,13 @@ typedef void(__cdecl *PFN_CS_FUNC)(HANDLE hPrivateData, SWR_CS_CONTEXT* pCsConte
typedef void(__cdecl *PFN_SO_FUNC)(SWR_STREAMOUT_CONTEXT& soContext);
typedef void(__cdecl *PFN_PIXEL_KERNEL)(HANDLE hPrivateData, SWR_PS_CONTEXT *pContext);
typedef void(__cdecl *PFN_CPIXEL_KERNEL)(HANDLE hPrivateData, SWR_PS_CONTEXT *pContext);
-typedef void(__cdecl *PFN_BLEND_JIT_FUNC)(const SWR_BLEND_STATE*, simdvector&, simdvector&, uint32_t, uint8_t*, simdvector&, simdscalari*, simdscalari*);
+typedef void(__cdecl *PFN_BLEND_JIT_FUNC)(const SWR_BLEND_STATE*,
+ simdvector& vSrc, simdvector& vSrc1, simdscalar& vSrc0Alpha, uint32_t sample,
+ uint8_t* pDst, simdvector& vResult, simdscalari* vOMask, simdscalari* vCoverageMask);
typedef simdscalar(*PFN_QUANTIZE_DEPTH)(simdscalar);
+
+
//////////////////////////////////////////////////////////////////////////
/// FRONTEND_STATE
/////////////////////////////////////////////////////////////////////////
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp
index d69d503..43e3d36 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
--
2.7.4
More information about the mesa-dev
mailing list