mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
Iris-style packs hand MobileGL the same source text repeatedly: probed across three shaderpack traces, 28-32% of all glCompileShader work was redundant - ~9% same-object recompiles with byte-identical source, ~21% distinct shader objects sharing identical source (the same common GLSL chunk glued into many program stages). Two layers, both keyed by XXH64 + length with a full byte compare on every hit (correctness never rides on the hash): - Per-object: a successful (or failed) compile remembers its source hash; glShaderSource with byte-identical text keeps the compiled state and glCompileShader on unchanged source returns immediately. Deterministic (stage, source) pipeline makes the memo observationally identical to recompiling; the consume-once TakeShaderForLink re-parse path is untouched. - Cross-object: a per-context bounded cache (ProgramState-owned, declared to outlive every shader object) shares the preprocessed source, both explicit side-channel maps, and the validation verdicts between objects with equal source; only the glslang parse stays per-object. Single-GL-thread today; flagged for a mutex when compiles go async (P1). Interleaved A/B on the iterationrp trace (the recompile-heavy pack): 5.65s -> 5.46s median total replay, every round faster; BSL/complementary stay flat (their duplicate sources are the small common shaders, so calls drop but wall time is parse-bound on unique sources). Full DirectGLES retrace, 445-test unit suite, and dedupe-semantics tests (no-op recompile, invalidation on new source, failed-compile memo, cache bounds) all green.
45 lines
1.2 KiB
CMake
45 lines
1.2 KiB
CMake
cmake_minimum_required(VERSION 3.24)
|
|
|
|
add_executable(
|
|
ProgramUtilTest
|
|
ProgramUtilTest.cpp
|
|
|
|
${MGL_ROOT}/MobileGL/MG_Util/Converters/GLToStr/GLEnumConverter.cpp
|
|
${MGL_ROOT}/MobileGL/MG_Util/Converters/GLToGlslang/ProgramEnumConverter.cpp
|
|
${MGL_ROOT}/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp
|
|
${MGL_ROOT}/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp
|
|
${MGL_ROOT}/MobileGL/MG_Util/ShaderTranspiler/glslang/UniformTraverser.cpp
|
|
${MGL_ROOT}/MobileGL/MG_State/GLState/ProgramState/ShaderPreprocessCache.cpp
|
|
)
|
|
|
|
target_include_directories(ProgramUtilTest PRIVATE
|
|
${MGL_ROOT}/include
|
|
${MGL_ROOT}/MobileGL
|
|
)
|
|
|
|
target_link_libraries(
|
|
ProgramUtilTest
|
|
GTest::gtest_main
|
|
${LINK_LIBRARIES}
|
|
)
|
|
|
|
add_executable(
|
|
ProgramTest
|
|
ProgramTest.cpp
|
|
)
|
|
|
|
target_include_directories(ProgramTest PRIVATE
|
|
${MGL_ROOT}/include
|
|
${MGL_ROOT}/MobileGL
|
|
)
|
|
|
|
target_link_libraries(
|
|
ProgramTest PRIVATE
|
|
GTest::gtest_main
|
|
${LINK_LIBRARIES}
|
|
)
|
|
|
|
include(GoogleTest)
|
|
gtest_discover_tests(ProgramUtilTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
|
gtest_discover_tests(ProgramTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|