From f23ba862f6505e4392521c6bfddaa80bb31e093b Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sun, 27 Oct 2019 00:36:55 +0300 Subject: [PATCH] [D3D12] Trace viewer entry point --- .../gpu/d3d12/d3d12_command_processor.cc | 4 ++ .../gpu/d3d12/d3d12_trace_viewer_main.cc | 61 +++++++++++++++++++ src/xenia/gpu/d3d12/premake5.lua | 44 +++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 src/xenia/gpu/d3d12/d3d12_trace_viewer_main.cc diff --git a/src/xenia/gpu/d3d12/d3d12_command_processor.cc b/src/xenia/gpu/d3d12/d3d12_command_processor.cc index 330bfe020..8cd8f98f8 100644 --- a/src/xenia/gpu/d3d12/d3d12_command_processor.cc +++ b/src/xenia/gpu/d3d12/d3d12_command_processor.cc @@ -1001,6 +1001,10 @@ void D3D12CommandProcessor::WriteRegister(uint32_t index, uint32_t value) { void D3D12CommandProcessor::PerformSwap(uint32_t frontbuffer_ptr, uint32_t frontbuffer_width, uint32_t frontbuffer_height) { + // FIXME(Triang3l): frontbuffer_ptr is currently unreliable, in the trace + // player it's set to 0, but it's not needed anyway since the fetch constant + // contains the address. + SCOPE_profile_cpu_f("gpu"); // In case the swap command is the only one in the frame. diff --git a/src/xenia/gpu/d3d12/d3d12_trace_viewer_main.cc b/src/xenia/gpu/d3d12/d3d12_trace_viewer_main.cc new file mode 100644 index 000000000..064c92d44 --- /dev/null +++ b/src/xenia/gpu/d3d12/d3d12_trace_viewer_main.cc @@ -0,0 +1,61 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2019 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include "xenia/base/logging.h" +#include "xenia/base/main.h" +#include "xenia/gpu/d3d12/d3d12_command_processor.h" +#include "xenia/gpu/d3d12/d3d12_graphics_system.h" +#include "xenia/gpu/trace_viewer.h" + +namespace xe { +namespace gpu { +namespace d3d12 { + +using namespace xe::gpu::xenos; + +class D3D12TraceViewer : public TraceViewer { + public: + std::unique_ptr CreateGraphicsSystem() override { + return std::unique_ptr(new D3D12GraphicsSystem()); + } + + uintptr_t GetColorRenderTarget(uint32_t pitch, MsaaSamples samples, + uint32_t base, + ColorRenderTargetFormat format) override { + // TODO(Triang3l): EDRAM viewer. + return 0; + } + + uintptr_t GetDepthRenderTarget(uint32_t pitch, MsaaSamples samples, + uint32_t base, + DepthRenderTargetFormat format) override { + // TODO(Triang3l): EDRAM viewer. + return 0; + } + + uintptr_t GetTextureEntry(const TextureInfo& texture_info, + const SamplerInfo& sampler_info) override { + // TODO(Triang3l): Textures, but from a fetch constant rather than + // TextureInfo/SamplerInfo which are going away. + return 0; + } +}; + +int trace_viewer_main(const std::vector& args) { + D3D12TraceViewer trace_viewer; + return trace_viewer.Main(args); +} + +} // namespace d3d12 +} // namespace gpu +} // namespace xe + +DEFINE_ENTRY_POINT(L"xenia-gpu-d3d12-trace-viewer", + xe::gpu::d3d12::trace_viewer_main, "some.trace", + "target_trace_file"); diff --git a/src/xenia/gpu/d3d12/premake5.lua b/src/xenia/gpu/d3d12/premake5.lua index 001be5b88..c0e87106f 100644 --- a/src/xenia/gpu/d3d12/premake5.lua +++ b/src/xenia/gpu/d3d12/premake5.lua @@ -18,6 +18,50 @@ project("xenia-gpu-d3d12") "shaders/bin/*.h", }) +group("src") +project("xenia-gpu-d3d12-trace-viewer") + uuid("7b5b9fcb-7bf1-43ff-a774-d4c41c8706be") + kind("WindowedApp") + language("C++") + links({ + "aes_128", + "capstone", + "dxbc", + "imgui", + "libavcodec", + "libavutil", + "mspack", + "snappy", + "xenia-apu", + "xenia-apu-nop", + "xenia-base", + "xenia-core", + "xenia-cpu", + "xenia-cpu-backend-x64", + "xenia-gpu", + "xenia-gpu-d3d12", + "xenia-hid", + "xenia-hid-nop", + "xenia-kernel", + "xenia-ui", + "xenia-ui-d3d12", + "xenia-vfs", + "xxhash", + }) + files({ + "d3d12_trace_viewer_main.cc", + "../../base/main_"..platform_suffix..".cc", + }) + -- Only create the .user file if it doesn't already exist. + local user_file = project_root.."/build/xenia-gpu-d3d12-trace-viewer.vcxproj.user" + if not os.isfile(user_file) then + debugdir(project_root) + debugargs({ + "2>&1", + "1>scratch/stdout-trace-viewer.txt", + }) + end + group("src") project("xenia-gpu-d3d12-trace-dump") uuid("686b859c-0046-44c4-a02c-41fc3fb75698")