From 52da124a2bee2e2e77be116c643d96341a1ce32c Mon Sep 17 00:00:00 2001 From: lightningterror Date: Sat, 16 Mar 2019 18:41:04 +0100 Subject: [PATCH] gsdx-ogl: Check if primitives are triangles instead of overlapping. Single triangle draw can now hit the tex_is_fb path. Primitive Overlap will return no overlap for single primitive (triangle). Ratchet and Clank, Jak, tri-Ace games. It should improve shadow rendering. Idea by Gregory. --- plugins/GSdx/Renderers/DX11/GSRendererDX11.cpp | 1 - plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp | 16 ++++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/GSdx/Renderers/DX11/GSRendererDX11.cpp b/plugins/GSdx/Renderers/DX11/GSRendererDX11.cpp index 8da0bde483..4694c0afe3 100644 --- a/plugins/GSdx/Renderers/DX11/GSRendererDX11.cpp +++ b/plugins/GSdx/Renderers/DX11/GSRendererDX11.cpp @@ -662,7 +662,6 @@ void GSRendererDX11::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sou EmulateTextureShuffleAndFbmask(); // DATE: selection of the algorithm. - if (DATE) { if (m_texture_shuffle) diff --git a/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp b/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp index 9d4606c911..e745fac747 100644 --- a/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp +++ b/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp @@ -1021,15 +1021,20 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour // Upscaling hack to avoid various line/grid issues MergeSprite(tex); - // Always check if primitive overlap. The function will return PRIM_OVERLAP_UNKNOW for non sprite primitive + // Always check if primitive overlap as it is used in plenty of effects. m_prim_overlap = PrimitiveOverlap(); - if ((m_context->FRAME.Block() == m_context->TEX0.TBP0) && PRIM->TME && m_sw_blending && (m_prim_overlap != PRIM_OVERLAP_NO) && (m_vertex.next > 2)) { - if (m_context->FRAME.FBMSK == 0x00FFFFFF) { - // Ratchet & Clank / Jak uses this pattern to compute the shadows. Alpha (multiplication) tfx is mostly equivalent to -1/+1 stencil operation + + // Detect framebuffer read that will need special handling + if ((m_context->FRAME.Block() == m_context->TEX0.TBP0) && PRIM->TME && m_sw_blending) { + if ((m_context->FRAME.FBMSK == 0x00FFFFFF) && (m_vt.m_primclass == GS_TRIANGLE_CLASS)) { + // Ratchet & Clank, Jak, Tri-Ace (Star Ocean 3) games use this pattern to compute the shadows. + // Alpha (multiplication) tfx is mostly equivalent to -1/+1 stencil operation. GL_DBG("ERROR: Source and Target are the same! Let's sample the framebuffer"); m_ps_sel.tex_is_fb = 1; m_require_full_barrier = true; - } else { + } else if (m_prim_overlap != PRIM_OVERLAP_NO) { + // Note: It is fine if the texture fits in a single GS page. First access will cache + // the page in the GS texture buffer. GL_INS("ERROR: Source and Target are the same!"); } } @@ -1037,7 +1042,6 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour EmulateTextureShuffleAndFbmask(); // DATE: selection of the algorithm. Must be done before blending because GL42 is not compatible with blending - if (DATE) { if (m_prim_overlap == PRIM_OVERLAP_NO || m_texture_shuffle) { // It is way too complex to emulate texture shuffle with DATE. So just use