C++17ification.

C++17ification!

- Filesystem interaction now uses std::filesystem::path.
- Usage of const char*, std::string have been changed to
  std::string_view where appropriate.
- Usage of printf-style functions changed to use fmt.
This commit is contained in:
gibbed
2020-03-02 09:37:11 -06:00
committed by Rick Gibbed
parent 114cea6fb7
commit 5bf0b34445
220 changed files with 4944 additions and 4294 deletions

View File

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2018 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -85,12 +85,14 @@ void D3D12CommandProcessor::ClearCaches() {
}
void D3D12CommandProcessor::InitializeShaderStorage(
const std::wstring& storage_root, uint32_t title_id, bool blocking) {
const std::filesystem::path& storage_root, uint32_t title_id,
bool blocking) {
CommandProcessor::InitializeShaderStorage(storage_root, title_id, blocking);
pipeline_cache_->InitializeShaderStorage(storage_root, title_id, blocking);
}
void D3D12CommandProcessor::RequestFrameTrace(const std::wstring& root_path) {
void D3D12CommandProcessor::RequestFrameTrace(
const std::filesystem::path& root_path) {
// Capture with PIX if attached.
if (GetD3D12Context()->GetD3D12Provider()->GetGraphicsAnalysis() != nullptr) {
pix_capture_requested_.store(true, std::memory_order_relaxed);
@@ -668,16 +670,16 @@ void D3D12CommandProcessor::SetExternalGraphicsPipeline(
}
}
std::wstring D3D12CommandProcessor::GetWindowTitleText() const {
std::string D3D12CommandProcessor::GetWindowTitleText() const {
if (IsROVUsedForEDRAM()) {
// Currently scaling is only supported with ROV.
if (texture_cache_ != nullptr && texture_cache_->IsResolutionScale2X()) {
return L"Direct3D 12 - ROV 2x";
return "Direct3D 12 - ROV 2x";
} else {
return L"Direct3D 12 - ROV";
return "Direct3D 12 - ROV";
}
} else {
return L"Direct3D 12 - RTV/DSV";
return "Direct3D 12 - RTV/DSV";
}
}

View File

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2018 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -43,10 +43,10 @@ class D3D12CommandProcessor : public CommandProcessor {
void ClearCaches() override;
void InitializeShaderStorage(const std::wstring& storage_root,
void InitializeShaderStorage(const std::filesystem::path& storage_root,
uint32_t title_id, bool blocking) override;
void RequestFrameTrace(const std::wstring& root_path) override;
void RequestFrameTrace(const std::filesystem::path& root_path) override;
void TracePlaybackWroteMemory(uint32_t base_ptr, uint32_t length) override;
@@ -154,7 +154,7 @@ class D3D12CommandProcessor : public CommandProcessor {
bool changing_stencil_ref = false);
// Returns the text to display in the GPU backend name in the window title.
std::wstring GetWindowTitleText() const;
std::string GetWindowTitleText() const;
std::unique_ptr<xe::ui::RawImage> Capture();

View File

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2018 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -31,13 +31,13 @@ bool D3D12GraphicsSystem::IsAvailable() {
return xe::ui::d3d12::D3D12Provider::IsD3D12APIAvailable();
}
std::wstring D3D12GraphicsSystem::name() const {
std::string D3D12GraphicsSystem::name() const {
auto d3d12_command_processor =
static_cast<D3D12CommandProcessor*>(command_processor());
if (d3d12_command_processor != nullptr) {
return d3d12_command_processor->GetWindowTitleText();
}
return L"Direct3D 12";
return "Direct3D 12";
}
X_STATUS D3D12GraphicsSystem::Setup(cpu::Processor* processor,

View File

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2018 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -28,7 +28,7 @@ class D3D12GraphicsSystem : public GraphicsSystem {
static bool IsAvailable();
std::wstring name() const override;
std::string name() const override;
X_STATUS Setup(cpu::Processor* processor, kernel::KernelState* kernel_state,
ui::Window* target_window) override;

View File

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -45,7 +45,7 @@ class D3D12TraceDump : public TraceDump {
}
};
int trace_dump_main(const std::vector<std::wstring>& args) {
int trace_dump_main(const std::vector<std::string>& args) {
D3D12TraceDump trace_dump;
return trace_dump.Main(args);
}
@@ -54,6 +54,6 @@ int trace_dump_main(const std::vector<std::wstring>& args) {
} // namespace gpu
} // namespace xe
DEFINE_ENTRY_POINT(L"xenia-gpu-d3d12-trace-dump",
DEFINE_ENTRY_POINT("xenia-gpu-d3d12-trace-dump",
xe::gpu::d3d12::trace_dump_main, "some.trace",
"target_trace_file");

View File

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -47,7 +47,7 @@ class D3D12TraceViewer : public TraceViewer {
}
};
int trace_viewer_main(const std::vector<std::wstring>& args) {
int trace_viewer_main(const std::vector<std::string>& args) {
D3D12TraceViewer trace_viewer;
return trace_viewer.Main(args);
}
@@ -56,6 +56,6 @@ int trace_viewer_main(const std::vector<std::wstring>& args) {
} // namespace gpu
} // namespace xe
DEFINE_ENTRY_POINT(L"xenia-gpu-d3d12-trace-viewer",
DEFINE_ENTRY_POINT("xenia-gpu-d3d12-trace-viewer",
xe::gpu::d3d12::trace_viewer_main, "some.trace",
"target_trace_file");

View File

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2018 Ben Vanik. All rights reserved. *
* Copyright 2020 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -18,8 +18,8 @@
#include <mutex>
#include <utility>
#include "third_party/fmt/include/fmt/format.h"
#include "third_party/xxhash/xxhash.h"
#include "xenia/base/assert.h"
#include "xenia/base/byte_order.h"
#include "xenia/base/clock.h"
@@ -138,7 +138,7 @@ void PipelineCache::Shutdown() {
void PipelineCache::ClearCache(bool shutting_down) {
bool reinitialize_shader_storage =
!shutting_down && storage_write_thread_ != nullptr;
std::wstring shader_storage_root;
std::filesystem::path shader_storage_root;
uint32_t shader_storage_title_id = shader_storage_title_id_;
if (reinitialize_shader_storage) {
shader_storage_root = shader_storage_root_;
@@ -188,19 +188,19 @@ void PipelineCache::ClearCache(bool shutting_down) {
}
}
void PipelineCache::InitializeShaderStorage(const std::wstring& storage_root,
uint32_t title_id, bool blocking) {
void PipelineCache::InitializeShaderStorage(
const std::filesystem::path& storage_root, uint32_t title_id,
bool blocking) {
ShutdownShaderStorage();
auto shader_storage_root = xe::join_paths(storage_root, L"shaders");
auto shader_storage_root = storage_root / "shaders";
// For files that can be moved between different hosts.
// Host PSO blobs - if ever added - should be stored in shaders/local/ (they
// currently aren't used because because they may be not very practical -
// would need to invalidate them every commit likely, and additional I/O
// cost - though D3D's internal validation would possibly be enough to ensure
// they are up to date).
auto shader_storage_shareable_root =
xe::join_paths(shader_storage_root, L"shareable");
auto shader_storage_shareable_root = shader_storage_root / "shareable";
if (!xe::filesystem::CreateFolder(shader_storage_shareable_root)) {
return;
}
@@ -215,8 +215,7 @@ void PipelineCache::InitializeShaderStorage(const std::wstring& storage_root,
uint64_t shader_storage_initialization_start =
xe::Clock::QueryHostTickCount();
shader_storage_file_ = xe::filesystem::OpenFile(
xe::join_paths(shader_storage_shareable_root,
xe::format_string(L"%.8X.xsh", title_id)),
shader_storage_shareable_root / fmt::format("{:08X}.xsh", title_id),
"a+b");
if (!shader_storage_file_) {
return;
@@ -388,11 +387,11 @@ void PipelineCache::InitializeShaderStorage(const std::wstring& storage_root,
// Initialize the pipeline state storage stream.
uint64_t pipeline_state_storage_initialization_start_ =
xe::Clock::QueryHostTickCount();
pipeline_state_storage_file_ = xe::filesystem::OpenFile(
xe::join_paths(shader_storage_shareable_root,
xe::format_string(L"%.8X.%s.d3d12.xpso", title_id,
edram_rov_used_ ? L"rov" : L"rtv")),
"a+b");
pipeline_state_storage_file_ =
xe::filesystem::OpenFile(shader_storage_shareable_root /
fmt::format("{:08X}.{}.d3d12.xpso", title_id,
edram_rov_used_ ? "rov" : "rtv"),
"a+b");
if (!pipeline_state_storage_file_) {
fclose(shader_storage_file_);
shader_storage_file_ = nullptr;
@@ -1694,13 +1693,12 @@ ID3D12PipelineState* PipelineCache::CreateD3D12PipelineState(
}
std::wstring name;
if (runtime_description.pixel_shader != nullptr) {
name =
xe::format_string(L"VS %.16I64X, PS %.16I64X",
runtime_description.vertex_shader->ucode_data_hash(),
runtime_description.pixel_shader->ucode_data_hash());
name = fmt::format(L"VS {:016X}, PS {:016X}",
runtime_description.vertex_shader->ucode_data_hash(),
runtime_description.pixel_shader->ucode_data_hash());
} else {
name = xe::format_string(
L"VS %.16I64X", runtime_description.vertex_shader->ucode_data_hash());
name = fmt::format(L"VS {:016X}",
runtime_description.vertex_shader->ucode_data_hash());
}
state->SetName(name.c_str());
return state;

View File

@@ -46,7 +46,7 @@ class PipelineCache {
void Shutdown();
void ClearCache(bool shutting_down = false);
void InitializeShaderStorage(const std::wstring& storage_root,
void InitializeShaderStorage(const std::filesystem::path& storage_root,
uint32_t title_id, bool blocking);
void ShutdownShaderStorage();
@@ -262,7 +262,7 @@ class PipelineCache {
PipelineState* current_pipeline_state_ = nullptr;
// Currently open shader storage path.
std::wstring shader_storage_root_;
std::filesystem::path shader_storage_root_;
uint32_t shader_storage_title_id_ = 0;
// Shader storage output stream, for preload in the next emulator runs.

View File

@@ -7,6 +7,7 @@ project("xenia-gpu-d3d12")
kind("StaticLib")
language("C++")
links({
"fmt",
"xenia-base",
"xenia-gpu",
"xenia-ui",
@@ -27,6 +28,7 @@ project("xenia-gpu-d3d12-trace-viewer")
"aes_128",
"capstone",
"dxbc",
"fmt",
"imgui",
"libavcodec",
"libavutil",
@@ -71,6 +73,7 @@ project("xenia-gpu-d3d12-trace-dump")
"aes_128",
"capstone",
"dxbc",
"fmt",
"imgui",
"libavcodec",
"libavutil",