From 460a4da53de360f5a155910df8c0d007c36f230c Mon Sep 17 00:00:00 2001 From: Roderick Kennedy Date: Tue, 17 Dec 2024 01:20:49 +0000 Subject: [PATCH] Some D3d12 safety checks. --- DirectX12/RenderPlatform.cpp | 3 ++- DirectX12/Texture.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DirectX12/RenderPlatform.cpp b/DirectX12/RenderPlatform.cpp index c9f38a31..991ebcfc 100644 --- a/DirectX12/RenderPlatform.cpp +++ b/DirectX12/RenderPlatform.cpp @@ -2833,7 +2833,8 @@ void RenderPlatform::DeactivateRenderTargets(crossplatform::GraphicsDeviceContex void RenderPlatform::SetViewports(crossplatform::GraphicsDeviceContext &deviceContext, int num, const crossplatform::Viewport *vps) { ID3D12GraphicsCommandList *commandList = deviceContext.asD3D12Context(); - + if(!commandList) + return; D3D12_VIEWPORT viewports[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT] = {}; D3D12_RECT scissors[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT] = {}; diff --git a/DirectX12/Texture.cpp b/DirectX12/Texture.cpp index db2e08be..5d67d963 100644 --- a/DirectX12/Texture.cpp +++ b/DirectX12/Texture.cpp @@ -1037,6 +1037,8 @@ void Texture::RestoreExternalTextureState(crossplatform::DeviceContext& deviceCo { if ((crossplatform::ResourceState)mExternalLayout == crossplatform::ResourceState::UNKNOWN) return; + if(!IsValid()) + return; auto rPlat = (dx12::RenderPlatform*)(renderPlatform); SetLayout(deviceContext, mExternalLayout); }