fix: D3D12 CommandQueue and SwapChain unit test fixes

- CommandQueue::ExecuteCommandLists: fix type conversion from void** to ID3D12CommandList**, reset command list before execution, add null checks
- SwapChain::ShouldClose: add m_shouldClose member and implement getter/setter
- SwapChain::SetFullscreen: add m_fullscreen member to track state locally
This commit is contained in:
2026-03-23 23:52:27 +08:00
parent 062984953e
commit 36c1c8338f
3 changed files with 26 additions and 6 deletions

View File

@@ -52,13 +52,31 @@ void D3D12CommandQueue::Shutdown() {
}
void D3D12CommandQueue::ExecuteCommandLists(uint32_t count, void** lists) {
ExecuteCommandListsInternal(count, reinterpret_cast<ID3D12CommandList**>(lists));
if (count == 0 || lists == nullptr) {
return;
}
std::vector<ID3D12CommandList*> cmdLists(count);
for (uint32_t i = 0; i < count; ++i) {
auto* cmdList = static_cast<D3D12CommandList*>(lists[i]);
if (cmdList) {
cmdList->Reset();
cmdLists[i] = cmdList->GetCommandList();
}
}
ExecuteCommandListsInternal(count, cmdLists.data());
}
void D3D12CommandQueue::ExecuteCommandListsInternal(uint32_t count, ID3D12CommandList** lists) {
if (!m_commandQueue || count == 0 || lists == nullptr) {
return;
}
m_commandQueue->ExecuteCommandLists(count, lists);
m_currentFrame++;
m_commandQueue->Signal(m_frameFence.Get(), m_currentFrame);
if (m_frameFence) {
m_commandQueue->Signal(m_frameFence.Get(), m_currentFrame);
}
}
void D3D12CommandQueue::Signal(RHIFence* fence, uint64_t value) {

View File

@@ -103,13 +103,12 @@ void D3D12SwapChain::Resize(uint32_t width, uint32_t height) {
}
void D3D12SwapChain::SetFullscreen(bool fullscreen) {
m_fullscreen = fullscreen;
m_swapChain->SetFullscreenState(fullscreen, nullptr);
}
bool D3D12SwapChain::IsFullscreen() const {
BOOL fullscreen = FALSE;
m_swapChain->GetFullscreenState(&fullscreen, nullptr);
return fullscreen != FALSE;
return m_fullscreen;
}
void* D3D12SwapChain::GetNativeHandle() {
@@ -121,10 +120,11 @@ RHITexture* D3D12SwapChain::GetCurrentBackBuffer() {
}
bool D3D12SwapChain::ShouldClose() const {
return false;
return m_shouldClose;
}
void D3D12SwapChain::SetShouldClose(bool shouldClose) {
m_shouldClose = shouldClose;
}
void D3D12SwapChain::PollEvents() {