Merge branch 'master' into vulkan

This commit is contained in:
Triang3l 2020-10-07 23:18:08 +03:00
commit afcd01def5
2 changed files with 10 additions and 7 deletions

View File

@ -22,7 +22,7 @@
DEFINE_bool(d3d12_tiled_shared_memory, true, DEFINE_bool(d3d12_tiled_shared_memory, true,
"Enable tiled resources for shared memory emulation. Disabling " "Enable tiled resources for shared memory emulation. Disabling "
"them greatly video memory usage - a 512 MB buffer is created - " "them increases video memory usage - a 512 MB buffer is created - "
"but allows graphics debuggers that don't support tiled resources " "but allows graphics debuggers that don't support tiled resources "
"to work.", "to work.",
"D3D12"); "D3D12");
@ -100,7 +100,7 @@ bool D3D12SharedMemory::Initialize() {
&buffer_descriptor_heap_desc, &buffer_descriptor_heap_desc,
IID_PPV_ARGS(&buffer_descriptor_heap_)))) { IID_PPV_ARGS(&buffer_descriptor_heap_)))) {
XELOGE( XELOGE(
"Failed to create the descriptor heap for shared memory buffer views"); "Shared memory: Failed to create the descriptor heap for buffer views");
Shutdown(); Shutdown();
return false; return false;
} }
@ -286,7 +286,6 @@ bool D3D12SharedMemory::InitializeTraceSubmitDownloads() {
ResetTraceDownload(); ResetTraceDownload();
PrepareForTraceDownload(); PrepareForTraceDownload();
uint32_t download_page_count = trace_download_page_count(); uint32_t download_page_count = trace_download_page_count();
// Request downloading of GPU-written memory.
if (!download_page_count) { if (!download_page_count) {
return false; return false;
} }
@ -312,7 +311,7 @@ bool D3D12SharedMemory::InitializeTraceSubmitDownloads() {
UseAsCopySource(); UseAsCopySource();
command_processor_.SubmitBarriers(); command_processor_.SubmitBarriers();
uint32_t download_buffer_offset = 0; uint32_t download_buffer_offset = 0;
for (auto& download_range : trace_download_ranges()) { for (const auto& download_range : trace_download_ranges()) {
command_list.D3DCopyBufferRegion( command_list.D3DCopyBufferRegion(
trace_download_buffer_, download_buffer_offset, buffer_, trace_download_buffer_, download_buffer_offset, buffer_,
download_range.first, download_range.second); download_range.first, download_range.second);
@ -328,7 +327,7 @@ void D3D12SharedMemory::InitializeTraceCompleteDownloads() {
void* download_mapping; void* download_mapping;
if (SUCCEEDED(trace_download_buffer_->Map(0, nullptr, &download_mapping))) { if (SUCCEEDED(trace_download_buffer_->Map(0, nullptr, &download_mapping))) {
uint32_t download_buffer_offset = 0; uint32_t download_buffer_offset = 0;
for (auto download_range : trace_download_ranges()) { for (const auto& download_range : trace_download_ranges()) {
trace_writer_.WriteMemoryRead( trace_writer_.WriteMemoryRead(
download_range.first, download_range.second, download_range.first, download_range.second,
reinterpret_cast<const uint8_t*>(download_mapping) + reinterpret_cast<const uint8_t*>(download_mapping) +
@ -338,8 +337,8 @@ void D3D12SharedMemory::InitializeTraceCompleteDownloads() {
trace_download_buffer_->Unmap(0, &download_write_range); trace_download_buffer_->Unmap(0, &download_write_range);
} else { } else {
XELOGE( XELOGE(
"Failed to map the GPU-written memory download buffer for frame " "Shared memory: Failed to map the GPU-written memory download buffer "
"tracing"); "for frame tracing");
} }
ResetTraceDownload(); ResetTraceDownload();
} }

View File

@ -536,6 +536,10 @@ void SharedMemory::PrepareForTraceDownload() {
} else { } else {
uint32_t gpu_written_range_length = uint32_t gpu_written_range_length =
gpu_written_page - gpu_written_range_start; gpu_written_page - gpu_written_range_start;
// Call EnsureHostGpuMemoryAllocated in case the page was marked as
// GPU-written not as a result to an actual write to the shared memory
// buffer, but, for instance, by resolving with resolution scaling (to a
// separate buffer).
if (EnsureHostGpuMemoryAllocated( if (EnsureHostGpuMemoryAllocated(
gpu_written_range_start << page_size_log2_, gpu_written_range_start << page_size_log2_,
gpu_written_range_length << page_size_log2_)) { gpu_written_range_length << page_size_log2_)) {