GPU/VRAM: investigate resource retention by released dynamic descriptor slots under memory pressure #266

Open
opened 2026-11-26 13:55:24 +00:00 by github-bot · 1 comment
Owner

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

<html>

Summary

While investigating memory pressure on NVIDIA GPUs with 8 GiB of VRAM, I identified a potentially important distinction between dynamic descriptor slot reclamation and the reclamation of resources referenced by those slots.

HostHeap::release() returns descriptor indices to the allocator but does not clear the corresponding retained ID3D12Resource references.

Consequently, a dynamic descriptor slot can be available for allocation while still retaining its previous buffer or texture.

This may also interfere with idle texture reclamation, which explicitly requires the host texture to have a single remaining COM reference.

However, some of this retention is intentional and protects against previously observed GPU page faults. This report therefore proposes measurement and controlled validation rather than unconditional resource release.

1. Affected revision

Repository: avatarmanz/VIctory-7900XTX

Commit:

c9c932cbcc38defd8f1683d62dd298187f565031

Relevant files:

  • crates/victory-gpu/src/descriptor/host.rs

  • crates/victory-gpu/src/descriptor.rs

  • crates/victory-gpu/src/draw.rs

  • crates/victory-gpu/src/resource.rs

  • crates/victory-gpu/src/host.rs

  • crates/victory-gpu/src/pool.rs

2. Descriptor allocation state and resource ownership are independent

The dynamic descriptor release implementation is located in:

descriptor/host.rs:2780–2793

pub(crate) fn release(&self, first: u32, n: u32) {
    let Some(at) = first.checked_sub(self.count) else {
        return;
    };
let mut guard = self.next.lock()
    .unwrap_or_else(|e| e.into_inner());

let end = (at + n).min(self.dynamic) as usize;

if let Some(slots) = guard.1.get_mut(at as usize..end) {
    let given = slots.iter()
        .filter(|taken| **taken)
        .count() as u32;

    self.free.fetch_add(
        given,
        std::sync::atomic::Ordering::Relaxed
    );

    self.too_long.store(
        u32::MAX,
        std::sync::atomic::Ordering::Relaxed
    );

    slots.fill(false);
}

}

This releases the allocator reservation.

However, it does not:

  • Remove the retained resource from self.kept.

  • Replace the existing descriptor with a null descriptor.

  • Clear an associated raw twin.

  • Transfer the retained resource to the retirement mechanism.

The allocator's free-slot state is therefore independent of the resource ownership state.

3. Strong resource references survive slot release

The dynamic raw buffer descriptor path retains its underlying resource:

descriptor/host.rs:2936–2962

self.put(index);
self.clear_twin(index);
self.keep(index, Some(buffer.clone()));

Similarly, make_at() and make_listed() retain resources associated with dynamic descriptors.

See:

descriptor/host.rs:2800–2852

The keep() implementation replaces the resource associated with a slot and retires the previous reference:

descriptor/host.rs:2908–2931

let old = {
use windows::core::Interface;

let mut slot = slot.lock()
    .unwrap_or_else(|e| e.into_inner());

if slot.as_ref().map(Interface::as_raw)
    == resource.as_ref().map(Interface::as_raw)
{
    return;
}

std::mem::replace(&amp;mut *slot, resource)

};

if let Some(old) = old {
crate::host::retire_resource(old);
}

Since release() does not call this mechanism, a free dynamic slot may retain its previous resource until the slot is overwritten, explicitly cleared or the descriptor heap is destroyed.

This is bounded retention rather than evidence of an unbounded memory leak.

4. Potential interaction with idle texture reclamation

The existing idle texture sweep evaluates resource ownership before reclaiming a texture.

See:

resource.rs:2145–2160

The relevant conditions include:

std::sync::Arc::strong_count(host) == 1
&& crate::host::references(&host.texture) == 1

Consider a synthetic ownership sequence:

Host texture exists.
A dynamic descriptor retains the texture.
The corresponding command list completes.
Its dynamic descriptor slot is returned.
The slot continues to retain the texture.
The texture becomes old enough for idle reclamation.
The texture has more than one COM reference.
The ownership check prevents reclamation.

This is a conditional consequence of the current ownership mechanism.

Other references may also prevent reclamation, including:

  • Active command lists.

  • Title descriptor slots.

  • Thread-local descriptor caches.

  • Pending resource retirements.

  • Other host-side owners.

The important unresolved question is how often released dynamic slots are the remaining obstacle to texture reclamation.

5. Existing safety rationale must be preserved

The constant-buffer descriptor implementation documents why additional resource retention was introduced:

descriptor/host.rs:3045–3054

The comments describe previously observed device page faults when shaders calculated incorrect descriptor indices and accessed memory associated with freed scratch buffers.

The additional slot ownership was introduced as a defensive lifetime mechanism.

Therefore, I am not proposing:

  • Disabling VICTORY_SLOT_HOLDS by default.

  • Immediately dropping every resource when a dynamic slot is returned.

  • Removing the existing retirement delay.

  • Assuming that GPU fence completion alone guarantees that no future access is possible.

Any optimization must preserve the documented page-fault protection or establish that it is unnecessary for the affected resource category.

The command-list state also documents potential descriptor reuse hazards when a list is submitted again after its tables have been returned.

See:

draw.rs:446–479

These considerations should be treated as explicit constraints.

6. Proposed diagnostic instrumentation

Before modifying resource lifetimes, I suggest measuring the following counters.

Dynamic descriptor ownership

dynamic_slots_total
dynamic_slots_allocated
dynamic_slots_free

dynamic_allocated_slots_with_resource
dynamic_free_slots_with_resource

dynamic_allocated_unique_resources
dynamic_free_unique_resources

Resource categories

Where identifiable, separate:

Textures
Default-heap buffers
Upload buffers
Constant-buffer scratch allocations
Other resources

Idle texture reclamation

Additional counters could distinguish:

idle_texture_candidates
idle_texture_rejected_arc_count
idle_texture_rejected_com_count
idle_texture_rejected_free_dynamic_slot_reference

The final counter requires establishing that free dynamic descriptor ownership is the relevant remaining obstacle, rather than simply finding another reference to the same resource.

Memory accounting

Resource counts must be deduplicated by COM identity.

Multiple descriptors referencing the same resource should not be interpreted as multiple independent memory allocations.

For placed textures and suballocated scratch buffers, backing allocations must be considered separately.

Estimated resource sizes should not be presented as measured physical VRAM residency.

Where possible, correlate the diagnostic counters with DXGI local and nonlocal memory usage.

Diagnostics should avoid retaining additional resource references that could themselves interfere with the reference-count-based idle reclamation test.

Sampling should occur outside the hot draw path.

7. Asset-free synthetic validation

The attached Python model verifies basic resource ownership and concurrent slot-reuse invariants.

All eight tests passed.

The model covers:

  • Current release retaining resource ownership.

  • Resource replacement after slot reuse.

  • Shared references to a single resource.

  • Deduplication by resource identity.

  • Cleanup ordering.

  • Protection of a subsequent slot owner.

  • Empty allocator state.

  • Exhaustive enumeration of three legal abstract cleanup orderings.

Illustrative synthetic ownership results:

Free-slot references Distinct retained resources Modeled resource sizes
8 1 64 KiB
128 16 1 MiB
2,048 256 16 MiB

These implementations continue returning allocator ranges without clearing the corresponding retained resources in release().

This is complementary to their objectives.

In particular:

  • #47 improves free-range allocation.

  • #48 returns descriptor ranges earlier after GPU completion.

  • #96 introduces sharded descriptor allocation.

  • #237 improves NVIDIA descriptor allocation and early release.

  • #212 introduces fence-safe texture eviction and adaptive mip clamping.

Earlier descriptor index reclamation does not necessarily imply earlier reclamation of the resources referenced by those descriptors.

The diagnostic work may also complement #69, which introduces memory-category logging.

The duplicate search was limited to selected PRs and source paths.

11. Possible optimization after validation

If diagnostics establish meaningful memory pressure from released dynamic slots, a narrowly scoped opt-in optimization could be investigated.

Potential requirements include:

  • Confirmed GPU completion.

  • Explicit handling of device removal.

  • No possible subsequent command-list replay using the released descriptor.

  • Preservation of defensive ownership for invalid shader indexing.

  • Replacement of old descriptors and raw twins before retirement.

  • Atomic ownership transfer relative to allocator reuse.

  • Existing deferred resource retirement and bury-lag semantics.

  • No interference with newer slot generations.

  • No additional lock-ordering hazards.

The existing resource retirement implementation should be preserved:

host.rs:591–625

A blanket removal of retained references is not recommended.

12. Relevance to NVIDIA GPUs with limited VRAM

This investigation complements two earlier reports:

  • #256 — Recovery after transient texture allocation failures.

  • #262 — Texture pool accounting and allocation eligibility.

The three investigations address different stages of memory management:

Determine whether new allocations should proceed.
Identify resources that remain retained after use.
Recover resources after temporary allocation failure.

The objective is to determine whether a meaningful amount of memory can be reclaimed safely without weakening existing stability protections.

Attachment

avatar_descriptor_retention_audit.zip

Contents:

  • README.md

  • model.py

  • test_model.py

  • results.txt

  • native_probe.rs

Reproduction:

python model.py
python -m unittest -v test_model

No external Python dependencies are required.

Requested verification

Could an independent contributor run the proposed native observation test and determine whether free dynamic descriptor references are a significant obstacle to idle texture reclamation?

If the retained resources account for meaningful memory pressure, I suggest coordinating a diagnostic-first optimization with the authors of #48, #69, #212 and #237.

Credits and limitations

AI-assisted source investigation, synthetic ownership modeling and test design using ChatGPT.

Only public repository source and invented test data were used. No proprietary game files, binaries, SDK material, shader dumps or gameplay captures are included.

All eight Python tests passed.

The proposed Rust observation test has not been compiled or executed by this investigation.

No production correction, native concurrency reproduction, measured VRAM reduction or FPS improvement is claimed.

</html>## Summary

While investigating memory pressure on NVIDIA GPUs with 8 GiB of VRAM, I identified a potentially important distinction between dynamic descriptor slot reclamation and the reclamation of resources referenced by those slots.

HostHeap::release() returns descriptor indices to the allocator but does not clear the corresponding retained ID3D12Resource references.

Consequently, a dynamic descriptor slot can be available for allocation while still retaining its previous buffer or texture.

This may also interfere with idle texture reclamation, which explicitly requires the host texture to have a single remaining COM reference.

However, some of this retention is intentional and protects against previously observed GPU page faults. This report therefore proposes measurement and controlled validation rather than unconditional resource release.

1. Affected revision

Repository: avatarmanz/VIctory-7900XTX

Commit:

c9c932cbcc38defd8f1683d62dd298187f565031

Relevant files:

  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/descriptor.rs
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/resource.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/pool.rs

2. Descriptor allocation state and resource ownership are independent

The dynamic descriptor release implementation is located in:

[descriptor/host.rs:2780–2793](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2780-L2793)

pub(crate) fn release(&self, first: u32, n: u32) {
    let Some(at) = first.checked_sub(self.count) else {
        return;
    };

    let mut guard = self.next.lock()
        .unwrap_or_else(|e| e.into_inner());

    let end = (at + n).min(self.dynamic) as usize;

    if let Some(slots) = guard.1.get_mut(at as usize..end) {
        let given = slots.iter()
            .filter(|taken| **taken)
            .count() as u32;

        self.free.fetch_add(
            given,
            std::sync::atomic::Ordering::Relaxed
        );

        self.too_long.store(
            u32::MAX,
            std::sync::atomic::Ordering::Relaxed
        );

        slots.fill(false);
    }
}

This releases the allocator reservation.

However, it does not:

  • Remove the retained resource from self.kept.
  • Replace the existing descriptor with a null descriptor.
  • Clear an associated raw twin.
  • Transfer the retained resource to the retirement mechanism.

The allocator's free-slot state is therefore independent of the resource ownership state.

3. Strong resource references survive slot release

The dynamic raw buffer descriptor path retains its underlying resource:

[descriptor/host.rs:2936–2962](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2936-L2962)

self.put(index);
self.clear_twin(index);
self.keep(index, Some(buffer.clone()));

Similarly, make_at() and make_listed() retain resources associated with dynamic descriptors.

See:

[descriptor/host.rs:2800–2852](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2800-L2852)

The keep() implementation replaces the resource associated with a slot and retires the previous reference:

[descriptor/host.rs:2908–2931](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2908-L2931)

let old = {
    use windows::core::Interface;

    let mut slot = slot.lock()
        .unwrap_or_else(|e| e.into_inner());

    if slot.as_ref().map(Interface::as_raw)
        == resource.as_ref().map(Interface::as_raw)
    {
        return;
    }

    std::mem::replace(&mut *slot, resource)
};

if let Some(old) = old {
    crate::host::retire_resource(old);
}

Since release() does not call this mechanism, a free dynamic slot may retain its previous resource until the slot is overwritten, explicitly cleared or the descriptor heap is destroyed.

This is bounded retention rather than evidence of an unbounded memory leak.

4. Potential interaction with idle texture reclamation

The existing idle texture sweep evaluates resource ownership before reclaiming a texture.

See:

[resource.rs:2145–2160](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/resource.rs#L2145-L2160)

The relevant conditions include:

std::sync::Arc::strong_count(host) == 1
    && crate::host::references(&host.texture) == 1

Consider a synthetic ownership sequence:

Host texture exists.
A dynamic descriptor retains the texture.
The corresponding command list completes.
Its dynamic descriptor slot is returned.
The slot continues to retain the texture.
The texture becomes old enough for idle reclamation.
The texture has more than one COM reference.
The ownership check prevents reclamation.

This is a conditional consequence of the current ownership mechanism.

Other references may also prevent reclamation, including:

  • Active command lists.
  • Title descriptor slots.
  • Thread-local descriptor caches.
  • Pending resource retirements.
  • Other host-side owners.

The important unresolved question is how often released dynamic slots are the remaining obstacle to texture reclamation.

5. Existing safety rationale must be preserved

The constant-buffer descriptor implementation documents why additional resource retention was introduced:

[descriptor/host.rs:3045–3054](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L3045-L3054)

The comments describe previously observed device page faults when shaders calculated incorrect descriptor indices and accessed memory associated with freed scratch buffers.

The additional slot ownership was introduced as a defensive lifetime mechanism.

Therefore, I am not proposing:

  • Disabling VICTORY_SLOT_HOLDS by default.
  • Immediately dropping every resource when a dynamic slot is returned.
  • Removing the existing retirement delay.
  • Assuming that GPU fence completion alone guarantees that no future access is possible.

Any optimization must preserve the documented page-fault protection or establish that it is unnecessary for the affected resource category.

The command-list state also documents potential descriptor reuse hazards when a list is submitted again after its tables have been returned.

See:

[draw.rs:446–479](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/draw.rs#L446-L479)

These considerations should be treated as explicit constraints.

6. Proposed diagnostic instrumentation

Before modifying resource lifetimes, I suggest measuring the following counters.

Dynamic descriptor ownership

dynamic_slots_total
dynamic_slots_allocated
dynamic_slots_free

dynamic_allocated_slots_with_resource
dynamic_free_slots_with_resource

dynamic_allocated_unique_resources
dynamic_free_unique_resources

Resource categories

Where identifiable, separate:

Textures
Default-heap buffers
Upload buffers
Constant-buffer scratch allocations
Other resources

Idle texture reclamation

Additional counters could distinguish:

idle_texture_candidates
idle_texture_rejected_arc_count
idle_texture_rejected_com_count
idle_texture_rejected_free_dynamic_slot_reference

The final counter requires establishing that free dynamic descriptor ownership is the relevant remaining obstacle, rather than simply finding another reference to the same resource.

Memory accounting

Resource counts must be deduplicated by COM identity.

Multiple descriptors referencing the same resource should not be interpreted as multiple independent memory allocations.

For placed textures and suballocated scratch buffers, backing allocations must be considered separately.

Estimated resource sizes should not be presented as measured physical VRAM residency.

Where possible, correlate the diagnostic counters with DXGI local and nonlocal memory usage.

Diagnostics should avoid retaining additional resource references that could themselves interfere with the reference-count-based idle reclamation test.

Sampling should occur outside the hot draw path.

7. Asset-free synthetic validation

The attached Python model verifies basic resource ownership and concurrent slot-reuse invariants.

All eight tests passed.

The model covers:

  • Current release retaining resource ownership.
  • Resource replacement after slot reuse.
  • Shared references to a single resource.
  • Deduplication by resource identity.
  • Cleanup ordering.
  • Protection of a subsequent slot owner.
  • Empty allocator state.
  • Exhaustive enumeration of three legal abstract cleanup orderings.

Illustrative synthetic ownership results:

Free-slot references Distinct retained resources Modeled resource sizes
8 1 64 KiB
128 16 1 MiB
2,048 256 16 MiB

These values are invented test data.

They do not represent observed allocations, physical GPU residency or expected memory savings.

8. Concurrency hazard in a naive correction

Simply clearing a retained reference after making a slot available introduces a potential ownership race.

Thread A:
    Publish slot as free.

Thread B:
    Allocate the same slot.
    Install a new descriptor.
    Retain resource B.

Thread A:
    Clear the old resource reference.

The final cleanup can remove the new owner's reference.

The synthetic model evaluates the following legal abstract sequences:

Sequence Preserves the new owner's reference
Clear, publish free, allocate new Yes
Publish free, clear, allocate new Yes
Publish free, allocate new, clear No

This is a potential regression of an incorrectly implemented future correction, not a race demonstrated in the current source.

A candidate implementation would require existing allocator synchronization or a generation-aware quarantined state.

The slot must not become reusable before its required cleanup is complete.

Additional lock-ordering and GPU lifetime constraints must also be considered.

9. Proposed native observation test

The attached native_probe.rs contains a proposed test for the existing descriptor/host.rs test module.

Test name:

observe_dynamic_slot_resource_retention_after_release

The test uses the same synthetic buffer and descriptor APIs as the existing views_are_made_beside_the_heap_and_copied_in test.

Its sequence is:

  1. Create a small synthetic D3D12 buffer.
  2. Allocate one dynamic descriptor slot.
  3. Create a raw buffer descriptor in that slot.
  4. Confirm that kept_in() retains the buffer.
  5. Release the dynamic slot.
  6. Confirm that the resource reference remains.
  7. Force the allocator to reuse the same slot.
  8. Replace the descriptor with a null raw view.
  9. Confirm that the slot no longer retains the previous resource.

Suggested execution after reviewing and inserting the proposed test into the pinned source:

cargo test -p victory-gpu observe_dynamic_slot_resource_retention_after_release -- --nocapture --test-threads=1

The proposed test requires a functioning D3D12 host and deliberately avoids silently passing when no host is available.

It submits no GPU work.

Its purpose is to document baseline resource retention, not to demonstrate that removing the retention would be safe.

A subsequent regression should exercise an actual idle texture with controlled ownership and verify reclamation eligibility.

10. Relationship to existing descriptor and memory PRs

I inspected the HostHeap::release() implementations in the following candidate revisions:

PR Revision
#47 025eddeadff7b61ee48ca039f95161809d015992
#48 dca516de780ff3ebfa8d7a65600118787ab3437b
#96 defe56b5a0543d25f8ff9d12e988eb0feaee5e3a
#237 77e4543121a687aa17d30347f9ed161bb327c818
#212 1e710c4bbeb03ce24bd3f2398621c0cb1c572702

These implementations continue returning allocator ranges without clearing the corresponding retained resources in release().

This is complementary to their objectives.

In particular:

  • #47 improves free-range allocation.
  • #48 returns descriptor ranges earlier after GPU completion.
  • #96 introduces sharded descriptor allocation.
  • #237 improves NVIDIA descriptor allocation and early release.
  • #212 introduces fence-safe texture eviction and adaptive mip clamping.

Earlier descriptor index reclamation does not necessarily imply earlier reclamation of the resources referenced by those descriptors.

The diagnostic work may also complement #69, which introduces memory-category logging.

The duplicate search was limited to selected PRs and source paths.

11. Possible optimization after validation

If diagnostics establish meaningful memory pressure from released dynamic slots, a narrowly scoped opt-in optimization could be investigated.

Potential requirements include:

  • Confirmed GPU completion.
  • Explicit handling of device removal.
  • No possible subsequent command-list replay using the released descriptor.
  • Preservation of defensive ownership for invalid shader indexing.
  • Replacement of old descriptors and raw twins before retirement.
  • Atomic ownership transfer relative to allocator reuse.
  • Existing deferred resource retirement and bury-lag semantics.
  • No interference with newer slot generations.
  • No additional lock-ordering hazards.

The existing resource retirement implementation should be preserved:

[host.rs:591–625](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/host.rs#L591-L625)

A blanket removal of retained references is not recommended.

12. Relevance to NVIDIA GPUs with limited VRAM

This investigation complements two earlier reports:

  • #256 — Recovery after transient texture allocation failures.
  • #262 — Texture pool accounting and allocation eligibility.

The three investigations address different stages of memory management:

Determine whether new allocations should proceed.
Identify resources that remain retained after use.
Recover resources after temporary allocation failure.

The objective is to determine whether a meaningful amount of memory can be reclaimed safely without weakening existing stability protections.

Attachment

avatar_descriptor_retention_audit.zip

Contents:

  • README.md
  • model.py
  • test_model.py
  • results.txt
  • native_probe.rs

Reproduction:

python model.py
python -m unittest -v test_model

No external Python dependencies are required.

Requested verification

Could an independent contributor run the proposed native observation test and determine whether free dynamic descriptor references are a significant obstacle to idle texture reclamation?

If the retained resources account for meaningful memory pressure, I suggest coordinating a diagnostic-first optimization with the authors of #48, #69, #212 and #237.

Credits and limitations

avatar_descriptor_retention_audit.zip

Only public repository source and invented test data were used. No proprietary game files, binaries, SDK material, shader dumps or gameplay captures are included.

All eight Python tests passed.

The proposed Rust observation test has not been compiled or executed by this investigation.

No production correction, native concurrency reproduction, measured VRAM reduction or FPS improvement is claimed.

**@⁠FunWithFlagsDev** on GitHub · 2026-11-26 13:50 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/266) <html> <body> <!--StartFragment--><h2><span>Summary</span></h2><p><span>While investigating memory pressure on NVIDIA GPUs with 8 GiB of VRAM, I identified a potentially important distinction between dynamic descriptor slot reclamation and the reclamation of resources referenced by those slots.</span></p><p><code><span>HostHeap::release()</span></code><span> returns descriptor indices to the allocator but does not clear the corresponding retained </span><code><span>ID3D12Resource</span></code><span> references.</span></p><p><span>Consequently, a dynamic descriptor slot can be available for allocation while still retaining its previous buffer or texture.</span></p><p><span>This may also interfere with idle texture reclamation, which explicitly requires the host texture to have a single remaining COM reference.</span></p><p><span>However, some of this retention is intentional and protects against previously observed GPU page faults. This report therefore proposes measurement and controlled validation rather than unconditional resource release.</span></p><h2><span>1. Affected revision</span></h2><p><span>Repository: </span><code><span>avatarmanz/VIctory-7900XTX</span></code></p><p><span>Commit:</span></p><p><code><span>c9c932cbcc38defd8f1683d62dd298187f565031</span></code></p><p><span>Relevant files:</span></p><ul><li><p><code><span>crates/victory-gpu/src/descriptor/host.rs</span></code></p></li><li><p><code><span>crates/victory-gpu/src/descriptor.rs</span></code></p></li><li><p><code><span>crates/victory-gpu/src/draw.rs</span></code></p></li><li><p><code><span>crates/victory-gpu/src/resource.rs</span></code></p></li><li><p><code><span>crates/victory-gpu/src/host.rs</span></code></p></li><li><p><code><span>crates/victory-gpu/src/pool.rs</span></code></p></li></ul><h2><span>2. Descriptor allocation state and resource ownership are independent</span></h2><p><span>The dynamic descriptor release implementation is located in:</span></p><p><a href="https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2780-L2793"><code><span>descriptor/host.rs:2780–2793</span></code></a></p><pre><code><span>pub(crate) fn release(&amp;self, first: u32, n: u32) { let Some(at) = first.checked_sub(self.count) else { return; }; let mut guard = self.next.lock() .unwrap_or_else(|e| e.into_inner()); let end = (at + n).min(self.dynamic) as usize; if let Some(slots) = guard.1.get_mut(at as usize..end) { let given = slots.iter() .filter(|taken| **taken) .count() as u32; self.free.fetch_add( given, std::sync::atomic::Ordering::Relaxed ); self.too_long.store( u32::MAX, std::sync::atomic::Ordering::Relaxed ); slots.fill(false); } }</span></code></pre><p><span>This releases the allocator reservation.</span></p><p><span>However, it does not:</span></p><ul><li><p><span>Remove the retained resource from </span><code><span>self.kept</span></code><span>.</span></p></li><li><p><span>Replace the existing descriptor with a null descriptor.</span></p></li><li><p><span>Clear an associated raw twin.</span></p></li><li><p><span>Transfer the retained resource to the retirement mechanism.</span></p></li></ul><p><span>The allocator's free-slot state is therefore independent of the resource ownership state.</span></p><h2><span>3. Strong resource references survive slot release</span></h2><p><span>The dynamic raw buffer descriptor path retains its underlying resource:</span></p><p><a href="https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2936-L2962"><code><span>descriptor/host.rs:2936–2962</span></code></a></p><pre><code><span>self.put(index); self.clear_twin(index); self.keep(index, Some(buffer.clone()));</span></code></pre><p><span>Similarly, </span><code><span>make_at()</span></code><span> and </span><code><span>make_listed()</span></code><span> retain resources associated with dynamic descriptors.</span></p><p><span>See:</span></p><p><a href="https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2800-L2852"><code><span>descriptor/host.rs:2800–2852</span></code></a></p><p><span>The </span><code><span>keep()</span></code><span> implementation replaces the resource associated with a slot and retires the previous reference:</span></p><p><a href="https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2908-L2931"><code><span>descriptor/host.rs:2908–2931</span></code></a></p><pre><code><span>let old = { use windows::core::Interface; let mut slot = slot.lock() .unwrap_or_else(|e| e.into_inner()); if slot.as_ref().map(Interface::as_raw) == resource.as_ref().map(Interface::as_raw) { return; } std::mem::replace(&amp;mut *slot, resource) }; if let Some(old) = old { crate::host::retire_resource(old); }</span></code></pre><p><span>Since </span><code><span>release()</span></code><span> does not call this mechanism, a free dynamic slot may retain its previous resource until the slot is overwritten, explicitly cleared or the descriptor heap is destroyed.</span></p><p><span>This is bounded retention rather than evidence of an unbounded memory leak.</span></p><h2><span>4. Potential interaction with idle texture reclamation</span></h2><p><span>The existing idle texture sweep evaluates resource ownership before reclaiming a texture.</span></p><p><span>See:</span></p><p><a href="https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/resource.rs#L2145-L2160"><code><span>resource.rs:2145–2160</span></code></a></p><p><span>The relevant conditions include:</span></p><pre><code><span>std::sync::Arc::strong_count(host) == 1 &amp;&amp; crate::host::references(&amp;host.texture) == 1</span></code></pre><p><span>Consider a synthetic ownership sequence:</span></p><pre><code><span>Host texture exists. A dynamic descriptor retains the texture. The corresponding command list completes. Its dynamic descriptor slot is returned. The slot continues to retain the texture. The texture becomes old enough for idle reclamation. The texture has more than one COM reference. The ownership check prevents reclamation.</span></code></pre><p><span>This is a conditional consequence of the current ownership mechanism.</span></p><p><span>Other references may also prevent reclamation, including:</span></p><ul><li><p><span>Active command lists.</span></p></li><li><p><span>Title descriptor slots.</span></p></li><li><p><span>Thread-local descriptor caches.</span></p></li><li><p><span>Pending resource retirements.</span></p></li><li><p><span>Other host-side owners.</span></p></li></ul><p><span>The important unresolved question is how often released dynamic slots are the remaining obstacle to texture reclamation.</span></p><h2><span>5. Existing safety rationale must be preserved</span></h2><p><span>The constant-buffer descriptor implementation documents why additional resource retention was introduced:</span></p><p><a href="https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L3045-L3054"><code><span>descriptor/host.rs:3045–3054</span></code></a></p><p><span>The comments describe previously observed device page faults when shaders calculated incorrect descriptor indices and accessed memory associated with freed scratch buffers.</span></p><p><span>The additional slot ownership was introduced as a defensive lifetime mechanism.</span></p><p><span>Therefore, I am not proposing:</span></p><ul><li><p><span>Disabling </span><code><span>VICTORY_SLOT_HOLDS</span></code><span> by default.</span></p></li><li><p><span>Immediately dropping every resource when a dynamic slot is returned.</span></p></li><li><p><span>Removing the existing retirement delay.</span></p></li><li><p><span>Assuming that GPU fence completion alone guarantees that no future access is possible.</span></p></li></ul><p><span>Any optimization must preserve the documented page-fault protection or establish that it is unnecessary for the affected resource category.</span></p><p><span>The command-list state also documents potential descriptor reuse hazards when a list is submitted again after its tables have been returned.</span></p><p><span>See:</span></p><p><a href="https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/draw.rs#L446-L479"><code><span>draw.rs:446–479</span></code></a></p><p><span>These considerations should be treated as explicit constraints.</span></p><h2><span>6. Proposed diagnostic instrumentation</span></h2><p><span>Before modifying resource lifetimes, I suggest measuring the following counters.</span></p><h3><span>Dynamic descriptor ownership</span></h3><pre><code><span>dynamic_slots_total dynamic_slots_allocated dynamic_slots_free dynamic_allocated_slots_with_resource dynamic_free_slots_with_resource dynamic_allocated_unique_resources dynamic_free_unique_resources</span></code></pre><h3><span>Resource categories</span></h3><p><span>Where identifiable, separate:</span></p><pre><code><span>Textures Default-heap buffers Upload buffers Constant-buffer scratch allocations Other resources</span></code></pre><h3><span>Idle texture reclamation</span></h3><p><span>Additional counters could distinguish:</span></p><pre><code><span>idle_texture_candidates idle_texture_rejected_arc_count idle_texture_rejected_com_count idle_texture_rejected_free_dynamic_slot_reference</span></code></pre><p><span>The final counter requires establishing that free dynamic descriptor ownership is the relevant remaining obstacle, rather than simply finding another reference to the same resource.</span></p><h3><span>Memory accounting</span></h3><p><span>Resource counts must be deduplicated by COM identity.</span></p><p><span>Multiple descriptors referencing the same resource should not be interpreted as multiple independent memory allocations.</span></p><p><span>For placed textures and suballocated scratch buffers, backing allocations must be considered separately.</span></p><p><span>Estimated resource sizes should not be presented as measured physical VRAM residency.</span></p><p><span>Where possible, correlate the diagnostic counters with DXGI local and nonlocal memory usage.</span></p><p><span>Diagnostics should avoid retaining additional resource references that could themselves interfere with the reference-count-based idle reclamation test.</span></p><p><span>Sampling should occur outside the hot draw path.</span></p><h2><span>7. Asset-free synthetic validation</span></h2><p><span>The attached Python model verifies basic resource ownership and concurrent slot-reuse invariants.</span></p><p><span>All eight tests passed.</span></p><p><span>The model covers:</span></p><ul><li><p><span>Current release retaining resource ownership.</span></p></li><li><p><span>Resource replacement after slot reuse.</span></p></li><li><p><span>Shared references to a single resource.</span></p></li><li><p><span>Deduplication by resource identity.</span></p></li><li><p><span>Cleanup ordering.</span></p></li><li><p><span>Protection of a subsequent slot owner.</span></p></li><li><p><span>Empty allocator state.</span></p></li><li><p><span>Exhaustive enumeration of three legal abstract cleanup orderings.</span></p></li></ul><p><span>Illustrative synthetic ownership results:</span></p> Free-slot references | Distinct retained resources | Modeled resource sizes -- | -- | -- 8 | 1 | 64 KiB 128 | 16 | 1 MiB 2,048 | 256 | 16 MiB <p><span>These implementations continue returning allocator ranges without clearing the corresponding retained resources in </span><code><span>release()</span></code><span>.</span></p><p><span>This is complementary to their objectives.</span></p><p><span>In particular:</span></p><ul><li><p><span>#47 improves free-range allocation.</span></p></li><li><p><span>#48 returns descriptor ranges earlier after GPU completion.</span></p></li><li><p><span>#96 introduces sharded descriptor allocation.</span></p></li><li><p><span>#237 improves NVIDIA descriptor allocation and early release.</span></p></li><li><p><span>#212 introduces fence-safe texture eviction and adaptive mip clamping.</span></p></li></ul><p><span>Earlier descriptor index reclamation does not necessarily imply earlier reclamation of the resources referenced by those descriptors.</span></p><p><span>The diagnostic work may also complement #69, which introduces memory-category logging.</span></p><p><span>The duplicate search was limited to selected PRs and source paths.</span></p><h2><span>11. Possible optimization after validation</span></h2><p><span>If diagnostics establish meaningful memory pressure from released dynamic slots, a narrowly scoped opt-in optimization could be investigated.</span></p><p><span>Potential requirements include:</span></p><ul><li><p><span>Confirmed GPU completion.</span></p></li><li><p><span>Explicit handling of device removal.</span></p></li><li><p><span>No possible subsequent command-list replay using the released descriptor.</span></p></li><li><p><span>Preservation of defensive ownership for invalid shader indexing.</span></p></li><li><p><span>Replacement of old descriptors and raw twins before retirement.</span></p></li><li><p><span>Atomic ownership transfer relative to allocator reuse.</span></p></li><li><p><span>Existing deferred resource retirement and bury-lag semantics.</span></p></li><li><p><span>No interference with newer slot generations.</span></p></li><li><p><span>No additional lock-ordering hazards.</span></p></li></ul><p><span>The existing resource retirement implementation should be preserved:</span></p><p><a href="https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/host.rs#L591-L625"><code><span>host.rs:591–625</span></code></a></p><p><span>A blanket removal of retained references is not recommended.</span></p><h2><span>12. Relevance to NVIDIA GPUs with limited VRAM</span></h2><p><span>This investigation complements two earlier reports:</span></p><ul><li><p><span>#256 — Recovery after transient texture allocation failures.</span></p></li><li><p><span>#262 — Texture pool accounting and allocation eligibility.</span></p></li></ul><p><span>The three investigations address different stages of memory management:</span></p><pre><code><span>Determine whether new allocations should proceed. Identify resources that remain retained after use. Recover resources after temporary allocation failure.</span></code></pre><p><span>The objective is to determine whether a meaningful amount of memory can be reclaimed safely without weakening existing stability protections.</span></p><h2><span>Attachment</span></h2><p><code><span>avatar_descriptor_retention_audit.zip</span></code></p><p><span>Contents:</span></p><ul><li><p><code><span>README.md</span></code></p></li><li><p><code><span>model.py</span></code></p></li><li><p><code><span>test_model.py</span></code></p></li><li><p><code><span>results.txt</span></code></p></li><li><p><code><span>native_probe.rs</span></code></p></li></ul><p><span>Reproduction:</span></p><pre><code><span>python model.py python -m unittest -v test_model</span></code></pre><p><span>No external Python dependencies are required.</span></p><h2><span>Requested verification</span></h2><p><span>Could an independent contributor run the proposed native observation test and determine whether free dynamic descriptor references are a significant obstacle to idle texture reclamation?</span></p><p><span>If the retained resources account for meaningful memory pressure, I suggest coordinating a diagnostic-first optimization with the authors of #48, #69, #212 and #237.</span></p><h2><span>Credits and limitations</span></h2><p><span>AI-assisted source investigation, synthetic ownership modeling and test design using ChatGPT.</span></p><p><span>Only public repository source and invented test data were used. No proprietary game files, binaries, SDK material, shader dumps or gameplay captures are included.</span></p><p><span>All eight Python tests passed.</span></p><p><span>The proposed Rust observation test has not been compiled or executed by this investigation.</span></p><p><span>No production correction, native concurrency reproduction, measured VRAM reduction or FPS improvement is claimed.</span></p><!--EndFragment--> </body> </html>## Summary While investigating memory pressure on NVIDIA GPUs with 8 GiB of VRAM, I identified a potentially important distinction between dynamic descriptor slot reclamation and the reclamation of resources referenced by those slots. `HostHeap::release()` returns descriptor indices to the allocator but does not clear the corresponding retained `ID3D12Resource` references. Consequently, a dynamic descriptor slot can be available for allocation while still retaining its previous buffer or texture. This may also interfere with idle texture reclamation, which explicitly requires the host texture to have a single remaining COM reference. However, some of this retention is intentional and protects against previously observed GPU page faults. This report therefore proposes measurement and controlled validation rather than unconditional resource release. ## 1. Affected revision Repository: `avatarmanz/VIctory-7900XTX` Commit: `c9c932cbcc38defd8f1683d62dd298187f565031` Relevant files: - `crates/victory-gpu/src/descriptor/host.rs` - `crates/victory-gpu/src/descriptor.rs` - `crates/victory-gpu/src/draw.rs` - `crates/victory-gpu/src/resource.rs` - `crates/victory-gpu/src/host.rs` - `crates/victory-gpu/src/pool.rs` ## 2. Descriptor allocation state and resource ownership are independent The dynamic descriptor release implementation is located in: [`[descriptor/host.rs:2780–2793](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2780-L2793)`](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2780-L2793) ```rust pub(crate) fn release(&self, first: u32, n: u32) { let Some(at) = first.checked_sub(self.count) else { return; }; let mut guard = self.next.lock() .unwrap_or_else(|e| e.into_inner()); let end = (at + n).min(self.dynamic) as usize; if let Some(slots) = guard.1.get_mut(at as usize..end) { let given = slots.iter() .filter(|taken| **taken) .count() as u32; self.free.fetch_add( given, std::sync::atomic::Ordering::Relaxed ); self.too_long.store( u32::MAX, std::sync::atomic::Ordering::Relaxed ); slots.fill(false); } } ``` This releases the allocator reservation. However, it does not: - Remove the retained resource from `self.kept`. - Replace the existing descriptor with a null descriptor. - Clear an associated raw twin. - Transfer the retained resource to the retirement mechanism. The allocator's free-slot state is therefore independent of the resource ownership state. ## 3. Strong resource references survive slot release The dynamic raw buffer descriptor path retains its underlying resource: [`[descriptor/host.rs:2936–2962](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2936-L2962)`](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2936-L2962) ```rust self.put(index); self.clear_twin(index); self.keep(index, Some(buffer.clone())); ``` Similarly, `make_at()` and `make_listed()` retain resources associated with dynamic descriptors. See: [`[descriptor/host.rs:2800–2852](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2800-L2852)`](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2800-L2852) The `keep()` implementation replaces the resource associated with a slot and retires the previous reference: [`[descriptor/host.rs:2908–2931](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2908-L2931)`](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L2908-L2931) ```rust let old = { use windows::core::Interface; let mut slot = slot.lock() .unwrap_or_else(|e| e.into_inner()); if slot.as_ref().map(Interface::as_raw) == resource.as_ref().map(Interface::as_raw) { return; } std::mem::replace(&mut *slot, resource) }; if let Some(old) = old { crate::host::retire_resource(old); } ``` Since `release()` does not call this mechanism, a free dynamic slot may retain its previous resource until the slot is overwritten, explicitly cleared or the descriptor heap is destroyed. This is bounded retention rather than evidence of an unbounded memory leak. ## 4. Potential interaction with idle texture reclamation The existing idle texture sweep evaluates resource ownership before reclaiming a texture. See: [`[resource.rs:2145–2160](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/resource.rs#L2145-L2160)`](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/resource.rs#L2145-L2160) The relevant conditions include: ```rust std::sync::Arc::strong_count(host) == 1 && crate::host::references(&host.texture) == 1 ``` Consider a synthetic ownership sequence: ```text Host texture exists. A dynamic descriptor retains the texture. The corresponding command list completes. Its dynamic descriptor slot is returned. The slot continues to retain the texture. The texture becomes old enough for idle reclamation. The texture has more than one COM reference. The ownership check prevents reclamation. ``` This is a conditional consequence of the current ownership mechanism. Other references may also prevent reclamation, including: - Active command lists. - Title descriptor slots. - Thread-local descriptor caches. - Pending resource retirements. - Other host-side owners. The important unresolved question is how often released dynamic slots are the remaining obstacle to texture reclamation. ## 5. Existing safety rationale must be preserved The constant-buffer descriptor implementation documents why additional resource retention was introduced: [`[descriptor/host.rs:3045–3054](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L3045-L3054)`](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/descriptor/host.rs#L3045-L3054) The comments describe previously observed device page faults when shaders calculated incorrect descriptor indices and accessed memory associated with freed scratch buffers. The additional slot ownership was introduced as a defensive lifetime mechanism. Therefore, I am not proposing: - Disabling `VICTORY_SLOT_HOLDS` by default. - Immediately dropping every resource when a dynamic slot is returned. - Removing the existing retirement delay. - Assuming that GPU fence completion alone guarantees that no future access is possible. Any optimization must preserve the documented page-fault protection or establish that it is unnecessary for the affected resource category. The command-list state also documents potential descriptor reuse hazards when a list is submitted again after its tables have been returned. See: [`[draw.rs:446–479](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/draw.rs#L446-L479)`](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/draw.rs#L446-L479) These considerations should be treated as explicit constraints. ## 6. Proposed diagnostic instrumentation Before modifying resource lifetimes, I suggest measuring the following counters. ### Dynamic descriptor ownership ```text dynamic_slots_total dynamic_slots_allocated dynamic_slots_free dynamic_allocated_slots_with_resource dynamic_free_slots_with_resource dynamic_allocated_unique_resources dynamic_free_unique_resources ``` ### Resource categories Where identifiable, separate: ```text Textures Default-heap buffers Upload buffers Constant-buffer scratch allocations Other resources ``` ### Idle texture reclamation Additional counters could distinguish: ```text idle_texture_candidates idle_texture_rejected_arc_count idle_texture_rejected_com_count idle_texture_rejected_free_dynamic_slot_reference ``` The final counter requires establishing that free dynamic descriptor ownership is the relevant remaining obstacle, rather than simply finding another reference to the same resource. ### Memory accounting Resource counts must be deduplicated by COM identity. Multiple descriptors referencing the same resource should not be interpreted as multiple independent memory allocations. For placed textures and suballocated scratch buffers, backing allocations must be considered separately. Estimated resource sizes should not be presented as measured physical VRAM residency. Where possible, correlate the diagnostic counters with DXGI local and nonlocal memory usage. Diagnostics should avoid retaining additional resource references that could themselves interfere with the reference-count-based idle reclamation test. Sampling should occur outside the hot draw path. ## 7. Asset-free synthetic validation The attached Python model verifies basic resource ownership and concurrent slot-reuse invariants. All eight tests passed. The model covers: - Current release retaining resource ownership. - Resource replacement after slot reuse. - Shared references to a single resource. - Deduplication by resource identity. - Cleanup ordering. - Protection of a subsequent slot owner. - Empty allocator state. - Exhaustive enumeration of three legal abstract cleanup orderings. Illustrative synthetic ownership results: | Free-slot references | Distinct retained resources | Modeled resource sizes | |---:|---:|---:| | 8 | 1 | 64 KiB | | 128 | 16 | 1 MiB | | 2,048 | 256 | 16 MiB | These values are invented test data. They do not represent observed allocations, physical GPU residency or expected memory savings. ## 8. Concurrency hazard in a naive correction Simply clearing a retained reference after making a slot available introduces a potential ownership race. ```text Thread A: Publish slot as free. Thread B: Allocate the same slot. Install a new descriptor. Retain resource B. Thread A: Clear the old resource reference. ``` The final cleanup can remove the new owner's reference. The synthetic model evaluates the following legal abstract sequences: | Sequence | Preserves the new owner's reference | |---|---| | Clear, publish free, allocate new | Yes | | Publish free, clear, allocate new | Yes | | Publish free, allocate new, clear | No | This is a potential regression of an incorrectly implemented future correction, not a race demonstrated in the current source. A candidate implementation would require existing allocator synchronization or a generation-aware quarantined state. The slot must not become reusable before its required cleanup is complete. Additional lock-ordering and GPU lifetime constraints must also be considered. ## 9. Proposed native observation test The attached `native_probe.rs` contains a proposed test for the existing `descriptor/host.rs` test module. Test name: `observe_dynamic_slot_resource_retention_after_release` The test uses the same synthetic buffer and descriptor APIs as the existing `views_are_made_beside_the_heap_and_copied_in` test. Its sequence is: 1. Create a small synthetic D3D12 buffer. 2. Allocate one dynamic descriptor slot. 3. Create a raw buffer descriptor in that slot. 4. Confirm that `kept_in()` retains the buffer. 5. Release the dynamic slot. 6. Confirm that the resource reference remains. 7. Force the allocator to reuse the same slot. 8. Replace the descriptor with a null raw view. 9. Confirm that the slot no longer retains the previous resource. Suggested execution after reviewing and inserting the proposed test into the pinned source: ```bash cargo test -p victory-gpu observe_dynamic_slot_resource_retention_after_release -- --nocapture --test-threads=1 ``` The proposed test requires a functioning D3D12 host and deliberately avoids silently passing when no host is available. It submits no GPU work. Its purpose is to document baseline resource retention, not to demonstrate that removing the retention would be safe. A subsequent regression should exercise an actual idle texture with controlled ownership and verify reclamation eligibility. ## 10. Relationship to existing descriptor and memory PRs I inspected the `HostHeap::release()` implementations in the following candidate revisions: | PR | Revision | |---|---| | #47 | `025eddeadff7b61ee48ca039f95161809d015992` | | #48 | `dca516de780ff3ebfa8d7a65600118787ab3437b` | | #96 | `defe56b5a0543d25f8ff9d12e988eb0feaee5e3a` | | #237 | `77e4543121a687aa17d30347f9ed161bb327c818` | | #212 | `1e710c4bbeb03ce24bd3f2398621c0cb1c572702` | These implementations continue returning allocator ranges without clearing the corresponding retained resources in `release()`. This is complementary to their objectives. In particular: - #47 improves free-range allocation. - #48 returns descriptor ranges earlier after GPU completion. - #96 introduces sharded descriptor allocation. - #237 improves NVIDIA descriptor allocation and early release. - #212 introduces fence-safe texture eviction and adaptive mip clamping. Earlier descriptor index reclamation does not necessarily imply earlier reclamation of the resources referenced by those descriptors. The diagnostic work may also complement #69, which introduces memory-category logging. The duplicate search was limited to selected PRs and source paths. ## 11. Possible optimization after validation If diagnostics establish meaningful memory pressure from released dynamic slots, a narrowly scoped opt-in optimization could be investigated. Potential requirements include: - Confirmed GPU completion. - Explicit handling of device removal. - No possible subsequent command-list replay using the released descriptor. - Preservation of defensive ownership for invalid shader indexing. - Replacement of old descriptors and raw twins before retirement. - Atomic ownership transfer relative to allocator reuse. - Existing deferred resource retirement and bury-lag semantics. - No interference with newer slot generations. - No additional lock-ordering hazards. The existing resource retirement implementation should be preserved: [`[host.rs:591–625](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/host.rs#L591-L625)`](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/host.rs#L591-L625) A blanket removal of retained references is not recommended. ## 12. Relevance to NVIDIA GPUs with limited VRAM This investigation complements two earlier reports: - #256 — Recovery after transient texture allocation failures. - #262 — Texture pool accounting and allocation eligibility. The three investigations address different stages of memory management: ```text Determine whether new allocations should proceed. Identify resources that remain retained after use. Recover resources after temporary allocation failure. ``` The objective is to determine whether a meaningful amount of memory can be reclaimed safely without weakening existing stability protections. ## Attachment `avatar_descriptor_retention_audit.zip` Contents: - `README.md` - `model.py` - `test_model.py` - `results.txt` - `native_probe.rs` Reproduction: ```bash python model.py python -m unittest -v test_model ``` No external Python dependencies are required. ## Requested verification Could an independent contributor run the proposed native observation test and determine whether free dynamic descriptor references are a significant obstacle to idle texture reclamation? If the retained resources account for meaningful memory pressure, I suggest coordinating a diagnostic-first optimization with the authors of #48, #69, #212 and #237. ## Credits and limitations [avatar_descriptor_retention_audit.zip](https://github.com/user-attachments/files/35467193/avatar_descriptor_retention_audit.zip) Only public repository source and invented test data were used. No proprietary game files, binaries, SDK material, shader dumps or gameplay captures are included. All eight Python tests passed. The proposed Rust observation test has not been compiled or executed by this investigation. No production correction, native concurrency reproduction, measured VRAM reduction or FPS improvement is claimed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:55:24 +00:00
Author
Owner

@⁠LucaruluDev on GitHub · 2026-11-27 12:19 UTC · original

I ran an independent standalone D3D12 harness using synthetic buffers and the debug layer on both WARP and a physical RTX 5070 (driver 621.24).

Results per adapter:

  • 5 independent process runs.
  • 55 successful GPU readbacks.
  • 15 premature slot-reuse attempts correctly rejected by the harness.
  • Zero debug-layer messages.

The same SRV slot could be returned and reserved again while an explicit COM reference kept the previous buffer alive. A private-data destruction marker confirmed that the resource was destroyed only after its last owner released it, including the extra-owner and deferred-retirement controls.

This validates the resource ownership mechanism in a synthetic single-slot model. The behavior of HostHeap::release itself was checked through source review.

Production allocator behavior, idle-texture reclamation rates, and actual VRAM savings remain unmeasured.

I have the standalone C++ source, reproduction script, and traces from both adapters ready to share if useful.

**@⁠LucaruluDev** on GitHub · 2026-11-27 12:19 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/266#issuecomment-7218102239) I ran an independent standalone D3D12 harness using synthetic buffers and the debug layer on both WARP and a physical RTX 5070 (driver 621.24). Results per adapter: - 5 independent process runs. - 55 successful GPU readbacks. - 15 premature slot-reuse attempts correctly rejected by the harness. - Zero debug-layer messages. The same SRV slot could be returned and reserved again while an explicit COM reference kept the previous buffer alive. A private-data destruction marker confirmed that the resource was destroyed only after its last owner released it, including the extra-owner and deferred-retirement controls. This validates the resource ownership mechanism in a synthetic single-slot model. The behavior of `HostHeap::release` itself was checked through source review. Production allocator behavior, idle-texture reclamation rates, and actual VRAM savings remain unmeasured. I have the standalone C++ source, reproduction script, and traces from both adapters ready to share if useful.
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/avatarmanz--VIctory-7900XTX#266
No description provided.