A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
# ESEngine Tests
# doctest header-only framework
include_directories(${CMAKE_SOURCE_DIR}/third_party/doctest)
# Match the shipped WASM heap policy for every standalone harness. Deep
# hierarchy stress needs more than Emscripten's fixed default heap.
if(EMSCRIPTEN)
add_link_options(-sALLOW_MEMORY_GROWTH=1)
endif()
# ECS tests
add_executable(test_skeletal_batch_color renderer/test_skeletal_batch_color.cpp)
target_include_directories(test_skeletal_batch_color PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_test(NAME test_skeletal_batch_color COMMAND test_skeletal_batch_color)
add_executable(test_transform_traversal
ecs/test_transform_traversal.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_transform_traversal PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_transform_traversal COMMAND test_transform_traversal)
add_executable(test_ui_tree
ecs/test_ui_tree.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_ui_tree PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_ui_tree COMMAND test_ui_tree)
add_executable(test_tween_activity
ecs/test_tween_activity.cpp
${CMAKE_SOURCE_DIR}/src/esengine/animation/TweenSystem.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_tween_activity PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_tween_activity COMMAND test_tween_activity)
add_executable(test_springbone
springbone/test_springbone.cpp
${CMAKE_SOURCE_DIR}/src/esengine/springbone/SpringBoneSolver.cpp
${CMAKE_SOURCE_DIR}/src/esengine/springbone/SpringBoneSystem.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_springbone PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_springbone COMMAND test_springbone)
add_executable(test_entity_activity
ecs/test_entity_activity.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_entity_activity PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_entity_activity COMMAND test_entity_activity)
add_executable(test_hierarchy_links
ecs/test_hierarchy_links.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_hierarchy_links PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_hierarchy_links COMMAND test_hierarchy_links)
add_executable(test_ecs
ecs/test_registry.cpp
)
target_link_libraries(test_ecs PRIVATE esengine)
add_test(NAME test_ecs COMMAND test_ecs)
# Event system tests
add_executable(test_events
events/test_events.cpp
)
target_link_libraries(test_events PRIVATE esengine)
add_test(NAME test_events COMMAND test_events)
# Particle system tests
add_executable(test_particle
particle/test_particle.cpp
)
target_link_libraries(test_particle PRIVATE esengine)
add_test(NAME test_particle COMMAND test_particle)
# The native touch stream: header-only, so it builds without an NDK or an SDK and
# the ONE contract both mobile hosts feed is tested off-device (see
# native/host/platform/touch_stream.hpp).
add_executable(test_touch_stream
input/test_touch_stream.cpp
)
target_include_directories(test_touch_stream PRIVATE ${CMAKE_SOURCE_DIR}/native/host)
add_test(NAME test_touch_stream COMMAND test_touch_stream)
# The native hosts' frame pacer: header-only, the cap and the floor every looping
# host draws by (native/host/FramePacer.hpp).
add_executable(test_frame_pacer
input/test_frame_pacer.cpp
)
target_include_directories(test_frame_pacer PRIVATE ${CMAKE_SOURCE_DIR}/native/host)
add_test(NAME test_frame_pacer COMMAND test_frame_pacer)
# What a native host reads of game.config.json before any shader compiles.
add_executable(test_packaged_config
input/test_packaged_config.cpp
)
target_include_directories(test_packaged_config PRIVATE ${CMAKE_SOURCE_DIR}/native/host)
add_test(NAME test_packaged_config COMMAND test_packaged_config)
# The read-only mapping the native glyph rasterizer opens fonts through
# (native/host/media/mapped_file.hpp): header-only, so no host is needed.
add_executable(test_mapped_file
text/test_mapped_file.cpp
)
target_include_directories(test_mapped_file PRIVATE ${CMAKE_SOURCE_DIR}/native/host)
add_test(NAME test_mapped_file COMMAND test_mapped_file)
# The glyph SDF generator, byte for byte against the transform with no shortcuts.
add_executable(test_sdf_generator
text/test_sdf_generator.cpp
)
target_link_libraries(test_sdf_generator PRIVATE esengine)
add_test(NAME test_sdf_generator COMMAND test_sdf_generator)
# Tilemap system tests
add_executable(test_tilemap
tilemap/test_tilemap.cpp
)
target_link_libraries(test_tilemap PRIVATE esengine)
add_test(NAME test_tilemap COMMAND test_tilemap)
add_executable(test_tilemap_context
tilemap/test_tilemap_context.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
)
target_link_libraries(test_tilemap_context PRIVATE esengine)
if(EMSCRIPTEN)
# The context's WebGL overload pulls in GLDevice even though this harness
# initializes a mock device. Link its WebGL 2 symbols in both sanitizer modes.
target_link_options(test_tilemap_context PRIVATE -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2)
endif()
add_test(NAME test_tilemap_context COMMAND test_tilemap_context)
# AOT: compiled TypeScript against a real Registry. The .c is generated by
# @estella/compiler and checked in (compiler/tests/generated.test.ts keeps it
# fresh); this harness is what holds the generated OFFSETS against the C++
# structs they are claims about. Header-only ECS + Log.cpp, so it builds without
# linking esengine and therefore without emscripten.
# Both translation units: this host LINKS the artifact, so it reads the
# declaration table out of it. A wasm host loads the module into the engine's
# memory instead and must not compile that half — the table is a data section,
# and its bytes land where the engine already keeps its own.
add_executable(test_aot_host
aot/test_aot_host.cpp
aot/generated/move_system.c
aot/generated/move_system_decl.c
${CMAKE_SOURCE_DIR}/src/esengine/aot/AotComponents.generated.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_aot_host PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/esengine/aot
${CMAKE_SOURCE_DIR}/tests/aot
${CMAKE_SOURCE_DIR}/third_party/glm
)
# -ffp-contract=off is part of the contract, not a preference: a fused
# multiply-add is more accurate than the two roundings JS does, and more
# accurate is still a different number (compiler/src/codegen.ts CFLAGS).
target_compile_options(test_aot_host PRIVATE
$<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-ffp-contract=off>
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-ffp-contract=off>
$<$<CXX_COMPILER_ID:MSVC>:/fp:precise>
)
add_test(NAME test_aot_host COMMAND test_aot_host)
# The same compiled system as a LOADABLE module, which is the shape a native
# host takes. Built from the same two sources the harness links directly, so a
# difference between the two roads is the loading and nothing else.
#
# Native only, and that is the design rather than a limitation: loading is the
# road a host with dlopen takes, and the wasm road links the module into the
# engine's own memory and reads a manifest beside it (AotModule.hpp says so at
# the top). Emscripten turns a MODULE into a static archive, which no loader
# opens -- so leaving this on made every wasm run fail "the platform could not
# load it" for a file that was built exactly as asked. The harness gates its
# loading cases on the define, so dropping it here drops them with it;
# check-cpp-tests builds this target natively and is where they run.
if(NOT EMSCRIPTEN)
add_library(aot_move_system MODULE
aot/generated/move_system.c
aot/generated/move_system_decl.c
)
target_include_directories(aot_move_system PRIVATE
${CMAKE_SOURCE_DIR}/src/esengine/aot
${CMAKE_SOURCE_DIR}/tests/aot/generated
)
set_target_properties(aot_move_system PROPERTIES PREFIX "")
add_dependencies(test_aot_host aot_move_system)
# The path rather than a convention: where a MODULE lands differs by generator
# and by platform, and a harness guessing it reports "cannot load" for a file
# that was built perfectly.
target_compile_definitions(test_aot_host PRIVATE
ES_AOT_MODULE_PATH="$<TARGET_FILE:aot_move_system>"
)
endif()
# AOT: the same compiled TypeScript against the INTERPRETER's answer instead of
# against a twin loop written in C++. Both the C and the expected frames are
# generated by sdk/tests/aot-conformance.test.ts and checked in, which is what
# lets a C++ harness hold a JS closure's answer without running one.
#
# Its own generated directory, and NOT tests/aot/generated: the emitted C
# includes `estella_offsets.h` by that name and guards it by that name, so two
# fixtures sharing one include path would quietly take each other's offsets.
add_executable(test_aot_conformance
aot/test_aot_conformance.cpp
aot/generated/conformance/systems.c
aot/generated/conformance/systems_decl.c
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_aot_conformance PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/esengine/aot
${CMAKE_SOURCE_DIR}/tests/aot
${CMAKE_SOURCE_DIR}/tests/aot/generated/conformance
${CMAKE_SOURCE_DIR}/third_party/glm
)
# -ffp-contract=off is part of the contract, not a preference: a fused
# multiply-add is more accurate than the two roundings JS does, and more
# accurate is still a different number (compiler/src/codegen.ts CFLAGS).
target_compile_options(test_aot_conformance PRIVATE
$<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-ffp-contract=off>
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-ffp-contract=off>
$<$<CXX_COMPILER_ID:MSVC>:/fp:precise>
)
add_test(NAME test_aot_conformance COMMAND test_aot_conformance)
# SparseSet tests
add_executable(test_sparse_set
ecs/test_sparse_set.cpp
)
target_link_libraries(test_sparse_set PRIVATE esengine)
add_test(NAME test_sparse_set COMMAND test_sparse_set)
# View API matrix: instantiates every arity × entry point × callback shape
add_executable(test_view_api_matrix
ecs/test_view_api_matrix.cpp
)
target_link_libraries(test_view_api_matrix PRIVATE esengine)
add_test(NAME test_view_api_matrix COMMAND test_view_api_matrix)
# ResourcePool tests
add_executable(test_resource_pool
resource/test_resource_pool.cpp
)
target_link_libraries(test_resource_pool PRIVATE esengine)
add_test(NAME test_resource_pool COMMAND test_resource_pool)
# Shader-vs-device decoupling: compiles the converted Shader.cpp against a
# MockGfxDevice. Linking proves Shader contains no GL; asserts confirm it routes
# create/uniform/reflect/delete through GfxDevice.
add_executable(test_shader_device
renderer/test_shader_device.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Shader.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/draw/DrawParams.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_shader_device PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_shader_device COMMAND test_shader_device)
# DrawParams: the loose-uniform → std140 block rewriter + the Shader facade that
# routes setUniform writes into the params UBO seam (MockGfxDevice asserts no
# loose uploads for lifted members).
add_executable(test_draw_params
renderer/test_draw_params.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Shader.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/draw/DrawParams.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_draw_params PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_draw_params COMMAND test_draw_params)
# Per-draw uniform ranges: a frame of thousands of draws is a few pages, not a buffer each.
add_executable(test_per_draw_blocks
renderer/test_per_draw_blocks.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_per_draw_blocks PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_per_draw_blocks COMMAND test_per_draw_blocks)
# Which SpriteMask cuts a sprite — the reach rule, apart from a frame. Header-only.
add_executable(test_sprite_mask_range renderer/test_sprite_mask_range.cpp)
target_include_directories(test_sprite_mask_range PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_sprite_mask_range COMMAND test_sprite_mask_range)
add_executable(test_sprite_draw_mode renderer/test_sprite_draw_mode.cpp)
target_include_directories(test_sprite_draw_mode PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_sprite_draw_mode COMMAND test_sprite_draw_mode)
# The sort key's field layout, asserted on the bits. Header-only, so no engine link.
add_executable(test_sort_key renderer/test_sort_key.cpp)
target_include_directories(test_sort_key PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_sort_key COMMAND test_sort_key)
# A retained label's quads are clipped by the engine as the TS text culling clips them, quad for quad: the cases file is what that TS keeps on
# random batches (tools/gen-retained-text-cases.mjs). Header-only, so no engine link.
add_executable(test_retained_text renderer/test_retained_text.cpp)
target_include_directories(test_retained_text PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
# A wasm harness has an empty file system of its own: node's, from the repository root where the run is started, is what it must read the cases from.
if(EMSCRIPTEN)
target_link_options(test_retained_text PRIVATE -sNODERAWFS=1)
endif()
add_test(NAME test_retained_text COMMAND test_retained_text ${CMAKE_CURRENT_SOURCE_DIR}/renderer/data/retained_text_cases.txt)
# Clip-depth convention: the engine builds for [-1,1] and a device keeping [0,1]
# is handed the same projection in its terms. Header-only math, so no engine link.
add_executable(test_clip_depth renderer/test_clip_depth.cpp)
target_include_directories(test_clip_depth PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_clip_depth COMMAND test_clip_depth)
add_executable(test_planar_reflection renderer/test_planar_reflection.cpp)
target_include_directories(test_planar_reflection PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_planar_reflection COMMAND test_planar_reflection)
# Shadow atlas allocation. Header-only, and here rather than in a pixel gate for
# the arithmetic a frame cannot show: which square a claim hands out, and what a
# refused one leaves behind. Whether a light READS the square it was given is a
# pixel question, and point-shadow asks it.
# Emission shapes: the sampler is a pure function of the emitter's config, so the
# distributions are asked here rather than through a frame that could not show a
# bias along the view axis. Header-only — no engine to link.
add_executable(test_particle_shapes particle/test_particle_shapes.cpp)
target_include_directories(test_particle_shapes PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_particle_shapes COMMAND test_particle_shapes)
# Stretched billboards: where the quad turns and how long it grows. Header-only.
add_executable(test_particle_stretch particle/test_particle_stretch.cpp)
target_include_directories(test_particle_stretch PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_particle_stretch COMMAND test_particle_stretch)
# Particle speed limit: the braking arithmetic, and that it does not depend on the frame rate. Header-only.
add_executable(test_particle_speed_limit particle/test_particle_speed_limit.cpp)
target_include_directories(test_particle_speed_limit PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_particle_speed_limit COMMAND test_particle_speed_limit)
# Particle burst schedule: each burst fires once per pass of the clock, and a looping emitter passes every duration. Header-only.
add_executable(test_particle_bursts particle/test_particle_bursts.cpp)
target_include_directories(test_particle_bursts PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_particle_bursts COMMAND test_particle_bursts)
# LOD selection: the projection arithmetic, the hysteresis band and the per-view
# memory. Header-only, so it runs without a device — the pixel gates say which
# level was drawn, this says which of the claims behind it broke.
add_executable(test_lod_selection renderer/test_lod_selection.cpp)
target_include_directories(test_lod_selection PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_lod_selection COMMAND test_lod_selection)
add_executable(test_placement_bounds renderer/test_placement_bounds.cpp)
target_include_directories(test_placement_bounds PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_placement_bounds COMMAND test_placement_bounds)
# How a Billboard is turned to a view: the view plane, upright about world up, an orthographic view. Header-only.
add_executable(test_billboard_facing renderer/test_billboard_facing.cpp)
target_include_directories(test_billboard_facing PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_billboard_facing COMMAND test_billboard_facing)
# Which direction each picture of an impostor atlas is taken from, and which a view is shown. Header-only.
add_executable(test_impostor_frames renderer/test_impostor_frames.cpp)
target_include_directories(test_impostor_frames PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_impostor_frames COMMAND test_impostor_frames)
# How a view shades its meshes: Shaded unless it asked, and no entry left once it goes back.
add_executable(test_view_shading renderer/test_view_shading.cpp)
target_include_directories(test_view_shading PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_view_shading COMMAND test_view_shading)
# The edges a wireframe draws, from a triangle list. Header-only, so no device: a pixel gate says
# the lines came out wrong, this says whether an edge was doubled, dropped or split by a seam.
add_executable(test_mesh_edges resource/test_mesh_edges.cpp)
target_include_directories(test_mesh_edges PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_mesh_edges COMMAND test_mesh_edges)
# Which volume holds a point, and what it says there. Header-only, so it runs
# without a device — the pixel gates say a draw came out the wrong colour, this
# says whether the read left the box, took the wrong volume, or accepted a grid
# too short to fill it.
# What an occluder hides and what it must not. Header-only, so it runs without a
# device — and it runs every claim under BOTH depth conventions, which is the one
# thing a pixel gate on one backend cannot ask.
add_executable(test_occlusion_view renderer/test_occlusion_view.cpp)
target_include_directories(test_occlusion_view PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_occlusion_view COMMAND test_occlusion_view)
add_executable(test_probe_store renderer/test_probe_store.cpp)
target_include_directories(test_probe_store PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_probe_store COMMAND test_probe_store)
# Which screen tiles a light's sphere can reach (tiled forward lighting's CPU half). Header-only, so it runs without a device.
add_executable(test_tiled_lights renderer/test_tiled_lights.cpp)
target_include_directories(test_tiled_lights PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_tiled_lights COMMAND test_tiled_lights)
# The range of sprite layers a light reaches, and the lane it rides in. Header-only, so it runs without a device.
add_executable(test_light_layers renderer/test_light_layers.cpp)
target_include_directories(test_light_layers PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_light_layers COMMAND test_light_layers)
# Which channel of the 2D shadow mask each casting light draws into. Header-only, so it runs without a device.
add_executable(test_shadow_channels renderer/test_shadow_channels.cpp)
target_include_directories(test_shadow_channels PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_shadow_channels COMMAND test_shadow_channels)
# Which baked column a point reflects. Header-only, so it runs without a device —
# the pixel gate says a surface came out the wrong colour, this says whether the
# lookup took the wrong box or let two bakes into one frame.
add_executable(test_reflection_store renderer/test_reflection_store.cpp)
target_include_directories(test_reflection_store PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_reflection_store COMMAND test_reflection_store)
add_executable(test_shadow_atlas renderer/test_shadow_atlas.cpp)
target_include_directories(test_shadow_atlas PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_shadow_atlas COMMAND test_shadow_atlas)
add_executable(test_hdr_format renderer/test_hdr_format.cpp)
target_include_directories(test_hdr_format PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_hdr_format COMMAND test_hdr_format)
# Texture path cache: compiles ResourceManager.cpp against MockGfxDevice and asserts
# which requests avoided an upload. A shipped build decodes in the host and registers
# an id, so acquireTextureByPath is the only place that decision is made.
add_executable(test_texture_cache
resource/test_texture_cache.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/resource/ResourceManager.cpp
${CMAKE_SOURCE_DIR}/src/esengine/resource/ShaderParser.cpp
${CMAKE_SOURCE_DIR}/src/esengine/text/BitmapFont.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Shader.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Texture.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Buffer.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/draw/DrawParams.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_texture_cache PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/tests
${CMAKE_SOURCE_DIR}/third_party/glm
${CMAKE_SOURCE_DIR}/third_party/stb
)
add_test(NAME test_texture_cache COMMAND test_texture_cache)
# The real resource pool and material store against the same device boundary.
get_target_property(ES_TEXTURE_CACHE_SOURCES test_texture_cache SOURCES)
list(REMOVE_ITEM ES_TEXTURE_CACHE_SOURCES resource/test_texture_cache.cpp)
add_executable(test_material_shader_lifetime
resource/test_material_shader_lifetime.cpp
${ES_TEXTURE_CACHE_SOURCES}
${CMAKE_SOURCE_DIR}/src/esengine/renderer/store/MaterialStore.cpp
)
target_include_directories(test_material_shader_lifetime PRIVATE
${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests
${CMAKE_SOURCE_DIR}/third_party/glm ${CMAKE_SOURCE_DIR}/third_party/stb
)
add_test(NAME test_material_shader_lifetime COMMAND test_material_shader_lifetime)
# Persistent mesh identity across a device generation. Same shape as the texture
# cache harness: the REAL ResourceManager.cpp against MockGfxDevice, so what it
# asserts is the engine's invalidation and not a model of it.
add_executable(test_mesh_recovery
resource/test_mesh_recovery.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/resource/ResourceManager.cpp
${CMAKE_SOURCE_DIR}/src/esengine/resource/ShaderParser.cpp
${CMAKE_SOURCE_DIR}/src/esengine/text/BitmapFont.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Shader.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Texture.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Buffer.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/draw/DrawParams.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_mesh_recovery PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/tests
${CMAKE_SOURCE_DIR}/third_party/glm
${CMAKE_SOURCE_DIR}/third_party/stb
)
add_test(NAME test_mesh_recovery COMMAND test_mesh_recovery)
# Shader variant (feature-permutation) system (RC7-6). Compiles ShaderParser.cpp
# directly — no GL/engine link — and checks #pragma feature parsing + #define injection.
add_executable(test_shader_variant
renderer/test_shader_variant.cpp
${CMAKE_SOURCE_DIR}/src/esengine/resource/ShaderParser.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_shader_variant PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_test(NAME test_shader_variant COMMAND test_shader_variant)
add_executable(test_audio_watchdog native/test_audio_watchdog.cpp)
target_include_directories(test_audio_watchdog PRIVATE ${CMAKE_SOURCE_DIR}/native/host)
add_test(NAME test_audio_watchdog COMMAND test_audio_watchdog)
# Texture + Framebuffer decoupling: compiles the converted classes against a
# MockGfxDevice. The harness stubs the (uncalled) stb file loader.
add_executable(test_texture_fb
renderer/test_texture_fb.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Texture.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Framebuffer.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_texture_fb PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/stb
)
add_test(NAME test_texture_fb COMMAND test_texture_fb)
# RenderGraph: compiles the graph against a MockGfxDevice and asserts on the
# SEQUENCE of device calls — which target each pass opened, what it bound, and
# how many physical targets a chain actually costs.
add_executable(test_render_graph
renderer/test_render_graph.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/graph/RenderGraph.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/graph/TargetPool.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Texture.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Framebuffer.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_render_graph PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/stb
)
add_test(NAME test_render_graph COMMAND test_render_graph)
# Buffer + CustomGeometry decoupling: compiles the converted classes against a
# MockGfxDevice. Linking proves they contain no GL; asserts confirm create/
# upload/attribute-setup/bind/delete route through GfxDevice.
add_executable(test_buffer_device
renderer/test_buffer_device.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Buffer.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/draw/CustomGeometry.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_buffer_device PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_test(NAME test_buffer_device COMMAND test_buffer_device)
# The device's record tables and its pipeline index: header-only, so it links alone.
add_executable(test_record_table
renderer/test_record_table.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_record_table PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_test(NAME test_record_table COMMAND test_record_table)
# Device loss: the shared state machine (GfxDevice), driven through MockGfxDevice.
# Header-only, so nothing but Log.cpp is needed to link.
add_executable(test_device_loss
renderer/test_device_loss.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/Texture.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_device_loss PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_test(NAME test_device_loss COMMAND test_device_loss)
# WebGPU backend slice 1 (REARCH_WGSL Phase 2): the enum→WGPU mapping layer +
# the null-device-safe WebGPUDevice skeleton, compiled against the REAL Dawn C
# headers via the emdawnwebgpu port (emscripten-only; the port supplies
# <webgpu/webgpu.h> and its JS glue).
if(EMSCRIPTEN)
add_executable(test_webgpu_device
renderer/test_webgpu_device.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/webgpu/WebGPUDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_webgpu_device PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
target_compile_options(test_webgpu_device PRIVATE --use-port=emdawnwebgpu)
target_link_options(test_webgpu_device PRIVATE --use-port=emdawnwebgpu)
add_test(NAME test_webgpu_device COMMAND test_webgpu_device)
endif()
# WebGPU bring-up program (REARCH_WGSL Phase 2 slice 2): NOT a test harness — a
# browser-run wasm that renders the shape-shader WGSL twin through the real
# WebGPUDevice (surface pass + lazy pipeline + bind group + indexed draw). Driven
# by desktop/scripts/webgpu-bringup.mjs under electron, which asserts the pixels.
if(EMSCRIPTEN)
add_executable(webgpu_bringup
renderer/webgpu_bringup.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/webgpu/WebGPUDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
# The twins assemble from the embedded .esshaders (WGSL target).
${CMAKE_SOURCE_DIR}/src/esengine/resource/ShaderParser.cpp
)
target_include_directories(webgpu_bringup PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
target_compile_options(webgpu_bringup PRIVATE --use-port=emdawnwebgpu)
target_link_options(webgpu_bringup PRIVATE --use-port=emdawnwebgpu)
endif()
# WebGPU compute bring-up: a browser-run wasm that drives the compute half of the RHI through the real WebGPUDevice
# (storage buffers and textures, dispatch, readback) and prints what the GPU computed. Driven by
# desktop/scripts/webgpu-compute-bringup.mjs, which asserts it.
if(EMSCRIPTEN)
add_executable(webgpu_compute_bringup
renderer/webgpu_compute_bringup.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/webgpu/WebGPUDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(webgpu_compute_bringup PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
target_compile_options(webgpu_compute_bringup PRIVATE --use-port=emdawnwebgpu)
target_link_options(webgpu_compute_bringup PRIVATE --use-port=emdawnwebgpu)
endif()
# Engine-level backend parity harness (REARCH_WGSL Phase 2): the FULL engine —
# EstellaContext with every subsystem — booted on an injected backend (WebGPU
# via emdawnwebgpu, or the stock WebGL2 path, chosen by URL) rendering one ECS
# scene. Driven by desktop/scripts/engine-parity.mjs, which asserts the SAME
# pixels on both backends. WebGL2 link flags are required because the GL run
# uses the production GLES3 path.
if(EMSCRIPTEN)
add_executable(webgpu_engine_bringup
renderer/webgpu_engine_bringup.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/webgpu/WebGPUDevice.cpp
)
target_link_libraries(webgpu_engine_bringup PRIVATE esengine)
target_compile_options(webgpu_engine_bringup PRIVATE --use-port=emdawnwebgpu)
target_link_options(webgpu_engine_bringup PRIVATE
--use-port=emdawnwebgpu
-sUSE_WEBGL2=1
-sFULL_ES3=1
-sALLOW_MEMORY_GROWTH=1
)
endif()
# Boundary-span validation (RC3): JS-supplied pointer+length pairs are null-,
# overflow-, and heap-range-checked ALWAYS ON. Header-only + Log.cpp; under
# emscripten the heap-range cases exercise the real linear-memory bound.
add_executable(test_boundary_span
bindings/test_boundary_span.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_boundary_span PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_test(NAME test_boundary_span COMMAND test_boundary_span)
# Unified submission face (render-pipeline unification): BatchBuilder is the single
# DrawCommand producer for every stream. Compiles BatchBuilder/DrawList/
# TransientBufferPool against the MockGfxDevice and asserts per-stream baseVertex
# math, texture-slot rules, instanced assembly, merge behavior, and execute() dispatch.
#
# LINKED against the engine rather than compiled from a hand-listed set of its
# sources: that list said which units BatchBuilder needs, and stopped being true
# the day a material started resolving its texture through the ResourceManager —
# a link error, on every push, for as long as nobody read the C++ job's log.
add_executable(test_batch_builder
renderer/test_batch_builder.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
)
target_link_libraries(test_batch_builder PRIVATE esengine)
target_include_directories(test_batch_builder PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
# How many times a frame is closed, which the static gate cannot ask. The GL
# backends stub endFrame, so a second close is invisible on WebGL2 and shows up
# only as an empty WebGPU readback; this counts it on a mock device instead.
add_executable(test_frame_lifecycle
renderer/test_frame_lifecycle.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
)
target_link_libraries(test_frame_lifecycle PRIVATE esengine)
target_include_directories(test_frame_lifecycle PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_frame_lifecycle COMMAND test_frame_lifecycle)
add_test(NAME test_batch_builder COMMAND test_batch_builder)
# GfxDevice compressed-texture entry (RC6-A). Header-only: drives MockGfxDevice to
# assert the compressed upload + capability-gated RGBA8 fallback. No GL, no emsdk.
add_executable(test_compressed_format
renderer/test_compressed_format.cpp
${CMAKE_SOURCE_DIR}/src/esengine/renderer/rhi/GfxDevice.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_compressed_format PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_test(NAME test_compressed_format COMMAND test_compressed_format)
# Log format-string precision parsing (Audit A1). Only needs Log.cpp.
# Should be compiled with exceptions OFF to mirror the engine's release config:
# proves malformed float specs like "{:.f}" no longer abort (the old std::stoi
# path threw -> abort under -fno-exceptions).
add_executable(test_log_format
core/test_log_format.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_log_format PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_compile_options(test_log_format PRIVATE -fno-exceptions)
add_test(NAME test_log_format COMMAND test_log_format)
# Registry/SparseSet release-safety (Audit A6 + A7). Header-only against
# Registry.hpp + Log.cpp (no esengine link). MUST stay free of -DES_DEBUG so
# ES_ASSERT is stripped, matching the release config where the OOB read
# (get on a non-member) and entity_count underflow (re-entrant destroy) appear.
add_executable(test_registry_safety
ecs/test_registry_safety.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_registry_safety PRIVATE ${CMAKE_SOURCE_DIR}/src)
# Run under AddressSanitizer: the bugs this guards (emplace-on-invalid OOB write,
# over-range index alias) are memory-safety faults that only ASAN catches
# deterministically. Skipped on MSVC (different sanitizer flag syntax).
set(_es_safety_asan $<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>)
target_compile_options(test_registry_safety PRIVATE $<${_es_safety_asan}:-fsanitize=address>)
target_link_options(test_registry_safety PRIVATE $<${_es_safety_asan}:-fsanitize=address>)
add_test(NAME test_registry_safety COMMAND test_registry_safety)
# Change stamps: a write is seen once by the reader that looked before it, a stamp moves with its component, and the audit
# finds a write that left none. Header-only against Registry.hpp.
add_executable(test_change_stamps
ecs/test_change_stamps.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_change_stamps PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_test(NAME test_change_stamps COMMAND test_change_stamps)
# onDestroy RAII Connection / dual-order teardown safety (RC12 B1, fixes A12).
# Built with AddressSanitizer so the use-after-free the old bare-`this` callback
# caused (in either teardown order) is actually caught, not just "didn't crash".
add_executable(test_registry_ondestroy
ecs/test_registry_ondestroy.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_registry_ondestroy PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm)
target_compile_options(test_registry_ondestroy PRIVATE $<${_es_safety_asan}:-fsanitize=address>)
target_link_options(test_registry_ondestroy PRIVATE $<${_es_safety_asan}:-fsanitize=address>)
add_test(NAME test_registry_ondestroy COMMAND test_registry_ondestroy)
# Physics render interpolation. The snapshot pair and the lerp live in the physics
# module, not the SDK: they touch every dynamic body every frame, which the no-JIT
# budget keeps off the JS path (docs/REARCH_NATIVE.md §3.2). The whole module is
# compiled in because its entry TU calls into the shape/joint/query ones.
if(ES_ENABLE_BOX2D)
add_executable(test_physics_interpolation
bindings/test_physics_interpolation.cpp
${CMAKE_SOURCE_DIR}/src/esengine/bindings/modules/physics/PhysicsModuleEntry.cpp
${CMAKE_SOURCE_DIR}/src/esengine/bindings/modules/physics/PhysicsReadback.cpp
${CMAKE_SOURCE_DIR}/src/esengine/bindings/modules/physics/PhysicsContext.cpp
${CMAKE_SOURCE_DIR}/src/esengine/bindings/modules/physics/PhysicsShapes.cpp
${CMAKE_SOURCE_DIR}/src/esengine/bindings/modules/physics/PhysicsJoints.cpp
${CMAKE_SOURCE_DIR}/src/esengine/bindings/modules/physics/PhysicsQueries.cpp
${CMAKE_SOURCE_DIR}/src/esengine/bindings/modules/physics/PhysicsTaskPool.cpp
)
target_link_libraries(test_physics_interpolation PRIVATE box2d)
target_include_directories(test_physics_interpolation PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/box2d/include
)
add_test(NAME test_physics_interpolation COMMAND test_physics_interpolation)
endif()
# The bitmap-font atlas guard. Compiled in rather than linked, like the shader
# harnesses: BitmapFont's only tie to the resource stack is a loader this never
# calls, and the harness stubs those two symbols itself.
add_executable(test_bitmap_font
text/test_bitmap_font.cpp
${CMAKE_SOURCE_DIR}/src/esengine/text/BitmapFont.cpp
${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp
)
target_include_directories(test_bitmap_font PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
add_test(NAME test_bitmap_font COMMAND test_bitmap_font)
# The desktop text-editing model. It lives in the native host rather than in the
# engine, and it is compiled in directly (not linked) because the host is not a
# library — which is fine, since the model is pure by construction: no SDL, no
# host state, so the rules are testable as what they are.
add_executable(test_text_edit
text/test_text_edit.cpp
${CMAKE_SOURCE_DIR}/native/host/media/text_edit.cpp
)
target_include_directories(test_text_edit PRIVATE ${CMAKE_SOURCE_DIR}/native/host)
add_test(NAME test_text_edit COMMAND test_text_edit)