mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-03 11:46:09 +00:00
D3D12: Fix swapchains after 921fb5e1cef
The Swapchain::Configure was changed to not require an initial usage anymore. Previously the code was doing a transition to this usage causing the code to now transition to <uninitialized data> usage. Fix this by deleting code. Also make TextureD3D12 responsible for the transition to PRESENT.
This commit is contained in:
parent
eba7c027f9
commit
099656dc7a
@ -62,22 +62,11 @@ namespace backend { namespace d3d12 {
|
||||
backendDevice->NextSerial();
|
||||
}
|
||||
|
||||
void ExecuteCommandLists(nxtDevice device,
|
||||
std::initializer_list<ID3D12CommandList*> commandLists) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
backendDevice->ExecuteCommandLists(commandLists);
|
||||
}
|
||||
|
||||
void WaitForSerial(nxtDevice device, uint64_t serial) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
backendDevice->WaitForSerial(serial);
|
||||
}
|
||||
|
||||
void OpenCommandList(nxtDevice device, ComPtr<ID3D12GraphicsCommandList>* commandList) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
return backendDevice->OpenCommandList(commandList);
|
||||
}
|
||||
|
||||
void ASSERT_SUCCESS(HRESULT hr) {
|
||||
ASSERT(SUCCEEDED(hr));
|
||||
}
|
||||
|
@ -44,6 +44,9 @@ namespace backend { namespace d3d12 {
|
||||
resourceState |= D3D12_RESOURCE_STATE_RENDER_TARGET;
|
||||
}
|
||||
}
|
||||
if (usage & nxt::TextureUsageBit::Present) {
|
||||
resourceState |= D3D12_RESOURCE_STATE_PRESENT;
|
||||
}
|
||||
|
||||
return resourceState;
|
||||
}
|
||||
|
@ -37,10 +37,7 @@ namespace backend { namespace d3d12 {
|
||||
ComPtr<ID3D12CommandQueue> GetCommandQueue(nxtDevice device);
|
||||
uint64_t GetSerial(const nxtDevice device);
|
||||
void NextSerial(nxtDevice device);
|
||||
void ExecuteCommandLists(nxtDevice device,
|
||||
std::initializer_list<ID3D12CommandList*> commandLists);
|
||||
void WaitForSerial(nxtDevice device, uint64_t serial);
|
||||
void OpenCommandList(nxtDevice device, ComPtr<ID3D12GraphicsCommandList>* commandList);
|
||||
}} // namespace backend::d3d12
|
||||
|
||||
namespace utils {
|
||||
@ -188,24 +185,6 @@ namespace utils {
|
||||
|
||||
ASSERT_SUCCESS(mSwapChain->Present(1, 0));
|
||||
|
||||
// Transition last frame's render target back to being a render target
|
||||
if (mRenderTargetResourceState != D3D12_RESOURCE_STATE_PRESENT) {
|
||||
ComPtr<ID3D12GraphicsCommandList> commandList = {};
|
||||
backend::d3d12::OpenCommandList(mBackendDevice, &commandList);
|
||||
|
||||
D3D12_RESOURCE_BARRIER resourceBarrier;
|
||||
resourceBarrier.Transition.pResource =
|
||||
mRenderTargetResources[mPreviousRenderTargetIndex].Get();
|
||||
resourceBarrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
|
||||
resourceBarrier.Transition.StateAfter = mRenderTargetResourceState;
|
||||
resourceBarrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
|
||||
resourceBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||
resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
||||
commandList->ResourceBarrier(1, &resourceBarrier);
|
||||
ASSERT_SUCCESS(commandList->Close());
|
||||
backend::d3d12::ExecuteCommandLists(mBackendDevice, {commandList.Get()});
|
||||
}
|
||||
|
||||
backend::d3d12::NextSerial(mBackendDevice);
|
||||
|
||||
mPreviousRenderTargetIndex = mRenderTargetIndex;
|
||||
@ -240,8 +219,6 @@ namespace utils {
|
||||
uint32_t mRenderTargetIndex = 0;
|
||||
uint32_t mPreviousRenderTargetIndex = 0;
|
||||
uint64_t mLastSerialRenderTargetWasUsed[kFrameCount] = {};
|
||||
|
||||
D3D12_RESOURCE_STATES mRenderTargetResourceState;
|
||||
};
|
||||
|
||||
class D3D12Binding : public BackendBinding {
|
||||
|
Loading…
x
Reference in New Issue
Block a user