You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit efd1ebb
Browse filesBrowse the repository at this point in the historyBrowse files
Luma2: Step 4B, texture mirrors and sampler mirrors on D3D11, FF7R's upgrade rules
Resources::Upgrade ports 1.0's rule matching (Game::Resources::SetUpgrades, DXGI formats); D3D11 mirrors are
made with the game's textures and views, swapped at binds, and copies, resolves, clears and CPU uploads follow
them. Sampler mirrors add 16x anisotropy and the LOD bias offset. Resources tab, luma_status resources, tests.
Copy file name to clipboardExpand all lines: Luma2/Docs/Guidelines.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -530,3 +530,7 @@ Add a row whenever 2.0 behaves differently from 1.0 on purpose, or when an impro
530
530
| Recipe resources | `managed_resources` entries, `luma_settings`/`luma_data` handles, `fast_noise` mapped to "FAST Noise" by name | `Resources::Database` entries by name (textures from the Textures folders, `LumaSettings`, `LumaData`) as requests; bound before the draw events as 1.0 | one database for everything Luma owns | decided, Step 3 |
531
531
| Textures from disk | `LoadTexture2DArray` of a PNG sequence behind `ENABLE_FAST_NOISE_TEXTURES` | `.dds` files in the Textures folders, all loaded when the game sets `Options::textures.load` (inclusion and exclusion lists later); FAST noise converted to one DDS array | a per-game option instead of a define; any texture by name | decided, Step 3 |
532
532
| Patches with bindings on D3D12 | (no D3D12) | not published: DXP adds SM5.0 bindings in space 0, which the game's signature doesn't describe; the game's pipeline runs | needs DXP's upgrade to SM5.1 (Plan.md Step 3) | idea, DXP |
533
+
| Sampler mirrors | made for every sampler at once when the LOD bias offset changes (at present) | made at the first bind of a sampler after the offset changed, kept per offset | no sampler list to walk; D3D11 shares equal state objects, so a creation is cheap | decided, Step 4 |
534
+
| Copy compatibility | `AreFormatsCopyCompatible` took two formats without a typeless family (R11G11B10, R9G9B9E5) as compatible | equal, or the same typeless family, or two 8 bit RGBA/BGRA | 1.0 would `CopyResource` R11G11B10 into R9G9B9E5 | decided, Step 4 |
535
+
| CPU data into mirrors | `ConvertResourceData`: 8 bit RGBA and BGRA to RGBA16F | the same plus R10G10B10A2_UNORM and R11G11B10_FLOAT, pitches respected | FF7R's upgraded formats | decided, Step 4 |
536
+
| Readback targets | PS and CS passes, through the debug draw | any call, by its primary shader (a depth only VS pass too), the call run by Luma before the copy | the readback isn't tied to the debug draw any more | decided, Step 4 |
Copy file name to clipboardExpand all lines: Luma2/Docs/Plan.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -677,6 +677,18 @@ Built on part C's answers; the shapes below are the starting point.
677
677
* Memory: accept the doubled targets, measure at 4K, note the number.
678
678
* Mirror creation on D3D12 synchronous at the original's creation (it's the game's creation call, already allowed to be slow), not a job.
679
679
680
+
**Notes (parts A and B built, commits `09e8e428` to the part B commit; nothing verified in the game yet):**
681
+
* Readback (`Trace/Readback.*`, `Trace/D3D11/D3D11Readback.*`, `Trace/D3D12/D3D12Readback.*`, Development): one target at a time, armed by the pipe thread, which waits for the result and writes the `.bin`. The target call is the n-th call of a shader at its stage in the frame (Track's instance; `Capture::GetInstance` shared with the Trace panel). By `index` it is the entry's primary shader (PS, else VS, else CS), so any pass with views is read, where 1.0 took PS and CS only. At the call the handler runs the game's call itself (unless a callback already ran, skipped or replaced it, as 1.0's `replaced`) and copies the view; the present reads the copy. D3D11: rtv, srv, uav, depth, stencil (MSAA resolved first), on the immediate context only. D3D12: a readback buffer filled on the game's list right after the call, read once a queue executed that list (a fence wait at the next present); the resource state is the call's own for render targets and UAVs, and for shader resources the last transition the list recorded (new `ResourceBarrier` hook, Development); depth, stencil and MSAA aren't read on D3D12 yet. `view=swapchain` reads the back buffer at present on both APIs, before the overlay (D3D12 on a list of Luma's on the presenting queue). `ui` and `registered:<name>` wait for Step 5. `luma_compare` and `luma_golden` are the bridge's (`Scripts/luma_mcp.py`): nothing in the game. `luma_read_cbuffer` runs on Track (`frames` for a series, the overlay's tracking put back after).
682
+
* Trace: copies, resolves, clears and CPU writes are events on both APIs (`EventType::Copy`, `Clear`, `CpuWrite`; MCP types `copy`, `clear`, `cpu_write`, `copy_kind`, and in `trace_get` 1.0's `source`, `target`, `copy`, `clear_values`), recorded as the game made the call, before the mirrors redirect it. Buffer writes are hidden unless `include_buffer_writes` (the panel's "Buffer writes" chip). D3D12 gained hooks for `CopyResource`, `CopyTextureRegion`, `CopyBufferRegion`, `ResolveSubresource` and the four clears (`Function::Copy`, `Clear`), whose handlers part D extends. A trace resource that is a mirror is described as the game's texture with `mirror` (format and size).
683
+
* Game API (Guidelines section 8): Core now hooks texture and view creation, view and sampler binds, writes, copies and clears, so the native callbacks on those are `Game::D3D11::Events` fields with the same signatures: `on_create_buffer`/`on_init_buffer`, `on_create_texture_2d`/`on_init_texture_2d`, `on_resource_destroyed`, `on_init_*_view`, `on_view_destroyed`, `on_create_sampler_state`, `on_bind_render_targets*`, `on_map`, `on_unmap`, `on_unmapped`, `on_update_subresource`, `on_copy_resource`, `on_copy_subresource_region`, `on_resolve_subresource`, `on_clear_render_target_view`, `on_clear_view`. `Callbacks` keeps blend state creation, the IA binds, `CopyStructureCount` and deferred contexts. No ported game used any of them.
684
+
* Upgrade rules: `Game::Resources::SetUpgrades(Resources::Upgrade::Rules)` with `DXGI_FORMAT` (decided with the owner after reviewing the sketch); `Resources::Upgrade::Match` is 1.0's `GetOptionalResourceUpgradeDesc` for what Step 4 needs: render targets, UAVs and depth of GPU-only textures, the 2D size filters, LUTs. Not ported: writable shader resources (1.0 took them with its chains: Step 6), the Development warning about 1x1 aspect matches; `custom_dimensions` is `LUMA_UNIMPLEMENTED` (a size change is Step 6). The display size is the primary screen's until Step 5.
685
+
* Mirrors on D3D11 (`Resources/Mirrors.*`, `Resources/D3D11/D3D11Mirrors.*`): made in `PostCreateTexture1D/2D/3D` with the game's desc in the upgraded format, `SHADER_RESOURCE` added (Luma's converting copies and readbacks read it), shared and CPU flags dropped; initial data converted. State in private data both ways (`MirrorState` on the game's texture, `OriginalState` on the mirror, `ViewState` on each game view), so a mirror and its views go with the game's objects (checked on WARP). Swapped at `*SetShaderResources`, `CSSetUnorderedAccessViews`, `OMSetRenderTargets(AndUnorderedAccessViews)` (after the game's event) while `Mirrors::IsSwapping()` (`Luma.Enabled` and `Luma.Resources.Upgrades`, Development setting); a bind costs one atomic load when no view is mirrored, else one `GetPrivateData` per view. Copies and region copies between copy-compatible formats are issued on the mirrors; between a mirror and a texture of another format through `Draw::D3D11::Copy`/`Scale` (1.0's `OnCopyResource_Internal`), with proxies made per copy where a side lacks the bind flag (1.0 cached two); a region copy converts only a whole single subresource, else it asserts and the originals are copied. A resolve between a mirror and another family is `LUMA_UNIMPLEMENTED`. Clears go to the mirror's view. `UpdateSubresource` into a mirrored texture is converted into the mirror always (1.0's `ConvertResourceData`, with R10G10B10A2 and R11G11B10 added: FF7R's formats), the original written too. `Map` isn't handled: textures the rules match are GPU only, so they can't be mapped.
686
+
* Samplers (`Resources/Samplers.*`, `Resources/D3D11/D3D11Samplers.*`, `Options::samplers.upgrade`): 1.0's Publishing branch of `CreateCustomSampler` (mode 4, comparison samplers too) in every build. A mirror is made at the first bind after the offset's generation moved, not at the present (1.0 made every sampler's at once when the offset changed): no list of samplers to walk, and the cost is one `CreateSamplerState` that D3D11 usually answers with a shared object. Development settings `Luma.Development.Samplers.CustomBias` and `.Bias` stand for 1.0's `custom_texture_mip_lod_bias_offset`; 1.0's Development-only modes 5 to 7 and `samplers_upgrade_mode_2` aren't ported. `SetLodBiasOffset` is for Step 7's SR.
687
+
* Dev UI: "Resources" tab (rules, mirror count, views and memory, the mirror list newest first, sampler state, Luma's database entries). `luma_status` has `resources` (`upgrades`, `samplers`, `mirrors`, `mirror_mb`, `views`, `lod_bias_offset`).
688
+
* FF7R: `SetUpgrades` with 1.0's formats, filters and 3D LUT, `.samplers = {.upgrade = true}`.
689
+
* Tests (94 cases): FF7R's rules against the textures 1.0 upgraded, the size filters and view formats, copy compatibility, the conversions, the sampler mirror desc, and on WARP a mirror with its view, swapped at bind, written by the CPU and released with the game's texture.
690
+
* Not done yet: everything in Verify A and B (in the game, both APIs where it says), the 1.0 goldens (the owner packages `5788b1c6`), the bind cost measured on WARP through the real hooks, part C (a D3D12 research session) and part D.
0 commit comments