Repository navigation
Conversation
|
Tested 6c00e0c on RTX 5090, 621.24, Windows 11: pass. Built the runtime from this tree and ran the texture targets → 5/5 passed ( |
Hiiva
left a comment
There was a problem hiding this comment.
Independent bounded Windows review at 6c00e0cdfa452433c7c4786273d946261707fe7c, with LEONIDA_TEXTURE_MIP_DROP=0 and =1 explicitly set in separate processes. Two issues reproduce when the switch is enabled: the retained-mip whole copy uses the old extent, and a read of the dropped mip only zeros one row.
Synthetic control
One 8x8 R8G8B8A8_UNORM texture, three mips, one layer, flags 0, in a CUSTOM / WRITE_BACK / L0 heap. Both used subresources are mapped with a null data pointer. The layer is given the existing test Vulkan device with host_image_copy=false, so retained copies take the production staging path. No shaders or game files.
| Production / drop value | Created Vulkan image | Read original mip 0, pitch 32 | Original mip 1, explicit 4x4 box | Original mip 1, whole-copy form |
|---|---|---|---|---|
Parent 561b65a8, drop 0 |
8x8, 3 mips | 256 zero bytes | 64 bytes exact | 64 bytes exact |
| Same parent, drop 1 | 8x8, 3 mips | 256 zero bytes | 64 bytes exact | 64 bytes exact |
| PR head, drop 0 | 8x8, 3 mips | 256 zero bytes | 64 bytes exact | 64 bytes exact |
| PR head, drop 1 | 4x4, 2 mips | S_OK; 32 zero bytes, 224 unchanged 0xcd bytes | 64 bytes exact at physical mip 0 | Emits an 8x8 copy into physical mip 0, which is 4x4; blocked before Vulkan |
Every read also checks all remaining bytes of its 512-byte destination buffer stay at 0xcd. The retained payload is an independent 64-byte literal sequence. The source allocation is deliberately larger than the requested payload, so the incorrect whole-copy packing cannot read beyond the probe's allocation.
What executed and what stopped at preflight
Production sources and the existing tests are unchanged. The external probe wraps the provided Vulkan procedure loader to record actual vkCreateImage arguments and copy ranges. Valid commands pass through unchanged. It checks image bounds before forwarding image copies, clears and barriers; after any invalid range it refuses queue submission.
The three passing processes each submit five valid staging copies. At head/drop 1, the dropped-mip read is CPU-only and the boxed write/read submits two valid copies with exact readback. The later 8x8-to-4x4 transfer is intercepted before vkCmdCopyBufferToImage, and its command buffer is not submitted. The resulting E_FAIL is caused by this preflight guard, not presented as an unmodified-driver return value. No invalid-range GPU execution or resulting GPU output is claimed.
The source explains the range: TextureCreateInfo shrinks the image, but create_texture still registers binding_.width/height/mip_levels from the original descriptor. After cpu_copy remaps original mip 1 to physical mip 0, region() derives a whole-mip 8x8 extent from that old binding. A 4x4 explicit box avoids that extent calculation and passes.
Windows 11 Pro build 26200, MSVC 19.44.35228, Windows SDK 10.0.26100, RTX 4080 / NVIDIA 610.62, Vulkan SDK 1.4.363. Core validation and synchronization validation requested and captured. All four processes have zero validation errors and no VUID or sync-hazard diagnostics, consistent with the invalid transfer being blocked before Vulkan. The unchanged Python suite passes 9/9; it models the arithmetic rather than exercising the C++ copy path.
Source, library, executable, runner and log hashes retained. This is an exact-head owner review with an exact-parent control, not current-main integration or a memory-saving/performance measurement. AI-assisted.
| const UINT new_mips = desc_.MipLevels - mips_dropped_; | ||
| subresource = slice * new_mips + (mip - mips_dropped_); | ||
| } | ||
| Region r{}; | ||
| if (!region(subresource, box, r)) return E_INVALIDARG; |
There was a problem hiding this comment.
[P1] Keep retained-mip copy geometry consistent with the reduced image
With LEONIDA_TEXTURE_MIP_DROP=1, an 8x8 RGBA8 resource with three mips is backed by a 4x4 image with two mips. This maps original subresource 1 to physical mip 0, but region() still reads the original 8x8 extent from binding_ (which create_texture fills from desc_). Consequently the valid whole-mip call WriteToSubresource(1, nullptr, source, 16, 64) emits an 8x8 VkBufferImageCopy into an actual 4x4 mip. The same call emits 4x4 and roundtrips 64 bytes on the parent and with drop 0; an explicit 4x4 box also passes at head/drop 1.
I captured the real image/copy arguments and blocked the out-of-range call before forwarding it to Vulkan, so no invalid GPU execution was needed. Remapping the index alone is insufficient: the physical image geometry and the copy/initialization paths using the registered binding must agree, while the public D3D12 descriptor can retain the original dimensions.
| const UINT mip = subresource % orig_mips; | ||
| const UINT slice = subresource / orig_mips; | ||
| if (mip < mips_dropped_) { | ||
| if (!write) std::memset(data, 0, row_pitch); |
There was a problem hiding this comment.
[P2] Zero the requested region of a dropped mip
row_pitch is the distance between rows, not the byte size of the requested subresource. Reading dropped mip 0 of the 8x8 RGBA8 texture with row pitch 32 and depth pitch 256 returns S_OK but changes only bytes 0..31 to zero; bytes 32..255 retain the caller's 0xcd fill. The parent and drop-0 control zero all 256 bytes, and the destination tail remains untouched in every run. This is a CPU-only path at drop 1.
The advertised zero-data read needs to cover the requested rows and slices using the supplied pitches and box rather than zeroing only the first row.
|
Thanks for the thorough review and synthetic test catch @Hiiva! Pushed commit
AI-assisted (Gemini / Antigravity). |
Hiiva
left a comment
There was a problem hiding this comment.
Follow-up at 64b27fbaeb57f0c408a4c4e6b1117b1dc5ef1545. Both findings from my previous review are resolved in the retained synthetic control. The newly added Map fast path introduces one separate invalid-subresource regression, described inline.
Original copy controls now pass
The original external C++ probe is byte-for-byte unchanged. It creates one 8x8 RGBA8 texture with three mips and one array layer in a CUSTOM / WRITE_BACK / L0 heap. Host image copy remains disabled so retained-mip copies use production staging. The provided Vulkan procedure loader still checks image bounds before forwarding copies, clears, and barriers, and refuses queue submission after any invalid range.
| New head mode | Actual Vulkan image | Original mip 0 read | Original mip 1, explicit box | Original mip 1, whole-copy form |
|---|---|---|---|---|
| drop 0 | 8x8, 3 mips | All 256 requested bytes zero | 64 literal bytes exact at physical mip 1 | 64 literal bytes exact at physical mip 1 |
| drop 1 | 4x4, 2 mips | All 256 requested bytes zero, no submission | 64 literal bytes exact at physical mip 0 | 64 literal bytes exact at physical mip 0 |
All remaining bytes of each 512-byte destination retain the 0xcd sentinel. Both Map(0, nullptr, nullptr) and Map(1, nullptr, nullptr) return S_OK. The drop-0 process forwards five valid staging submissions; drop 1 forwards four. No preflight block or refused submission occurs. Both processes finish with zero validation errors and no VUID or synchronization-hazard diagnostics.
The changed binding geometry now matches the physical image, and the dropped-mip read covers every requested row in this case. These are fresh results at the new head; the prior head and parent copy results remain historical evidence.
Separate Map regression control
A separate adaptation keeps the same device/resource setup and valid Map calls, replaces the entire copy body with Map queries for subresources 3 and UINT_MAX, and performs no copy or queue submission. Both processes explicitly set drop 1.
| Map subresource | Retained parent 561b65a8 |
New head 64b27fba |
|---|---|---|
| 0 | S_OK | S_OK |
| 1 | S_OK | S_OK |
| 3, beyond this one-layer texture's three subresources | E_INVALIDARG | S_OK |
| UINT_MAX, the explicitly rejected all_subresources sentinel | E_INVALIDARG | S_OK |
The new head reaches the dropped-mip early return before validating the original array slice or rejecting the sentinel. The separate regression process reports two failed expectations; the parent reports none. Both forward zero submissions and report zero validation errors.
The owner's unchanged Python suite passes 11/11. Those tests model the arithmetic; the C++ controls above exercise the actual compiled resource implementation.
Windows 11 build 26200, MSVC 19.44.35228, Windows SDK 10.0.26100, RTX 4080 / NVIDIA 610.62, Vulkan SDK 1.4.363. Core validation and synchronization validation requested and captured. Production sources remain unchanged, and source/library/executable/runner/log hashes are retained.
This is bounded exact-head validation against the retained parent, not a current-main integration result, a native D3D12 comparison, or a VRAM/performance measurement. Synthetic inputs only; no game files. AI-assisted.
| if (mip < mips_dropped_) { | ||
| return !data && cpu_visible() ? S_OK : E_INVALIDARG; |
There was a problem hiding this comment.
[P2] Validate the original subresource before accepting a dropped mip
The new early return bypasses both the existing all_subresources rejection and the image-range check. For the one-layer, three-mip texture with drop 1, subresource 3 decodes to dropped mip 0 of nonexistent array slice 1; UINT_MAX also has remainder 0. Both now return S_OK from Map(..., nullptr, nullptr).
A separate no-copy control on the exact compiled head confirms both S_OK results. The identical control against the retained parent returns E_INVALIDARG for both, while valid subresources 0 and 1 return S_OK on each library. Neither process submits commands.
Check the original resource's subresource bounds and sentinel before this fast path, so dropping mips does not turn invalid Map requests into successful mappings.
|
Tested 64b27fb on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: concern
AI-assisted (Claude Code). |
|
Thanks for verifying the copy fixes and catching that boundary condition @Hiiva! Pushed commit
AI-assisted (Gemini / Antigravity). |
|
Tested the current head 9bad4b6 on Windows 11 26200, MSVC 14.51 (VS 2026), Vulkan SDK 1.4.363. The runtime test targets were built from this head. I ran @Jadiac5's 13 texture tests through
The open question from Jadiac5's comment still stands. With the drop on, any AI-assisted: yes |
|
Tested and reviewed Build/test:
Findings on
|
|
Thanks for the thorough review and catching these edge conditions @TillusStark26! Pushed commit
Verified on Windows 11 (MSVC, NVIDIA GeForce RTX 4050 6GB Laptop GPU, driver 591.66, Vulkan 1.3):
AI-assisted (Gemini / Antigravity). |
|
Tested and reviewed Test results
Findings on
|
|
At Use a 4×4 I checked six synthetic arithmetic cases against the retained source-mip set. Only drop 1 / clamp 2 incorrectly selected the empty-view branch. Clamp 0 kept an accessible mip for both drop settings. Clamp 3 correctly left the view empty for both. Rebasing the absolute minimum LOD into the physical image's coordinates, with a floor of zero, matched all six. A draw regression could upload the opaque-red 1×1 mip and sample this SRV with Source review and CPU arithmetic only on Intel Core Ultra 7 265K, Windows 11. The pixel values above are predictions from the branch; no native build or readback in this review. NVIDIA GeForce RTX 5070 (621.01) and integrated Intel Graphics were idle. Review claim AI-assisted by GPT-6.2 Astra. |
|
Thanks for the thorough reviews, test verification, and arithmetic analysis @auswhalen999-debug and @jeremygold02! Pushed commit
Tested on Windows 11 AMD64, NVIDIA GeForce RTX 4050 Laptop GPU (6 GB VRAM, driver 591.66, Vulkan 1.3 / SDK 1.4.363). Synthetic fixtures only, no game files. AI-assisted (Gemini / Antigravity). |
|
Tested
AI-assisted (Claude Code). |
…#6043) - Reads LEONIDA_TEXTURE_MIP_DROP (clamped 0..3) to drop top mip levels of pure sampled textures at creation time. - Halves dimensions (>> N) and reduces mip count (mipLevels - N), yielding ~75% texture VRAM savings for drop 1 on low-VRAM GPUs. - Preserves render targets, depth-stencils, UAVs, and 1-mip textures at native resolution. - Remaps subresource CPU copies and adjusts SRV first_mip/mip_count clamping. - Adds test suite tests/test_texture_mip_drop.py and updates documentation in docs/boot.md and docs/d3d12_vulkan.md.
…duced image (ItsNotRexed#6043) - Register binding_ extents and mip levels from info.extent/mipLevels so whole-mip copies derive geometry from the physical image. - Zero the full requested box/rows/slices across row_pitch and depth_pitch on dropped-mip reads without touching memory outside the region. - Remap subresources in Map() for both dropped and retained mips. - Add whole-mip extent and pitch zero-fill unit tests to tests/test_texture_mip_drop.py.
…gic in Map and cpu_copy (ItsNotRexed#6043) - Validate subresource != all_subresources and subresource < total_orig_subresources before evaluating dropped-mip early returns in Map() and cpu_copy(). - Ensure out-of-range subresources and the all_subresources sentinel return E_INVALIDARG rather than S_OK when mips are dropped. - Add test_map_and_copy_reject_out_of_range_and_sentinel to tests/test_texture_mip_drop.py.
…ources (ItsNotRexed#6043) - In vulkan_replay.h: - Register mips_dropped in ResourceBinding from d3d12_vulkan_device.cpp. - In prepare_texture_copy(): - Validate total subresource bounds against orig_mips * array_layers. - If mip < mips_dropped, mark p.skip = true and return ReplayResult::success to gracefully no-op the copy command without failing the command list. - If mip >= mips_dropped, remap to physical image subresource index: slice * physical_mips + (mip - mips_dropped). - Apply check to both Buffer <-> Texture and Texture <-> Texture copies. - In prepare_resource_copy(): skip gracefully if mip levels mismatch due to mip dropping. - In replay_command_list(): skip transfer and barrier emission when p.skip == true. - Add test coverage in tests/test_texture_mip_drop.py and tests/test_command_list_mip_skip.py. AI-assisted (Gemini / Antigravity).
…NotRexed#6043) - 3D volume depth: In TextureCreateInfo, downscale info.extent.depth by mips_dropped for 3D textures (std::max(1u, DepthOrArraySize >> mips_dropped)). - Resource barriers: In vulkan_replay.h, validate subresource bounds, skip dropped-mip TransitionBarrier and TextureBarrier commands (p.skip = true), and remap retained subresources to physical indices. In replay_command_list, bypass skipped barriers without emitting image barriers or tracker mutations. - SRV clamping: In CreateShaderResourceView, when first_mip < drop, reduce view.mip_count by (drop - first_mip) to prevent bleeding into lower mips. - Static init guard (RT-488): In configured_texture_mip_drop, use a constant-initialized namespace-scope atomic to avoid dynamic function-local static init guards on guest threads. - Test coverage: Add runtime/test/d3d12_texture_mip_drop_test.cpp exercising multi-mip 2D/3D creation, upload copies, barriers, SRVs, and execution. Register in runtime/CMakeLists.txt and extend tests/test_texture_mip_drop.py. AI-assisted (Gemini / Antigravity).
…se SRV min LOD (ItsNotRexed#6043) - Loop continuation: In prepare(), use continue instead of returning ReplayResult::success when skipping dropped-mip TransitionBarrier and TextureBarrier commands, ensuring subsequent commands in the list are prepared and dispatched. - Ranged barriers: In prepare(), remap index_or_first_mip and mip_count for ranged TextureBarrier commands (mip_count > 0), skipping when the range falls entirely within dropped mips. - SRV min LOD clamp: In CreateShaderResourceView, rebase view.min_lod into physical image coordinates (std::max(0.0f, view.min_lod - float(drop))) to prevent out-of-range LOD clamps from evaluating as empty views. - Test coverage: Update runtime/test/d3d12_texture_mip_drop_test.cpp to execute and read back a retained-mip copy recorded after a dropped-mip barrier in the same command list, and test SRV min LOD clamping. Extend tests/test_texture_mip_drop.py with unit tests for ranged barriers, min LOD rebasing, and loop continuation (20/20 pass). AI-assisted (Gemini / Antigravity).
d6aa864 to
cd7d720
Compare
|
Tested
AI-assisted: Codex GPT-6.2 Sol ran the tests, Claude Opus 5.5 reviewed the report. No game files used. |
…NotRexed#6043) - Strengthen d3d12_texture_mip_drop_test to verify that GetResourceAllocationInfo reports reduced memory for droppable sampled textures versus protected render-target textures of identical dimensions. - Resolves BatSmacker84 review observation on PR ItsNotRexed#6365: ensures the test fixture strictly fails on main (where drop is ignored) and only passes when LEONIDA_TEXTURE_MIP_DROP=1 actively shrinks physical allocation. AI-assisted (Gemini / Antigravity).
|
Thanks for testing on AMD RDNA3 @BatSmacker84! 1. Baseline Engine Parity (Zero Regressions Unset)As your numbers verify, when 2. Conformance Tests Under
|
|
Thanks, that makes sense: with the switch off the texture group matches The new allocation-size assertion in AI-assisted. |
…mip readback skip (ItsNotRexed#6043) - In runtime/test/d3d12_texture_mip_drop_test.cpp: - Tighten GetResourceAllocationInfo assertion to compare against a 1-mip texture of identical declared dimensions and format (plus top mip raw bytes floor), ensuring it strictly fails on main and passes only when mip drop is active (resolving BatSmacker84 finding). - Add dropped-mip readback copy check: copy from dropped mip 0 to a readback buffer initialized with sentinel 0xCD; verify sentinel remains untouched (proving copy was skipped without GPU write). - Add CPU-visible custom heap texture subresource tests: verify ReadFromSubresource pitch-aware zero fill on dropped mip 0, WriteToSubresource graceful no-op, retained mip 1 round-trip, and Map() probe vs pointer rejection. - In tests/test_texture_mip_drop.py: - Add unit test for droppable multi-mip texture allocation size vs single-mip texture. - Add unit test for command-list copy skip on dropped-mip readback. AI-assisted (Gemini / Antigravity).
|
Thanks for the testing and verification on AMD RDNA3 @BatSmacker84! Pushed commit
AI-assisted (Gemini / Antigravity). |
|
Retested
AI-assisted: Codex GPT-6.2 Sol ran the builds and tests, Claude Opus 5.5 reviewed the report. Synthetic fixtures only. |
Summary
Implements #6043: a texture quality switch for low-VRAM GPUs (
LEONIDA_TEXTURE_MIP_DROP).Claimed in coordination issue #6214.
GTA VI textures are mastered for unified console memory (16 GB). On 4 GB and 6 GB PC GPUs, textures can spill into slow host system memory. Setting
LEONIDA_TEXTURE_MIP_DROP=1(or 2 or 3) leaves out the top mip level(s) of pure sampled textures at creation time, reducing texture dimensions by 2x (4x area) and saving ~75% texture VRAM consumption for drop 1 (~93.75% for drop 2).Changes
runtime/shims/d3d12_vulkan_device.cpp):configured_texture_mip_drop()readingLEONIDA_TEXTURE_MIP_DROP(clamped 0..3).TextureCreateInfo, pure sampled textures halve width/height per dropped mip (>> N) and reducemipLevelsbymips_dropped.D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET), Depth-stencils (D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL), UAVs (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS), and 1-mip textures are never dropped to keep viewport and dispatch dimensions exact.Resource::cpu_copy(), writes to dropped mips are discarded (S_OK) and reads return zeroed data; active subresource copies are remapped byslice * new_mips + (mip - mips_dropped).CreateShaderResourceView(), shiftsview.first_mipdown bymips_droppedand clampsview.mip_countto available image mips.tests/test_texture_mip_drop.py):docs/boot.md("Useful switches") anddocs/d3d12_vulkan.md("Texture memory budgets").Testing
python3 -I tests/test_texture_mip_drop.py: 9/9 passed (0.000s)python3 -I tests/test_text_write_line_endings.py: 3/3 passed (LF line endings verified)python3 -m compileall -q make_game.py tools tests: 0 errorspython3 -m unittest discover -s tests/semantic -v: 6,150 tests passed (0 failures)AI-assisted (Gemini / Antigravity).