From 7049d52dbb9fa311e7744556f40210d9a4fb998e Mon Sep 17 00:00:00 2001 From: Triang3l Date: Tue, 5 Mar 2019 10:26:40 +0300 Subject: [PATCH] [D3D12] Display texture cache size in the profiler --- src/xenia/gpu/d3d12/texture_cache.cc | 7 +++++++ src/xenia/gpu/d3d12/texture_cache.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/xenia/gpu/d3d12/texture_cache.cc b/src/xenia/gpu/d3d12/texture_cache.cc index 47d3c703e..07da70e4d 100644 --- a/src/xenia/gpu/d3d12/texture_cache.cc +++ b/src/xenia/gpu/d3d12/texture_cache.cc @@ -683,6 +683,8 @@ void TextureCache::ClearCache() { } textures_.clear(); COUNT_profile_set("gpu/texture_cache/textures", 0); + textures_total_size_ = 0; + COUNT_profile_set("gpu/texture_cache/total_size_kb", 0); // Clear texture descriptor cache. for (auto& page : srv_descriptor_cache_) { @@ -1748,6 +1750,8 @@ TextureCache::Texture* TextureCache::FindOrCreateTexture(TextureKey key) { Texture* texture = new Texture; texture->key = key; texture->resource = resource; + texture->resource_size = + device->GetResourceAllocationInfo(0, 1, &desc).SizeInBytes; texture->state = state; texture->mip_offsets[0] = 0; uint32_t width_blocks, height_blocks, depth_blocks; @@ -1812,6 +1816,9 @@ TextureCache::Texture* TextureCache::FindOrCreateTexture(TextureKey key) { texture->cached_srv_descriptor_swizzle = 0b100100100100; textures_.insert(std::make_pair(map_key, texture)); COUNT_profile_set("gpu/texture_cache/textures", textures_.size()); + textures_total_size_ += texture->resource_size; + COUNT_profile_set("gpu/texture_cache/total_size_kb", + uint32_t(textures_total_size_ >> 10)); LogTextureAction(texture, "Created"); return texture; diff --git a/src/xenia/gpu/d3d12/texture_cache.h b/src/xenia/gpu/d3d12/texture_cache.h index ba628568c..42a6eb487 100644 --- a/src/xenia/gpu/d3d12/texture_cache.h +++ b/src/xenia/gpu/d3d12/texture_cache.h @@ -341,6 +341,7 @@ class TextureCache { struct Texture { TextureKey key; ID3D12Resource* resource; + uint64_t resource_size; D3D12_RESOURCE_STATES state; // Byte size of the top guest mip level. @@ -542,6 +543,7 @@ class TextureCache { resolve_tile_pipelines_[size_t(ResolveTileMode::kCount)] = {}; std::unordered_multimap textures_; + uint64_t textures_total_size_ = 0; std::vector srv_descriptor_cache_;