Reverted changes that were made to fix DQ8's display.

FindCompatibleFramebuffer was wrong and it was also wrong
to change the width of a framebuffer without invalidating its contents.
This commit is contained in:
Jean-Philip Desjardins 2016-01-01 19:03:36 -05:00
parent 578904c146
commit 77d1385533
3 changed files with 8 additions and 18 deletions

View File

@ -220,7 +220,7 @@ void CGSH_OpenGL::FlipImpl()
if(framebuffer)
{
float u1 = static_cast<float>(dispWidth) / static_cast<float>(framebuffer->m_textureWidth);
float u1 = static_cast<float>(dispWidth) / static_cast<float>(framebuffer->m_width);
float v1 = static_cast<float>(dispHeight) / static_cast<float>(framebuffer->m_height);
glDisable(GL_BLEND);
@ -902,7 +902,7 @@ void CGSH_OpenGL::SetupFramebuffer(const SHADERINFO& shaderInfo, uint64 frameReg
}
//Look for a framebuffer that matches the specified information
auto framebuffer = FindCompatibleFramebuffer(frame);
auto framebuffer = FindFramebuffer(frame);
if(!framebuffer)
{
framebuffer = FramebufferPtr(new CFramebuffer(frame.GetBasePtr(), frame.GetWidth(), 1024, frame.nPsm));
@ -911,7 +911,6 @@ void CGSH_OpenGL::SetupFramebuffer(const SHADERINFO& shaderInfo, uint64 frameReg
PopulateFramebuffer(framebuffer);
#endif
}
framebuffer->SetBufferWidth(frame.GetWidth());
CommitFramebufferDirtyPages(framebuffer, scissor.scay0, scissor.scay1);
@ -922,6 +921,8 @@ void CGSH_OpenGL::SetupFramebuffer(const SHADERINFO& shaderInfo, uint64 frameReg
m_depthbuffers.push_back(depthbuffer);
}
assert(framebuffer->m_width == depthbuffer->m_width);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->m_framebuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthbuffer->m_depthBuffer);
@ -1235,14 +1236,14 @@ void CGSH_OpenGL::SetupTexture(const SHADERINFO& shaderInfo, uint64 primReg, uin
}
}
CGSH_OpenGL::FramebufferPtr CGSH_OpenGL::FindCompatibleFramebuffer(const FRAME& frame) const
CGSH_OpenGL::FramebufferPtr CGSH_OpenGL::FindFramebuffer(const FRAME& frame) const
{
auto framebufferIterator = std::find_if(std::begin(m_framebuffers), std::end(m_framebuffers),
[&] (const FramebufferPtr& framebuffer)
{
return (framebuffer->m_basePtr == frame.GetBasePtr()) &&
(framebuffer->m_psm == frame.nPsm) &&
(framebuffer->m_width >= frame.GetWidth());
(framebuffer->m_width == frame.GetWidth());
}
);
@ -1885,7 +1886,6 @@ CGSH_OpenGL::CFramebuffer::CFramebuffer(uint32 basePtr, uint32 width, uint32 hei
, m_psm(psm)
, m_framebuffer(0)
, m_texture(0)
, m_textureWidth(width)
{
m_cachedArea.SetArea(psm, basePtr, width, height);
@ -1917,13 +1917,6 @@ CGSH_OpenGL::CFramebuffer::~CFramebuffer()
}
}
void CGSH_OpenGL::CFramebuffer::SetBufferWidth(uint32 newWidth)
{
if(m_width == newWidth) return;
m_width = newWidth;
m_cachedArea.SetArea(m_psm, m_basePtr, m_width, m_height);
}
void CGSH_OpenGL::PopulateFramebuffer(const FramebufferPtr& framebuffer)
{
if(framebuffer->m_psm != PSMCT32)

View File

@ -175,8 +175,6 @@ private:
CFramebuffer(uint32, uint32, uint32, uint32);
~CFramebuffer();
void SetBufferWidth(uint32);
uint32 m_basePtr;
uint32 m_width;
uint32 m_height;
@ -184,7 +182,6 @@ private:
GLuint m_framebuffer;
GLuint m_texture;
uint32 m_textureWidth;
CGsCachedArea m_cachedArea;
};
@ -286,7 +283,7 @@ private:
static bool IsCompatibleFramebufferPSM(unsigned int, unsigned int);
static uint32 GetFramebufferBitDepth(uint32);
FramebufferPtr FindCompatibleFramebuffer(const FRAME&) const;
FramebufferPtr FindFramebuffer(const FRAME&) const;
DepthbufferPtr FindDepthbuffer(const ZBUF&, const FRAME&) const;
void DumpTexture(unsigned int, unsigned int, uint32);

View File

@ -119,7 +119,7 @@ CGSH_OpenGL::TEXTURE_INFO CGSH_OpenGL::PrepareTexture(const TEX0& tex0)
//We have a winner
glBindTexture(GL_TEXTURE_2D, candidateFramebuffer->m_texture);
float scaleRatioX = static_cast<float>(tex0.GetWidth()) / static_cast<float>(candidateFramebuffer->m_textureWidth);
float scaleRatioX = static_cast<float>(tex0.GetWidth()) / static_cast<float>(candidateFramebuffer->m_width);
float scaleRatioY = static_cast<float>(tex0.GetHeight()) / static_cast<float>(candidateFramebuffer->m_height);
texInfo.offsetX = offsetX;