Don't use undefined OpenGL behavior, even if it does somehow work. Also, enable PEEK_COLOR logic. Not sure if any games use it.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3814 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Nolan Check 2009-07-16 09:06:16 +00:00
parent ca750d1368
commit a48e148104
2 changed files with 22 additions and 25 deletions

View File

@ -106,6 +106,9 @@ public:
GLuint GetEFBFramebuffer() const { return m_efbFramebuffer; } GLuint GetEFBFramebuffer() const { return m_efbFramebuffer; }
// Resolved framebuffer is only used in MSAA mode.
GLuint GetResolvedFramebuffer() const { return m_resolvedFramebuffer; }
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) const; TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) const;
private: private:

View File

@ -556,10 +556,9 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
{ {
if (s_MSAASamples > 1) if (s_MSAASamples > 1)
{ {
// XXX: What is this? Binding a texture to a framebuffer slot? // Resolve our rectangle.
// It's not documented in the OpenGL spec, but it seems to work! s_framebufferManager.GetEFBDepthTexture(efbPixelRc);
// (ATI Radeon HD 3870, CATALYST 9.6 drivers, Windows Vista 64-bit...) glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, s_framebufferManager.GetResolvedFramebuffer());
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, ResolveAndGetDepthTarget(efbPixelRc));
} }
// Sample from the center of the target region. // Sample from the center of the target region.
@ -570,10 +569,6 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
glReadPixels(srcX, srcY, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, &z); glReadPixels(srcX, srcY, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, &z);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
if (s_MSAASamples > 1)
// Return to the EFB (this may not be necessary).
SetFramebuffer(0);
// Scale the 32-bit value returned by glReadPixels to a 24-bit // Scale the 32-bit value returned by glReadPixels to a 24-bit
// value (GC uses a 24-bit Z-buffer). // value (GC uses a 24-bit Z-buffer).
return z >> 8; return z >> 8;
@ -584,26 +579,25 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
break; break;
case PEEK_COLOR: case PEEK_COLOR:
/*{ {
u32 z = 0; if (s_MSAASamples > 1)
int srcX = (targetPixelRc.left + targetPixelRc.right) / 2; {
int srcY = (targetPixelRc.top + targetPixelRc.bottom) / 2; // Resolve our rectangle.
s_framebufferManager.GetEFBColorTexture(efbPixelRc);
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, s_framebufferManager.GetResolvedFramebuffer());
}
if (s_MSAASamples > 1) // Sample from the center of the target region.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ResolveAndGetRenderTarget(efbPixelRc)); int srcX = (targetPixelRc.left + targetPixelRc.right) / 2;
int srcY = (targetPixelRc.top + targetPixelRc.bottom) / 2;
// Read the z value! Also adjust the pixel to read to the upscaled EFB resolution u32 color = 0;
// Plus we need to flip the y value as the OGL image is upside down glReadPixels(srcX, srcY, 1, 1, GL_RGBA, GL_UNSIGNED_INT, &color);
glReadPixels(srcX, srcY, 1, 1, GL_RGB, GL_UNSIGNED_INT, &z); GL_REPORT_ERRORD();
GL_REPORT_ERRORD();
// We should probably re-bind the old fbo here. // TODO: Find some way to test PEEK_COLOR.
if (s_MSAASamples > 1) return color;
SetFramebuffer(0); }
return z;
}*/
break;
case POKE_COLOR: case POKE_COLOR:
// TODO: Implement. One way is to draw a tiny pixel-sized rectangle at // TODO: Implement. One way is to draw a tiny pixel-sized rectangle at