GSdx: Extend support of "Preload Frame Data" for Direct3D.

Fixes glitchy water in Rogue Galaxy in Direct3D when the hack is
enabled.
Fixes Test Drive car reflection in Direct3D when the hack is enabled.

OTher games are affected as well.
This commit is contained in:
lightningterror 2017-11-07 02:23:27 +01:00 committed by Gregory Hainaut
parent 025eef63b5
commit 3c74f0f907
1 changed files with 17 additions and 18 deletions

View File

@ -517,27 +517,26 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
// //
// From a performance point of view, it might cost a little on big upscaling // From a performance point of view, it might cost a little on big upscaling
// but normally few RT are miss so it must remain reasonable. // but normally few RT are miss so it must remain reasonable.
if (s_IS_OPENGL) { bool supported_fmt = m_can_convert_depth || psm_s.depth == 0;
if (m_preload_frame && TEX0.TBW > 0) { if (m_preload_frame && TEX0.TBW > 0 && supported_fmt) {
GL_INS("Preloading the RT DATA"); GL_INS("Preloading the RT DATA");
// RT doesn't have height but if we use a too big value, we will read outside of the GS memory. // RT doesn't have height but if we use a too big value, we will read outside of the GS memory.
int page0 = TEX0.TBP0 >> 5; int page0 = TEX0.TBP0 >> 5;
int max_page = (MAX_PAGES - page0); int max_page = (MAX_PAGES - page0);
int max_h = 32 * max_page / TEX0.TBW; int max_h = 32 * max_page / TEX0.TBW;
// h is likely smaller than w (true most of the time). Reduce the upload size (speed) // h is likely smaller than w (true most of the time). Reduce the upload size (speed)
max_h = std::min<int>(max_h, TEX0.TBW * 64); max_h = std::min<int>(max_h, TEX0.TBW * 64);
dst->m_dirty.push_back(GSDirtyRect(GSVector4i(0, 0, TEX0.TBW * 64, max_h), TEX0.PSM)); dst->m_dirty.push_back(GSDirtyRect(GSVector4i(0, 0, TEX0.TBW * 64, max_h), TEX0.PSM));
dst->Update(); dst->Update();
} else { } else {
#ifdef ENABLE_OGL_DEBUG #ifdef ENABLE_OGL_DEBUG
switch (type) { switch (type) {
case RenderTarget: m_renderer->m_dev->ClearRenderTarget(dst->m_texture, 0); break; case RenderTarget: m_renderer->m_dev->ClearRenderTarget(dst->m_texture, 0); break;
case DepthStencil: m_renderer->m_dev->ClearDepth(dst->m_texture); break; case DepthStencil: m_renderer->m_dev->ClearDepth(dst->m_texture); break;
default:break; default: break;
}
#endif
} }
#endif
} }
} }
ScaleTexture(dst->m_texture); ScaleTexture(dst->m_texture);