Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
235 commits
Select commit Hold shift + click to select a range
b6ba0f5
Update clang-format so clang-21 works
yohjimane Sep 22, 2025
def52a3
Cmake for windows can load in vs2022
yohjimane Sep 22, 2025
26298cb
23/29 building with cmake on windows
yohjimane Sep 23, 2025
1b3f013
More work on windows cmake build
yohjimane Sep 23, 2025
5050cc3
linux works again, windows 27/30
yohjimane Sep 23, 2025
e45badf
cmake for windows builds successfully
yohjimane Sep 23, 2025
0885d0c
Cmake for windows - final commit
yohjimane Sep 23, 2025
74003c5
address some PR comments
yohjimane Sep 23, 2025
3e557db
Don't set CMAKE_DEFAULT_BUILD_TYPE for visual studio
yohjimane Sep 23, 2025
e61183b
Fix cmake for windows release master gold
yohjimane Sep 23, 2025
ef7ba28
feat(xrAnimation): Initial module setup and build system integration
yohjimane Jul 11, 2025
5d76f47
feat(xrAnimation): Add animation conversion infrastructure
yohjimane Jul 11, 2025
b8b78a7
feat(xrAnimation): Implement ozz-animation runtime system
yohjimane Jul 11, 2025
5f6f09b
feat(xrAnimation): Add documentation and test infrastructure
yohjimane Jul 11, 2025
307f169
feat(xrAnimation): Complete Phase 1 ozz-animation integration
yohjimane Jul 11, 2025
0dd0e9e
feat(xrAnimation): Add test infrastructure and build configuration
yohjimane Jul 11, 2025
a4a067d
build: Add ozz-animation as git submodule
yohjimane Jul 11, 2025
0ec5203
refactor: Replace STL types with X-Ray equivalents in xrAnimation
yohjimane Jul 11, 2025
6e676a5
Implement OGF/OMF to ozz-animation converters
yohjimane Jul 11, 2025
153b596
fix: Implement SBoneShape validity check in OGF converter to fix skel…
yohjimane Jul 12, 2025
f135297
fix: Critical animation playback and skeleton orientation fixes
yohjimane Jul 13, 2025
0eb182f
[xrAnimation] Add ozz_animation_viewer
yohjimane Jul 13, 2025
2d32594
[xrAnimation] support multiple anims in one .ozz file
yohjimane Jul 13, 2025
18b9db6
tmp commit bc housefire
yohjimane Sep 17, 2025
3cccac6
fix cmake, add scripts, codex stuff
yohjimane Sep 18, 2025
15a6fc2
Fresh start
yohjimane Sep 18, 2025
05ab1db
checkpoint 1 - bind pose matches
yohjimane Sep 18, 2025
a379e14
checkpoint 2 - cmake fixes
yohjimane Sep 18, 2025
9ef8022
fix vs build
yohjimane Sep 18, 2025
5e25499
add initial tests
yohjimane Sep 19, 2025
541b683
checkpoint - animation converted, almost matches source of truth
yohjimane Sep 19, 2025
5fad365
Prep for some tests
yohjimane Sep 19, 2025
f7c7723
Add bone logging
yohjimane Sep 19, 2025
be2d238
Add bind pose toggle to ozz animation viewer
yohjimane Sep 19, 2025
6dbf35f
Add test for multi motion conversion
yohjimane Sep 19, 2025
401ba3f
Multi motion conversion and ui in ozz_animation_viewer
yohjimane Sep 20, 2025
2f10d82
Prevent skeleton from appearing incorrectly in viewer
yohjimane Sep 20, 2025
f56218f
Cleanup
yohjimane Sep 20, 2025
e8acc66
add script into tools folder
yohjimane Sep 20, 2025
1d25cfb
add test for ozz mesh generation
yohjimane Sep 20, 2025
dbb7c9e
update helper script, continue work on mesh tests
yohjimane Sep 20, 2025
d9e3ac9
begin work on vertex test
yohjimane Sep 20, 2025
4bdc19b
more work on vertex/skinning test
yohjimane Sep 20, 2025
43553cf
chkpoint
yohjimane Sep 21, 2025
7d5e6fa
checkpoint 2
yohjimane Sep 21, 2025
b2ed144
checkpoint 3 - separate meshes in one ozz file
yohjimane Sep 21, 2025
dafe51c
More tests
yohjimane Sep 21, 2025
de41e66
Revert deduping faces bc ogf viewer doesnt do that
yohjimane Sep 21, 2025
59f47f0
Textures working
yohjimane Sep 21, 2025
448426f
Add timers
yohjimane Sep 21, 2025
2d92065
Remove redundant script, rename npc asset and move to npc path
yohjimane Sep 21, 2025
dd2dd9f
Add scripts and assets for arms, weapon, monster, gunsl arms, gunsl w…
yohjimane Sep 21, 2025
3d88777
Refactor ozz animation viewer to use actual dearimgui lib
yohjimane Sep 21, 2025
7113e52
Wire up gtest, begin ozzkinematics tdd
yohjimane Sep 21, 2025
0de51c9
Set up bind pose test
yohjimane Sep 21, 2025
580e9bd
Bind pose test passes
yohjimane Sep 21, 2025
69b947f
setup animation parity test
yohjimane Sep 21, 2025
73b6285
animation parity test passes
yohjimane Sep 21, 2025
b816373
animation parity test checks all bones
yohjimane Sep 21, 2025
f4e63e4
cleanup
yohjimane Sep 21, 2025
7309836
add bundled .ozz mesh/skeleton test
yohjimane Sep 21, 2025
9965141
first pass at bundling
yohjimane Sep 21, 2025
b9cad7b
remove unnecessary json dump feature
yohjimane Sep 22, 2025
3fbaa7f
Update docs, expand ozzkinematics class
yohjimane Sep 22, 2025
9d51f8c
Add skeleton initialization from ozz buffer test
yohjimane Sep 22, 2025
329511d
moar tests, add root level agents.md
yohjimane Sep 22, 2025
f13fef1
Add more parity tests
yohjimane Sep 22, 2025
f21b09b
Begin wiring ozzx/ozz into engine
yohjimane Sep 22, 2025
54b58e5
more work hooking OzzKinematics into engine
yohjimane Sep 22, 2025
e222416
more work hooking OzzKinematics into engine - part 2
yohjimane Sep 22, 2025
e88c186
Refactor to use engine types
yohjimane Sep 22, 2025
0d4596e
hook into dsgraph, update docs
yohjimane Sep 22, 2025
eaf8ea0
add bundle regression test, more documentation, more work to wire int…
yohjimane Sep 22, 2025
2cace4b
Preserve .ozzx visuals through model_Create
yohjimane Sep 22, 2025
28f2bb3
More work on integrating ozzkinematics
yohjimane Sep 22, 2025
b7a1386
Fix cmake build on linux
yohjimane Sep 23, 2025
7df679f
Fix windows cmake build
yohjimane Sep 24, 2025
6bd4a28
Fix windows mixed cmake build
yohjimane Sep 24, 2025
5b33444
Fix mixed build on linux
yohjimane Sep 24, 2025
41c5059
fix windows mixed build (again)
yohjimane Sep 24, 2025
ef4fb97
Fix vs build pt1
yohjimane Sep 24, 2025
add9488
Fix vs2022 build
yohjimane Sep 24, 2025
5b455f3
Work to support playing ozz anim files
yohjimane Sep 24, 2025
fbb8195
Update scripts to run for linux and windows
yohjimane Sep 24, 2025
0b06568
tmp
yohjimane Sep 24, 2025
538ecbc
tmp2
yohjimane Sep 24, 2025
16ae981
tmp3 - build works again
yohjimane Sep 24, 2025
1dfd59c
xrAnimation: cover skeleton conversion output location
yohjimane Sep 24, 2025
7374e95
Auto convert animations on loading ozzx, ozzx contains motion refs now
yohjimane Sep 24, 2025
4a2e932
Visual studio build fixed
yohjimane Sep 24, 2025
62e247e
Fix vertex buffer issue
yohjimane Sep 25, 2025
395ba64
tmp
yohjimane Sep 25, 2025
fcce486
tmp2
yohjimane Sep 25, 2025
d8dbc84
tmp
yohjimane Sep 26, 2025
76273e1
tmp
yohjimane Sep 27, 2025
836a307
no more box bug
yohjimane Sep 27, 2025
4ff57b0
TPOSE WORKS
yohjimane Sep 27, 2025
6d3e002
tmp - animation almost playing
yohjimane Sep 27, 2025
a8ffee7
tmp
yohjimane Sep 28, 2025
b89ce8f
Cleanup
yohjimane Sep 28, 2025
190007f
tmp
yohjimane Sep 28, 2025
b1da70b
enable palette dumping for ogf, add rs_skeleton_force_bind_pose command
yohjimane Sep 28, 2025
a38c65b
tmp2
yohjimane Sep 28, 2025
3f6c0a6
Exact parity between engine and ozz_animation_viewer
yohjimane Sep 29, 2025
ffb2551
Animation can play successfully in engine :)
yohjimane Sep 29, 2025
b72bc8c
Fix mirroring
yohjimane Sep 29, 2025
452d1b2
Port vertex fix from ogf viewer
yohjimane Sep 30, 2025
eb3dbea
Add vertex inspector
yohjimane Sep 30, 2025
36763a9
Triangle inspector
yohjimane Sep 30, 2025
bfe09f8
Triangle visualization
yohjimane Sep 30, 2025
06a6931
More debug stuff in ozz viewer
yohjimane Sep 30, 2025
35f37c4
accurate raypick
yohjimane Sep 30, 2025
5cb6e97
Vert data in triangle inspector
yohjimane Sep 30, 2025
e0dcc1c
Track original/remap indexes on vertices
yohjimane Sep 30, 2025
962859f
Remove vertex remapping logic
yohjimane Sep 30, 2025
1a9616c
account for OGF_SWIDATA, progressive window
yohjimane Oct 1, 2025
0896f79
Fix final bug
yohjimane Oct 1, 2025
2788954
Fix tests, remove blender test
yohjimane Oct 1, 2025
6fae4cd
Refactor tests
yohjimane Oct 1, 2025
dbaf16c
Doc next steps
yohjimane Oct 1, 2025
5db7b52
Progress on steps 1, 2 and IK
yohjimane Oct 1, 2025
68816c4
remove deprecated code in xray_to_ozz_converter
yohjimane Oct 1, 2025
37c8cd0
StartupConversionInventory progress
yohjimane Oct 1, 2025
ed2b92f
Fix bugs with previous commit on windows
yohjimane Oct 1, 2025
333d05a
Convert assets to ozzx/ozz during loading phase POC works
yohjimane Oct 1, 2025
ae0962a
Refactor OzzKinematicsVisual a bit
yohjimane Oct 2, 2025
1de3a83
Fix anims saved under wrong dir
yohjimane Oct 2, 2025
dc26163
Tmp1 anim support
yohjimane Oct 2, 2025
d740532
Loading test level success
yohjimane Oct 2, 2025
27baa01
Add disable for triangle debugger in ozz_animation_viewer
yohjimane Oct 2, 2025
f4fa8a8
Fix UV bug
yohjimane Oct 2, 2025
a661c67
Cleanup OzzKinematics
yohjimane Oct 2, 2025
a37a4db
Tmp implement LL_PlayCycle
yohjimane Oct 2, 2025
d1e4421
Fix physics box crash
yohjimane Oct 2, 2025
ee42884
Fix vs2022 build
yohjimane Oct 2, 2025
51dd36b
cleanup pt1
yohjimane Oct 2, 2025
8a0e0f8
cleanup pt2
yohjimane Oct 2, 2025
c436352
Tmp3
yohjimane Oct 2, 2025
364b682
Tmp4 add bone motions
yohjimane Oct 2, 2025
c9187b3
Fix anim playback
yohjimane Oct 3, 2025
9727b66
Passing bone motions along with other data now in .ozz/.ozzx
yohjimane Oct 3, 2025
00c813e
Try rebuilding model pool on initial load
yohjimane Oct 3, 2025
8d5ed4a
Handle legacy ogf
yohjimane Oct 3, 2025
3d98e25
Reloading modelpool to load ozz assets on initial load
yohjimane Oct 3, 2025
1ce0702
Fix grenade crash due to incorrect chunk parsing
yohjimane Oct 4, 2025
a9d119e
fix crash1
yohjimane Oct 4, 2025
a9660b2
Create embedded motions and motion
yohjimane Oct 6, 2025
dad7c11
tmp
yohjimane Oct 6, 2025
de103a6
Boot into full game on mixed build
yohjimane Oct 6, 2025
7a9bda5
slightly more stable?
yohjimane Oct 6, 2025
72e635d
Working on stability + luajit debugging
yohjimane Oct 7, 2025
e15ada0
fix lighting issues
yohjimane Oct 7, 2025
eebdfe6
Fix making motions when unnecessary
yohjimane Oct 7, 2025
57a26ff
update animation viewer to see embedded anims
yohjimane Oct 7, 2025
eeb388b
Refactoring OzzKinematics -> OzzKinematicsCore, OzzKinematics, OzzKin…
yohjimane Oct 7, 2025
a23b61d
Refactoring OzzKinematics -> OzzKinematicsCore, OzzKinematics, OzzKin…
yohjimane Oct 7, 2025
6e18790
fix bug1
yohjimane Oct 7, 2025
f205dda
Enable smart_cast on debug build
yohjimane Oct 7, 2025
2639fbc
Fix comparator crash in r__dsgraph_render
yohjimane Oct 8, 2025
bc9f138
Fix iterator crash in ui_focus.cpp
yohjimane Oct 8, 2025
cbe88e3
Remove OzzAnimationController, refactor related logic
yohjimane Oct 8, 2025
9a0c967
Fix use after free memory issues
yohjimane Oct 8, 2025
9768727
Some cleanup
yohjimane Oct 8, 2025
8a4dd0e
Revert "Enable smart_cast on debug build"
yohjimane Oct 8, 2025
53fa6b9
Fix engine build and casting issues
yohjimane Oct 8, 2025
709f7de
HUGE refactor because ozz stuff is composition, not inheritance
yohjimane Oct 8, 2025
724c125
missed some Visual() dcast conversions
yohjimane Oct 8, 2025
216bc48
Refactor plan
yohjimane Oct 8, 2025
cf3e28e
Refactor plan pt2
yohjimane Oct 8, 2025
afb864f
Implement Ozz Motion Container + fix some missed Visual dcasts
yohjimane Oct 9, 2025
b8c18c1
Fix embedded animations not being loaded
yohjimane Oct 9, 2025
a8dc11e
Fixing some issues pt1
yohjimane Oct 9, 2025
15338b5
Cleanup comments and debug logs
yohjimane Oct 9, 2025
3bea533
Fix crashes due to missing Visual dcast_pkinematics/animated
yohjimane Oct 9, 2025
892d9cf
Reenable full asset conversion on initial launch
yohjimane Oct 9, 2025
466e420
fix player hud crash
yohjimane Oct 9, 2025
258c21d
Parallel ogf->ozzx conversion
yohjimane Oct 9, 2025
42fb011
Parallel per-anim omf conversion
yohjimane Oct 9, 2025
e4eb744
add performance logging
yohjimane Oct 9, 2025
ccaaadf
Introduce ECS/ENTT to OzzKinematicsAnimated
yohjimane Oct 9, 2025
213348f
tmp
yohjimane Oct 9, 2025
03e9a39
fix vs2022 release master gold build
yohjimane Oct 9, 2025
ae72fc8
Begin porting xray_animation_viewer utilities to imgui ingame, fix ho…
yohjimane Oct 9, 2025
3a65c4c
Add ozz animation updates
yohjimane Oct 9, 2025
b1dbf40
Fix ik arm slightly
yohjimane Oct 9, 2025
c8bb8ac
ECS IK integration pt1
yohjimane Oct 10, 2025
a1bf559
ECS IK integration pt2
yohjimane Oct 10, 2025
3c97990
Finishing hooking up ECS to ozz_animation_viewer; add multi instance …
yohjimane Oct 10, 2025
9538b69
Lightweight vulkan implementation for ozz_animation_viewer
yohjimane Oct 10, 2025
d15a58d
Camera controller, skeleton shaders, draw triangle
yohjimane Oct 10, 2025
6af378f
fix capitalization of include
yohjimane Oct 10, 2025
e00529c
Triangle render works
yohjimane Oct 10, 2025
dc5a6b6
Rendering skeleton
yohjimane Oct 10, 2025
461f4b0
Imgui launches
yohjimane Oct 10, 2025
6e9483d
Fix Vulkan palette indexing and converter filesystem setup
yohjimane Oct 10, 2025
5c3aba2
Animations work for some meshes, add animation ui to imgui
yohjimane Oct 10, 2025
b037248
Add renderer files
yohjimane Oct 10, 2025
35af442
Fix full build on linux
yohjimane Oct 10, 2025
7a8004f
Fix palette merge for multi-mesh ozzx bundles
yohjimane Oct 10, 2025
02eae8c
Progress on animations, bone debugging
yohjimane Oct 10, 2025
2835e49
Almost fixed everything...
yohjimane Oct 10, 2025
bb513a3
debugging depth issues
yohjimane Oct 11, 2025
0f00c3f
Add shaded bone shaders
yohjimane Oct 11, 2025
6e6e34c
Fix scripts
yohjimane Oct 12, 2025
e3d3624
???
yohjimane Oct 12, 2025
0a82ad0
Vulkan renderer works on windows vs2022 build now
yohjimane Oct 12, 2025
19ac9d6
Vulkan modernization
yohjimane Oct 12, 2025
5a5a8ac
Fix depth bug
yohjimane Oct 13, 2025
0ce1bd5
Integrate ECS back again
yohjimane Oct 13, 2025
fded9f2
ECS pt2
yohjimane Oct 13, 2025
19bb020
Fair test case for ecs vs non-ecs
yohjimane Oct 13, 2025
dd56028
Fix linux build
yohjimane Oct 13, 2025
242de11
remove ssbo debugging
yohjimane Oct 13, 2025
edfc860
[xrAnimation] Consolidate documentation into organized structure
yohjimane Oct 13, 2025
51095b3
Remove missed doc (moved to src/xrAnimation/docs)
yohjimane Oct 13, 2025
639a13f
[xrAnimation] Add IK panel to ozz_animation_viewer with multi-limb su…
yohjimane Oct 13, 2025
15f9537
IK working on all 4 limbs
yohjimane Oct 13, 2025
4a2ca3b
Some cleanup
yohjimane Oct 13, 2025
b501436
tmp
yohjimane Oct 13, 2025
c7c5f07
[xrAnimation] Add ECS debug rendering refactoring plan
yohjimane Oct 13, 2025
d4ef0e5
[xrAnimation] Implement ECS debug rendering (Phases 1-3)
yohjimane Oct 13, 2025
6f27ce1
[xrAnimation] Implement IDebugDrawContext in VulkanRenderer (Phase 4)
yohjimane Oct 13, 2025
1eb0d44
ECS debug rendering refactor
yohjimane Oct 13, 2025
9d6f678
[xrAnimation] Implement true GPU instancing for bone rendering
yohjimane Oct 14, 2025
c047d9e
Implement GPU instancing for skinned meshes
yohjimane Oct 14, 2025
629f400
Fix stuck hud
yohjimane Oct 14, 2025
f66a67d
Add arms debugging to ozz animation utility
yohjimane Oct 14, 2025
c54c3df
Begin work on integrating compute shaders
yohjimane Oct 10, 2025
751b232
Add docs
yohjimane Oct 14, 2025
869ba4d
Cleanup some inconsistent ID3D types
yohjimane Oct 15, 2025
c47efb4
Fix build issues
yohjimane Oct 15, 2025
2b192c1
Fix constant buffer parser to handle structs, uints, and UAV/SRV buffers
yohjimane Oct 15, 2025
4b8873d
Fix stuck arms
yohjimane Oct 15, 2025
19ec375
Add simd and matrix tests
yohjimane Oct 15, 2025
b97914c
Merge branch 'yohji/feat/computeshaders' into revolution
yohjimane Oct 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

# Omit scripts to avoid messing up line endings
*.sh text eol=lf
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@

# exclude doxygen output
doc/doxygen/html/*

# exclude ozz_utils folder
ozz_utils/*
src/intermediate/*
intermediate/*
src/xrAnimation/tests/testdata/*
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@
[submodule "Externals/sse2rvv"]
path = Externals/sse2rvv
url = https://github.com/pattonkan/sse2rvv.git
[submodule "Externals/ozz-animation"]
path = Externals/ozz-animation
url = https://github.com/guillaumeblanc/ozz-animation.git
[submodule "Externals/entt"]
path = Externals/entt
url = https://github.com/skypjack/entt.git
[submodule "Externals/glfw"]
path = Externals/glfw
url = https://github.com/glfw/glfw.git
37 changes: 37 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# AGENTS.md – Assistant Quick Guide

## Mission Snapshot
- Modernise OpenXRay's animation runtime by integrating ozz-animation while keeping legacy behaviour intact.
- xrAnimation module owns the façade around `OzzKinematics`, converter tools, parity tests, and the in-engine `.ozzx` visual.
- Converter CLI already produces `.ozz/.ozzx` assets from legacy `.ogf/.omf`; viewer tooling validates bind pose and animation parity.
- Minimum Viable Product is shipped: the runtime façade, converter, and bundle visual now mirror legacy behaviour for the shipped fixtures.

## Active Priorities
1. Harden the MVP: keep regression suites green, extend automation around `.ozzx` bundle loading, and react quickly to edge cases raised in gameplay smoke tests.
2. Capture and publish lightweight telemetry comparing legacy vs. Ozz frame costs; feed the numbers back into docs and tuning guidelines.
3. Shape the next phase (threading, GPU skinning, richer metadata) by collecting follow-up requirements and documenting the proposed roadmap.

## Workflow Expectations
- Read existing memory (docs, notes) before running commands or changing files.
- Prefer Debug/Mixed builds for iteration; use engine containers (`xr_vector`, `shared_str`, etc.) and `Msg()` for logging.
- After every code or doc change: rebuild the affected targets and rerun their tests without waiting for a prompt.
- Keep responses concise, factual, and professional; update documentation immediately when behaviour changes.

## Build & Test Quickstart
- Configure (if needed): `cmake -S xray-16 -B ozz_utils -DCMAKE_BUILD_TYPE=Debug`
- Build animation targets: `cmake --build ozz_utils --target ozz_kinematics_tests xrAnimation_converter_tests -j`
- Run suites: `ctest --test-dir ozz_utils --output-on-failure`
- Focused test loop: `ozz_utils/bin/Debug/ozz_kinematics_tests --gtest_filter=OzzKinematicsParity.*`

## Handy Tools & Scripts
- `convert_assets.sh` (repo root) -> regenerates sample `.ozz` skeletons/animations.
- `xray_to_ozz_converter` CLI handles skeleton/animation/batch conversion.
- `ozz_animation_viewer` (Debug build) can dump bind poses, JSON animation samples, and headless previews for parity checks.
- Blender snippets in `AGENT_COMMANDS.md` extract rest-pose matrices for cross-validation when needed.

## Where To Look Next
- Detailed guidance: `src/xrAnimation/AGENT_DOCS.md`
- Command recipes: `src/xrAnimation/AGENT_COMMANDS.md`
- Roadmap & priorities: `src/xrAnimation/AGENT_NEXT_STEPS.md`
- Historical context: `src/xrAnimation/CLAUDE.md`

12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project(OpenXRay
HOMEPAGE_URL "https://github.com/OpenXRay/xray-16"
LANGUAGES CXX C
)
include(CTest)

option(BUILD_SHARED_LIBS "Build shared libraries" ${BUILD_SHARED_LIBS_DEFAULT_VALUE})

Expand All @@ -21,7 +22,18 @@ option(XRAY_ENABLE_TRACY "Enable tracy profiler" OFF)
include(XRay.Build)
include(XRay.Packaging)

add_compile_definitions(
$<$<CONFIG:ReleaseMasterGold>:MASTER_GOLD>
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:XRAY_STATIC_BUILD>
)

add_subdirectory(Externals)
if(BUILD_TESTING)
get_property(_ozz_tests DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
foreach(_test IN LISTS _ozz_tests)
set_tests_properties(${_test} PROPERTIES DISABLED TRUE)
endforeach()
endif()
add_subdirectory(src)
add_subdirectory(res)
add_subdirectory(misc)
148 changes: 148 additions & 0 deletions COMPUTE_INFRASTRUCTURE_STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Detail Manager Compute Infrastructure - Implementation Status

## Completed Components

### 1. GPU Data Structures (`DetailManager_Compute.h`)
**DetailInstanceGPU** (128 bytes, cache-aligned)
- Transform data: position, scale, rotation_y
- Rendering data: lighting (c_hemi, c_sun), object_id, vis_id, color_rgb
- Bounding data: AABB min/max, sphere radius
- Metadata: slot coordinates, flags, fade distance

**FrustumGPU** (64 bytes)
- 6 frustum planes extracted from view-projection matrix

**DetailCullParams** (64 bytes)
- Camera position/direction
- Fade limits (start/end squared distances)
- SSA thresholds for culling/LOD
- Frame number for temporal effects

**IndirectDrawArgs**
- Matches D3D11_DRAW_INDEXED_ARGUMENTS layout
- `instance_count` written by compute shader

### 2. Compute Shader (`detail_cull.cs`)
**Culling Pipeline** (256 threads per group)
1. Distance culling (fade_limit_sqr)
2. Frustum culling (sphere vs 6 planes)
3. SSA (Screen Space Area) culling
4. Sort into 3 visibility lists by vis_id (still/wave1/wave2)
5. Atomic counter updates
6. Output to UAV buffers

**Functions:**
- `SphereInsidePlane()` - Plane/sphere intersection
- `FrustumCullSphere()` - 6-plane frustum test
- `ComputeSSA()` - Screen-space area for LOD

### 3. Manager Class (`DetailManager_Compute.h`)
**DetailComputeManager**
- Instance management (Begin/Add/End)
- GPU buffer allocation (structured buffers, UAVs, SRVs)
- Compute dispatch (culling pass)
- Indirect rendering support
- Statistics tracking

**GPU Resources:**
- Instance buffer (all instances) + SRV
- Visible indices buffers [3] + UAVs + SRVs
- Counter buffer (atomic) + UAV
- Indirect args buffers [3] + UAVs
- Constant buffer (cull params)
- Compute shader reference

**Utility Functions:**
- `BuildFrustumGPU()` - Extract planes from VP matrix
- `ConvertToGPUInstance()` - CPU SlotItem → GPU format

## Next Steps

### Phase 1: Implementation (Current)
- [ ] Create `DetailManager_Compute.cpp` with buffer creation/destruction
- [ ] Implement `CreateBuffers()` - allocate structured buffers
- [ ] Implement `UploadInstances()` - CPU→GPU transfer
- [ ] Implement `DispatchCulling()` - bind resources & dispatch compute
- [ ] Implement `RenderIndirect()` - DrawIndexedInstancedIndirect calls
- [ ] Compile shader: `detail_cull.cs` → compiled bytecode

### Phase 2: Integration
- [ ] Add compute path toggle to `DetailManager.h`
- [ ] Integrate with existing `cache_Decompress()` to build instance list
- [ ] Replace `UpdateVisibleM()` with compute dispatch
- [ ] Hook into `hw_Render()` for indirect draws
- [ ] Add console commands for enable/disable/stats

### Phase 3: Testing & Optimization
- [ ] Verify visual parity with CPU path
- [ ] Profile GPU/CPU times
- [ ] Benchmark instance counts (10K, 100K, 500K)
- [ ] Tune thread group size (current: 256)
- [ ] Add GPU timestamps for perf tracking

## Architecture Benefits

### Memory Efficiency
- CPU: ~80 bytes per SlotItem (pointers, matrices, scattered data)
- GPU: 128 bytes per instance (cache-aligned, contiguous)
- Structured buffers avoid pre-multiplied VB/IB waste

### Performance Gains
- **Culling**: GPU parallel > CPU serial
- **Draw Calls**: 3 indirect draws vs 100s of batched draws
- **Bandwidth**: No constant buffer spam (64×4 float4s per batch)
- **Scalability**: 100K+ instances possible

### Flexibility
- Easy to add Hi-Z occlusion culling (future)
- Temporal anti-aliasing support (frame counter)
- GPU-driven LOD selection
- Foundation for grass state texture

## File Structure

```
src/Layers/xrRender/
├── DetailManager_Compute.h ✅ Created (GPU structs, manager class)
└── DetailManager_Compute.cpp ⏳ Next (implementation)
res/gamedata/shaders/r5/
└── detail_cull.cs ✅ Created (frustum culling)
Documentation/
├── GRASS_RENDERING_ARCHITECTURE.md ✅ Created (design doc)
└── COMPUTE_INFRASTRUCTURE_STATUS.md ✅ This file
```

## Shader Compilation

The compute shader needs to be compiled:
```
input: res/gamedata/shaders/r5/detail_cull.cs
output: <shader_cache>/detail_cull_cs.cso
```

Engine should auto-compile on first load, or use shader compiler tool.

## Configuration

Future console variables:
```
r_detail_compute 1/0 - Enable GPU compute path
r_detail_compute_stats 1/0 - Show culling statistics
r_detail_max_instances 100000 - Max instances to allocate
```

## Notes

- All structures are tightly packed for GPU efficiency
- Frustum extraction follows standard VP matrix decomposition
- SSA calculation matches existing CPU logic for consistency
- Vis_id splitting (0/1/2) preserves animation system
- Indirect args allow GPU to control draw count dynamically

---

**Status**: Infrastructure complete, ready for implementation phase
**Branch**: `yohji/feat/mt-detailmanager`
**Last Updated**: 2025-10-09
Loading
Loading