render: extract WMO render resource finalizer
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
Own the mutually exclusive cached, missing and pending states for normalized
|
||||
lightweight-WMO render paths outside the monolithic streamer. The state holder
|
||||
accepts only caller-validated `Resource` references and records cache paths for
|
||||
threaded requests whose I/O lifecycle remains in `StreamingWorldLoader`.
|
||||
threaded requests whose terminal I/O lifecycle belongs to
|
||||
`WmoRenderResourceFinalizer`.
|
||||
|
||||
## Non-goals
|
||||
|
||||
@@ -34,7 +35,8 @@ flowchart LR
|
||||
State -->|cached Resource| Loader
|
||||
Loader -->|cache path| ResourceLoader[Godot ResourceLoader]
|
||||
ResourceLoader -->|status and loaded Resource| Loader
|
||||
Loader --> Validate[Script and FORMAT_VERSION validation]
|
||||
Loader --> Finalizer[WmoRenderResourceFinalizer]
|
||||
Finalizer --> Validate[Script and FORMAT_VERSION validation]
|
||||
Validate -->|accepted Resource or missing| State
|
||||
Loader --> Fallback[Cached scene or live-prototype fallback]
|
||||
```
|
||||
@@ -53,8 +55,8 @@ or editor dependency. Cache validation stays at the I/O boundary in the loader.
|
||||
| `has_request(path)` | Query | Test pending threaded-request state | Renderer main thread | Empty returns false |
|
||||
| `remember_request(path, cache_path)` | Command/query | Record one loader-started request | Renderer main thread; until terminal/reset | Invalid or occupied state returns false |
|
||||
| `request_paths_snapshot()` | Query | Copy pending normalized/cache-path mapping | Poll or shutdown drain | Detached Dictionary |
|
||||
| `complete_request_with_resource(path, resource)` | Command/query | Remove pending request and adopt caller-validated Resource | Terminal loader poll | Unknown/null returns false |
|
||||
| `complete_request_as_missing(path)` | Command/query | Remove pending request and adopt negative state | Terminal loader poll | Unknown returns false |
|
||||
| `complete_request_with_resource(path, resource)` | Command/query | Remove pending request and adopt caller-validated Resource | Terminal finalizer poll | Unknown/null returns false |
|
||||
| `complete_request_as_missing(path)` | Command/query | Remove pending request and adopt negative state | Terminal finalizer poll | Unknown returns false |
|
||||
| `clear_transient_state()` | Command | Clear pending and missing while retaining accepted Resources | Map reset/request drain | Idempotent |
|
||||
| `clear_all()` | Command | Release Resources, pending and missing | Final runtime cache release | Idempotent |
|
||||
| `pending_request_count()` | Query | Preserve renderer queue metric contribution | Renderer diagnostics | None |
|
||||
@@ -81,11 +83,11 @@ flowchart TD
|
||||
Blocked -->|yes| Null[Return null; loader waits/falls back]
|
||||
Blocked -->|no| Start[Loader starts threaded request]
|
||||
Start --> Remember[remember_request]
|
||||
Remember --> Poll[Loader polls detached request snapshot]
|
||||
Remember --> Poll[Finalizer polls detached request snapshot]
|
||||
Poll --> Terminal{Loaded or failed?}
|
||||
Terminal -->|no| Poll
|
||||
Terminal -->|failed| Missing[complete as missing]
|
||||
Terminal -->|loaded| Validate[Loader validates script/version]
|
||||
Terminal -->|loaded| Validate[Finalizer validates script/version]
|
||||
Validate -->|valid| Adopt[complete with Resource]
|
||||
Validate -->|invalid| Missing
|
||||
```
|
||||
@@ -113,28 +115,31 @@ stateDiagram-v2
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant Loader as StreamingWorldLoader
|
||||
participant Finalizer as WmoRenderResourceFinalizer
|
||||
participant State as WmoRenderResourceCacheState
|
||||
participant RL as ResourceLoader
|
||||
Loader->>State: cached/missing/pending queries
|
||||
Loader->>RL: exists + load_threaded_request(cache path)
|
||||
Loader->>State: remember_request(normalized, cache path)
|
||||
loop renderer tick
|
||||
Loader->>State: request_paths_snapshot()
|
||||
Loader->>RL: load_threaded_get_status(cache path)
|
||||
Loader->>Finalizer: poll_terminal_requests(State)
|
||||
Finalizer->>State: request_paths_snapshot()
|
||||
Finalizer->>RL: load_threaded_get_status(cache path)
|
||||
end
|
||||
alt load failed
|
||||
Loader->>State: complete_request_as_missing(normalized)
|
||||
Finalizer->>State: complete_request_as_missing(normalized)
|
||||
else loaded
|
||||
Loader->>RL: load_threaded_get(cache path)
|
||||
Loader->>Loader: validate script and FORMAT_VERSION
|
||||
Loader->>State: complete with Resource or as missing
|
||||
Finalizer->>RL: load_threaded_get(cache path)
|
||||
Finalizer->>Finalizer: validate script and FORMAT_VERSION
|
||||
Finalizer->>State: complete with Resource or as missing
|
||||
end
|
||||
```
|
||||
|
||||
## Ownership, threading and resources
|
||||
|
||||
- The state owns three Dictionaries and strong references to accepted Resources.
|
||||
- The loader owns normalization, cache paths, ResourceLoader calls and validation.
|
||||
- The loader owns normalization, cache paths and request admission; the finalizer
|
||||
owns terminal ResourceLoader calls and validation.
|
||||
- All mutation is serialized by the renderer main-thread lookup/drain lifecycle.
|
||||
- No mutex or callback is needed; detached request snapshots permit safe removal.
|
||||
- The loader/build queue borrow Resources without transferring ownership.
|
||||
@@ -158,8 +163,8 @@ format version, request scheduling and WMO build budgets remain loader-owned.
|
||||
## Persistence, cache and migration
|
||||
|
||||
The state is runtime-only and serializes nothing. `WMOStreamingResource` script
|
||||
identity and `FORMAT_VERSION` validation remain unchanged in the loader; no cache
|
||||
migration or rebuild is introduced by this extraction.
|
||||
identity and `FORMAT_VERSION` validation remain unchanged in the finalizer; no
|
||||
cache migration or rebuild is introduced by this extraction.
|
||||
|
||||
## Diagnostics and observability
|
||||
|
||||
@@ -189,7 +194,7 @@ states; Resource references and cache file paths are not exposed. No logs emit.
|
||||
| Capability | Status | Evidence | Gap/next step |
|
||||
|---|---|---|---|
|
||||
| Lightweight WMO render Resource state | Implemented extraction | Lifecycle/source/timing and shutdown verifiers | Asset-backed traversal/leak evidence pending |
|
||||
| Cache script/version validation | Preserved in loader | Source boundary and WMO regressions | Dedicated corrupt-cache fixture could follow |
|
||||
| Cache script/version validation | Implemented extraction | Finalizer source and synthetic validation verifier | Serialized corrupt-cache fixture could follow |
|
||||
| Cached WMO scene state | Implemented extraction | Scene-cache lifecycle/source/timing verifier | Asset-backed traversal/leak evidence pending |
|
||||
| WMO materialization | Partial/loader-owned | Queue/planner regressions | Further safe extraction |
|
||||
|
||||
@@ -206,7 +211,8 @@ states; Resource references and cache file paths are not exposed. No logs emit.
|
||||
| Path | Responsibility |
|
||||
|---|---|
|
||||
| `src/render/wmo/wmo_render_resource_cache_state.gd` | Resource/missing/request state and resets |
|
||||
| `src/scenes/streaming/streaming_world_loader.gd` | Normalize, request, poll, validate, fallback and shutdown I/O |
|
||||
| `src/render/wmo/wmo_render_resource_finalizer.gd` | Terminal polling, script/format validation and publication |
|
||||
| `src/scenes/streaming/streaming_world_loader.gd` | Normalize, request admission, fallback and shutdown order |
|
||||
| `src/tools/verify_wmo_render_resource_cache_state.gd` | State, boundary and timing regression |
|
||||
| `src/tools/verify_render_runtime_cache_shutdown.gd` | Loader final Resource ownership regression |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user