Compare commits

...

6 Commits

Author SHA1 Message Date
Daisuke Kasuga
ff356216d5 Set OFF by default to FILAMENT_ENABLE_INIT_GL_WARNINGS_FOR_OPTIMIZED_BUILD 2025-05-02 20:44:53 +09:00
Daisuke Kasuga
6fd87cdfef Call assert for debug builds and check for non-debug builds 2025-05-02 20:44:53 +09:00
Daisuke Kasuga
8ba001d0ca fix #ifdef directives wrong usage 2025-05-02 20:44:53 +09:00
Daisuke Kasuga
6fd031c611 add the macro to gl init codes 2025-05-02 20:44:53 +09:00
Daisuke Kasuga
b0e90c48a2 define themacro 2025-05-02 20:44:52 +09:00
Daisuke Kasuga
149acf4213 cmake integration 2025-05-02 20:44:52 +09:00
4 changed files with 31 additions and 0 deletions

View File

@@ -49,6 +49,8 @@ option(FILAMENT_SUPPORTS_OSMESA "Enable OSMesa (headless GL context) for Filamen
option(FILAMENT_ENABLE_FGVIEWER "Enable the frame graph viewer" OFF)
option(FILAMENT_ENABLE_INIT_GL_WARNINGS_FOR_OPTIMIZED_BUILD "Enable GL error warnings during init in optimized builds" OFF)
set(FILAMENT_NDK_VERSION "" CACHE STRING
"Android NDK version or version prefix to be used when building for Android."
)

View File

@@ -318,6 +318,13 @@ if (WIN32 AND FILAMENT_SUPPORTS_WEBGPU)
target_compile_definitions(${TARGET} PRIVATE "WGPU_IMPLEMENTATION")
endif()
# enable OpenGL init warnings for the optimized build
if(FILAMENT_ENABLE_INIT_GL_WARNINGS_FOR_OPTIMIZED_BUILD)
target_compile_definitions(${TARGET} PRIVATE "FILAMENT_ENABLE_INIT_GL_WARNINGS_FOR_OPTIMIZED_BUILD")
endif()
# ==================================================================================================
# Expose a header-only target to minimize dependencies.
# ==================================================================================================

View File

@@ -50,6 +50,14 @@ void assertFramebufferStatus(utils::io::ostream& out, GLenum target, const char*
# define CHECK_GL_FRAMEBUFFER_STATUS(out, target) { GLUtils::checkFramebufferStatus(out, target, __func__, __LINE__); }
#endif
#ifndef NDEBUG
# define CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(out) { GLUtils::assertGLError(out, __func__, __LINE__);}
#elif defined(FILAMENT_ENABLE_INIT_GL_WARNINGS_FOR_OPTIMIZED_BUILD)
# define CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(out) { GLUtils::checkGLError(out, __func__, __LINE__);}
#else
# define CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(out)
#endif
constexpr GLuint getComponentCount(ElementType const type) noexcept {
using ElementType = ElementType;
switch (type) {

View File

@@ -59,6 +59,9 @@ bool OpenGLContext::queryOpenGLVersion(GLint* major, GLint* minor) noexcept {
// OpenGL version
glGetIntegerv(GL_MAJOR_VERSION, major);
glGetIntegerv(GL_MINOR_VERSION, minor);
CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(utils::slog.e)
return (glGetError() == GL_NO_ERROR);
#endif
}
@@ -109,6 +112,8 @@ OpenGLContext::OpenGLContext(OpenGLPlatform& platform,
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &gets.max_3d_texture_size);
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &gets.max_array_texture_layers);
CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(utils::slog.e)
mFeatureLevel = resolveFeatureLevel(state.major, state.minor, ext, gets, bugs);
#ifdef BACKEND_OPENGL_VERSION_GLES
@@ -149,6 +154,7 @@ OpenGLContext::OpenGLContext(OpenGLPlatform& platform,
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
&gets.uniform_buffer_offset_alignment);
#endif
CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(utils::slog.e)
}
#ifdef BACKEND_OPENGL_VERSION_GLES
@@ -235,6 +241,7 @@ OpenGLContext::OpenGLContext(OpenGLPlatform& platform,
}
#endif
#endif
CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(utils::slog.e)
// in practice KHR_Debug has never been useful, and actually is confusing. We keep this
// only for our own debugging, in case we need it some day.
@@ -269,6 +276,7 @@ OpenGLContext::OpenGLContext(OpenGLPlatform& platform,
glDebugMessageCallback(cb, nullptr);
}
#endif
CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(utils::slog.e)
mTimerQueryFactory = TimerQueryFactory::init(platform, *this);
}
@@ -384,6 +392,8 @@ void OpenGLContext::setDefaultState() noexcept {
glEnable(GL_CLIP_DISTANCE0);
glEnable(GL_CLIP_DISTANCE1);
}
CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(utils::slog.e)
}
@@ -761,6 +771,8 @@ void OpenGLContext::initExtensionsGLES(Extensions* ext, GLint major, GLint minor
ext->EXT_discard_framebuffer = true;
ext->OES_vertex_array_object = true;
}
CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(utils::slog.e)
}
#endif // BACKEND_OPENGL_VERSION_GLES
@@ -831,6 +843,8 @@ void OpenGLContext::initExtensionsGL(Extensions* ext, GLint major, GLint minor)
if (major > 4 || (major == 4 && minor >= 5)) {
ext->EXT_clip_control = true;
}
CHECK_GL_INIT_ERROR_FOR_OPTIMIZED_BUILD(utils::slog.e)
}
#endif // BACKEND_OPENGL_VERSION_GL