diff --git a/Source/Core/VideoBackends/D3D12/D3D12BoundingBox.cpp b/Source/Core/VideoBackends/D3D12/D3D12BoundingBox.cpp index 75b3f6064a..4eec9f2e22 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12BoundingBox.cpp +++ b/Source/Core/VideoBackends/D3D12/D3D12BoundingBox.cpp @@ -101,8 +101,8 @@ bool D3D12BoundingBox::CreateBuffers() D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS}; HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource( - &gpu_heap_properties, D3D12_HEAP_FLAG_NONE, &buffer_desc, - D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr, IID_PPV_ARGS(&m_gpu_buffer)); + &gpu_heap_properties, D3D12_HEAP_FLAG_NONE, &buffer_desc, D3D12_RESOURCE_STATE_COMMON, + nullptr, IID_PPV_ARGS(&m_gpu_buffer)); ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating bounding box GPU buffer failed: {}", DX12HRWrap(hr)); if (FAILED(hr) || !g_dx_context->GetDescriptorHeapManager().Allocate(&m_gpu_descriptor)) return false; diff --git a/Source/Core/VideoBackends/D3D12/D3D12Renderer.cpp b/Source/Core/VideoBackends/D3D12/D3D12Renderer.cpp index fc76f8e6f2..f4ef717c07 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12Renderer.cpp +++ b/Source/Core/VideoBackends/D3D12/D3D12Renderer.cpp @@ -236,18 +236,20 @@ void Renderer::SetFramebuffer(AbstractFramebuffer* framebuffer) void Renderer::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer) { - BindFramebuffer(static_cast(framebuffer)); + SetFramebuffer(framebuffer); static const D3D12_DISCARD_REGION dr = {0, nullptr, 0, 1}; if (framebuffer->HasColorBuffer()) { - g_dx_context->GetCommandList()->DiscardResource( - static_cast(framebuffer->GetColorAttachment())->GetResource(), &dr); + DXTexture* color_attachment = static_cast(framebuffer->GetColorAttachment()); + color_attachment->TransitionToState(D3D12_RESOURCE_STATE_RENDER_TARGET); + g_dx_context->GetCommandList()->DiscardResource(color_attachment->GetResource(), &dr); } if (framebuffer->HasDepthBuffer()) { - g_dx_context->GetCommandList()->DiscardResource( - static_cast(framebuffer->GetDepthAttachment())->GetResource(), &dr); + DXTexture* depth_attachment = static_cast(framebuffer->GetDepthAttachment()); + depth_attachment->TransitionToState(D3D12_RESOURCE_STATE_DEPTH_WRITE); + g_dx_context->GetCommandList()->DiscardResource(depth_attachment->GetResource(), &dr); } } diff --git a/Source/Core/VideoBackends/D3D12/DescriptorHeapManager.cpp b/Source/Core/VideoBackends/D3D12/DescriptorHeapManager.cpp index 97d0c8ce2e..9827057626 100644 --- a/Source/Core/VideoBackends/D3D12/DescriptorHeapManager.cpp +++ b/Source/Core/VideoBackends/D3D12/DescriptorHeapManager.cpp @@ -25,7 +25,6 @@ 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(); m_num_descriptors = num_descriptors; m_descriptor_increment_size = device->GetDescriptorHandleIncrementSize(type); @@ -60,7 +59,7 @@ bool DescriptorHeapManager::Allocate(DescriptorHandle* handle) handle->index = index; handle->cpu_handle.ptr = m_heap_base_cpu.ptr + index * m_descriptor_increment_size; - handle->gpu_handle.ptr = m_heap_base_gpu.ptr + index * m_descriptor_increment_size; + handle->gpu_handle.ptr = 0; return true; } diff --git a/Source/Core/VideoBackends/D3D12/DescriptorHeapManager.h b/Source/Core/VideoBackends/D3D12/DescriptorHeapManager.h index 7ff42c8e5b..c7c00d518f 100644 --- a/Source/Core/VideoBackends/D3D12/DescriptorHeapManager.h +++ b/Source/Core/VideoBackends/D3D12/DescriptorHeapManager.h @@ -41,7 +41,6 @@ private: u32 m_descriptor_increment_size = 0; D3D12_CPU_DESCRIPTOR_HANDLE m_heap_base_cpu = {}; - D3D12_GPU_DESCRIPTOR_HANDLE m_heap_base_gpu = {}; static constexpr u32 BITSET_SIZE = 1024; using BitSetType = std::bitset;