1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00

Improve error checks in COpenGL3DriverBase

This commit is contained in:
sfan5 2024-04-12 12:18:41 +02:00
parent 7a6ca85081
commit 13e271c6cb
6 changed files with 99 additions and 31 deletions

View file

@ -59,6 +59,18 @@ public:
if (!InternalFormat)
return;
#ifdef _DEBUG
char lbuf[128];
snprintf_irr(lbuf, sizeof(lbuf),
"COpenGLCoreTexture: Type = %d Size = %dx%d (%dx%d) ColorFormat = %d (%d)%s -> %#06x %#06x %#06x%s",
(int)Type, Size.Width, Size.Height, OriginalSize.Width, OriginalSize.Height,
(int)ColorFormat, (int)OriginalColorFormat,
HasMipMaps ? " +Mip" : "",
InternalFormat, PixelFormat, PixelType, Converter ? " (c)" : ""
);
os::Printer::log(lbuf, ELL_DEBUG);
#endif
const core::array<IImage *> *tmpImages = &images;
if (KeepImage || OriginalSize != Size || OriginalColorFormat != ColorFormat) {
@ -104,6 +116,8 @@ public:
}
#endif
TEST_GL_ERROR(Driver);
for (u32 i = 0; i < (*tmpImages).size(); ++i)
uploadTexture(true, i, 0, (*tmpImages)[i]->getData());
@ -124,7 +138,7 @@ public:
Driver->getCacheHandler()->getTextureCache().set(0, prevTexture);
Driver->testGLError(__LINE__);
TEST_GL_ERROR(Driver);
}
COpenGLCoreTexture(const io::path &name, const core::dimension2d<u32> &size, E_TEXTURE_TYPE type, ECOLOR_FORMAT format, TOpenGLDriver *driver) :
@ -155,6 +169,16 @@ public:
return;
}
#ifdef _DEBUG
char lbuf[100];
snprintf_irr(lbuf, sizeof(lbuf),
"COpenGLCoreTexture: RTT Type = %d Size = %dx%d ColorFormat = %d -> %#06x %#06x %#06x%s",
(int)Type, Size.Width, Size.Height, (int)ColorFormat,
InternalFormat, PixelFormat, PixelType, Converter ? " (c)" : ""
);
os::Printer::log(lbuf, ELL_DEBUG);
#endif
GL.GenTextures(1, &TextureName);
const COpenGLCoreTexture *prevTexture = Driver->getCacheHandler()->getTextureCache().get(0);
@ -188,7 +212,7 @@ public:
}
Driver->getCacheHandler()->getTextureCache().set(0, prevTexture);
if (Driver->testGLError(__LINE__)) {
if (TEST_GL_ERROR(Driver)) {
char msg[256];
snprintf_irr(msg, 256, "COpenGLCoreTexture: InternalFormat:0x%04x PixelFormat:0x%04x", (int)InternalFormat, (int)PixelFormat);
os::Printer::log(msg, ELL_ERROR);
@ -241,7 +265,7 @@ public:
IImage *tmpImage = LockImage; // not sure yet if the size required by glGetTexImage is always correct, if not we might have to allocate a different tmpImage and convert colors later on.
Driver->getCacheHandler()->getTextureCache().set(0, this);
Driver->testGLError(__LINE__);
TEST_GL_ERROR(Driver);
GLenum tmpTextureType = TextureType;
@ -252,7 +276,7 @@ public:
}
GL.GetTexImage(tmpTextureType, MipLevelStored, PixelFormat, PixelType, tmpImage->getData());
Driver->testGLError(__LINE__);
TEST_GL_ERROR(Driver);
if (IsRenderTarget && lockFlags == ETLF_FLIP_Y_UP_RTT) {
const s32 pitch = tmpImage->getPitch();
@ -334,7 +358,7 @@ public:
}
}
Driver->testGLError(__LINE__);
TEST_GL_ERROR(Driver);
}
return (LockImage) ? getLockImageData(MipLevelStored) : 0;
@ -392,6 +416,7 @@ public:
} while (width != 1 || height != 1);
} else {
Driver->irrGlGenerateMipmap(TextureType);
TEST_GL_ERROR(Driver);
}
Driver->getCacheHandler()->getTextureCache().set(0, prevTexture);
@ -544,7 +569,7 @@ protected:
GL.TexImage2D(tmpTextureType, level, InternalFormat, width, height, 0, PixelFormat, PixelType, tmpData);
else
GL.TexSubImage2D(tmpTextureType, level, 0, 0, width, height, PixelFormat, PixelType, tmpData);
Driver->testGLError(__LINE__);
TEST_GL_ERROR(Driver);
break;
default:
break;
@ -561,7 +586,7 @@ protected:
Driver->irrGlCompressedTexImage2D(tmpTextureType, level, InternalFormat, width, height, 0, dataSize, data);
else
Driver->irrGlCompressedTexSubImage2D(tmpTextureType, level, 0, 0, width, height, PixelFormat, dataSize, data);
Driver->testGLError(__LINE__);
TEST_GL_ERROR(Driver);
break;
default:
break;