mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
Implements GL timer queries end to end: a frontend query registry (modeled on the sync module - mutex-guarded objects wrapping opaque backend handles behind optional function pointers) serving glGenQueries/glBeginQuery/glEndQuery(GL_TIME_ELAPSED)/glQueryCounter (GL_TIMESTAMP)/glGetQueryObject*/glGetQueryiv with GL 3.3 error semantics and a graceful zero-result fallback when a backend cannot time. DirectGLES backs spans with GL_EXT_disjoint_timer_query (context- generation-stamped handles, bounded result waits). DirectVulkan gets a VkTimerQueryManager: per-frame-in-flight timestamp query pools reset at command-buffer begin (outside render passes), records harvested by frame serial before their pool recycles, elapsed = masked tick delta x timestampPeriod; handles are stamped with a renderer generation that also now guards fence syncs across renderer recreation. GL_QUERY_ COUNTER_BITS reports 0 unless the live backend can actually time (dynamic IsTimerQuerySupported hook), and a failed blocking read keeps the handle alive so the real value stays reachable once the frame submits. GL_ARB_timer_query is advertised only when the device supports timing and MOBILEGL_DISABLE_TIMERQUERY is unset - LWJGL keys Minecraft's F3 'GPU: x%' line off exactly that extension string; verified on device (Adreno 830) on both backends. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
78 lines
1.8 KiB
CMake
78 lines
1.8 KiB
CMake
cmake_minimum_required(VERSION 3.24)
|
|
project(MobileGLTest)
|
|
|
|
message(STATUS "Generating build files for MobileGL Test...")
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(MGL_ROOT ${CMAKE_CURRENT_LIST_DIR}/../..)
|
|
|
|
# # Add the directory containing our custom Find modules
|
|
# list(APPEND CMAKE_MODULE_PATH "${MGL_ROOT}/buildsystem/cmake")
|
|
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
googletest
|
|
GIT_REPOSITORY https://github.com/google/googletest.git
|
|
GIT_TAG v1.17.0
|
|
)
|
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
FetchContent_MakeAvailable(googletest)
|
|
|
|
enable_testing()
|
|
|
|
# # Find the required libraries using our custom Find modules
|
|
# find_package(glslang REQUIRED)
|
|
# find_package(SPIRVCross REQUIRED)
|
|
# find_package(SPIRVTools)
|
|
|
|
add_executable(
|
|
SanityTest
|
|
SanityTest.cpp
|
|
)
|
|
target_link_libraries(
|
|
SanityTest
|
|
GTest::gtest_main
|
|
MobileGL_s
|
|
)
|
|
|
|
target_include_directories(SanityTest PRIVATE
|
|
${MGL_ROOT}/include
|
|
${MGL_ROOT}/MobileGL
|
|
)
|
|
|
|
# message(STATUS "glslang_LIBRARIES: ${glslang_LIBRARIES}")
|
|
# message(STATUS "SPIRVTools_LIBRARIES: ${SPIRVTools_LIBRARIES}")
|
|
# message(STATUS "SPIRVCross_LIBRARIES: ${SPIRVCross_LIBRARIES}")
|
|
|
|
# # Set the libraries to link against
|
|
# set(LINK_LIBRARIES
|
|
# ${glslang_LIBRARIES}
|
|
# ${SPIRVCross_LIBRARIES}
|
|
# )
|
|
|
|
# if (SPIRVTools_FOUND)
|
|
# list(APPEND LINK_LIBRARIES ${SPIRVTools_LIBRARIES})
|
|
# endif()
|
|
|
|
set(LINK_LIBRARIES
|
|
MobileGL_s
|
|
)
|
|
|
|
include(GoogleTest)
|
|
gtest_discover_tests(SanityTest DISCOVERY_TIMEOUT 30)
|
|
|
|
add_subdirectory(BackendLoader)
|
|
add_subdirectory(Buffer)
|
|
add_subdirectory(EGLState)
|
|
add_subdirectory(Framebuffer)
|
|
add_subdirectory(Texture)
|
|
add_subdirectory(VertexArray)
|
|
add_subdirectory(Program)
|
|
add_subdirectory(Query)
|
|
if (ENABLE_INTEGRATION_TESTS)
|
|
add_subdirectory(Backend/DirectVulkan)
|
|
endif()
|