From bf2f369bf0450ebcf3807f356a2df6ab91c2803c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Wed, 31 Dec 2025 08:34:10 +0100 Subject: [PATCH] dx12 fix: DeleteSubresources didn't handle rtvs and dsvs --- WickedEngine/wiGraphicsDevice_DX12.cpp | 55 +++++++++++--------------- WickedEngine/wiVersion.cpp | 2 +- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/WickedEngine/wiGraphicsDevice_DX12.cpp b/WickedEngine/wiGraphicsDevice_DX12.cpp index e5a6ea0aa..f745dacc0 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.cpp +++ b/WickedEngine/wiGraphicsDevice_DX12.cpp @@ -1348,6 +1348,11 @@ namespace dx12_internal D3D12_GPU_VIRTUAL_ADDRESS gpu_address = 0; + SingleDescriptor rtv = {}; + SingleDescriptor dsv = {}; + wi::vector subresources_rtv; + wi::vector subresources_dsv; + wi::vector mapped_subresources; UINT64 total_size = 0; wi::vector footprints; wi::vector rowSizesInBytes; @@ -1358,6 +1363,8 @@ namespace dx12_internal { srv.destroy(); uav.destroy(); + rtv.destroy(); + dsv.destroy(); for (auto& x : subresources_srv) { x.destroy(); @@ -1368,9 +1375,19 @@ namespace dx12_internal x.destroy(); } subresources_uav.clear(); + for (auto& x : subresources_rtv) + { + x.destroy(); + } + subresources_rtv.clear(); + for (auto& x : subresources_dsv) + { + x.destroy(); + } + subresources_dsv.clear(); } - virtual ~Resource_DX12() + ~Resource_DX12() { std::scoped_lock lck(allocationhandler->destroylocker); uint64_t framecount = allocationhandler->framecount; @@ -1379,32 +1396,6 @@ namespace dx12_internal destroy_subresources(); } }; - struct Texture_DX12 final : public Resource_DX12 - { - SingleDescriptor rtv = {}; - SingleDescriptor dsv = {}; - wi::vector subresources_rtv; - wi::vector subresources_dsv; - - wi::vector mapped_subresources; - - ~Texture_DX12() override - { - std::scoped_lock lck(allocationhandler->destroylocker); - uint64_t framecount = allocationhandler->framecount; - - rtv.destroy(); - dsv.destroy(); - for (auto& x : subresources_rtv) - { - x.destroy(); - } - for (auto& x : subresources_dsv) - { - x.destroy(); - } - } - }; struct Sampler_DX12 { wi::allocator::shared_ptr allocationhandler; @@ -1517,7 +1508,7 @@ namespace dx12_internal #else ComPtr swapChain; #endif // PLATFORM_XBOX - wi::vector> textures; // shared_ptr is used because they can be given out by GetBackBuffer() + wi::vector> textures; // shared_ptr is used because they can be given out by GetBackBuffer() Texture dummyTexture; ColorSpace colorSpace = ColorSpace::SRGB; @@ -1549,7 +1540,7 @@ namespace dx12_internal template struct DX12Type; template<> struct DX12Type { using type = Resource_DX12; }; template<> struct DX12Type { using type = Resource_DX12; }; - template<> struct DX12Type { using type = Texture_DX12; }; + template<> struct DX12Type { using type = Resource_DX12; }; template<> struct DX12Type { using type = Sampler_DX12; }; template<> struct DX12Type { using type = QueryHeap_DX12; }; template<> struct DX12Type { using type = PipelineState_DX12; }; @@ -3100,7 +3091,7 @@ std::mutex queue_locker; internal_state->textures.resize(swapchain->desc.buffer_count); for (uint32_t i = 0; i < swapchain->desc.buffer_count; ++i) { - internal_state->textures[i] = wi::allocator::make_shared(); + internal_state->textures[i] = wi::allocator::make_shared(); dx12_check(device->CreateCommittedResource( &heap_properties, D3D12_HEAP_FLAG_ALLOW_DISPLAY, @@ -3245,7 +3236,7 @@ std::mutex queue_locker; for (uint32_t i = 0; i < desc->buffer_count; ++i) { - internal_state->textures[i] = wi::allocator::make_shared(); + internal_state->textures[i] = wi::allocator::make_shared(); internal_state->textures[i]->allocationhandler = allocationhandler; dx12_check(internal_state->swapChain->GetBuffer(i, PPV_ARGS(internal_state->textures[i]->resource))); internal_state->textures[i]->rtv.init(this, rtv_desc, internal_state->textures[i]->resource.Get()); @@ -3491,7 +3482,7 @@ std::mutex queue_locker; } bool GraphicsDevice_DX12::CreateTexture(const TextureDesc* desc, const SubresourceData* initial_data, Texture* texture, const GPUResource* alias, uint64_t alias_offset) const { - auto internal_state = wi::allocator::make_shared(); + auto internal_state = wi::allocator::make_shared(); internal_state->allocationhandler = allocationhandler; texture->internal_state = internal_state; texture->type = GPUResource::Type::TEXTURE; diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 85580bdfc..79ddda36d 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 873; + const int revision = 874; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);