From 8c8b1f497c256a6634e2bd172cf28c28edbab1f9 Mon Sep 17 00:00:00 2001 From: Kojin Date: Sun, 20 Jan 2019 01:19:59 -0500 Subject: [PATCH] gsdx-d3d11: ICO depth HLE Game reads framebuffer depth as alpha of texture. However, this is a problem for d3d11 as a shader read on the fb is not allowed. So let's handle it in a similar fasion to channel shuffle: - Set depth to slot 4 - Detect when slot 4 matches depth rt - Copy and send the copy to the shader --- .../GSdx/Renderers/DXCommon/GSRendererDX.cpp | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp b/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp index a2cf3a2e26..18f4081aba 100644 --- a/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp +++ b/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp @@ -948,9 +948,25 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc { // Note potentially we can limit to TBP0:0x2800 - // DX doesn't support depth or channel shuffle yet so we can just do a partial port that skips the bad drawcalls, - // this way we can purge any remaining crc hacks. - throw GSDXRecoverableError(); + // Depth buffer was moved so GSdx will invalide it which means a + // downscale. ICO uses the MSB depth bits as the texture alpha + // channel. However this depth of field effect requires + // texel:pixel mapping accuracy. + // + // Use an HLE shader to sample depth directly as the alpha channel + + // OutputDebugString("ICO HLE"); + + m_ps_sel.depth_fmt = 1; + m_ps_sel.channel = ChannelFetch_BLUE; + + dev->PSSetShaderResource(4, ds); + + if (!tex->m_palette) + { + uint16 pal = GSLocalMemory::m_psm[tex->m_TEX0.PSM].pal; + m_tc->AttachPaletteToSource(tex, pal, true); + } } }