Skip to content

Commit

Permalink
[D3D11] Fixed SRC/UAV tracking in D3D11ResourceHeap.
Browse files Browse the repository at this point in the history
D3DSubresourceLocator::index must be default initialized to -1 instead of 0.
Otherwise, subresourceContext.newIndex will be initialized with wrong value and GarbageCollectSubresource() will crash.
  • Loading branch information
LukasBanana committed Nov 6, 2024
1 parent 3f2c786 commit cf877ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions sources/Renderer/Direct3D11/RenderState/D3D11ResourceHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ std::uint32_t D3D11ResourceHeap::WriteResourceViews(std::uint32_t firstDescripto
/* Get SRV and UAV objects for textures and buffers */
ID3D11ShaderResourceView* srv = nullptr;
ID3D11UnorderedAccessView* uav = nullptr;
D3DSubresourceLocator subresourceLocator = {};
D3DSubresourceLocator subresourceLocator;
SubresourceIndexContext subresourceContext;

if (binding.type == D3DResourceType_SRV)
Expand Down Expand Up @@ -996,7 +996,7 @@ static D3D11SubresourceRange GetD3D11TextureSubresourceRange(D3D11Texture& textu

ID3D11ShaderResourceView* D3D11ResourceHeap::GetOrCreateTextureSRV(D3D11Texture& textureD3D, const TextureViewDescriptor& textureViewDesc, D3DSubresourceLocator& outLocator)
{
outLocator .locator = textureD3D.GetBindingLocator();
outLocator.locator = textureD3D.GetBindingLocator();
outLocator.range = GetD3D11TextureSubresourceRange(textureD3D, textureViewDesc);

if (IsTextureViewEnabled(textureViewDesc))
Expand Down
6 changes: 3 additions & 3 deletions sources/Renderer/Direct3D11/RenderState/D3D11ResourceHeap.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ class D3D11ResourceHeap final : public ResourceHeap
// Helper structure for SRV and UAV output.
struct D3DSubresourceLocator
{
std::size_t index; // Index into the subresource containers (subresourceSRVs_ and subresourceUAVs_).
D3D11BindingLocator* locator; // Binding table locator.
D3D11SubresourceRange range; // Binding table subresource range.
std::size_t index = -1; // Index into the subresource containers (subresourceSRVs_ and subresourceUAVs_).
D3D11BindingLocator* locator = nullptr; // Binding table locator.
D3D11SubresourceRange range = {}; // Binding table subresource range.
};

private:
Expand Down

0 comments on commit cf877ae

Please sign in to comment.