microsoft / DirectXTK12

The DirectX Tool Kit (aka DirectXTK12) is a collection of helper classes for writing DirectX 12 code in C++
https://walbourn.github.io/directx-tool-kit-for-directx-12/
MIT License
1.45k stars 371 forks source link

PostProcess Problem with Radeons 570 & 580 #126

Closed hasseily closed 2 years ago

hasseily commented 2 years ago

Some of the players of my game Deathlord Relorded have reported weird black artifacts when playing under Radeons 570 and 580. See a sample of the problem here: RPGCodex post

After a lot of analysis, I have come to the conclusion that the problem lies inside the PostProcess class. Here's some relevant code in my game when using BasicPostProcess::Copy:

m_postProcessCopy = std::make_unique<BasicPostProcess>(device, rtState, BasicPostProcess::Copy);
m_postProcessCopy->SetSourceTexture(
    m_resourceDescriptors->GetGpuHandle((size_t)TextureDescriptors::OffscreenTexture2),
            m_offscreenTexture2->GetResource());
m_postProcessCopy->Process(commandList);

If I instead replace the above with the below, the Radeon problem goes away:

            auto offscreenTarget = m_offscreenTexture2->GetResource();
            auto renderTarget = m_offscreenTexture1->GetResource();
            m_offscreenTexture2->TransitionTo(commandList, D3D12_RESOURCE_STATE_COPY_SOURCE);
            m_offscreenTexture1->TransitionTo(commandList, D3D12_RESOURCE_STATE_COPY_DEST);
            commandList->CopyResource(renderTarget, offscreenTarget);
            m_offscreenTexture2->TransitionTo(commandList, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
            m_offscreenTexture1->TransitionTo(commandList, D3D12_RESOURCE_STATE_RENDER_TARGET);

I've also confirmed that the problem happens with the Blur post process.

walbourn commented 2 years ago

Any output from the debug device output in this scenario with the original code?

Can you verify the descriptor binding is correct at that point?

hasseily commented 2 years ago

I don't have a Radeon 570 or 580 for testing. The original code works fine with all other cards it seems. So I'd be surprised if the descriptor binding is a problem. I do have an AMD+Radeon laptop that doesn't have the problem, but the card is more modern. It might be purely a 500 series issue.

There's no output whatsoever from the debug device. It does work since at startup I do get a couple of invalid resource state warnings, but that's not relevant and this part of the code uses different resources.

walbourn commented 2 years ago

Sounds like a driver bug to me... Weird.

You should report it to AMD.