From 3b98229c6f855d8303b4803c938646ca4cd1064b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 13 Nov 2015 23:10:30 -0800 Subject: [PATCH 1/3] Correct texture preview in D3D9, oops. --- GPU/Directx9/GPU_DX9.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index bb848eba08..ae3d858c3f 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -2094,6 +2094,7 @@ bool DIRECTX9_GPU::GetCurrentTexture(GPUDebugBuffer &buffer, int level) { } textureCache_.SetTexture(true); + textureCache_.ApplyTexture(); int w = gstate.getTextureWidth(level); int h = gstate.getTextureHeight(level); From 13a09647e298916decbedba8bdef21d23866bbc1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 13 Nov 2015 23:11:06 -0800 Subject: [PATCH 2/3] d3d9: Disable shader blending, not implemented. Fixes bad graphics in Ridge Racer, etc. --- GPU/Common/GPUStateUtils.cpp | 5 ++--- GPU/Common/GPUStateUtils.h | 2 +- GPU/Directx9/StateMappingDX9.cpp | 9 +++++++-- GPU/GLES/StateMapping.cpp | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index d5fedcd25b..1e815801fd 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -768,7 +768,7 @@ void ApplyStencilReplaceAndLogicOp(ReplaceAlphaType replaceAlphaWithStencil, Gen // Called even if AlphaBlendEnable == false - it also deals with stencil-related blend state. -void ConvertBlendState(GenericBlendState &blendState) { +void ConvertBlendState(GenericBlendState &blendState, bool allowShaderBlend) { // Blending is a bit complex to emulate. This is due to several reasons: // // * Doubled blend modes (src, dst, inversed) aren't supported in OpenGL. @@ -778,13 +778,12 @@ void ConvertBlendState(GenericBlendState &blendState) { // * The written output alpha should actually be the stencil value. Alpha is not written. // // If we can't apply blending, we make a copy of the framebuffer and do it manually. - gstate_c.allowShaderBlend = !g_Config.bDisableSlowFramebufEffects; blendState.applyShaderBlending = false; blendState.dirtyShaderBlend = false; blendState.useBlendColor = false; - ReplaceBlendType replaceBlend = ReplaceBlendWithShader(gstate_c.allowShaderBlend, gstate.FrameBufFormat()); + ReplaceBlendType replaceBlend = ReplaceBlendWithShader(allowShaderBlend, gstate.FrameBufFormat()); ReplaceAlphaType replaceAlphaWithStencil = ReplaceAlphaWithStencil(replaceBlend); bool usePreSrc = false; diff --git a/GPU/Common/GPUStateUtils.h b/GPU/Common/GPUStateUtils.h index 58eda73d96..f7a2c53685 100644 --- a/GPU/Common/GPUStateUtils.h +++ b/GPU/Common/GPUStateUtils.h @@ -135,5 +135,5 @@ struct GenericBlendState { } }; -void ConvertBlendState(GenericBlendState &blendState); +void ConvertBlendState(GenericBlendState &blendState, bool allowShaderBlend); void ApplyStencilReplaceAndLogicOp(ReplaceAlphaType replaceAlphaWithStencil, GenericBlendState &blendState); diff --git a/GPU/Directx9/StateMappingDX9.cpp b/GPU/Directx9/StateMappingDX9.cpp index f3f7762413..ca3f90144a 100644 --- a/GPU/Directx9/StateMappingDX9.cpp +++ b/GPU/Directx9/StateMappingDX9.cpp @@ -86,7 +86,9 @@ static const D3DSTENCILOP stencilOps[] = { }; bool TransformDrawEngineDX9::ApplyShaderBlending() { - bool skipBlit = false; + if (gstate_c.featureFlags & GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH) { + return true; + } static const int MAX_REASONABLE_BLITS_PER_FRAME = 24; @@ -137,9 +139,12 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) { bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; + // Unfortunately, this isn't implemented yet. + gstate_c.allowShaderBlend = false; + // Set blend - unless we need to do it in the shader. GenericBlendState blendState; - ConvertBlendState(blendState); + ConvertBlendState(blendState, gstate_c.allowShaderBlend); ViewportAndScissor vpAndScissor; ConvertViewportAndScissor(useBufferedRendering, framebufferManager_->GetRenderWidth(), framebufferManager_->GetRenderHeight(), diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 5cd8e45e58..3a3a9fa6a3 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -167,10 +167,12 @@ void TransformDrawEngine::ApplyDrawState(int prim) { bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; + gstate_c.allowShaderBlend = !g_Config.bDisableSlowFramebufEffects; + // Do the large chunks of state conversion. We might be able to hide these two behind a dirty-flag each, // to avoid recomputing heavy stuff unnecessarily every draw call. GenericBlendState blendState; - ConvertBlendState(blendState); + ConvertBlendState(blendState, gstate_c.allowShaderBlend); ViewportAndScissor vpAndScissor; ConvertViewportAndScissor(useBufferedRendering, framebufferManager_->GetRenderWidth(), framebufferManager_->GetRenderHeight(), From 294f09a61f617d522107660443c52771f80a2836 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 13 Nov 2015 23:13:52 -0800 Subject: [PATCH 3/3] Call ResetShaderBlending() from ApplyDrawState(). Cleaner this way. --- GPU/Directx9/StateMappingDX9.cpp | 2 +- GPU/GLES/StateMapping.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GPU/Directx9/StateMappingDX9.cpp b/GPU/Directx9/StateMappingDX9.cpp index ca3f90144a..4b095abf17 100644 --- a/GPU/Directx9/StateMappingDX9.cpp +++ b/GPU/Directx9/StateMappingDX9.cpp @@ -104,7 +104,6 @@ bool TransformDrawEngineDX9::ApplyShaderBlending() { ++blitsThisFrame; if (blitsThisFrame > MAX_REASONABLE_BLITS_PER_FRAME * 2) { WARN_LOG_ONCE(blendingBlit2, G3D, "Skipping additional blits needed for obscure blending: %d per frame, blend %d/%d/%d", blitsThisFrame, gstate.getBlendFuncA(), gstate.getBlendFuncB(), gstate.getBlendEq()); - ResetShaderBlending(); return false; } @@ -157,6 +156,7 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) { ApplyStencilReplaceAndLogicOp(blendState.replaceAlphaWithStencil, blendState); } else { // Until next time, force it off. + ResetShaderBlending(); gstate_c.allowShaderBlend = false; } } else if (blendState.resetShaderBlending) { diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 3a3a9fa6a3..b737121bff 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -130,7 +130,6 @@ bool TransformDrawEngine::ApplyShaderBlending() { ++blitsThisFrame; if (blitsThisFrame > MAX_REASONABLE_BLITS_PER_FRAME * 2) { WARN_LOG_ONCE(blendingBlit2, G3D, "Skipping additional blits needed for obscure blending: %d per frame, blend %d/%d/%d", blitsThisFrame, gstate.getBlendFuncA(), gstate.getBlendFuncB(), gstate.getBlendEq()); - ResetShaderBlending(); return false; } @@ -185,6 +184,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { ApplyStencilReplaceAndLogicOp(blendState.replaceAlphaWithStencil, blendState); } else { // Until next time, force it off. + ResetShaderBlending(); gstate_c.allowShaderBlend = false; } } else if (blendState.resetShaderBlending) {