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.
This commit is contained in:
lightningterror 2019-03-16 18:41:04 +01:00 committed by Gregory Hainaut
parent a58f56fa4a
commit 52da124a2b
2 changed files with 10 additions and 7 deletions

View File

@ -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)

View File

@ -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