mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-31 00:32:53 +00:00
VideoBackends:D3D12: Defer binding framebuffer in SetAndDiscardFramebuffer
BindFramebuffer depends on the pipeline which might not be set yet. That's why the framebuffer dirty flag exists in the first place. I assume BindFramebuffer was called directly here, in order to handle the texture state transitions necessary for DiscardResource. The state is tracked anyway, so we can just issue those transitions there too and defer binding the actual framebuffer. Fixes an issue in Zelda Twilight Princess with EFB depth peeks. Dolphin would bind a frame buffer which doesn't have an integer format descriptor for the color target before binding the new pipeline. So it would accidentally use the 0 descriptor. Debug layer error: D3D12 ERROR: ID3D12CommandList::OMSetRenderTargets: Specified CPU descriptor handle ptr=0x0000000000000000 does not refer to a location in a descriptor heap. pRenderTargetDescriptors[0] is the issue. [ EXECUTION ERROR #646: INVALID_DESCRIPTOR_HANDLE]
This commit is contained in:
parent
a6aa651291
commit
a07ee729e5
@ -236,18 +236,20 @@ void Renderer::SetFramebuffer(AbstractFramebuffer* framebuffer)
|
||||
|
||||
void Renderer::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer)
|
||||
{
|
||||
BindFramebuffer(static_cast<DXFramebuffer*>(framebuffer));
|
||||
SetFramebuffer(framebuffer);
|
||||
|
||||
static const D3D12_DISCARD_REGION dr = {0, nullptr, 0, 1};
|
||||
if (framebuffer->HasColorBuffer())
|
||||
{
|
||||
g_dx_context->GetCommandList()->DiscardResource(
|
||||
static_cast<DXTexture*>(framebuffer->GetColorAttachment())->GetResource(), &dr);
|
||||
DXTexture* color_attachment = static_cast<DXTexture*>(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<DXTexture*>(framebuffer->GetDepthAttachment())->GetResource(), &dr);
|
||||
DXTexture* depth_attachment = static_cast<DXTexture*>(framebuffer->GetDepthAttachment());
|
||||
depth_attachment->TransitionToState(D3D12_RESOURCE_STATE_DEPTH_WRITE);
|
||||
g_dx_context->GetCommandList()->DiscardResource(depth_attachment->GetResource(), &dr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user