Fensalir/README.md

185 lines
7.3 KiB
Markdown
Raw Normal View History

2026-05-08 20:04:10 +01:00
# Aquarium Engine
2026-05-07 23:11:50 +01:00
2026-05-08 20:04:10 +01:00
![Aquarium Engine icon](Aquarium-Engine-Icon.png)
2026-05-08 20:04:10 +01:00
C# engine core for Aquarium: a native, owned renderer and interaction runtime
for a living Epiphany client.
2026-05-07 23:11:50 +01:00
## Intent
- C# host with renderer architecture kept legible in Rider.
2026-05-11 05:15:42 +01:00
- Vortice/D3D12 renderer spine with the native boundary kept explicit.
2026-05-08 16:38:39 +01:00
- DirectWrite/Direct2D overlay text after the scene pass for crisp debug and UI
typography.
2026-05-07 23:11:50 +01:00
- Grid-centered camera and world-space interaction invariants as first-class
engine contracts.
- Diegetic UI surfaces driven by Aquarium objects instead of admin chrome.
- CultNet for Epiphany communication.
- CultCache for settings, persistent client state, and reload recovery.
- Procedural audio and visual state treated as coupled signals.
2026-05-08 20:04:10 +01:00
## Current Shape
2026-05-07 23:11:50 +01:00
2026-05-11 05:15:42 +01:00
The engine opens a Win32 window, owns a D3D12 swapchain, renders the visible
2026-05-08 20:04:10 +01:00
Aquarium world in HLSL, and draws crisp overlay text through DirectWrite. The
camera target is the Grid center. Grid radius follows zoom distance. Body anchors
remain world-space.
2026-05-07 23:11:50 +01:00
The Epiphany client is split behind `Aquarium.Engine.Contracts`, so client code
can reload while the engine host, window, renderer, and D3D device stay alive.
Runtime state is banked through CultCache MessagePack documents instead of loose JSON.
2026-05-08 00:32:51 +01:00
## Run
2026-05-08 12:42:08 +01:00
Aquarium currently expects the sibling `CultMath` and `CultLib` repos at
`E:\Projects\CultMath` and `E:\Projects\CultLib`, or the equivalent
`..\..\..\CultMath` / `..\..\..\CultLib` paths from the engine project.
2026-05-08 02:20:12 +01:00
2026-05-08 00:32:51 +01:00
```powershell
dotnet build Aquarium.Engine.slnx
dotnet run --project src\Aquarium.Engine\Aquarium.Engine.csproj -- --client-assembly src\Aquarium.Epiphany\bin\Debug\net10.0\Aquarium.Epiphany.dll
2026-05-08 00:32:51 +01:00
```
2026-05-11 13:35:22 +01:00
For Rider, open `Aquarium.Engine.sln`. The `.slnx` stays as the compact
CLI-friendly solution, but Rider may show empty project trees when opening it.
2026-05-12 03:49:11 +01:00
`src\Aquarium.Sample.Minimal` is a tiny non-Epiphany client used to keep the
engine boundary honest. It references only `Aquarium.Engine.Contracts`, declares
an `AquariumRenderPlan`, and boots through the same host/client loader path.
2026-05-08 12:15:46 +01:00
For iteration while an Aquarium window is already open, use the dev reload
runner instead of `dotnet run`:
```powershell
.\scripts\dev-reload.ps1
```
2026-05-08 15:10:33 +01:00
It builds an apphost executable into a fresh disposable slot under
`artifacts\dev-reload`, records the slot/PID in PowerShell CLIXML, and launches
the runtime with a MessagePack CultCache store at
`artifacts\dev-reload\cultcache\aquarium-client.msgpack`.
2026-05-08 12:42:08 +01:00
The previous script-owned process is stopped only after the replacement build
succeeds. This keeps MSBuild away from the locked normal `bin\Debug` output
while a live window is still open.
If the visible dev window was closed but the last slot is still present, reopen
it without rebuilding:
```powershell
.\scripts\dev-reload.ps1 -Reopen
```
Visible and headless runs keep separate PID state and logs, so a headless smoke
does not replace the visible dev window.
2026-05-08 12:42:08 +01:00
For automatic rebuild/restart on source changes, use the watcher:
```powershell
.\scripts\dev-watch.ps1
```
The watcher polls source files, waits for writes to settle, builds into a new
slot, and only replaces the running Aquarium after the new build succeeds. If a
build fails, the previous good process keeps running and that same broken source
fingerprint is not retried until files change again.
2026-05-08 23:29:56 +01:00
It also watches the recorded script-owned process. If the visible window is
closed or the recorded process dies, the watcher relaunches from a fresh slot on
the next poll instead of sitting there with its hands folded like this is fine.
2026-05-09 00:04:45 +01:00
To reopen a closed visible window from the last good slot without rebuilding,
run the watcher with:
```powershell
.\scripts\dev-watch.ps1 -ReopenWhenClosed
```
2026-05-08 12:42:08 +01:00
2026-05-08 15:31:38 +01:00
Shader edits do not restart the process. The dev reload runner passes the
2026-05-11 05:15:42 +01:00
shader source directory into the live app, and the renderer polls
`D3D12Grid.hlsl`, `D3D12Scene.hlsl`, and `D3D12Post.hlsl`, compiles changed
shaders in the running process, then swaps the D3D shader objects only after
compilation succeeds. A bad shader edit leaves the previous working shaders
bound and writes the compiler failure to stderr.
2026-05-08 15:31:38 +01:00
Epiphany client/runtime code is split into `Aquarium.Epiphany` behind
`Aquarium.Engine.Contracts`. The host loads that client DLL through a collectible
assembly load context, while `dev-watch.ps1` builds client-only changes into
2026-05-08 16:04:52 +01:00
`artifacts\dev-reload\live-slots` and updates `live-current.txt`. The running
host sees the pointer change, loads and starts the new runtime first, then
disposes the old one only after the replacement is valid. A bad client DLL leaves
2026-05-09 00:04:45 +01:00
the previous runtime alive and reports the reload failure to stderr. The watcher
waits for the host log to acknowledge the exact client DLL path before calling a
client reload successful; pointer updates without host acknowledgement are treated
2026-05-09 00:04:45 +01:00
as reload failures. Successful reloads rehydrate through CultCache without
restarting the window or D3D device.
Host, renderer, contract, project, script, and `src\Aquarium.Engine\Assets`
content changes still rebuild and restart the apphost. Runtime content belongs
to the process image; shader hot reload cannot make a running renderer discover
new files it never loaded.
2026-05-08 16:04:52 +01:00
2026-05-08 12:42:08 +01:00
Runtime live state is a typed CultCache document, not a loose sidecar file. The
first document is `epiphany.aquarium.live_state`, currently banking camera
target, yaw, pitch, distance, time, and save generation every few frames so a
reload can rehydrate without pretending memory is vibes.
2026-05-08 12:15:46 +01:00
Stop the script-owned Aquarium process:
```powershell
.\scripts\dev-stop.ps1
```
2026-05-08 00:32:51 +01:00
Headless smoke:
```powershell
dotnet run --project src\Aquarium.Engine\Aquarium.Engine.csproj -- --headless --client-assembly src\Aquarium.Epiphany\bin\Debug\net10.0\Aquarium.Epiphany.dll
2026-05-08 00:32:51 +01:00
```
2026-05-08 12:15:46 +01:00
Headless reload smoke without touching the normal build output:
```powershell
.\scripts\dev-reload.ps1 -Headless
```
Renderer/client boundary check:
```powershell
.\scripts\verify-boundaries.ps1
```
2026-05-08 12:42:08 +01:00
Headless watch smoke:
```powershell
.\scripts\dev-watch.ps1 -Headless
```
2026-05-08 19:41:30 +01:00
Shipping publish:
```powershell
.\scripts\publish-win-x64.ps1 -Clean -Zip
```
This writes a self-contained Windows build to
`artifacts\publish\win-x64`, verifies the executable, Epiphany client DLL,
2026-05-08 19:41:30 +01:00
contracts DLL, icon, bundled fonts, and shader source, then optionally creates
`artifacts\publish\EpiphanyAquariumEngine-win-x64.zip`.
2026-05-08 20:04:10 +01:00
## Persistent State
This repo carries its own Aquarium memory:
- `state/map.yaml`: canonical project map and next actions.
- `state/memory.json`: durable taste, doctrine, renderer rules, and warnings.
- `state/evidence.jsonl`: compact lessons that should change future behavior.
- `state/scratch.md`: disposable working context for the current pass.
Keep that state current when the engine learns something durable. Dead lessons
go out with the trash; the repo is not a scrapbook.
## Docs
2026-05-08 02:33:50 +01:00
2026-05-08 20:04:10 +01:00
- `docs/aquarium-engine-doctrine.md`: engine doctrine and invariants.
- `docs/engine-client-boundary.md`: Engine/Epiphany ownership split.
2026-05-12 03:21:11 +01:00
- `docs/epiphany-extraction-render-api-plan.md`: migration plan for the client
extraction and ergonomic render graph API.
2026-05-08 20:04:10 +01:00
- `docs/vortice-spine.md`: native host/renderer spine.
- `docs/hlsl-renderer.md`: current shader path.
- `docs/input.md`: camera and input contract.
- `docs/cult-runtime-surface.md`: CultCache/CultNet runtime surface.