From 2aa51db614b946ddfec3597ada1f0eb2a7154ffa Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 30 Aug 2024 13:41:45 -0700 Subject: [PATCH] add texture tagging in the FrameGraph Also tag user texture "FTexture" if user doesn't provide a tag, this is so that we can distinguish them from internal textures that might not be tagged. --- filament/src/ResourceAllocator.cpp | 7 +++++-- filament/src/details/Texture.cpp | 2 ++ filament/src/details/View.cpp | 12 ++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/filament/src/ResourceAllocator.cpp b/filament/src/ResourceAllocator.cpp index 6d12ccf0a3..4699def134 100644 --- a/filament/src/ResourceAllocator.cpp +++ b/filament/src/ResourceAllocator.cpp @@ -143,12 +143,14 @@ void ResourceAllocator::terminate() noexcept { } } -RenderTargetHandle ResourceAllocator::createRenderTarget(const char*, +RenderTargetHandle ResourceAllocator::createRenderTarget(const char* name, TargetBufferFlags targetBufferFlags, uint32_t width, uint32_t height, uint8_t samples, uint8_t layerCount, MRT color, TargetBufferInfo depth, TargetBufferInfo stencil) noexcept { - return mBackend.createRenderTarget(targetBufferFlags, + auto handle = mBackend.createRenderTarget(targetBufferFlags, width, height, samples ? samples : 1u, layerCount, color, depth, stencil); + mBackend.setDebugTag(handle.getId(), CString{ name }); + return handle; } void ResourceAllocator::destroyRenderTarget(RenderTargetHandle h) noexcept { @@ -201,6 +203,7 @@ backend::TextureHandle ResourceAllocator::createTexture(const char* name, } } mDisposer->checkout(handle, key); + mBackend.setDebugTag(handle.getId(), CString{ name }); return handle; } diff --git a/filament/src/details/Texture.cpp b/filament/src/details/Texture.cpp index a59a24da97..b2cfbf6839 100644 --- a/filament/src/details/Texture.cpp +++ b/filament/src/details/Texture.cpp @@ -245,6 +245,8 @@ FTexture::FTexture(FEngine& engine, const Builder& builder) { } if (auto name = builder.getName(); !name.empty()) { driver.setDebugTag(mHandle.getId(), std::move(name)); + } else { + driver.setDebugTag(mHandle.getId(), CString{"FTexture"}); } } diff --git a/filament/src/details/View.cpp b/filament/src/details/View.cpp index 85fc9df5ca..f9bf724921 100644 --- a/filament/src/details/View.cpp +++ b/filament/src/details/View.cpp @@ -1040,10 +1040,8 @@ void FView::commitFrameHistory(FEngine& engine) noexcept { auto& frameHistory = mFrameHistory; FrameHistoryEntry& last = frameHistory.back(); - disposer.destroy(last.taa.color.handle); - disposer.destroy(last.ssr.color.handle); - last.taa.color.handle.clear(); - last.ssr.color.handle.clear(); + disposer.destroy(std::move(last.taa.color.handle)); + disposer.destroy(std::move(last.ssr.color.handle)); // and then push the new history entry to the history stack frameHistory.commit(); @@ -1055,10 +1053,8 @@ void FView::clearFrameHistory(FEngine& engine) noexcept { auto& frameHistory = mFrameHistory; for (size_t i = 0; i < frameHistory.size(); ++i) { FrameHistoryEntry& last = frameHistory[i]; - disposer.destroy(last.taa.color.handle); - disposer.destroy(last.ssr.color.handle); - last.taa.color.handle.clear(); - last.ssr.color.handle.clear(); + disposer.destroy(std::move(last.taa.color.handle)); + disposer.destroy(std::move(last.ssr.color.handle)); } }