From d9538e6cc25078fbaad8cf2be16dc86205d62171 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Thu, 27 Sep 2018 10:27:55 +0300 Subject: [PATCH] [D3D12] Log unsupported texture formats and don't log texture invalidation --- src/xenia/gpu/d3d12/d3d12_command_processor.cc | 2 ++ src/xenia/gpu/d3d12/texture_cache.cc | 16 ++++++++++++++-- src/xenia/gpu/d3d12/texture_cache.h | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/xenia/gpu/d3d12/d3d12_command_processor.cc b/src/xenia/gpu/d3d12/d3d12_command_processor.cc index da1200bc8..a9d0903a4 100644 --- a/src/xenia/gpu/d3d12/d3d12_command_processor.cc +++ b/src/xenia/gpu/d3d12/d3d12_command_processor.cc @@ -1183,6 +1183,8 @@ bool D3D12CommandProcessor::EndFrame() { render_target_cache_->EndFrame(); + texture_cache_->EndFrame(); + shared_memory_->EndFrame(); // Submit barriers now because resources the queued barriers are for may be diff --git a/src/xenia/gpu/d3d12/texture_cache.cc b/src/xenia/gpu/d3d12/texture_cache.cc index 77b5d93a6..ce7720363 100644 --- a/src/xenia/gpu/d3d12/texture_cache.cc +++ b/src/xenia/gpu/d3d12/texture_cache.cc @@ -411,6 +411,19 @@ void TextureCache::BeginFrame() { // sure bindings are reset so a new attempt will surely be made if the texture // is requested again. ClearBindings(); + + unsupported_formats_used_ = 0; +} + +void TextureCache::EndFrame() { + if (unsupported_formats_used_ != 0) { + XELOGE("Unsupported texture formats used in the frame:"); + uint32_t format; + while (xe::bit_scan_forward(unsupported_formats_used_, &format)) { + unsupported_formats_used_ &= ~(1ull << format); + XELOGE("* %s", FormatInfo::Get(TextureFormat(format))->name); + } + } } void TextureCache::RequestTextures(uint32_t used_vertex_texture_mask, @@ -935,6 +948,7 @@ TextureCache::Texture* TextureCache::FindOrCreateTexture(TextureKey key) { D3D12_RESOURCE_DESC desc; desc.Format = GetDXGIFormat(key); if (desc.Format == DXGI_FORMAT_UNKNOWN) { + unsupported_formats_used_ |= 1ull << uint32_t(key.format); return nullptr; } if (key.dimension == Dimension::k3D) { @@ -1248,8 +1262,6 @@ void TextureCache::WatchCallback(Texture* texture, bool is_mip) { texture->base_in_sync = false; texture->base_watch_handle = nullptr; } - XELOGGPU("Texture %s at 0x%.8X invalidated", is_mip ? "mips" : "base", - (is_mip ? texture->key.mip_page : texture->key.base_page) << 12); texture_invalidated_.store(true, std::memory_order_relaxed); } diff --git a/src/xenia/gpu/d3d12/texture_cache.h b/src/xenia/gpu/d3d12/texture_cache.h index faa3c19e6..c7cf35949 100644 --- a/src/xenia/gpu/d3d12/texture_cache.h +++ b/src/xenia/gpu/d3d12/texture_cache.h @@ -65,6 +65,7 @@ class TextureCache { void TextureFetchConstantWritten(uint32_t index); void BeginFrame(); + void EndFrame(); // Must be called within a frame - creates and untiles textures needed by // shaders and puts them in the SRV state. This may bind compute pipelines @@ -373,6 +374,10 @@ class TextureCache { // been changed. A simple notification (texture validity is protected by a // mutex), so memory_order_relaxed is enough. std::atomic texture_invalidated_ = false; + + // Unsupported texture formats used during this frame (for research and + // testing). + uint64_t unsupported_formats_used_; }; } // namespace d3d12