D3D12Device: Fix sampler group cache going stale and never resetting

Destroyed samplers' indices could be reused, returning the old sampler.
The reset threshold counted groups, which could never reach it before the
heap filled, causing endless submits in PreDrawCheck().
This commit is contained in:
Stenzek committed 2026-10-19 16:48:38 +10:00
1 parent 060537cb47
commit 4eeecc16af
2 files changed
+6 -2

No files matched your search

+2 -2
View File
@@ -94,7 +94,7 @@ public:
bool Allocate(u32 num_handles, D3D12DescriptorHandle* out_base_handle);
void Reset();
private:
protected:
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> m_descriptor_heap;
u32 m_descriptor_increment_size = 0;
u32 m_num_descriptors = 0;
@@ -258,5 +258,5 @@ bool D3D12GroupedSamplerAllocator<NumSamplers>::ShouldReset() const
{
// We only reset the sampler heap if more than half of the descriptors are used.
// This saves descriptor copying when there isn't a large number of sampler configs per frame.
return m_groups.size() >= (D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE / 2);
return (m_current_offset >= (m_num_descriptors / 2));
}
+4
View File
@@ -2201,6 +2201,10 @@ void D3D12Device::UnbindSampler(D3D12Sampler* sampler)
m_dirty_flags |= DIRTY_FLAG_SAMPLERS;
}
}
// Groups are keyed by descriptor index, which can be reused by a new sampler.
for (CommandList& res : m_command_lists)
res.sampler_allocator.InvalidateCache();
}
void D3D12Device::RenderTextureMipmap(D3D12Texture* texture, u32 layer, u32 dst_level, u32 dst_width, u32 dst_height,