Fix PeekZ when not using native resolution

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3643 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
sl1nk3.s
2009-07-02 01:49:28 +00:00
parent b69d218a82
commit ae2a5b8587
3 changed files with 14 additions and 6 deletions

View File

@ -467,23 +467,26 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y)
if (!g_VideoInitialize.bUseDualCore)
{
u32 z = 0;
float xScale = Renderer::GetTargetScaleX();
float yScale = Renderer::GetTargetScaleY();
if (g_Config.iMultisampleMode != MULTISAMPLE_OFF)
{
// Find the proper dimensions
TRectangle source, scaledTargetSource;
ComputeBackbufferRectangle(&source);
source.Scale(Renderer::GetTargetScaleX(), Renderer::GetTargetScaleY(), &scaledTargetSource);
source.Scale(xScale, yScale, &scaledTargetSource);
// This will resolve and bind to the depth buffer
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Renderer::ResolveAndGetDepthTarget(scaledTargetSource));
}
// Read the z value!
glReadPixels(x, Renderer::GetTargetHeight()-y, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, &z);
// Read the z value! Also adjust the pixel to read to the upscaled EFB resolution
// Plus we need to flip the y value as the OGL image is upside down
glReadPixels(x*xScale, Renderer::GetTargetHeight() - y*yScale, xScale, yScale, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, &z);
GL_REPORT_ERRORD();
// Mask away the stencil bits
return z & 0xffffff;
// Clamp the 32bits value returned by glReadPixels to a 24bits value (GC uses a 24bits Z-Buffer)
return z / 0x100;
}
}
break;