Skip to content
Permalink
Browse files

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.
  • Loading branch information...
lightningterror authored and gregory38 committed Mar 16, 2019
1 parent a58f56f commit 52da124a2bee2e2e77be116c643d96341a1ce32c
Showing with 10 additions and 7 deletions.
  1. +0 −1 plugins/GSdx/Renderers/DX11/GSRendererDX11.cpp
  2. +10 −6 plugins/GSdx/Renderers/OpenGL/GSRendererOGL.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)
@@ -1021,23 +1021,27 @@ 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!");
}
}

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

0 comments on commit 52da124

Please sign in to comment.
You can’t perform that action at this time.