GPU diagnostics: texture census does not account for all live HostTexture allocations #3334

Open
opened 2026-11-26 18:58:10 +00:00 by github-bot · 1 comment
Owner

@⁠FunWithFlagsDev on GitHub · 2026-11-26 18:50 UTC · original

<html>

Summary

On main at 63bcca43c6a00a758510398fa43096ce7e4f7df0, the global host texture counters and the detailed texture census cover different populations of live objects.

This may make memory retention analysis difficult, particularly on memory-constrained adapters.

Source-level findings

  1. HostTexture::new() increments TEXTURES and TEXTURE_BYTES, while Drop decrements them.

  2. texture_census() enumerates weak references stored in MEMORY.

  3. shared_texture() can replace an existing entry in MEMORY while the previous host texture remains alive through other references.

  4. Auxiliary depth twin textures are constructed through HostTexture::new() without being inserted into MEMORY.

Consequently, summing the detailed census categories does not necessarily reproduce the global live texture byte count.

Relevant source locations

  • resource.rs:831–859

  • resource.rs:936–969

  • resource.rs:1246–1263

  • twin.rs:140–143

  • host.rs:3084–3119

Synthetic reproduction

An independent weak-reference model demonstrates the accounting difference:

State | Global live MiB | Indexed MiB -- | -- | -- Initial resource | 8 | 8 Replacement while old resource remains referenced | 24 | 16 Additional unindexed auxiliary resource | 28 | 16 Old resource released | 20 | 16 Auxiliary resource released | 16 | 16 All resources released | 0 | 0

Six automated model tests and six deterministic assertions passed.

These are synthetic allocation sizes, not measured GPU residency.

Suggested improvement

Could the diagnostics explicitly distinguish indexed texture bytes from total live HostTexture bytes?

A separate category for unclassified or unindexed live allocations would make the scope of the census clearer. If this limited coverage is intentional, documenting it in the diagnostic output would also address the ambiguity.

Concurrent updates and the cost of diagnostic collection should be considered.

Scope and limitations

This report identifies a diagnostic coverage discrepancy, not a confirmed GPU memory leak.

No native D3D12 execution or Rust workspace validation was performed. No proprietary assets or game files were used.

</html>

cache_census_model.py

**@⁠FunWithFlagsDev** on GitHub · 2026-11-26 18:50 UTC · [original](https://github.com/Marvisak/VIctory/issues/3334) <html> <body> <!--StartFragment--><h2><span></span></h2><h3><span>Summary</span></h3><p><span>On main at </span><code><span>63bcca43c6a00a758510398fa43096ce7e4f7df0</span></code><span>, the global host texture counters and the detailed texture census cover different populations of live objects.</span></p><p><span>This may make memory retention analysis difficult, particularly on memory-constrained adapters.</span></p><h3><span>Source-level findings</span></h3><ol start="1"><li><p><code><span>HostTexture::new()</span></code><span> increments </span><code><span>TEXTURES</span></code><span> and </span><code><span>TEXTURE_BYTES</span></code><span>, while </span><code><span>Drop</span></code><span> decrements them.</span></p></li><li><p><code><span>texture_census()</span></code><span> enumerates weak references stored in </span><code><span>MEMORY</span></code><span>.</span></p></li><li><p><code><span>shared_texture()</span></code><span> can replace an existing entry in </span><code><span>MEMORY</span></code><span> while the previous host texture remains alive through other references.</span></p></li><li><p><span>Auxiliary depth twin textures are constructed through </span><code><span>HostTexture::new()</span></code><span> without being inserted into </span><code><span>MEMORY</span></code><span>.</span></p></li></ol><p><span>Consequently, summing the detailed census categories does not necessarily reproduce the global live texture byte count.</span></p><h3><span>Relevant source locations</span></h3><ul><li><p><code><span>resource.rs:831–859</span></code></p></li><li><p><code><span>resource.rs:936–969</span></code></p></li><li><p><code><span>resource.rs:1246–1263</span></code></p></li><li><p><code><span>twin.rs:140–143</span></code></p></li><li><p><code><span>host.rs:3084–3119</span></code></p></li></ul><h3><span>Synthetic reproduction</span></h3><p><span>An independent weak-reference model demonstrates the accounting difference:</span></p> State | Global live MiB | Indexed MiB -- | -- | -- Initial resource | 8 | 8 Replacement while old resource remains referenced | 24 | 16 Additional unindexed auxiliary resource | 28 | 16 Old resource released | 20 | 16 Auxiliary resource released | 16 | 16 All resources released | 0 | 0 <p><span>Six automated model tests and six deterministic assertions passed.</span></p><p><span>These are synthetic allocation sizes, not measured GPU residency.</span></p><h3><span>Suggested improvement</span></h3><p><span>Could the diagnostics explicitly distinguish indexed texture bytes from total live HostTexture bytes?</span></p><p><span>A separate category for unclassified or unindexed live allocations would make the scope of the census clearer. If this limited coverage is intentional, documenting it in the diagnostic output would also address the ambiguity.</span></p><p><span>Concurrent updates and the cost of diagnostic collection should be considered.</span></p><h3><span>Scope and limitations</span></h3><p><span>This report identifies a diagnostic coverage discrepancy, not a confirmed GPU memory leak.</span></p><p><span>No native D3D12 execution or Rust workspace validation was performed. No proprietary assets or game files were used.</span></p><p><span></span></p><!--EndFragment--> </body> </html> [cache_census_model.py](https://github.com/user-attachments/files/35478395/cache_census_model.py)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:58:10 +00:00
Author
Owner

@⁠Ingenioeren on GitHub · 2026-11-26 21:42 UTC · original

Confirmed the diagnostic gap on Windows WARP at public main 63bcca4 using real D3D12 resources and the production constructors. Both tests used synthetic 64×64 textures and read texture_counts() and texture_census() directly.

Fixture at the observation point Extra live HostTexture bytes Extra indexed census bytes
RGBA8 allocation replaced at the same memory key to add UAV support, with the old allocation still held 131,072 65,536
One writable twin plane made from an R16 typeless depth texture 65,536 0

Releasing the old allocation brought the first case's indexed and live totals back into agreement. The counters returned to baseline after releasing the test textures. These values are VIctory's allocation accounting from D3D12, separate from adapter residency measurements. Labeling the detailed row as the title-memory index census would make that scope visible without adding a registry or subtracting two counters that can change independently. Replacement path · Census · Twin constructor

AI-assisted synthetic verification with OpenAI Codex.

**@⁠Ingenioeren** on GitHub · 2026-11-26 21:42 UTC · [original](https://github.com/Marvisak/VIctory/issues/3334#issuecomment-7203980148) Confirmed the diagnostic gap on Windows WARP at public main `63bcca4` using real D3D12 resources and the production constructors. Both tests used synthetic 64×64 textures and read `texture_counts()` and `texture_census()` directly. | Fixture at the observation point | Extra live HostTexture bytes | Extra indexed census bytes | | --- | ---: | ---: | | RGBA8 allocation replaced at the same memory key to add UAV support, with the old allocation still held | 131,072 | 65,536 | | One writable twin plane made from an R16 typeless depth texture | 65,536 | 0 | Releasing the old allocation brought the first case's indexed and live totals back into agreement. The counters returned to baseline after releasing the test textures. These values are VIctory's allocation accounting from D3D12, separate from adapter residency measurements. Labeling the detailed row as the **title-memory index census** would make that scope visible without adding a registry or subtracting two counters that can change independently. [Replacement path](https://github.com/Marvisak/VIctory/blob/63bcca43c6a00a758510398fa43096ce7e4f7df0/crates/victory-gpu/src/resource.rs#L1244-L1265) · [Census](https://github.com/Marvisak/VIctory/blob/63bcca43c6a00a758510398fa43096ce7e4f7df0/crates/victory-gpu/src/resource.rs#L927-L951) · [Twin constructor](https://github.com/Marvisak/VIctory/blob/63bcca43c6a00a758510398fa43096ce7e4f7df0/crates/victory-gpu/src/twin.rs#L116-L142) AI-assisted synthetic verification with OpenAI Codex.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#3334
No description provided.