fixed blending in dx9 and dx11
fixed fps counter in all the plugins enjoy git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5778 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
10b5d2371c
commit
3435c0f647
|
@ -766,60 +766,40 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
|
||||||
u32 rgbaColor = (color & 0xFF00FF00) | ((color >> 16) & 0xFF) | ((color << 16) & 0xFF0000);
|
u32 rgbaColor = (color & 0xFF00FF00) | ((color >> 16) & 0xFF) | ((color << 16) & 0xFF0000);
|
||||||
D3D::stateman->PushDepthState(cleardepthstates[zEnable]);
|
D3D::stateman->PushDepthState(cleardepthstates[zEnable]);
|
||||||
D3D::stateman->PushRasterizerState(clearraststate);
|
D3D::stateman->PushRasterizerState(clearraststate);
|
||||||
D3D::stateman->PushBlendState(resetblendstate);
|
//D3D::stateman->PushBlendState(resetblendstate); temporarily comented till i found the cause of th blending error in mkwii
|
||||||
|
D3D::stateman->Apply();
|
||||||
D3D::drawClearQuad(rgbaColor, (z & 0xFFFFFF) / float(0xFFFFFF), PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader(), VertexShaderCache::GetClearInputLayout());
|
D3D::drawClearQuad(rgbaColor, (z & 0xFFFFFF) / float(0xFFFFFF), PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader(), VertexShaderCache::GetClearInputLayout());
|
||||||
|
|
||||||
D3D::stateman->PopDepthState();
|
D3D::stateman->PopDepthState();
|
||||||
D3D::stateman->PopRasterizerState();
|
D3D::stateman->PopRasterizerState();
|
||||||
D3D::stateman->PopBlendState();
|
//D3D::stateman->PopBlendState();
|
||||||
UpdateViewport();
|
UpdateViewport();
|
||||||
SetScissorRect();
|
SetScissorRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetBlendMode(bool forceUpdate)
|
void Renderer::SetBlendMode(bool forceUpdate)
|
||||||
{
|
{
|
||||||
#define BLEND_ENABLE_MASK 1
|
if (bpmem.blendmode.logicopenable)
|
||||||
#define BLENDOP_SHIFT 2
|
|
||||||
#define BLENDOP_MASK 4
|
|
||||||
#define SRCFACTOR_SHIFT 3
|
|
||||||
#define DESTFACTOR_SHIFT 6
|
|
||||||
#define FACTOR_MASK 7
|
|
||||||
|
|
||||||
|
|
||||||
// blend mode bit mask
|
|
||||||
// 0 - blend enable
|
|
||||||
// 2 - reverse subtract enable (else add)
|
|
||||||
// 3-5 - srcRGB function
|
|
||||||
// 6-8 - dstRGB function
|
|
||||||
if (bpmem.blendmode.logicopenable && bpmem.blendmode.logicmode != 3)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u32 newval = bpmem.blendmode.subtract << BLENDOP_SHIFT;
|
|
||||||
if (bpmem.blendmode.subtract) // enable blending src 1 dst 1
|
if (bpmem.blendmode.subtract) // enable blending src 1 dst 1
|
||||||
{
|
{
|
||||||
newval |= BLEND_ENABLE_MASK | (1 << SRCFACTOR_SHIFT) | (1 << DESTFACTOR_SHIFT);
|
D3D::gfxstate->SetAlphaBlendEnable(true);
|
||||||
|
D3D::gfxstate->SetBlendOp(D3D11_BLEND_OP_REV_SUBTRACT);
|
||||||
|
D3D::gfxstate->SetSrcBlend(d3dSrcFactors[1]);
|
||||||
|
D3D::gfxstate->SetDestBlend(d3dDestFactors[1]);
|
||||||
}
|
}
|
||||||
else if (bpmem.blendmode.blendenable)
|
else
|
||||||
{
|
{
|
||||||
newval |= BLEND_ENABLE_MASK; // enable blending
|
D3D::gfxstate->SetAlphaBlendEnable(bpmem.blendmode.blendenable && (!( bpmem.blendmode.srcfactor == 1 && bpmem.blendmode.dstfactor == 0)));
|
||||||
newval |= bpmem.blendmode.srcfactor << SRCFACTOR_SHIFT;
|
if (bpmem.blendmode.blendenable && (!( bpmem.blendmode.srcfactor == 1 && bpmem.blendmode.dstfactor == 0)))
|
||||||
newval |= bpmem.blendmode.dstfactor << DESTFACTOR_SHIFT;
|
{
|
||||||
|
D3D::gfxstate->SetBlendOp(D3D11_BLEND_OP_ADD);
|
||||||
|
D3D::gfxstate->SetSrcBlend(d3dSrcFactors[bpmem.blendmode.srcfactor]);
|
||||||
|
D3D::gfxstate->SetDestBlend(d3dDestFactors[bpmem.blendmode.dstfactor]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode;
|
|
||||||
|
|
||||||
if (changes & BLEND_ENABLE_MASK) // blend enable change
|
|
||||||
D3D::gfxstate->SetAlphaBlendEnable(newval & BLEND_ENABLE_MASK);
|
|
||||||
|
|
||||||
if (changes & BLENDOP_MASK) // subtract enable change
|
|
||||||
D3D::gfxstate->SetBlendOp((newval & BLENDOP_MASK) ? D3D11_BLEND_OP_REV_SUBTRACT : D3D11_BLEND_OP_ADD);
|
|
||||||
|
|
||||||
if (changes & 0x1F8) // blend RGB change
|
|
||||||
{
|
|
||||||
D3D::gfxstate->SetSrcBlend(d3dSrcFactors[(newval >> SRCFACTOR_SHIFT) & FACTOR_MASK]);
|
|
||||||
D3D::gfxstate->SetDestBlend(d3dDestFactors[(newval >> DESTFACTOR_SHIFT) & FACTOR_MASK]);
|
|
||||||
}
|
|
||||||
s_blendMode = newval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||||
|
@ -1011,7 +991,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||||
D3D::context->OMSetRenderTargets(1, &FBManager.GetEFBColorTexture()->GetRTV(), FBManager.GetEFBDepthTexture()->GetDSV());
|
D3D::context->OMSetRenderTargets(1, &FBManager.GetEFBColorTexture()->GetRTV(), FBManager.GetEFBDepthTexture()->GetDSV());
|
||||||
UpdateViewport();
|
UpdateViewport();
|
||||||
VertexShaderManager::SetViewportChanged();
|
VertexShaderManager::SetViewportChanged();
|
||||||
g_VideoInitialize.pCopiedToXFB(XFBWrited);
|
g_VideoInitialize.pCopiedToXFB(XFBWrited || g_ActiveConfig.bUseRealXFB);
|
||||||
XFBWrited = false;
|
XFBWrited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -907,9 +907,7 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
|
||||||
vp.Height = targetRc.GetHeight();
|
vp.Height = targetRc.GetHeight();
|
||||||
vp.MinZ = 0.0;
|
vp.MinZ = 0.0;
|
||||||
vp.MaxZ = 1.0;
|
vp.MaxZ = 1.0;
|
||||||
D3D::dev->SetViewport(&vp);
|
D3D::dev->SetViewport(&vp);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Always set the scissor in case it was set by the game and has not been reset
|
// Always set the scissor in case it was set by the game and has not been reset
|
||||||
RECT sirc;
|
RECT sirc;
|
||||||
|
@ -931,50 +929,26 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
|
||||||
|
|
||||||
void Renderer::SetBlendMode(bool forceUpdate)
|
void Renderer::SetBlendMode(bool forceUpdate)
|
||||||
{
|
{
|
||||||
// blend mode bit mask
|
if (bpmem.blendmode.logicopenable)
|
||||||
// 0 - blend enable
|
|
||||||
// 2 - reverse subtract enable (else add)
|
|
||||||
// 3-5 - srcRGB function
|
|
||||||
// 6-8 - dstRGB function
|
|
||||||
#define BLEND_ENABLE_MASK 1
|
|
||||||
#define BLENDOP_SHIFT 2
|
|
||||||
#define BLENDOP_MASK 4
|
|
||||||
#define SRCFACTOR_SHIFT 3
|
|
||||||
#define DESTFACTOR_SHIFT 6
|
|
||||||
#define FACTOR_MASK 7
|
|
||||||
|
|
||||||
if (bpmem.blendmode.logicopenable && bpmem.blendmode.logicmode != 3)
|
|
||||||
return;
|
return;
|
||||||
u32 newval = bpmem.blendmode.subtract << BLENDOP_SHIFT;
|
|
||||||
|
|
||||||
if (bpmem.blendmode.subtract) {
|
|
||||||
newval |= BLEND_ENABLE_MASK | (1 << SRCFACTOR_SHIFT) | (1 << DESTFACTOR_SHIFT);
|
|
||||||
} else if (bpmem.blendmode.blendenable) {
|
|
||||||
newval |= BLEND_ENABLE_MASK; // enable blending
|
|
||||||
newval |= bpmem.blendmode.srcfactor << SRCFACTOR_SHIFT;
|
|
||||||
newval |= bpmem.blendmode.dstfactor << DESTFACTOR_SHIFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode;
|
if (bpmem.blendmode.subtract && bpmem.blendmode.blendenable)
|
||||||
|
{
|
||||||
if (changes & BLEND_ENABLE_MASK) {
|
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, true);
|
||||||
// blend enable change
|
D3D::SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_REVSUBTRACT);
|
||||||
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, (newval & BLEND_ENABLE_MASK));
|
D3D::SetRenderState(D3DRS_SRCBLEND, d3dSrcFactors[1]);
|
||||||
|
D3D::SetRenderState(D3DRS_DESTBLEND, d3dDestFactors[1]);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (changes & BLENDOP_MASK) {
|
{
|
||||||
// subtract enable change
|
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, bpmem.blendmode.blendenable && (!( bpmem.blendmode.srcfactor == 1 && bpmem.blendmode.dstfactor == 0)));
|
||||||
D3D::SetRenderState(D3DRS_BLENDOP, newval & BLENDOP_MASK ? D3DBLENDOP_REVSUBTRACT : D3DBLENDOP_ADD);
|
if (bpmem.blendmode.blendenable && (!( bpmem.blendmode.srcfactor == 1 && bpmem.blendmode.dstfactor == 0)))
|
||||||
}
|
{
|
||||||
|
D3D::SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
|
||||||
if (changes & 0x1F8) {
|
D3D::SetRenderState(D3DRS_SRCBLEND, d3dSrcFactors[bpmem.blendmode.srcfactor]);
|
||||||
// blend RGB change
|
D3D::SetRenderState(D3DRS_DESTBLEND, d3dDestFactors[bpmem.blendmode.dstfactor]);
|
||||||
D3D::SetRenderState(D3DRS_SRCBLEND, d3dSrcFactors[(newval >> SRCFACTOR_SHIFT) & FACTOR_MASK]);
|
}
|
||||||
D3D::SetRenderState(D3DRS_DESTBLEND, d3dDestFactors[(newval >> DESTFACTOR_SHIFT) & FACTOR_MASK]);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
s_blendMode = newval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1292,7 +1266,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||||
UpdateViewport();
|
UpdateViewport();
|
||||||
VertexShaderManager::SetViewportChanged();
|
VertexShaderManager::SetViewportChanged();
|
||||||
g_VideoInitialize.pCopiedToXFB(XFBWrited);
|
g_VideoInitialize.pCopiedToXFB(XFBWrited || g_ActiveConfig.bUseRealXFB);
|
||||||
XFBWrited = false;
|
XFBWrited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1343,8 +1317,7 @@ void Renderer::SetLogicOpMode()
|
||||||
{
|
{
|
||||||
if (bpmem.blendmode.logicopenable && bpmem.blendmode.logicmode != 3)
|
if (bpmem.blendmode.logicopenable && bpmem.blendmode.logicmode != 3)
|
||||||
{
|
{
|
||||||
s_blendMode = 0;
|
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, true);
|
||||||
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
|
|
||||||
D3D::SetRenderState(D3DRS_BLENDOP, d3dLogicOpop[bpmem.blendmode.logicmode]);
|
D3D::SetRenderState(D3DRS_BLENDOP, d3dLogicOpop[bpmem.blendmode.logicmode]);
|
||||||
D3D::SetRenderState(D3DRS_SRCBLEND, d3dLogicOpSrcFactors[bpmem.blendmode.logicmode]);
|
D3D::SetRenderState(D3DRS_SRCBLEND, d3dLogicOpSrcFactors[bpmem.blendmode.logicmode]);
|
||||||
D3D::SetRenderState(D3DRS_DESTBLEND, d3dLogicOpDestFactors[bpmem.blendmode.logicmode]);
|
D3D::SetRenderState(D3DRS_DESTBLEND, d3dLogicOpDestFactors[bpmem.blendmode.logicmode]);
|
||||||
|
|
|
@ -1243,8 +1243,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||||
// For testing zbuffer targets.
|
// For testing zbuffer targets.
|
||||||
// Renderer::SetZBufferRender();
|
// Renderer::SetZBufferRender();
|
||||||
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight());
|
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight());
|
||||||
|
g_VideoInitialize.pCopiedToXFB(XFBWrited || g_ActiveConfig.bUseRealXFB);
|
||||||
XFBWrited = false;
|
XFBWrited = false;
|
||||||
g_VideoInitialize.pCopiedToXFB(XFBWrited);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create On-Screen-Messages
|
// Create On-Screen-Messages
|
||||||
|
|
Loading…
Reference in New Issue