From af73d8ac247713b40196f886499f7dc904817e5d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 27 Dec 2022 22:16:44 +1000 Subject: [PATCH] D3D12HostDisplay: Fix software cursor rendering --- src/common/d3d12/descriptor_heap_manager.cpp | 3 ++- src/frontend-common/d3d12_host_display.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/common/d3d12/descriptor_heap_manager.cpp b/src/common/d3d12/descriptor_heap_manager.cpp index 972521ba0..ca215fc62 100644 --- a/src/common/d3d12/descriptor_heap_manager.cpp +++ b/src/common/d3d12/descriptor_heap_manager.cpp @@ -25,7 +25,8 @@ bool DescriptorHeapManager::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_T return false; m_heap_base_cpu = m_descriptor_heap->GetCPUDescriptorHandleForHeapStart(); - m_heap_base_gpu = m_descriptor_heap->GetGPUDescriptorHandleForHeapStart(); + if (shader_visible) + m_heap_base_gpu = m_descriptor_heap->GetGPUDescriptorHandleForHeapStart(); m_num_descriptors = num_descriptors; m_descriptor_increment_size = device->GetDescriptorHandleIncrementSize(type); diff --git a/src/frontend-common/d3d12_host_display.cpp b/src/frontend-common/d3d12_host_display.cpp index 4928dd850..d502f0dbb 100644 --- a/src/frontend-common/d3d12_host_display.cpp +++ b/src/frontend-common/d3d12_host_display.cpp @@ -11,6 +11,7 @@ #include "common/string_util.h" #include "core/settings.h" #include "display_ps.hlsl.h" +#include "display_ps_alpha.hlsl.h" #include "display_vs.hlsl.h" #include "frontend-common/postprocessing_shadergen.h" #include "imgui.h" @@ -502,6 +503,7 @@ bool D3D12HostDisplay::CreateResources() if (!m_display_pipeline) return false; + gpbuilder.SetPixelShader(s_display_ps_alpha_bytecode, sizeof(s_display_ps_alpha_bytecode)); gpbuilder.SetBlendState(0, true, D3D12_BLEND_SRC_ALPHA, D3D12_BLEND_INV_SRC_ALPHA, D3D12_BLEND_OP_ADD, D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, D3D12_COLOR_WRITE_ENABLE_ALL); m_software_cursor_pipeline = gpbuilder.Create(g_d3d12_context->GetDevice(), false); @@ -743,9 +745,10 @@ void D3D12HostDisplay::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist, { const float uniforms[4] = {0.0f, 0.0f, 1.0f, 1.0f}; - cmdlist->SetPipelineState(m_display_pipeline.Get()); + cmdlist->SetGraphicsRootSignature(m_display_root_signature.Get()); + cmdlist->SetPipelineState(m_software_cursor_pipeline.Get()); cmdlist->SetGraphicsRoot32BitConstants(0, static_cast(std::size(uniforms)), uniforms, 0); - cmdlist->SetGraphicsRootDescriptorTable(1, static_cast(texture_handle)->GetRTVOrDSVDescriptor()); + cmdlist->SetGraphicsRootDescriptorTable(1, static_cast(texture_handle)->GetSRVDescriptor()); cmdlist->SetGraphicsRootDescriptorTable(2, m_linear_sampler); D3D12::SetViewportAndScissor(cmdlist, left, top, width, height);