From 36f4158f099ffed5f40c441102738992799b25fe Mon Sep 17 00:00:00 2001 From: Triang3l Date: Fri, 25 Oct 2019 21:32:17 +0300 Subject: [PATCH] [GPU] Trace dump: Do PIX/RenderDoc capture if attached --- src/xenia/gpu/d3d12/d3d12_trace_dump_main.cc | 19 ++++++++++++++++++ src/xenia/gpu/trace_dump.cc | 2 ++ src/xenia/gpu/trace_dump.h | 3 +++ .../gpu/vulkan/vulkan_trace_dump_main.cc | 20 +++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/src/xenia/gpu/d3d12/d3d12_trace_dump_main.cc b/src/xenia/gpu/d3d12/d3d12_trace_dump_main.cc index b10a9c1e5..c68b29788 100644 --- a/src/xenia/gpu/d3d12/d3d12_trace_dump_main.cc +++ b/src/xenia/gpu/d3d12/d3d12_trace_dump_main.cc @@ -12,6 +12,7 @@ #include "xenia/gpu/d3d12/d3d12_command_processor.h" #include "xenia/gpu/d3d12/d3d12_graphics_system.h" #include "xenia/gpu/trace_dump.h" +#include "xenia/ui/d3d12/d3d12_provider.h" namespace xe { namespace gpu { @@ -24,6 +25,24 @@ class D3D12TraceDump : public TraceDump { std::unique_ptr CreateGraphicsSystem() override { return std::unique_ptr(new D3D12GraphicsSystem()); } + + void BeginHostCapture() override { + auto provider = static_cast( + graphics_system_->provider()); + IDXGraphicsAnalysis* graphics_analysis = provider->GetGraphicsAnalysis(); + if (graphics_analysis) { + graphics_analysis->BeginCapture(); + } + } + + void EndHostCapture() override { + auto provider = static_cast( + graphics_system_->provider()); + IDXGraphicsAnalysis* graphics_analysis = provider->GetGraphicsAnalysis(); + if (graphics_analysis) { + graphics_analysis->EndCapture(); + } + } }; int trace_dump_main(const std::vector& args) { diff --git a/src/xenia/gpu/trace_dump.cc b/src/xenia/gpu/trace_dump.cc index 971d8fc16..b7b27df1a 100644 --- a/src/xenia/gpu/trace_dump.cc +++ b/src/xenia/gpu/trace_dump.cc @@ -126,10 +126,12 @@ bool TraceDump::Load(std::wstring trace_file_path) { } int TraceDump::Run() { + BeginHostCapture(); player_->SeekFrame(0); player_->SeekCommand( static_cast(player_->current_frame()->commands.size() - 1)); player_->WaitOnPlayback(); + EndHostCapture(); // Capture. int result = 0; diff --git a/src/xenia/gpu/trace_dump.h b/src/xenia/gpu/trace_dump.h index eb7ab43da..f2e4c7347 100644 --- a/src/xenia/gpu/trace_dump.h +++ b/src/xenia/gpu/trace_dump.h @@ -43,6 +43,9 @@ class TraceDump { virtual std::unique_ptr CreateGraphicsSystem() = 0; + virtual void BeginHostCapture() = 0; + virtual void EndHostCapture() = 0; + std::unique_ptr emulator_; GraphicsSystem* graphics_system_ = nullptr; std::unique_ptr player_; diff --git a/src/xenia/gpu/vulkan/vulkan_trace_dump_main.cc b/src/xenia/gpu/vulkan/vulkan_trace_dump_main.cc index bd4c1f9a5..a895b6e42 100644 --- a/src/xenia/gpu/vulkan/vulkan_trace_dump_main.cc +++ b/src/xenia/gpu/vulkan/vulkan_trace_dump_main.cc @@ -12,6 +12,8 @@ #include "xenia/gpu/trace_dump.h" #include "xenia/gpu/vulkan/vulkan_command_processor.h" #include "xenia/gpu/vulkan/vulkan_graphics_system.h" +#include "xenia/ui/vulkan/vulkan_device.h" +#include "xenia/ui/vulkan/vulkan_provider.h" namespace xe { namespace gpu { @@ -24,6 +26,24 @@ class VulkanTraceDump : public TraceDump { std::unique_ptr CreateGraphicsSystem() override { return std::unique_ptr(new VulkanGraphicsSystem()); } + + void BeginHostCapture() override { + auto device = static_cast( + graphics_system_->provider()) + ->device(); + if (device->is_renderdoc_attached()) { + device->BeginRenderDocFrameCapture(); + } + } + + void EndHostCapture() override { + auto device = static_cast( + graphics_system_->provider()) + ->device(); + if (device->is_renderdoc_attached()) { + device->EndRenderDocFrameCapture(); + } + } }; int trace_dump_main(const std::vector& args) {