[D3D12] Some stats in the profiler, tweak tiled buffer heap sizes
This commit is contained in:
parent
87d663d7e0
commit
317e5c3ce2
|
@ -924,6 +924,7 @@ PipelineCache::Pipeline* PipelineCache::GetPipeline(uint64_t hash_key) {
|
||||||
pipeline->state = state;
|
pipeline->state = state;
|
||||||
pipeline->root_signature = update_desc_.pRootSignature;
|
pipeline->root_signature = update_desc_.pRootSignature;
|
||||||
pipelines_.insert({hash_key, pipeline});
|
pipelines_.insert({hash_key, pipeline});
|
||||||
|
COUNT_profile_set("gpu/pipeline_cache/pipelines", pipelines_.size());
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,6 +353,7 @@ void RenderTargetCache::ClearCache() {
|
||||||
delete resolve_target;
|
delete resolve_target;
|
||||||
}
|
}
|
||||||
resolve_targets_.clear();
|
resolve_targets_.clear();
|
||||||
|
COUNT_profile_set("gpu/render_target_cache/resolve_targets", 0);
|
||||||
|
|
||||||
for (auto render_target_pair : render_targets_) {
|
for (auto render_target_pair : render_targets_) {
|
||||||
RenderTarget* render_target = render_target_pair.second;
|
RenderTarget* render_target = render_target_pair.second;
|
||||||
|
@ -360,6 +361,7 @@ void RenderTargetCache::ClearCache() {
|
||||||
delete render_target;
|
delete render_target;
|
||||||
}
|
}
|
||||||
render_targets_.clear();
|
render_targets_.clear();
|
||||||
|
COUNT_profile_set("gpu/render_target_cache/render_targets", 0);
|
||||||
|
|
||||||
while (descriptor_heaps_depth_ != nullptr) {
|
while (descriptor_heaps_depth_ != nullptr) {
|
||||||
auto heap = descriptor_heaps_depth_;
|
auto heap = descriptor_heaps_depth_;
|
||||||
|
@ -1938,6 +1940,8 @@ RenderTargetCache::ResolveTarget* RenderTargetCache::FindOrCreateResolveTarget(
|
||||||
xe::align(copy_buffer_size, UINT64(D3D12_TEXTURE_DATA_PITCH_ALIGNMENT));
|
xe::align(copy_buffer_size, UINT64(D3D12_TEXTURE_DATA_PITCH_ALIGNMENT));
|
||||||
resolve_target->copy_buffer_size = uint32_t(copy_buffer_size);
|
resolve_target->copy_buffer_size = uint32_t(copy_buffer_size);
|
||||||
resolve_targets_.insert(std::make_pair(key.value, resolve_target));
|
resolve_targets_.insert(std::make_pair(key.value, resolve_target));
|
||||||
|
COUNT_profile_set("gpu/render_target_cache/resolve_targets",
|
||||||
|
resolve_targets_.size());
|
||||||
|
|
||||||
return resolve_target;
|
return resolve_target;
|
||||||
}
|
}
|
||||||
|
@ -2254,6 +2258,8 @@ RenderTargetCache::RenderTarget* RenderTargetCache::FindOrCreateRenderTarget(
|
||||||
©_buffer_size);
|
©_buffer_size);
|
||||||
render_target->copy_buffer_size = uint32_t(copy_buffer_size);
|
render_target->copy_buffer_size = uint32_t(copy_buffer_size);
|
||||||
render_targets_.insert(std::make_pair(key.value, render_target));
|
render_targets_.insert(std::make_pair(key.value, render_target));
|
||||||
|
COUNT_profile_set("gpu/render_target_cache/render_targets",
|
||||||
|
render_targets_.size());
|
||||||
#if 0
|
#if 0
|
||||||
XELOGGPU(
|
XELOGGPU(
|
||||||
"Created %ux%u %s render target with format %u at heap 4 MB pages %u:%u",
|
"Created %ux%u %s render target with format %u at heap 4 MB pages %u:%u",
|
||||||
|
|
|
@ -94,6 +94,7 @@ bool SharedMemory::Initialize() {
|
||||||
buffer_gpu_address_ = buffer_->GetGPUVirtualAddress();
|
buffer_gpu_address_ = buffer_->GetGPUVirtualAddress();
|
||||||
|
|
||||||
std::memset(heaps_, 0, sizeof(heaps_));
|
std::memset(heaps_, 0, sizeof(heaps_));
|
||||||
|
heap_count_ = 0;
|
||||||
heap_creation_failed_ = false;
|
heap_creation_failed_ = false;
|
||||||
|
|
||||||
std::memset(valid_pages_.data(), 0, valid_pages_.size() * sizeof(uint64_t));
|
std::memset(valid_pages_.data(), 0, valid_pages_.size() * sizeof(uint64_t));
|
||||||
|
@ -124,6 +125,8 @@ void SharedMemory::Shutdown() {
|
||||||
for (uint32_t i = 0; i < xe::countof(heaps_); ++i) {
|
for (uint32_t i = 0; i < xe::countof(heaps_); ++i) {
|
||||||
ui::d3d12::util::ReleaseAndNull(heaps_[i]);
|
ui::d3d12::util::ReleaseAndNull(heaps_[i]);
|
||||||
}
|
}
|
||||||
|
heap_count_ = 0;
|
||||||
|
COUNT_profile_set("gpu/shared_memory/mb_used", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,6 +280,9 @@ bool SharedMemory::MakeTilesResident(uint32_t start, uint32_t length) {
|
||||||
heap_creation_failed_ = true;
|
heap_creation_failed_ = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
++heap_count_;
|
||||||
|
COUNT_profile_set("gpu/shared_memory/mb_used",
|
||||||
|
heap_count_ << kHeapSizeLog2 >> 20);
|
||||||
D3D12_TILED_RESOURCE_COORDINATE region_start_coordinates;
|
D3D12_TILED_RESOURCE_COORDINATE region_start_coordinates;
|
||||||
region_start_coordinates.X =
|
region_start_coordinates.X =
|
||||||
(i << kHeapSizeLog2) / D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES;
|
(i << kHeapSizeLog2) / D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES;
|
||||||
|
|
|
@ -130,13 +130,16 @@ class SharedMemory {
|
||||||
D3D12_GPU_VIRTUAL_ADDRESS buffer_gpu_address_ = 0;
|
D3D12_GPU_VIRTUAL_ADDRESS buffer_gpu_address_ = 0;
|
||||||
D3D12_RESOURCE_STATES buffer_state_ = D3D12_RESOURCE_STATE_COPY_DEST;
|
D3D12_RESOURCE_STATES buffer_state_ = D3D12_RESOURCE_STATE_COPY_DEST;
|
||||||
|
|
||||||
// Heaps are 16 MB, so not too many of them are allocated.
|
// Heaps are 4 MB, so not too many of them are allocated, but also not to
|
||||||
static constexpr uint32_t kHeapSizeLog2 = 24;
|
// waste too much memory for padding (with 16 MB there's too much).
|
||||||
|
static constexpr uint32_t kHeapSizeLog2 = 22;
|
||||||
static constexpr uint32_t kHeapSize = 1 << kHeapSizeLog2;
|
static constexpr uint32_t kHeapSize = 1 << kHeapSizeLog2;
|
||||||
static_assert((kHeapSize % D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES) == 0,
|
static_assert((kHeapSize % D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES) == 0,
|
||||||
"Heap size must be a multiple of Direct3D tile size");
|
"Heap size must be a multiple of Direct3D tile size");
|
||||||
// Resident portions of the tiled buffer.
|
// Resident portions of the tiled buffer.
|
||||||
ID3D12Heap* heaps_[kBufferSize >> kHeapSizeLog2] = {};
|
ID3D12Heap* heaps_[kBufferSize >> kHeapSizeLog2] = {};
|
||||||
|
// Number of the heaps currently resident, for profiling.
|
||||||
|
uint32_t heap_count_ = 0;
|
||||||
// Whether creation of a heap has failed in the current frame.
|
// Whether creation of a heap has failed in the current frame.
|
||||||
bool heap_creation_failed_ = false;
|
bool heap_creation_failed_ = false;
|
||||||
|
|
||||||
|
|
|
@ -467,6 +467,7 @@ bool TextureCache::Initialize() {
|
||||||
std::memset(scaled_resolve_pages_l2_, 0, sizeof(scaled_resolve_pages_l2_));
|
std::memset(scaled_resolve_pages_l2_, 0, sizeof(scaled_resolve_pages_l2_));
|
||||||
}
|
}
|
||||||
std::memset(scaled_resolve_heaps_, 0, sizeof(scaled_resolve_heaps_));
|
std::memset(scaled_resolve_heaps_, 0, sizeof(scaled_resolve_heaps_));
|
||||||
|
scaled_resolve_heap_count_ = 0;
|
||||||
|
|
||||||
// Create the loading root signature.
|
// Create the loading root signature.
|
||||||
D3D12_ROOT_PARAMETER root_parameters[2];
|
D3D12_ROOT_PARAMETER root_parameters[2];
|
||||||
|
@ -590,6 +591,8 @@ void TextureCache::Shutdown() {
|
||||||
for (uint32_t i = 0; i < xe::countof(scaled_resolve_heaps_); ++i) {
|
for (uint32_t i = 0; i < xe::countof(scaled_resolve_heaps_); ++i) {
|
||||||
ui::d3d12::util::ReleaseAndNull(scaled_resolve_heaps_[i]);
|
ui::d3d12::util::ReleaseAndNull(scaled_resolve_heaps_[i]);
|
||||||
}
|
}
|
||||||
|
scaled_resolve_heap_count_ = 0;
|
||||||
|
COUNT_profile_set("gpu/texture_cache/scaled_resolve_buffer_mb_used", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCache::ClearCache() {
|
void TextureCache::ClearCache() {
|
||||||
|
@ -602,6 +605,7 @@ void TextureCache::ClearCache() {
|
||||||
delete texture;
|
delete texture;
|
||||||
}
|
}
|
||||||
textures_.clear();
|
textures_.clear();
|
||||||
|
COUNT_profile_set("gpu/texture_cache/textures", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCache::TextureFetchConstantWritten(uint32_t index) {
|
void TextureCache::TextureFetchConstantWritten(uint32_t index) {
|
||||||
|
@ -1221,6 +1225,10 @@ bool TextureCache::EnsureScaledResolveBufferResident(uint32_t start_unscaled,
|
||||||
XELOGE("Texture cache: Failed to create a scaled resolve tile heap");
|
XELOGE("Texture cache: Failed to create a scaled resolve tile heap");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
++scaled_resolve_heap_count_;
|
||||||
|
COUNT_profile_set(
|
||||||
|
"gpu/texture_cache/scaled_resolve_buffer_mb_used",
|
||||||
|
scaled_resolve_heap_count_ << (kScaledResolveHeapSizeLog2 - 20));
|
||||||
D3D12_TILED_RESOURCE_COORDINATE region_start_coordinates;
|
D3D12_TILED_RESOURCE_COORDINATE region_start_coordinates;
|
||||||
region_start_coordinates.X = (i << kScaledResolveHeapSizeLog2) /
|
region_start_coordinates.X = (i << kScaledResolveHeapSizeLog2) /
|
||||||
D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES;
|
D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES;
|
||||||
|
@ -1663,6 +1671,7 @@ TextureCache::Texture* TextureCache::FindOrCreateTexture(TextureKey key) {
|
||||||
texture->base_watch_handle = nullptr;
|
texture->base_watch_handle = nullptr;
|
||||||
texture->mip_watch_handle = nullptr;
|
texture->mip_watch_handle = nullptr;
|
||||||
textures_.insert(std::make_pair(map_key, texture));
|
textures_.insert(std::make_pair(map_key, texture));
|
||||||
|
COUNT_profile_set("gpu/texture_cache/textures", textures_.size());
|
||||||
LogTextureAction(texture, "Created");
|
LogTextureAction(texture, "Created");
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
|
|
|
@ -549,9 +549,9 @@ class TextureCache {
|
||||||
ID3D12Resource* scaled_resolve_buffer_ = nullptr;
|
ID3D12Resource* scaled_resolve_buffer_ = nullptr;
|
||||||
D3D12_RESOURCE_STATES scaled_resolve_buffer_state_ =
|
D3D12_RESOURCE_STATES scaled_resolve_buffer_state_ =
|
||||||
D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||||
// Not very big heaps (32 MB) because they are needed pretty sparsely. One
|
// Not very big heaps (16 MB) because they are needed pretty sparsely. One
|
||||||
// scaled 1280x720x32bpp texture is slighly bigger than 14 MB.
|
// scaled 1280x720x32bpp texture is slighly bigger than 14 MB.
|
||||||
static constexpr uint32_t kScaledResolveHeapSizeLog2 = 25;
|
static constexpr uint32_t kScaledResolveHeapSizeLog2 = 24;
|
||||||
static constexpr uint32_t kScaledResolveHeapSize =
|
static constexpr uint32_t kScaledResolveHeapSize =
|
||||||
1 << kScaledResolveHeapSizeLog2;
|
1 << kScaledResolveHeapSizeLog2;
|
||||||
static_assert(
|
static_assert(
|
||||||
|
@ -560,6 +560,8 @@ class TextureCache {
|
||||||
// Resident portions of the tiled buffer.
|
// Resident portions of the tiled buffer.
|
||||||
ID3D12Heap* scaled_resolve_heaps_[kScaledResolveBufferSize >>
|
ID3D12Heap* scaled_resolve_heaps_[kScaledResolveBufferSize >>
|
||||||
kScaledResolveHeapSizeLog2] = {};
|
kScaledResolveHeapSizeLog2] = {};
|
||||||
|
// Number of currently resident portions of the tiled buffer, for profiling.
|
||||||
|
uint32_t scaled_resolve_heap_count_ = 0;
|
||||||
// Bit vector storing whether each 4 KB physical memory page contains scaled
|
// Bit vector storing whether each 4 KB physical memory page contains scaled
|
||||||
// resolve data. uint32_t rather than uint64_t because parts of it are sent to
|
// resolve data. uint32_t rather than uint64_t because parts of it are sent to
|
||||||
// shaders.
|
// shaders.
|
||||||
|
|
Loading…
Reference in New Issue