Stuff parameters into a blend context struct before passing down through
the PFN_BLEND_JIT_FUNC function pointer. Needed for stat changes.
---
 .../drivers/swr/rasterizer/core/backend_impl.h     | 44 ++++++++++---------
 src/gallium/drivers/swr/rasterizer/core/state.h    | 17 ++++++--
 .../drivers/swr/rasterizer/jitter/blend_jit.cpp    | 50 +++++++++++-----------
 3 files changed, 62 insertions(+), 49 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/backend_impl.h 
b/src/gallium/drivers/swr/rasterizer/core/backend_impl.h
index 2cfd52e..8c539e3 100644
--- a/src/gallium/drivers/swr/rasterizer/core/backend_impl.h
+++ b/src/gallium/drivers/swr/rasterizer/core/backend_impl.h
@@ -724,24 +724,26 @@ INLINE void OutputMerger4x2(SWR_PS_CONTEXT &psContext, 
uint8_t* (&pColorBase)[SW
 
         const SWR_RENDER_TARGET_BLEND_STATE *pRTBlend = 
&pBlendState->renderTarget[rt];
 
+        SWR_BLEND_CONTEXT blendContext = { 0 };
         {
             // pfnBlendFunc may not update all channels.  Initialize with PS 
output.
             /// TODO: move this into the blend JIT.
             blendOut = psContext.shaded[rt];
 
+            blendContext.pBlendState = pBlendState;
+            blendContext.src = &psContext.shaded[rt];
+            blendContext.src1 = &psContext.shaded[1];
+            blendContext.src0alpha = reinterpret_cast<simdvector 
*>(&psContext.shaded[0].w);
+            blendContext.sampleNum = sample;
+            blendContext.pDst = (simdvector *) &pColorSample;
+            blendContext.result = &blendOut;
+            blendContext.oMask = &psContext.oMask;
+            blendContext.pMask = reinterpret_cast<simdscalari 
*>(&coverageMask);
+
             // Blend outputs and update coverage mask for alpha test
             if(pfnBlendFunc[rt] != nullptr)
             {
-                pfnBlendFunc[rt](
-                    pBlendState,
-                    psContext.shaded[rt],
-                    psContext.shaded[1],
-                    psContext.shaded[0].w,
-                    sample,
-                    pColorSample,
-                    blendOut,
-                    &psContext.oMask,
-                    (simdscalari*)&coverageMask);
+                pfnBlendFunc[rt](&blendContext);
             }
         }
 
@@ -811,24 +813,26 @@ INLINE void OutputMerger8x2(SWR_PS_CONTEXT &psContext, 
uint8_t* (&pColorBase)[SW
             pColorSample = nullptr;
         }
 
+        SWR_BLEND_CONTEXT blendContext = { 0 };
         {
             // pfnBlendFunc may not update all channels.  Initialize with PS 
output.
             /// TODO: move this into the blend JIT.
             blendOut = psContext.shaded[rt];
 
+            blendContext.pBlendState    = pBlendState;
+            blendContext.src            = &psContext.shaded[rt];
+            blendContext.src1           = &psContext.shaded[1];
+            blendContext.src0alpha      = reinterpret_cast<simdvector 
*>(&psContext.shaded[0].w);
+            blendContext.sampleNum      = sample;
+            blendContext.pDst           = &blendSrc;
+            blendContext.result         = &blendOut;
+            blendContext.oMask          = &psContext.oMask;
+            blendContext.pMask          = reinterpret_cast<simdscalari 
*>(&coverageMask);
+
             // Blend outputs and update coverage mask for alpha test
             if(pfnBlendFunc[rt] != nullptr)
             {
-                pfnBlendFunc[rt](
-                    pBlendState,
-                    psContext.shaded[rt],
-                    psContext.shaded[1],
-                    psContext.shaded[0].w,
-                    sample,
-                    reinterpret_cast<uint8_t *>(&blendSrc),
-                    blendOut,
-                    &psContext.oMask,
-                    reinterpret_cast<simdscalari *>(&coverageMask));
+                pfnBlendFunc[rt](&blendContext);
             }
         }
 
diff --git a/src/gallium/drivers/swr/rasterizer/core/state.h 
b/src/gallium/drivers/swr/rasterizer/core/state.h
index 6b108d9..8c26ec6 100644
--- a/src/gallium/drivers/swr/rasterizer/core/state.h
+++ b/src/gallium/drivers/swr/rasterizer/core/state.h
@@ -876,6 +876,19 @@ struct SWR_BLEND_STATE
 };
 static_assert(sizeof(SWR_BLEND_STATE) == 36, "Invalid SWR_BLEND_STATE size");
 
+struct SWR_BLEND_CONTEXT
+{
+    const SWR_BLEND_STATE*  pBlendState;
+    simdvector*             src;
+    simdvector*             src1;
+    simdvector*             src0alpha;
+    uint32_t                sampleNum;
+    simdvector*             pDst;
+    simdvector*             result;
+    simdscalari*            oMask;
+    simdscalari*            pMask;
+};
+
 //////////////////////////////////////////////////////////////////////////
 /// FUNCTION POINTERS FOR SHADERS
 
@@ -892,9 +905,7 @@ 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& vSrc, simdvector& vSrc1, simdscalar& vSrc0Alpha, uint32_t 
sample,
-    uint8_t* pDst, simdvector& vResult, simdscalari* vOMask, simdscalari* 
vCoverageMask);
+typedef void(__cdecl *PFN_BLEND_JIT_FUNC)(SWR_BLEND_CONTEXT*);
 typedef simdscalar(*PFN_QUANTIZE_DEPTH)(simdscalar const &);
 
 
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp 
b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp
index a819765..6b7efbf 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp
@@ -448,7 +448,7 @@ struct BlendJit : public Builder
         Value* pRef = VBROADCAST(LOAD(pBlendState, { 0, 
SWR_BLEND_STATE_alphaTestReference }));
         
         // load alpha
-        Value* pAlpha = LOAD(ppAlpha);
+        Value* pAlpha = LOAD(ppAlpha, { 0, 0 });
 
         Value* pTest = nullptr;
         if (state.alphaTestFormat == ALPHA_TEST_UNORM8)
@@ -517,20 +517,16 @@ struct BlendJit : public Builder
         fnName << ComputeCRC(0, &state, sizeof(state));
 
         // blend function signature
-        //typedef void(*PFN_BLEND_JIT_FUNC)(const SWR_BLEND_STATE*, 
simdvector&, simdvector&, uint32_t, uint8_t*, simdvector&, simdscalari*, 
simdscalari*);
+        //typedef void(*PFN_BLEND_JIT_FUNC)(const SWR_BLEND_CONTEXT*);
 
         std::vector<Type*> args{
-            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
-            PointerType::get(mSimdInt32Ty, 0),              // simdscalari* 
oMask
-            PointerType::get(mSimdInt32Ty, 0),              // simdscalari* 
pMask
+            PointerType::get(Gen_SWR_BLEND_CONTEXT(JM()), 0) // 
SWR_BLEND_CONTEXT*
         };
 
+        //std::vector<Type*> args{
+        //    PointerType::get(Gen_SWR_BLEND_CONTEXT(JM()), 0), // 
SWR_BLEND_CONTEXT*
+        //};
+
         FunctionType* fTy = FunctionType::get(IRB()->getVoidTy(), args, false);
         Function* blendFunc = Function::Create(fTy, 
GlobalValue::ExternalLinkage, fnName.str(), JM()->mpCurrentModule);
         blendFunc->getParent()->setModuleIdentifier(blendFunc->getName());
@@ -541,23 +537,25 @@ struct BlendJit : public Builder
 
         // arguments
         auto argitr = blendFunc->arg_begin();
-        Value* pBlendState = &*argitr++;
+        Value* pBlendContext = &*argitr++;
+        pBlendContext->setName("pBlendContext");
+        Value* pBlendState = LOAD(pBlendContext, { 0, 
SWR_BLEND_CONTEXT_pBlendState });
         pBlendState->setName("pBlendState");
-        Value* pSrc = &*argitr++;
+        Value* pSrc = LOAD(pBlendContext, { 0, SWR_BLEND_CONTEXT_src });
         pSrc->setName("src");
-        Value* pSrc1 = &*argitr++;
+        Value* pSrc1 = LOAD(pBlendContext, { 0, SWR_BLEND_CONTEXT_src1 });
         pSrc1->setName("src1");
-        Value* pSrc0Alpha = &*argitr++;
+        Value* pSrc0Alpha = LOAD(pBlendContext, { 0, 
SWR_BLEND_CONTEXT_src0alpha });
         pSrc0Alpha->setName("src0alpha");
-        Value* sampleNum = &*argitr++;
+        Value* sampleNum = LOAD(pBlendContext, { 0, 
SWR_BLEND_CONTEXT_sampleNum });
         sampleNum->setName("sampleNum");
-        Value* pDst = &*argitr++;
+        Value* pDst = LOAD(pBlendContext, { 0, SWR_BLEND_CONTEXT_pDst });
         pDst->setName("pDst");
-        Value* pResult = &*argitr++;
+        Value* pResult = LOAD(pBlendContext, { 0, SWR_BLEND_CONTEXT_result });
         pResult->setName("result");
-        Value* ppoMask = &*argitr++;
+        Value* ppoMask = LOAD(pBlendContext, { 0, SWR_BLEND_CONTEXT_oMask });
         ppoMask->setName("ppoMask");
-        Value* ppMask = &*argitr++;
+        Value* ppMask = LOAD(pBlendContext, { 0, SWR_BLEND_CONTEXT_pMask });
         ppMask->setName("pMask");
 
         static_assert(KNOB_COLOR_HOT_TILE_FORMAT == R32G32B32A32_FLOAT, 
"Unsupported hot tile format");
@@ -569,16 +567,16 @@ struct BlendJit : public Builder
         for (uint32_t i = 0; i < 4; ++i)
         {
             // load hot tile
-            dst[i] = LOAD(pDst, { i });
+            dst[i] = LOAD(pDst, { 0, i });
 
             // load constant color
             constantColor[i] = VBROADCAST(LOAD(pBlendState, { 0, 
SWR_BLEND_STATE_constantColor, i }));
-
+        
             // load src
-            src[i] = LOAD(pSrc, { i });
+            src[i] = LOAD(pSrc, { 0, i });
 
             // load src1
-            src1[i] = LOAD(pSrc1, { i });
+            src1[i] = LOAD(pSrc1, { 0, i });
         }
         Value* currentSampleMask = VIMMED1(-1);
         if (state.desc.alphaToCoverageEnable)
@@ -646,7 +644,7 @@ struct BlendJit : public Builder
             // store results out
             for (uint32_t i = 0; i < 4; ++i)
             {
-                STORE(result[i], pResult, { i });
+                STORE(result[i], pResult, { 0, i });
             }
         }
         
@@ -756,7 +754,7 @@ struct BlendJit : public Builder
                     break;
                 }
 
-                STORE(result[i], pResult, {i});
+                STORE(result[i], pResult, {0, i});
             }
         }
 
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to