Clean up blending code a bit.
This commit is contained in:
parent
8a33d49de2
commit
c10d9ea87a
|
@ -621,6 +621,17 @@ union X10Y10
|
||||||
|
|
||||||
// Framebuffer/pixel stuff (incl fog)
|
// Framebuffer/pixel stuff (incl fog)
|
||||||
|
|
||||||
|
#define GX_BL_ZERO 0
|
||||||
|
#define GX_BL_ONE 1
|
||||||
|
#define GX_BL_SRCCLR 2 // for dst factor
|
||||||
|
#define GX_BL_INVSRCCLR 3 // for dst factor
|
||||||
|
#define GX_BL_SRCALPHA 4
|
||||||
|
#define GX_BL_INVSRCALPHA 5
|
||||||
|
#define GX_BL_DSTALPHA 6
|
||||||
|
#define GX_BL_INVDSTALPHA 7
|
||||||
|
#define GX_BL_DSTCLR GX_BL_SRCCLR // for src factor
|
||||||
|
#define GX_BL_INVDSTCLR GX_BL_INVSRCCLR // for src factor
|
||||||
|
|
||||||
union BlendMode
|
union BlendMode
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
|
|
|
@ -715,12 +715,12 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||||
if (bpmem.blendmode.logicopenable && !forceUpdate)
|
if (bpmem.blendmode.logicopenable && !forceUpdate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (bpmem.blendmode.subtract) // enable blending src 1 dst 1
|
if (bpmem.blendmode.subtract)
|
||||||
{
|
{
|
||||||
gx_state.blenddc.RenderTarget[0].BlendEnable = true;
|
gx_state.blenddc.RenderTarget[0].BlendEnable = true;
|
||||||
SetBlendOp(D3D11_BLEND_OP_REV_SUBTRACT);
|
SetBlendOp(D3D11_BLEND_OP_REV_SUBTRACT);
|
||||||
SetSrcBlend(d3dSrcFactors[1]);
|
SetSrcBlend(D3D11_BLEND_ONE);
|
||||||
SetDestBlend(d3dDestFactors[1]);
|
SetDestBlend(D3D11_BLEND_ONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -691,8 +691,8 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||||
{
|
{
|
||||||
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, true);
|
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, true);
|
||||||
D3D::SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_REVSUBTRACT);
|
D3D::SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_REVSUBTRACT);
|
||||||
D3D::SetRenderState(D3DRS_SRCBLEND, d3dSrcFactors[1]);
|
D3D::SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
|
||||||
D3D::SetRenderState(D3DRS_DESTBLEND, d3dDestFactors[1]);
|
D3D::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1008,23 +1008,22 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||||
u32 dstidx = (newval >> 6) & 7;
|
u32 dstidx = (newval >> 6) & 7;
|
||||||
GLenum srcFactor = glSrcFactors[srcidx];
|
GLenum srcFactor = glSrcFactors[srcidx];
|
||||||
GLenum dstFactor = glDestFactors[dstidx];
|
GLenum dstFactor = glDestFactors[dstidx];
|
||||||
|
|
||||||
|
// adjust alpha factors
|
||||||
if (useDualSource)
|
if (useDualSource)
|
||||||
{
|
{
|
||||||
srcidx = 1;
|
srcidx = GX_BL_ONE;
|
||||||
dstidx = 0;
|
dstidx = GX_BL_ZERO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we can't use GL_DST_COLOR or GL_ONE_MINUS_DST_COLOR for source in alpha channel so use their alpha equivalent instead
|
// we can't use GL_DST_COLOR or GL_ONE_MINUS_DST_COLOR for source in alpha channel so use their alpha equivalent instead
|
||||||
if (srcidx == 2 || srcidx == 3)
|
if (srcidx == GX_BL_DSTCLR) srcidx = GX_BL_DSTALPHA;
|
||||||
{
|
if (srcidx == GX_BL_INVDSTCLR) srcidx = GX_BL_INVDSTALPHA;
|
||||||
srcidx += 4;
|
|
||||||
}
|
|
||||||
// we can't use GL_SRC_COLOR or GL_ONE_MINUS_SRC_COLOR for destination in alpha channel so use their alpha equivalent instead
|
// we can't use GL_SRC_COLOR or GL_ONE_MINUS_SRC_COLOR for destination in alpha channel so use their alpha equivalent instead
|
||||||
if (dstidx == 2 || dstidx == 3)
|
if (dstidx == GX_BL_SRCCLR) dstidx = GX_BL_SRCALPHA;
|
||||||
{
|
if (dstidx == GX_BL_INVSRCCLR) dstidx = GX_BL_INVSRCALPHA;
|
||||||
dstidx += 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
GLenum srcFactorAlpha = glSrcFactors[srcidx];
|
GLenum srcFactorAlpha = glSrcFactors[srcidx];
|
||||||
GLenum dstFactorAlpha = glDestFactors[dstidx];
|
GLenum dstFactorAlpha = glDestFactors[dstidx];
|
||||||
|
|
Loading…
Reference in New Issue