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);
}
}
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);
}
}
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)
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());
// 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");
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)
// store results out
for (uint32_t i = 0; i < 4; ++i)
{
- STORE(result[i], pResult, { i });
+ STORE(result[i], pResult, { 0, i });
}
}
break;
}
- STORE(result[i], pResult, {i});
+ STORE(result[i], pResult, {0, i});
}
}