[GPU] Ownership-transfer-based RT cache, 3x3 resolution scaling

The ROV path is also disabled by default because of lower performance
This commit is contained in:
Triang3l
2021-04-26 22:12:09 +03:00
parent 30ea6e3ea3
commit 913e1e949c
362 changed files with 185259 additions and 38291 deletions

View File

@@ -21,6 +21,8 @@ DEFINE_bool(d3d12_debug, false, "Enable Direct3D 12 and DXGI debug layer.",
"D3D12");
DEFINE_bool(d3d12_break_on_error, false,
"Break on Direct3D 12 validation errors.", "D3D12");
DEFINE_bool(d3d12_break_on_warning, false,
"Break on Direct3D 12 validation warnings.", "D3D12");
DEFINE_int32(d3d12_adapter, -1,
"Index of the DXGI adapter to use. "
"-1 for any physical adapter, -2 for WARP software rendering.",
@@ -200,14 +202,20 @@ bool D3D12Provider::Initialize() {
}
// Configure the DXGI debug info queue.
if (cvars::d3d12_break_on_error) {
if (cvars::d3d12_break_on_error || cvars::d3d12_break_on_warning) {
IDXGIInfoQueue* dxgi_info_queue;
if (SUCCEEDED(pfn_dxgi_get_debug_interface1_(
0, IID_PPV_ARGS(&dxgi_info_queue)))) {
dxgi_info_queue->SetBreakOnSeverity(
DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, TRUE);
dxgi_info_queue->SetBreakOnSeverity(
DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, TRUE);
if (cvars::d3d12_break_on_error) {
dxgi_info_queue->SetBreakOnSeverity(
DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, TRUE);
dxgi_info_queue->SetBreakOnSeverity(
DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, TRUE);
}
if (cvars::d3d12_break_on_warning) {
dxgi_info_queue->SetBreakOnSeverity(
DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_WARNING, TRUE);
}
dxgi_info_queue->Release();
}
}
@@ -273,7 +281,7 @@ bool D3D12Provider::Initialize() {
dxgi_factory->Release();
return false;
}
adapter_vendor_id_ = adapter_desc.VendorId;
adapter_vendor_id_ = GpuVendorID(adapter_desc.VendorId);
int adapter_name_mb_size = WideCharToMultiByte(
CP_UTF8, 0, adapter_desc.Description, -1, nullptr, 0, nullptr, nullptr);
if (adapter_name_mb_size != 0) {
@@ -282,7 +290,7 @@ bool D3D12Provider::Initialize() {
if (WideCharToMultiByte(CP_UTF8, 0, adapter_desc.Description, -1,
adapter_name_mb, adapter_name_mb_size, nullptr,
nullptr) != 0) {
XELOGD3D("DXGI adapter: {} (vendor {:04X}, device {:04X})",
XELOGD3D("DXGI adapter: {} (vendor 0x{:04X}, device 0x{:04X})",
adapter_name_mb, adapter_desc.VendorId, adapter_desc.DeviceId);
}
}
@@ -307,9 +315,20 @@ bool D3D12Provider::Initialize() {
D3D12_MESSAGE_ID d3d12_info_queue_denied_messages[] = {
// Xbox 360 vertex fetch is explicit in shaders.
D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_EMPTY_LAYOUT,
// Bug in the debug layer (fixed in some version of Windows) - gaps in
// render target bindings must be represented with a fully typed RTV
// descriptor and DXGI_FORMAT_UNKNOWN in the pipeline state, but older
// debug layer versions give a format mismatch error in this case.
D3D12_MESSAGE_ID_RENDER_TARGET_FORMAT_MISMATCH_PIPELINE_STATE,
// Render targets and shader exports don't have to match on the Xbox
// 360.
D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RENDERTARGETVIEW_NOT_SET,
// Arbitrary scissor can be specified by the guest, also it can be
// explicitly used to disable drawing.
D3D12_MESSAGE_ID_DRAW_EMPTY_SCISSOR_RECTANGLE,
// Arbitrary clear values can be specified by the guest.
D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_MISMATCHINGCLEARVALUE,
D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_MISMATCHINGCLEARVALUE,
};
D3D12_INFO_QUEUE_FILTER d3d12_info_queue_filter = {};
d3d12_info_queue_filter.DenyList.NumSeverities =
@@ -325,6 +344,10 @@ bool D3D12Provider::Initialize() {
TRUE);
d3d12_info_queue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_ERROR, TRUE);
}
if (cvars::d3d12_break_on_warning) {
d3d12_info_queue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_WARNING,
TRUE);
}
d3d12_info_queue->Release();
}
@@ -373,14 +396,10 @@ bool D3D12Provider::Initialize() {
direct_queue_ = direct_queue;
// Get descriptor sizes for each type.
descriptor_size_view_ = device->GetDescriptorHandleIncrementSize(
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
descriptor_size_sampler_ = device->GetDescriptorHandleIncrementSize(
D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
descriptor_size_rtv_ =
device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
descriptor_size_dsv_ =
device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
for (uint32_t i = 0; i < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++i) {
descriptor_sizes_[i] =
device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE(i));
}
// Check if optional features are supported.
// D3D12_HEAP_FLAG_CREATE_NOT_ZEROED requires Windows 10 2004 (indicated by
@@ -391,13 +410,16 @@ bool D3D12Provider::Initialize() {
&options7, sizeof(options7)))) {
heap_flag_create_not_zeroed_ = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
}
ps_specified_stencil_reference_supported_ = false;
rasterizer_ordered_views_supported_ = false;
resource_binding_tier_ = D3D12_RESOURCE_BINDING_TIER_1;
tiled_resources_tier_ = D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED;
D3D12_FEATURE_DATA_D3D12_OPTIONS options;
if (SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS,
&options, sizeof(options)))) {
rasterizer_ordered_views_supported_ = options.ROVsSupported ? true : false;
ps_specified_stencil_reference_supported_ =
bool(options.PSSpecifiedStencilRefSupported);
rasterizer_ordered_views_supported_ = bool(options.ROVsSupported);
resource_binding_tier_ = options.ResourceBindingTier;
tiled_resources_tier_ = options.TiledResourcesTier;
}
@@ -421,6 +443,7 @@ bool D3D12Provider::Initialize() {
"Direct3D 12 device and OS features:\n"
"* Max GPU virtual address bits per resource: {}\n"
"* Non-zeroed heap creation: {}\n"
"* Pixel-shader-specified stencil reference: {}\n"
"* Programmable sample positions: tier {}\n"
"* Rasterizer-ordered views: {}\n"
"* Resource binding: tier {}\n"
@@ -428,6 +451,7 @@ bool D3D12Provider::Initialize() {
virtual_address_bits_per_resource_,
(heap_flag_create_not_zeroed_ & D3D12_HEAP_FLAG_CREATE_NOT_ZEROED) ? "yes"
: "no",
ps_specified_stencil_reference_supported_ ? "yes" : "no",
uint32_t(programmable_sample_positions_tier_),
rasterizer_ordered_views_supported_ ? "yes" : "no",
uint32_t(resource_binding_tier_), uint32_t(tiled_resources_tier_));