Fix minor issues in D3D12

This commit is contained in:
2026-04-23 18:39:09 +02:00
parent 7437b69d52
commit 0cacc58b53
4 changed files with 7 additions and 1 deletions
@@ -269,6 +269,7 @@ void GPUContextDX12::Reset()
_currentAllocator = _device->GetCommandQueue()->RequestAllocator(); _currentAllocator = _device->GetCommandQueue()->RequestAllocator();
_commandList->Reset(_currentAllocator, nullptr); _commandList->Reset(_currentAllocator, nullptr);
} }
IsOpen = true;
// Setup initial state // Setup initial state
_currentState = nullptr; _currentState = nullptr;
@@ -327,6 +328,7 @@ uint64 GPUContextDX12::Execute(bool waitForCompletion)
_currentState = nullptr; _currentState = nullptr;
// Execute commands // Execute commands
IsOpen = false;
const uint64 fenceValue = queue->ExecuteCommandList(_commandList); const uint64 fenceValue = queue->ExecuteCommandList(_commandList);
// Cleanup used allocator // Cleanup used allocator
@@ -93,6 +93,9 @@ public:
return _commandList; return _commandList;
} }
// Flag for command list state.
bool IsOpen = false;
uint64 FrameFenceValues[2]; uint64 FrameFenceValues[2];
public: public:
@@ -171,7 +171,7 @@ bool GPUTextureDX12::OnInit()
if (isWrite) if (isWrite)
{ {
_device->Locker.Lock(); _device->Locker.Lock();
if (IsInMainThread() && _device->IsRendering()) if (IsInMainThread() && _device->IsRendering() && _device->GetMainContextDX12()->IsOpen)
_device->GetMainContextDX12()->GetCommandList()->DiscardResource(_resource, nullptr); _device->GetMainContextDX12()->GetCommandList()->DiscardResource(_resource, nullptr);
else else
_device->PendingResourceDiscards.Add(_resource); _device->PendingResourceDiscards.Add(_resource);
@@ -83,6 +83,7 @@ protected:
#if GRAPHICS_API_DIRECTX12 #if GRAPHICS_API_DIRECTX12
case D3D_FEATURE_LEVEL_12_0: case D3D_FEATURE_LEVEL_12_0:
case D3D_FEATURE_LEVEL_12_1: case D3D_FEATURE_LEVEL_12_1:
case D3D_FEATURE_LEVEL_12_2:
return ShaderProfile::DirectX_SM5; return ShaderProfile::DirectX_SM5;
#endif #endif
default: default: