mirror of
https://github.com/TASEmulators/desmume
synced 2025-10-05 16:22:49 +02:00
Render3D: Improve robustness of Render3DColorOut buffer binding.
This commit is contained in:
@@ -1576,7 +1576,7 @@ size_t OpenGLRenderColorOut::BindRead32()
|
||||
this->_currentReadyIdx = RENDER3D_RESOURCE_INDEX_NONE;
|
||||
}
|
||||
|
||||
if ( (this->_currentReadingIdx32 != oldReadingIdx32) && (oldReadingIdx32 != RENDER3D_RESOURCE_INDEX_NONE) )
|
||||
if ( (oldReadingIdx32 != RENDER3D_RESOURCE_INDEX_NONE) && (this->_currentReadingIdx32 != oldReadingIdx32) )
|
||||
{
|
||||
this->_state[oldReadingIdx32] = AsyncReadState_Free;
|
||||
|
||||
@@ -1588,6 +1588,12 @@ size_t OpenGLRenderColorOut::BindRead32()
|
||||
}
|
||||
}
|
||||
|
||||
// Do not proceed if we can't bind a buffer for reading.
|
||||
if (this->_currentReadingIdx32 == RENDER3D_RESOURCE_INDEX_NONE)
|
||||
{
|
||||
return this->_currentReadingIdx32;
|
||||
}
|
||||
|
||||
if (this->_pbo[this->_currentReadingIdx32] != 0)
|
||||
{
|
||||
if (this->_buffer32[this->_currentReadingIdx32] == NULL)
|
||||
@@ -1870,6 +1876,12 @@ Render3DError OpenGLRenderColorOut::FillZero()
|
||||
{
|
||||
bufferIdx32 = this->_currentUsageIdx;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No buffer was or is in use, so there is nothing to modify.
|
||||
error = RENDER3DERROR_INVALID_BUFFER;
|
||||
return error;
|
||||
}
|
||||
|
||||
if (this->_willConvertColorOnGPU || (this->_texColorOut[bufferIdx32] != 0))
|
||||
{
|
||||
@@ -1882,8 +1894,7 @@ Render3DError OpenGLRenderColorOut::FillZero()
|
||||
|
||||
if ( (this->_pbo[bufferIdx32] != 0) &&
|
||||
this->_willConvertColorOnGPU &&
|
||||
(bufferIdx32 == this->_currentReadingIdx32) &&
|
||||
(bufferIdx32 != RENDER3D_RESOURCE_INDEX_NONE) )
|
||||
(bufferIdx32 == this->_currentReadingIdx32) )
|
||||
{
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, this->_pbo[bufferIdx32]);
|
||||
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
@@ -1899,7 +1910,7 @@ Render3DError OpenGLRenderColorOut::FillZero()
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if ( (bufferIdx32 == this->_currentReadingIdx32) && (bufferIdx32 != RENDER3D_RESOURCE_INDEX_NONE) )
|
||||
if (bufferIdx32 == this->_currentReadingIdx32)
|
||||
{
|
||||
this->_currentReadingIdx16 = bufferIdx32;
|
||||
memset(this->_buffer16[bufferIdx32], 0, this->_framebufferSize16);
|
||||
|
@@ -1587,8 +1587,14 @@ Render3DError SoftRasterizerColorOut::FillZero()
|
||||
{
|
||||
bufferIdx = this->_currentUsageIdx;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No buffer was or is in use, so there is nothing to modify.
|
||||
error = RENDER3DERROR_INVALID_BUFFER;
|
||||
return error;
|
||||
}
|
||||
|
||||
if ( (bufferIdx != RENDER3D_RESOURCE_INDEX_NONE) && (this->_buffer32[bufferIdx] != NULL) )
|
||||
if (this->_buffer32[bufferIdx] != NULL)
|
||||
{
|
||||
memset(this->_buffer32[bufferIdx], 0, this->_framebufferSize32);
|
||||
}
|
||||
|
@@ -385,7 +385,7 @@ size_t Render3DColorOut::BindRead32()
|
||||
this->_currentReadyIdx = RENDER3D_RESOURCE_INDEX_NONE;
|
||||
}
|
||||
|
||||
if ( (this->_currentReadingIdx32 != oldReadingIdx32) && (oldReadingIdx32 != RENDER3D_RESOURCE_INDEX_NONE) )
|
||||
if ( (oldReadingIdx32 != RENDER3D_RESOURCE_INDEX_NONE) && (this->_currentReadingIdx32 != oldReadingIdx32) )
|
||||
{
|
||||
this->_state[oldReadingIdx32] = AsyncReadState_Free;
|
||||
}
|
||||
|
Reference in New Issue
Block a user