Skip to content

Commit

Permalink
Don't batch resource data reads for trim capture
Browse files Browse the repository at this point in the history
Don't batch command list executions for reading resource data from GPU
for trimmed state capture. May reduce memory use during activation of
trimming. Reverts some changes from 0103dcf
  • Loading branch information
davidd-lunarg committed Nov 14, 2023
1 parent 8ed54df commit 2e86074
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 218 deletions.
23 changes: 0 additions & 23 deletions framework/encode/d3d12_capture_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ void D3D12CaptureManager::InitializeID3D12ResourceInfo(ID3D12Device_Wrapper*
D3D12_RESOURCE_DIMENSION dimension,
D3D12_TEXTURE_LAYOUT layout,
UINT64 width,
UINT64 size,
D3D12_HEAP_TYPE heap_type,
D3D12_CPU_PAGE_PROPERTY page_property,
D3D12_MEMORY_POOL memory_pool,
Expand All @@ -309,7 +308,6 @@ void D3D12CaptureManager::InitializeID3D12ResourceInfo(ID3D12Device_Wrapper*
info->page_property = page_property;
info->memory_pool = memory_pool;
info->has_write_watch = has_write_watch;
info->size_in_bytes = size;
info->dimension = dimension;
info->layout = layout;
info->heap_offset = heap_offset;
Expand Down Expand Up @@ -814,14 +812,11 @@ void D3D12CaptureManager::PostProcess_ID3D12Device_CreateCommittedResource(
{
auto resource_wrapper = reinterpret_cast<ID3D12Resource_Wrapper*>(*resource);

uint64_t total_size_in_bytes = GetResourceSizeInBytes(wrapper, desc);

InitializeID3D12ResourceInfo(wrapper,
resource_wrapper,
desc->Dimension,
desc->Layout,
desc->Width,
total_size_in_bytes,
heap_properties->Type,
heap_properties->CPUPageProperty,
heap_properties->MemoryPoolPreference,
Expand Down Expand Up @@ -856,14 +851,11 @@ void D3D12CaptureManager::PostProcess_ID3D12Device_CreatePlacedResource(ID3D12De
auto heap_info = heap_wrapper->GetObjectInfo();
assert(heap_info != nullptr);

uint64_t total_size_in_bytes = GetResourceSizeInBytes(wrapper, desc);

InitializeID3D12ResourceInfo(wrapper,
resource_wrapper,
desc->Dimension,
desc->Layout,
desc->Width,
total_size_in_bytes,
heap_info->heap_type,
heap_info->page_property,
heap_info->memory_pool,
Expand Down Expand Up @@ -891,14 +883,11 @@ void D3D12CaptureManager::PostProcess_ID3D12Device_CreateReservedResource(
{
auto resource_wrapper = reinterpret_cast<ID3D12Resource_Wrapper*>(*resource);

uint64_t total_size_in_bytes = GetResourceSizeInBytes(wrapper, desc);

InitializeID3D12ResourceInfo(wrapper,
resource_wrapper,
desc->Dimension,
desc->Layout,
desc->Width,
total_size_in_bytes,
D3D12_HEAP_TYPE_DEFAULT,
D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
D3D12_MEMORY_POOL_UNKNOWN,
Expand Down Expand Up @@ -928,14 +917,11 @@ void D3D12CaptureManager::PostProcess_ID3D12Device4_CreateReservedResource1(
{
auto resource_wrapper = reinterpret_cast<ID3D12Resource_Wrapper*>(*resource);

uint64_t total_size_in_bytes = GetResourceSizeInBytes(wrapper, desc);

InitializeID3D12ResourceInfo(wrapper,
resource_wrapper,
desc->Dimension,
desc->Layout,
desc->Width,
total_size_in_bytes,
D3D12_HEAP_TYPE_DEFAULT,
D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
D3D12_MEMORY_POOL_UNKNOWN,
Expand Down Expand Up @@ -1034,14 +1020,11 @@ void D3D12CaptureManager::PostProcess_ID3D12Device4_CreateCommittedResource1(
{
auto resource_wrapper = reinterpret_cast<ID3D12Resource_Wrapper*>(*resource);

uint64_t total_size_in_bytes = GetResourceSizeInBytes(wrapper, desc);

InitializeID3D12ResourceInfo(wrapper,
resource_wrapper,
desc->Dimension,
desc->Layout,
desc->Width,
total_size_in_bytes,
heap_properties->Type,
heap_properties->CPUPageProperty,
heap_properties->MemoryPoolPreference,
Expand Down Expand Up @@ -1075,14 +1058,11 @@ void D3D12CaptureManager::PostProcess_ID3D12Device8_CreateCommittedResource2(
{
auto resource_wrapper = reinterpret_cast<ID3D12Resource_Wrapper*>(*resource);

uint64_t total_size_in_bytes = GetResourceSizeInBytes(wrapper, desc);

InitializeID3D12ResourceInfo(wrapper,
resource_wrapper,
desc->Dimension,
desc->Layout,
desc->Width,
total_size_in_bytes,
heap_properties->Type,
heap_properties->CPUPageProperty,
heap_properties->MemoryPoolPreference,
Expand Down Expand Up @@ -1118,14 +1098,11 @@ void D3D12CaptureManager::PostProcess_ID3D12Device8_CreatePlacedResource1(
auto heap_info = heap_wrapper->GetObjectInfo();
assert(heap_info != nullptr);

uint64_t total_size_in_bytes = GetResourceSizeInBytes(wrapper, desc);

InitializeID3D12ResourceInfo(wrapper,
resource_wrapper,
desc->Dimension,
desc->Layout,
desc->Width,
total_size_in_bytes,
heap_info->heap_type,
heap_info->page_property,
heap_info->memory_pool,
Expand Down
1 change: 0 additions & 1 deletion framework/encode/d3d12_capture_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,6 @@ class D3D12CaptureManager : public CaptureManager
D3D12_RESOURCE_DIMENSION dimension,
D3D12_TEXTURE_LAYOUT layout,
UINT64 width,
UINT64 size,
D3D12_HEAP_TYPE heap_type,
D3D12_CPU_PAGE_PROPERTY page_property,
D3D12_MEMORY_POOL memory_pool,
Expand Down
12 changes: 0 additions & 12 deletions framework/encode/dx12_object_wrapper_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ struct ID3D12ResourceInfo : public DxWrapperInfo
D3D12_HEAP_TYPE heap_type{};
D3D12_CPU_PAGE_PROPERTY page_property{};
D3D12_MEMORY_POOL memory_pool{};
uint64_t size_in_bytes{ 0 };
D3D12_RESOURCE_DIMENSION dimension{ D3D12_RESOURCE_DIMENSION_UNKNOWN };
D3D12_TEXTURE_LAYOUT layout{ D3D12_TEXTURE_LAYOUT_UNKNOWN };
//// State tracking data:
Expand All @@ -387,17 +386,6 @@ struct ID3D12ResourceInfo : public DxWrapperInfo
// Track acceleration structures that were built to this resource
std::map<D3D12_GPU_VIRTUAL_ADDRESS, DxAccelerationStructureBuildInfo> acceleration_structure_builds;

graphics::dx12::ID3D12ResourceComPtr staging_buffer{ nullptr };
struct
{
size_t subresource_count;
std::vector<uint64_t> subresource_offsets;
std::vector<uint64_t> subresource_sizes;
std::vector<D3D12_PLACED_SUBRESOURCE_FOOTPRINT> layouts;
uint64_t required_data_size;
std::vector<BYTE> staging_buffer_data;
} staging_buffer_info;

ID3D12Heap_Wrapper* heap_wrapper{ nullptr };
uint64_t heap_offset;
};
Expand Down
Loading

0 comments on commit 2e86074

Please sign in to comment.