mirror of
https://github.com/Rosalie241/RMG.git
synced 2026-07-11 01:24:01 +02:00
3rdParty: revert to using GL_RGBA in mupen64plus-video-GLideN64
For some reason when using GL_RGB, it seems to corrupt memory and cause a crash, valgrind says the following: ==29295== Invalid write of size 1 ==29295== at 0x20BC10E6: convert_ubyte (format_utils.c:996) ==29295== by 0x20BDE59B: _mesa_format_convert (format_utils.c:452) ==29295== by 0x20CA072D: read_rgba_pixels (readpix.c:609) ==29295== by 0x20CA072D: _mesa_readpixels (readpix.c:923) ==29295== by 0x20CA6DCA: st_ReadPixels (st_cb_readpixels.c:577) ==29295== by 0x20CA120B: read_pixels (readpix.c:1218) ==29295== by 0x20CA120B: _mesa_ReadnPixelsARB (readpix.c:1235) ==29295== by 0x20CA1564: _mesa_ReadPixels (readpix.c:1250) ==29295== by 0x5741BCF4: opengl::GlReadPixelsCommand::commandToExecute() (opengl_WrappedFunctions.h:682) ==29295== by 0x5740EB75: opengl::OpenGlCommand::performCommandSingleThreaded() (opengl_Command.cpp:13) ==29295== by 0x574117B1: opengl::FunctionWrapper::executeCommand(std::shared_ptr<opengl::OpenGlCommand>) (opengl_Wrapper.cpp:30) ==29295== by 0x57412548: opengl::FunctionWrapper::wrReadPixels(int, int, int, int, unsigned int, unsigned int, void*) (opengl_Wrapper.cpp:316) ==29295== by 0x57507C74: DisplayWindowMupen64plus::_readScreen2(void*, int*, int*, int) (mupen64plus_DisplayWindow.cpp:263) ==29295== by 0x573B69D3: DisplayWindow::readScreen2(void*, int*, int*, int) (DisplayWindow.cpp:209) valgrind leads me to believe this might be a mesa issue where it writes out of bounds of the provided buffer, this issue does not occur when using GL_RGBA, nor does it appear when using an older mesa version in the AppImage. Reverting https://github.com/gonetz/GLideN64/pull/2856 fixes the issue. Fixes https://github.com/Rosalie241/RMG/issues/498
This commit is contained in:
+7
-6
@@ -252,6 +252,11 @@ void DisplayWindowMupen64plus::_readScreen2(void * _dest, int * _width, int * _h
|
||||
if (_dest == nullptr)
|
||||
return;
|
||||
|
||||
u8 *pBufferData = (u8*)malloc((*_width)*(*_height) * 4);
|
||||
if (pBufferData == nullptr)
|
||||
return;
|
||||
u8 *pDest = (u8*)_dest;
|
||||
|
||||
#if !defined(OS_ANDROID) && !defined(OS_IOS)
|
||||
GLint oldMode;
|
||||
glGetIntegerv(GL_READ_BUFFER, &oldMode);
|
||||
@@ -260,7 +265,7 @@ void DisplayWindowMupen64plus::_readScreen2(void * _dest, int * _width, int * _h
|
||||
glReadBuffer(GL_FRONT);
|
||||
else
|
||||
glReadBuffer(GL_BACK);
|
||||
glReadPixels(0, m_heightOffset, m_screenWidth, m_screenHeight, GL_RGB, GL_UNSIGNED_BYTE, _dest);
|
||||
glReadPixels(0, m_heightOffset, m_screenWidth, m_screenHeight, GL_RGBA, GL_UNSIGNED_BYTE, pBufferData);
|
||||
if (graphics::BufferAttachmentParam(oldMode) == graphics::bufferAttachment::COLOR_ATTACHMENT0) {
|
||||
FrameBuffer * pBuffer = frameBufferList().getCurrent();
|
||||
if (pBuffer != nullptr)
|
||||
@@ -268,11 +273,8 @@ void DisplayWindowMupen64plus::_readScreen2(void * _dest, int * _width, int * _h
|
||||
}
|
||||
glReadBuffer(oldMode);
|
||||
#else
|
||||
u8 *pBufferData = (u8*)malloc((*_width)*(*_height) * 4);
|
||||
if (pBufferData == nullptr)
|
||||
return;
|
||||
u8 *pDest = (u8*)_dest;
|
||||
glReadPixels(0, m_heightOffset, m_screenWidth, m_screenHeight, GL_RGBA, GL_UNSIGNED_BYTE, pBufferData);
|
||||
#endif
|
||||
|
||||
//Convert RGBA to RGB
|
||||
for (s32 y = 0; y < *_height; ++y) {
|
||||
@@ -287,7 +289,6 @@ void DisplayWindowMupen64plus::_readScreen2(void * _dest, int * _width, int * _h
|
||||
}
|
||||
|
||||
free(pBufferData);
|
||||
#endif
|
||||
}
|
||||
|
||||
graphics::ObjectHandle DisplayWindowMupen64plus::_getDefaultFramebuffer()
|
||||
|
||||
Reference in New Issue
Block a user