[D3D12] Switch from gflags to cvars
This commit is contained in:
@@ -9,19 +9,17 @@
|
||||
|
||||
#include "xenia/ui/d3d12/d3d12_context.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "xenia/base/cvar.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/gpu/gpu_flags.h"
|
||||
#include "xenia/ui/d3d12/d3d12_immediate_drawer.h"
|
||||
#include "xenia/ui/d3d12/d3d12_provider.h"
|
||||
#include "xenia/ui/window.h"
|
||||
|
||||
DEFINE_bool(d3d12_random_clear_color, false,
|
||||
"Randomize presentation back buffer clear color.");
|
||||
"Randomize presentation back buffer clear color.", "D3D12");
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
@@ -267,7 +265,7 @@ void D3D12Context::BeginSwap() {
|
||||
graphics_command_list->OMSetRenderTargets(1, &back_buffer_rtv, TRUE,
|
||||
nullptr);
|
||||
float clear_color[4];
|
||||
if (FLAGS_d3d12_random_clear_color) {
|
||||
if (cvars::d3d12_random_clear_color) {
|
||||
clear_color[0] =
|
||||
rand() / float(RAND_MAX); // NOLINT(runtime/threadsafe_fn)
|
||||
clear_color[1] = 1.0f;
|
||||
@@ -303,7 +301,7 @@ void D3D12Context::EndSwap() {
|
||||
graphics_command_list->ResourceBarrier(1, &barrier);
|
||||
command_list->Execute();
|
||||
// Present and check if the context was lost.
|
||||
HRESULT result = swap_chain_->Present(FLAGS_vsync ? 1 : 0, 0);
|
||||
HRESULT result = swap_chain_->Present(0, 0);
|
||||
if (result == DXGI_ERROR_DEVICE_RESET ||
|
||||
result == DXGI_ERROR_DEVICE_REMOVED) {
|
||||
context_lost_ = true;
|
||||
|
||||
@@ -9,18 +9,19 @@
|
||||
|
||||
#include "xenia/ui/d3d12/d3d12_provider.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <malloc.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "xenia/base/cvar.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/ui/d3d12/d3d12_context.h"
|
||||
|
||||
DEFINE_bool(d3d12_debug, false, "Enable Direct3D 12 and DXGI debug layer.");
|
||||
DEFINE_bool(d3d12_debug, false, "Enable Direct3D 12 and DXGI debug layer.",
|
||||
"D3D12");
|
||||
DEFINE_int32(d3d12_adapter, -1,
|
||||
"Index of the DXGI adapter to use. "
|
||||
"-1 for any physical adapter, -2 for WARP software rendering.");
|
||||
"-1 for any physical adapter, -2 for WARP software rendering.",
|
||||
"D3D12");
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
@@ -107,7 +108,7 @@ D3D12Provider::InitializationResult D3D12Provider::Initialize() {
|
||||
}
|
||||
|
||||
// Enable the debug layer.
|
||||
bool debug = FLAGS_d3d12_debug;
|
||||
bool debug = cvars::d3d12_debug;
|
||||
if (debug) {
|
||||
ID3D12Debug* debug_interface;
|
||||
if (SUCCEEDED(
|
||||
@@ -136,11 +137,11 @@ D3D12Provider::InitializationResult D3D12Provider::Initialize() {
|
||||
if (SUCCEEDED(adapter->GetDesc1(&adapter_desc))) {
|
||||
if (SUCCEEDED(pfn_d3d12_create_device_(adapter, D3D_FEATURE_LEVEL_11_0,
|
||||
_uuidof(ID3D12Device), nullptr))) {
|
||||
if (FLAGS_d3d12_adapter >= 0) {
|
||||
if (adapter_index == FLAGS_d3d12_adapter) {
|
||||
if (cvars::d3d12_adapter >= 0) {
|
||||
if (adapter_index == cvars::d3d12_adapter) {
|
||||
break;
|
||||
}
|
||||
} else if (FLAGS_d3d12_adapter == -2) {
|
||||
} else if (cvars::d3d12_adapter == -2) {
|
||||
if (adapter_desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,5 @@ project("xenia-ui")
|
||||
})
|
||||
defines({
|
||||
})
|
||||
includedirs({
|
||||
project_root.."/third_party/gflags/src",
|
||||
})
|
||||
local_platform_files()
|
||||
removefiles({"*_demo.cc"})
|
||||
|
||||
@@ -14,7 +14,6 @@ project("xenia-ui-spirv")
|
||||
defines({
|
||||
})
|
||||
includedirs({
|
||||
project_root.."/third_party/gflags/src",
|
||||
project_root.."/third_party/spirv-tools/external/include",
|
||||
})
|
||||
local_platform_files()
|
||||
|
||||
@@ -14,7 +14,6 @@ project("xenia-ui-vulkan")
|
||||
defines({
|
||||
})
|
||||
includedirs({
|
||||
project_root.."/third_party/gflags/src",
|
||||
project_root.."/third_party/vulkan/",
|
||||
})
|
||||
local_platform_files()
|
||||
@@ -29,7 +28,6 @@ project("xenia-ui-window-vulkan-demo")
|
||||
kind("WindowedApp")
|
||||
language("C++")
|
||||
links({
|
||||
"gflags",
|
||||
"imgui",
|
||||
"volk",
|
||||
"xenia-base",
|
||||
@@ -40,7 +38,6 @@ project("xenia-ui-window-vulkan-demo")
|
||||
defines({
|
||||
})
|
||||
includedirs({
|
||||
project_root.."/third_party/gflags/src",
|
||||
project_root.."/third_party/vulkan/",
|
||||
})
|
||||
files({
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
#include "xenia/ui/vulkan/vulkan.h"
|
||||
|
||||
DEFINE_bool(vulkan_validation, false, "Enable Vulkan validation layers.");
|
||||
DEFINE_bool(vulkan_validation, false, "Enable Vulkan validation layers.",
|
||||
"Vulkan");
|
||||
|
||||
DEFINE_bool(vulkan_primary_queue_only, false,
|
||||
"Force the use of the primary queue, ignoring any additional that "
|
||||
"may be present.");
|
||||
"may be present.",
|
||||
"Vulkan");
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#ifndef XENIA_UI_VULKAN_VULKAN_H_
|
||||
#define XENIA_UI_VULKAN_VULKAN_H_
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
@@ -25,6 +23,7 @@
|
||||
// We use a loader with its own function prototypes.
|
||||
#include "third_party/volk/volk.h"
|
||||
#include "third_party/vulkan/vulkan.h"
|
||||
#include "xenia/base/cvar.h"
|
||||
|
||||
#define XELOGVK XELOGI
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
#include "xenia/ui/vulkan/vulkan_device.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <climits>
|
||||
#include <mutex>
|
||||
@@ -33,7 +31,7 @@ namespace ui {
|
||||
namespace vulkan {
|
||||
|
||||
VulkanDevice::VulkanDevice(VulkanInstance* instance) : instance_(instance) {
|
||||
if (FLAGS_vulkan_validation) {
|
||||
if (cvars::vulkan_validation) {
|
||||
DeclareRequiredLayer("VK_LAYER_LUNARG_standard_validation",
|
||||
Version::Make(0, 0, 0), true);
|
||||
// DeclareRequiredLayer("VK_LAYER_GOOGLE_unique_objects", Version::Make(0,
|
||||
@@ -150,7 +148,7 @@ bool VulkanDevice::Initialize(DeviceInfo device_info) {
|
||||
}
|
||||
|
||||
// Some tools *cough* renderdoc *cough* can't handle multiple queues.
|
||||
if (FLAGS_vulkan_primary_queue_only) {
|
||||
if (cvars::vulkan_primary_queue_only) {
|
||||
queue_count = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
#include "xenia/ui/vulkan/vulkan_instance.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
@@ -38,7 +36,7 @@ namespace ui {
|
||||
namespace vulkan {
|
||||
|
||||
VulkanInstance::VulkanInstance() {
|
||||
if (FLAGS_vulkan_validation) {
|
||||
if (cvars::vulkan_validation) {
|
||||
DeclareRequiredLayer("VK_LAYER_LUNARG_standard_validation",
|
||||
Version::Make(0, 0, 0), true);
|
||||
// DeclareRequiredLayer("VK_LAYER_GOOGLE_unique_objects", Version::Make(0,
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
#include "xenia/ui/vulkan/vulkan_provider.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "xenia/base/logging.h"
|
||||
@@ -19,7 +17,8 @@
|
||||
#include "xenia/ui/vulkan/vulkan_instance.h"
|
||||
#include "xenia/ui/vulkan/vulkan_util.h"
|
||||
|
||||
DEFINE_uint64(vulkan_device_index, 0, "Index of the physical device to use.");
|
||||
DEFINE_uint64(vulkan_device_index, 0, "Index of the physical device to use.",
|
||||
"Vulkan");
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
@@ -73,7 +72,7 @@ bool VulkanProvider::Initialize() {
|
||||
return false;
|
||||
}
|
||||
size_t device_index =
|
||||
std::min(available_devices.size(), FLAGS_vulkan_device_index);
|
||||
std::min(available_devices.size(), cvars::vulkan_device_index);
|
||||
auto& device_info = available_devices[device_index];
|
||||
|
||||
// Create the device.
|
||||
|
||||
@@ -9,12 +9,11 @@
|
||||
|
||||
#include "xenia/ui/vulkan/vulkan_swap_chain.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/cvar.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/ui/vulkan/vulkan.h"
|
||||
@@ -23,7 +22,7 @@
|
||||
#include "xenia/ui/vulkan/vulkan_util.h"
|
||||
|
||||
DEFINE_bool(vulkan_random_clear_color, false,
|
||||
"Randomizes framebuffer clear color.");
|
||||
"Randomizes framebuffer clear color.", "Vulkan");
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
@@ -583,7 +582,7 @@ VkResult VulkanSwapChain::Begin() {
|
||||
clear_color.float32[1] = 238 / 255.0f;
|
||||
clear_color.float32[2] = 238 / 255.0f;
|
||||
clear_color.float32[3] = 1.0f;
|
||||
if (FLAGS_vulkan_random_clear_color) {
|
||||
if (cvars::vulkan_random_clear_color) {
|
||||
clear_color.float32[0] =
|
||||
rand() / static_cast<float>(RAND_MAX); // NOLINT(runtime/threadsafe_fn)
|
||||
clear_color.float32[1] = 1.0f;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/ui/vulkan/vulkan.h"
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "third_party/imgui/imgui.h"
|
||||
|
||||
Reference in New Issue
Block a user