mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Refactor: Make frame buffer singleton
This commit is contained in:
parent
954d5c3552
commit
bd8b73d5b5
|
@ -150,6 +150,7 @@ void DepthBuffer_Destroy()
|
||||||
|
|
||||||
void DepthBuffer_SetBuffer( u32 address )
|
void DepthBuffer_SetBuffer( u32 address )
|
||||||
{
|
{
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
FrameBuffer * pFrameBuffer = FrameBuffer_FindBuffer(address);
|
FrameBuffer * pFrameBuffer = FrameBuffer_FindBuffer(address);
|
||||||
if (pFrameBuffer == NULL)
|
if (pFrameBuffer == NULL)
|
||||||
pFrameBuffer = frameBuffer.top;
|
pFrameBuffer = frameBuffer.top;
|
||||||
|
@ -232,6 +233,6 @@ void DepthBuffer_ClearBuffer() {
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current->fbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current->fbo);
|
||||||
OGL_DrawRect(0,0,VI.width, VI.height, color);
|
OGL_DrawRect(0,0,VI.width, VI.height, color);
|
||||||
glBindImageTexture(depthImageUnit, current->depth_texture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
glBindImageTexture(depthImageUnit, current->depth_texture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().top->fbo);
|
||||||
#endif // GLES2
|
#endif // GLES2
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,6 @@ const GLint monohromeInternalformat = GL_LUMINANCE;
|
||||||
const GLenum monohromeformat = GL_LUMINANCE;
|
const GLenum monohromeformat = GL_LUMINANCE;
|
||||||
#endif // GLES2
|
#endif // GLES2
|
||||||
|
|
||||||
FrameBufferList frameBuffer;
|
|
||||||
|
|
||||||
#ifndef GLES2
|
#ifndef GLES2
|
||||||
class FrameBufferToRDRAM
|
class FrameBufferToRDRAM
|
||||||
{
|
{
|
||||||
|
@ -118,6 +116,7 @@ RDRAMtoFrameBuffer g_RDRAMtoFB;
|
||||||
|
|
||||||
void FrameBuffer_Init()
|
void FrameBuffer_Init()
|
||||||
{
|
{
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
frameBuffer.current = NULL;
|
frameBuffer.current = NULL;
|
||||||
frameBuffer.top = NULL;
|
frameBuffer.top = NULL;
|
||||||
frameBuffer.bottom = NULL;
|
frameBuffer.bottom = NULL;
|
||||||
|
@ -132,6 +131,7 @@ void FrameBuffer_Init()
|
||||||
|
|
||||||
void FrameBuffer_RemoveBottom()
|
void FrameBuffer_RemoveBottom()
|
||||||
{
|
{
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
FrameBuffer *newBottom = frameBuffer.bottom->higher;
|
FrameBuffer *newBottom = frameBuffer.bottom->higher;
|
||||||
|
|
||||||
textureCache().removeFrameBufferTexture(frameBuffer.bottom->texture);
|
textureCache().removeFrameBufferTexture(frameBuffer.bottom->texture);
|
||||||
|
@ -153,6 +153,7 @@ void FrameBuffer_RemoveBottom()
|
||||||
|
|
||||||
void FrameBuffer_Remove( FrameBuffer *buffer )
|
void FrameBuffer_Remove( FrameBuffer *buffer )
|
||||||
{
|
{
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
if ((buffer == frameBuffer.bottom) &&
|
if ((buffer == frameBuffer.bottom) &&
|
||||||
(buffer == frameBuffer.top))
|
(buffer == frameBuffer.top))
|
||||||
{
|
{
|
||||||
|
@ -191,7 +192,7 @@ void FrameBuffer_Remove( FrameBuffer *buffer )
|
||||||
|
|
||||||
void FrameBuffer_RemoveBuffer( u32 address )
|
void FrameBuffer_RemoveBuffer( u32 address )
|
||||||
{
|
{
|
||||||
FrameBuffer *current = frameBuffer.bottom;
|
FrameBuffer *current = frameBufferList().bottom;
|
||||||
|
|
||||||
while (current != NULL)
|
while (current != NULL)
|
||||||
{
|
{
|
||||||
|
@ -207,6 +208,7 @@ void FrameBuffer_RemoveBuffer( u32 address )
|
||||||
|
|
||||||
FrameBuffer *FrameBuffer_AddTop()
|
FrameBuffer *FrameBuffer_AddTop()
|
||||||
{
|
{
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
FrameBuffer *newtop = (FrameBuffer*)malloc( sizeof( FrameBuffer ) );
|
FrameBuffer *newtop = (FrameBuffer*)malloc( sizeof( FrameBuffer ) );
|
||||||
|
|
||||||
newtop->texture = textureCache().addFrameBufferTexture();
|
newtop->texture = textureCache().addFrameBufferTexture();
|
||||||
|
@ -231,6 +233,7 @@ FrameBuffer *FrameBuffer_AddTop()
|
||||||
|
|
||||||
void FrameBuffer_MoveToTop( FrameBuffer *newtop )
|
void FrameBuffer_MoveToTop( FrameBuffer *newtop )
|
||||||
{
|
{
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
if (newtop == frameBuffer.top)
|
if (newtop == frameBuffer.top)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -253,6 +256,7 @@ void FrameBuffer_MoveToTop( FrameBuffer *newtop )
|
||||||
|
|
||||||
void FrameBuffer_Destroy()
|
void FrameBuffer_Destroy()
|
||||||
{
|
{
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
while (frameBuffer.bottom)
|
while (frameBuffer.bottom)
|
||||||
FrameBuffer_RemoveBottom();
|
FrameBuffer_RemoveBottom();
|
||||||
frameBuffer.top = frameBuffer.bottom = frameBuffer.current = NULL;
|
frameBuffer.top = frameBuffer.bottom = frameBuffer.current = NULL;
|
||||||
|
@ -265,6 +269,7 @@ void FrameBuffer_Destroy()
|
||||||
|
|
||||||
void FrameBuffer_SaveBuffer( u32 address, u16 format, u16 size, u16 width, u16 height )
|
void FrameBuffer_SaveBuffer( u32 address, u16 format, u16 size, u16 width, u16 height )
|
||||||
{
|
{
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
frameBuffer.drawBuffer = GL_FRAMEBUFFER;
|
frameBuffer.drawBuffer = GL_FRAMEBUFFER;
|
||||||
FrameBuffer *current = frameBuffer.top;
|
FrameBuffer *current = frameBuffer.top;
|
||||||
if (current != NULL && gDP.colorImage.height > 1) {
|
if (current != NULL && gDP.colorImage.height > 1) {
|
||||||
|
@ -364,6 +369,7 @@ static
|
||||||
void _initDepthTexture()
|
void _initDepthTexture()
|
||||||
{
|
{
|
||||||
#ifndef GLES2
|
#ifndef GLES2
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
depthBuffer.top->depth_texture = textureCache().addFrameBufferTexture();
|
depthBuffer.top->depth_texture = textureCache().addFrameBufferTexture();
|
||||||
|
|
||||||
depthBuffer.top->depth_texture->width = (u32)(frameBuffer.top->width * OGL.scaleX);
|
depthBuffer.top->depth_texture->width = (u32)(frameBuffer.top->width * OGL.scaleX);
|
||||||
|
@ -405,6 +411,7 @@ void _initDepthTexture()
|
||||||
|
|
||||||
void FrameBuffer_AttachDepthBuffer()
|
void FrameBuffer_AttachDepthBuffer()
|
||||||
{
|
{
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
if ( frameBuffer.top != NULL && frameBuffer.top->fbo > 0 && depthBuffer.top != NULL && depthBuffer.top->renderbuf > 0) {
|
if ( frameBuffer.top != NULL && frameBuffer.top->fbo > 0 && depthBuffer.top != NULL && depthBuffer.top->renderbuf > 0) {
|
||||||
if (depthBuffer.top->depth_texture == NULL)
|
if (depthBuffer.top->depth_texture == NULL)
|
||||||
_initDepthTexture();
|
_initDepthTexture();
|
||||||
|
@ -484,7 +491,7 @@ void FrameBuffer_RenderBuffer( u32 address )
|
||||||
}
|
}
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().top->fbo);
|
||||||
OGL_SwapBuffers();
|
OGL_SwapBuffers();
|
||||||
gDP.changed |= CHANGED_SCISSOR;
|
gDP.changed |= CHANGED_SCISSOR;
|
||||||
}
|
}
|
||||||
|
@ -519,6 +526,7 @@ void FrameBuffer_RenderBuffer( u32 address )
|
||||||
gSP.textureTile[0]->fuls = gSP.textureTile[0]->fult = 0.0f;
|
gSP.textureTile[0]->fuls = gSP.textureTile[0]->fult = 0.0f;
|
||||||
combiner.current->compiled->UpdateTextureInfo(true);
|
combiner.current->compiled->UpdateTextureInfo(true);
|
||||||
|
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
frameBuffer.drawBuffer = GL_BACK;
|
frameBuffer.drawBuffer = GL_BACK;
|
||||||
OGL_DrawTexturedRect( 0.0f, 0.0f, width, height, 0.0f, 0.0f, width-1.0f, height-1.0f, false );
|
OGL_DrawTexturedRect( 0.0f, 0.0f, width, height, 0.0f, 0.0f, width-1.0f, height-1.0f, false );
|
||||||
|
@ -533,7 +541,7 @@ void FrameBuffer_RenderBuffer( u32 address )
|
||||||
|
|
||||||
FrameBuffer *FrameBuffer_FindBuffer( u32 address )
|
FrameBuffer *FrameBuffer_FindBuffer( u32 address )
|
||||||
{
|
{
|
||||||
FrameBuffer *current = frameBuffer.top;
|
FrameBuffer *current = frameBufferList().top;
|
||||||
|
|
||||||
while (current)
|
while (current)
|
||||||
{
|
{
|
||||||
|
@ -666,7 +674,7 @@ void FrameBufferToRDRAM::CopyToRDRAM( u32 address, bool bSync ) {
|
||||||
0, 0, current->width, current->height,
|
0, 0, current->width, current->height,
|
||||||
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||||
);
|
);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().top->fbo);
|
||||||
|
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO);
|
||||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||||
|
@ -801,7 +809,7 @@ void DepthBufferToRDRAM::CopyToRDRAM( u32 address) {
|
||||||
0, 0, current->width, current->height,
|
0, 0, current->width, current->height,
|
||||||
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||||
);
|
);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().top->fbo);
|
||||||
|
|
||||||
m_curIndex = (m_curIndex + 1) % 2;
|
m_curIndex = (m_curIndex + 1) % 2;
|
||||||
const u32 nextIndex = m_aAddress[m_curIndex] == 0 ? m_curIndex : (m_curIndex + 1) % 2;
|
const u32 nextIndex = m_aAddress[m_curIndex] == 0 ? m_curIndex : (m_curIndex + 1) % 2;
|
||||||
|
@ -975,7 +983,7 @@ void RDRAMtoFrameBuffer::CopyFromRDRAM( u32 _address, bool _bUseAlpha)
|
||||||
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||||
);
|
);
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().top->fbo);
|
||||||
#else
|
#else
|
||||||
if (_bUseAlpha)
|
if (_bUseAlpha)
|
||||||
CombinerInfo::get().setCombine( EncodeCombineMode( 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0 ) );
|
CombinerInfo::get().setCombine( EncodeCombineMode( 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0 ) );
|
||||||
|
|
|
@ -26,9 +26,23 @@ struct FrameBufferList
|
||||||
FrameBuffer *top, *bottom, *current;
|
FrameBuffer *top, *bottom, *current;
|
||||||
int numBuffers;
|
int numBuffers;
|
||||||
GLenum drawBuffer;
|
GLenum drawBuffer;
|
||||||
|
|
||||||
|
static FrameBufferList & get()
|
||||||
|
{
|
||||||
|
static FrameBufferList frameBufferList;
|
||||||
|
return frameBufferList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
FrameBufferList() : current(NULL), drawBuffer(GL_BACK) {}
|
||||||
|
FrameBufferList(const FrameBufferList &);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FrameBufferList frameBuffer;
|
inline
|
||||||
|
FrameBufferList & frameBufferList()
|
||||||
|
{
|
||||||
|
return FrameBufferList::get();
|
||||||
|
}
|
||||||
|
|
||||||
void FrameBuffer_Init();
|
void FrameBuffer_Init();
|
||||||
void FrameBuffer_Destroy();
|
void FrameBuffer_Destroy();
|
||||||
|
|
|
@ -693,6 +693,7 @@ void ShaderCombiner::updateDepthInfo(bool _bForce) {
|
||||||
if (!OGL.bImageTexture)
|
if (!OGL.bImageTexture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
if (frameBuffer.top == NULL || frameBuffer.top->pDepthBuffer == NULL)
|
if (frameBuffer.top == NULL || frameBuffer.top->pDepthBuffer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -727,6 +728,7 @@ void ShaderCombiner::updateAlphaTestInfo(bool _bForce) {
|
||||||
void GLSL_RenderDepth() {
|
void GLSL_RenderDepth() {
|
||||||
if (!OGL.bImageTexture)
|
if (!OGL.bImageTexture)
|
||||||
return;
|
return;
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
#if 0
|
#if 0
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, g_zbuf_fbo);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, g_zbuf_fbo);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
|
|
|
@ -589,11 +589,11 @@ void OGL_UpdateCullFace()
|
||||||
|
|
||||||
void OGL_UpdateViewport()
|
void OGL_UpdateViewport()
|
||||||
{
|
{
|
||||||
if (frameBuffer.drawBuffer == GL_BACK)
|
if (frameBufferList().drawBuffer == GL_BACK)
|
||||||
glViewport( gSP.viewport.x * OGL.scaleX, (VI.height - (gSP.viewport.y + gSP.viewport.height)) * OGL.scaleY + OGL.heightOffset,
|
glViewport( gSP.viewport.x * OGL.scaleX, (VI.height - (gSP.viewport.y + gSP.viewport.height)) * OGL.scaleY + OGL.heightOffset,
|
||||||
gSP.viewport.width * OGL.scaleX, gSP.viewport.height * OGL.scaleY );
|
gSP.viewport.width * OGL.scaleX, gSP.viewport.height * OGL.scaleY );
|
||||||
else
|
else
|
||||||
glViewport( gSP.viewport.x * OGL.scaleX, (frameBuffer.top->height - (gSP.viewport.y + gSP.viewport.height)) * OGL.scaleY,
|
glViewport( gSP.viewport.x * OGL.scaleX, (frameBufferList().top->height - (gSP.viewport.y + gSP.viewport.height)) * OGL.scaleY,
|
||||||
gSP.viewport.width * OGL.scaleX, gSP.viewport.height * OGL.scaleY );
|
gSP.viewport.width * OGL.scaleX, gSP.viewport.height * OGL.scaleY );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -798,6 +798,7 @@ void OGL_UpdateStates()
|
||||||
|
|
||||||
if (gDP.changed & CHANGED_SCISSOR)
|
if (gDP.changed & CHANGED_SCISSOR)
|
||||||
{
|
{
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
const u32 screenHeight = (frameBuffer.top == NULL || frameBuffer.top->height == 0 || frameBuffer.drawBuffer == GL_BACK) ? VI.height : frameBuffer.top->height;
|
const u32 screenHeight = (frameBuffer.top == NULL || frameBuffer.top->height == 0 || frameBuffer.drawBuffer == GL_BACK) ? VI.height : frameBuffer.top->height;
|
||||||
glScissor( gDP.scissor.ulx * OGL.scaleX, (screenHeight - gDP.scissor.lry) * OGL.scaleY + (frameBuffer.drawBuffer == GL_BACK ? OGL.heightOffset : 0),
|
glScissor( gDP.scissor.ulx * OGL.scaleX, (screenHeight - gDP.scissor.lry) * OGL.scaleY + (frameBuffer.drawBuffer == GL_BACK ? OGL.heightOffset : 0),
|
||||||
(gDP.scissor.lrx - gDP.scissor.ulx) * OGL.scaleX, (gDP.scissor.lry - gDP.scissor.uly) * OGL.scaleY );
|
(gDP.scissor.lrx - gDP.scissor.ulx) * OGL.scaleX, (gDP.scissor.lry - gDP.scissor.uly) * OGL.scaleY );
|
||||||
|
@ -1016,6 +1017,7 @@ void OGL_DrawRect( int ulx, int uly, int lrx, int lry, float *color )
|
||||||
currentCombiner()->updateRenderState();
|
currentCombiner()->updateRenderState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
if (frameBuffer.drawBuffer != GL_FRAMEBUFFER)
|
if (frameBuffer.drawBuffer != GL_FRAMEBUFFER)
|
||||||
glViewport( 0, (frameBuffer.drawBuffer == GL_BACK ? OGL.heightOffset : 0), OGL.width, OGL.height );
|
glViewport( 0, (frameBuffer.drawBuffer == GL_BACK ? OGL.heightOffset : 0), OGL.width, OGL.height );
|
||||||
else
|
else
|
||||||
|
@ -1071,6 +1073,7 @@ void OGL_DrawTexturedRect( float ulx, float uly, float lrx, float lry, float uls
|
||||||
GLS_SetShadowMapCombiner();
|
GLS_SetShadowMapCombiner();
|
||||||
#endif // GLES2
|
#endif // GLES2
|
||||||
|
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
if (frameBuffer.drawBuffer != GL_FRAMEBUFFER)
|
if (frameBuffer.drawBuffer != GL_FRAMEBUFFER)
|
||||||
glViewport( 0, (frameBuffer.drawBuffer == GL_BACK ? OGL.heightOffset : 0), OGL.width, OGL.height );
|
glViewport( 0, (frameBuffer.drawBuffer == GL_BACK ? OGL.heightOffset : 0), OGL.width, OGL.height );
|
||||||
else
|
else
|
||||||
|
@ -1204,7 +1207,7 @@ void OGL_DrawTexturedRect( float ulx, float uly, float lrx, float lry, float uls
|
||||||
|
|
||||||
void OGL_ClearDepthBuffer()
|
void OGL_ClearDepthBuffer()
|
||||||
{
|
{
|
||||||
if (config.frameBufferEmulation.enable && frameBuffer.top == NULL)
|
if (config.frameBufferEmulation.enable && frameBufferList().top == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DepthBuffer_ClearBuffer();
|
DepthBuffer_ClearBuffer();
|
||||||
|
|
1
gDP.cpp
1
gDP.cpp
|
@ -752,6 +752,7 @@ void gDPFillRDRAM(u32 address, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 width, u3
|
||||||
{
|
{
|
||||||
if (g_bDepthClearOnly && color != DEPTH_CLEAR_COLOR)
|
if (g_bDepthClearOnly && color != DEPTH_CLEAR_COLOR)
|
||||||
return;
|
return;
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
if (frameBuffer.drawBuffer == GL_FRAMEBUFFER) {
|
if (frameBuffer.drawBuffer == GL_FRAMEBUFFER) {
|
||||||
frameBuffer.top->cleared = true;
|
frameBuffer.top->cleared = true;
|
||||||
frameBuffer.top->fillcolor = color;
|
frameBuffer.top->fillcolor = color;
|
||||||
|
|
5
gSP.cpp
5
gSP.cpp
|
@ -1684,14 +1684,14 @@ void _copyDepthBuffer()
|
||||||
// It will be copy depth buffer
|
// It will be copy depth buffer
|
||||||
DepthBuffer_SetBuffer(gDP.colorImage.address);
|
DepthBuffer_SetBuffer(gDP.colorImage.address);
|
||||||
// Take any frame buffer and attach source depth buffer to it, to blit it into copy depth buffer
|
// Take any frame buffer and attach source depth buffer to it, to blit it into copy depth buffer
|
||||||
FrameBuffer * pTmpBuffer = frameBuffer.top->lower;
|
FrameBuffer * pTmpBuffer = frameBufferList().top->lower;
|
||||||
DepthBuffer * pTmpBufferDepth = pTmpBuffer->pDepthBuffer;
|
DepthBuffer * pTmpBufferDepth = pTmpBuffer->pDepthBuffer;
|
||||||
pTmpBuffer->pDepthBuffer = DepthBuffer_FindBuffer(gSP.bgImage.address);
|
pTmpBuffer->pDepthBuffer = DepthBuffer_FindBuffer(gSP.bgImage.address);
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, pTmpBuffer->fbo);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, pTmpBuffer->fbo);
|
||||||
glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, pTmpBuffer->pDepthBuffer->renderbuf);
|
glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, pTmpBuffer->pDepthBuffer->renderbuf);
|
||||||
GLuint attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT };
|
GLuint attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT };
|
||||||
glDrawBuffers(2, attachments);
|
glDrawBuffers(2, attachments);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().top->fbo);
|
||||||
glBlitFramebuffer(
|
glBlitFramebuffer(
|
||||||
0, 0, OGL.width, OGL.height,
|
0, 0, OGL.width, OGL.height,
|
||||||
0, 0, OGL.width, OGL.height,
|
0, 0, OGL.width, OGL.height,
|
||||||
|
@ -1945,6 +1945,7 @@ void gSPObjSprite( u32 sp )
|
||||||
gDPSetTileSize( 0, 0, 0, (imageW - 1) << 2, (imageH - 1) << 2 );
|
gDPSetTileSize( 0, 0, 0, (imageW - 1) << 2, (imageH - 1) << 2 );
|
||||||
gSPTexture( 1.0f, 1.0f, 0, 0, TRUE );
|
gSPTexture( 1.0f, 1.0f, 0, 0, TRUE );
|
||||||
|
|
||||||
|
FrameBufferList & frameBuffer = frameBufferList();
|
||||||
const float scaleX = frameBuffer.drawBuffer == GL_FRAMEBUFFER ? 1.0f/frameBuffer.top->width : VI.rwidth;
|
const float scaleX = frameBuffer.drawBuffer == GL_FRAMEBUFFER ? 1.0f/frameBuffer.top->width : VI.rwidth;
|
||||||
const float scaleY = frameBuffer.drawBuffer == GL_FRAMEBUFFER ? 1.0f/frameBuffer.top->height : VI.rheight;
|
const float scaleY = frameBuffer.drawBuffer == GL_FRAMEBUFFER ? 1.0f/frameBuffer.top->height : VI.rheight;
|
||||||
OGL.triangles.vertices[v0].x = 2.0f * scaleX * OGL.triangles.vertices[v0].x - 1.0f;
|
OGL.triangles.vertices[v0].x = 2.0f * scaleX * OGL.triangles.vertices[v0].x - 1.0f;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user