From 89a11519fb4e3eececd279d2d11afef5c87997b4 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 22 Jul 2021 13:57:46 +1000 Subject: [PATCH] D3D12: Use clears instead of draws for simple VRAM fills --- src/core/gpu_hw_d3d12.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/gpu_hw_d3d12.cpp b/src/core/gpu_hw_d3d12.cpp index cad7bac93..ca7262c66 100644 --- a/src/core/gpu_hw_d3d12.cpp +++ b/src/core/gpu_hw_d3d12.cpp @@ -998,8 +998,21 @@ void GPU_HW_D3D12::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color) GPU_HW::FillVRAM(x, y, width, height, color); const VRAMFillUBOData uniforms = GetVRAMFillUBOData(x, y, width, height, color); - ID3D12GraphicsCommandList* cmdlist = g_d3d12_context->GetCommandList(); + + const bool wrapped = IsVRAMFillOversized(x, y, width, height); + const bool interlaced = IsInterlacedRenderingEnabled(); + if (!wrapped && !interlaced) + { + const D3D12_RECT rc = {static_cast(x * m_resolution_scale), static_cast(y * m_resolution_scale), + static_cast((x + width) * m_resolution_scale), + static_cast((y + height) * m_resolution_scale)}; + cmdlist->ClearRenderTargetView(m_vram_texture.GetRTVOrDSVDescriptor(), uniforms.u_fill_color, 1, &rc); + cmdlist->ClearDepthStencilView(m_vram_depth_texture.GetRTVOrDSVDescriptor(), D3D12_CLEAR_FLAG_DEPTH, + uniforms.u_fill_color[3], 0, 1, &rc); + return; + } + cmdlist->SetGraphicsRootSignature(m_single_sampler_root_signature.Get()); cmdlist->SetGraphicsRoot32BitConstants(0, sizeof(uniforms) / sizeof(u32), &uniforms, 0); cmdlist->SetGraphicsRootDescriptorTable(1, g_d3d12_context->GetNullSRVDescriptor());