Skip to content

Commit ef06d90

Browse files
committed
[Fix] (MG_Backend/DirectGLES): record GenerateMipmap errors
1 parent e7e6888 commit ef06d90

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <MG_Util/Classifiers/TextureEnumClassifier.h>
1616
#include <MG_Util/Metrics/TextureMetrics.h>
1717
#include <MG_State/GLState/Core.h>
18+
#include <MG_State/GLState/ErrorState/Error.h>
1819
#include <MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h>
1920
#include <MG_Util/BackendLoaders/OpenGL/Loader.h>
2021
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
@@ -1647,6 +1648,39 @@ namespace MobileGL::MG_Backend::DirectGLES {
16471648
MG_Util::ConvertGLEnumToString(err).c_str());
16481649
}
16491650

1651+
static ErrorCode ConvertGLESErrorToErrorCode(GLenum err) {
1652+
switch (err) {
1653+
case GL_INVALID_ENUM:
1654+
return ErrorCode::InvalidEnum;
1655+
case GL_INVALID_VALUE:
1656+
return ErrorCode::InvalidValue;
1657+
case GL_INVALID_FRAMEBUFFER_OPERATION:
1658+
return ErrorCode::InvalidFramebufferOperation;
1659+
case GL_OUT_OF_MEMORY:
1660+
return ErrorCode::OutOfMemory;
1661+
case GL_INVALID_OPERATION:
1662+
default:
1663+
return ErrorCode::InvalidOperation;
1664+
}
1665+
}
1666+
1667+
static Bool RecordGLError(const char* operation, GLenum target, TextureInternalFormat format) {
1668+
const GLenum err = g_GLESFuncs.glGetError();
1669+
if (err == GL_NO_ERROR) {
1670+
return true;
1671+
}
1672+
1673+
MGLOG_E("%s failed: %s. target=%s, format=%s", operation,
1674+
MG_Util::ConvertGLEnumToString(err).c_str(),
1675+
MG_Util::ConvertGLEnumToString(target).c_str(),
1676+
MG_Util::ConvertTextureInternalFormatToString(format).c_str());
1677+
MG_State::pGLContext->RecordError(
1678+
ConvertGLESErrorToErrorCode(err),
1679+
MakeUnique<GenericErrorInfo>("DirectGLES", operation,
1680+
MG_Util::ConvertGLEnumToString(err)));
1681+
return false;
1682+
}
1683+
16501684
static void ClearGLErrors() {
16511685
while (g_GLESFuncs.glGetError() != GL_NO_ERROR) {}
16521686
}
@@ -2250,7 +2284,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
22502284
// Bind a complete internal FBO that does not reference the source texture.
22512285
ScopedCompleteFramebufferBinding completeFramebuffer;
22522286
g_GLESFuncs.glGenerateMipmap(target);
2253-
AssertNoGLError("glGenerateMipmap");
2287+
RecordGLError("glGenerateMipmap", target, texture->GetFormat());
22542288
}
22552289

22562290
const GLubyte* GetString(GLenum name) {

0 commit comments

Comments
 (0)