diff --git a/OptiScaler/SysUtils.h b/OptiScaler/SysUtils.h index 5888bfd1..7c64f077 100644 --- a/OptiScaler/SysUtils.h +++ b/OptiScaler/SysUtils.h @@ -106,6 +106,26 @@ inline DWORD processId; #define LOG_TRACK(msg, ...) #endif +#define SAFE_RELEASE(p) \ + do \ + { \ + if (p && p != nullptr) \ + { \ + (p)->Release(); \ + (p) = nullptr; \ + } \ + } while ((void) 0, 0); + +#define SAFE_CLOSE_HANDLE(p) \ + do \ + { \ + if (p) \ + { \ + CloseHandle(p); \ + (p) = nullptr; \ + } \ + } while ((void) 0, 0) + struct feature_version { unsigned int major; diff --git a/OptiScaler/framegen/IFGFeature_Dx12.cpp b/OptiScaler/framegen/IFGFeature_Dx12.cpp index c6124689..f7dae2f6 100644 --- a/OptiScaler/framegen/IFGFeature_Dx12.cpp +++ b/OptiScaler/framegen/IFGFeature_Dx12.cpp @@ -363,17 +363,8 @@ void IFGFeature_Dx12::DestroyCopyCmdList() { for (size_t i = 0; i < BUFFER_COUNT; i++) { - if (_copyCommandAllocator[i] != nullptr) - { - _copyCommandAllocator[i]->Release(); - _copyCommandAllocator[i] = nullptr; - } - - if (_copyCommandList[i] != nullptr) - { - _copyCommandList[i]->Release(); - _copyCommandList[i] = nullptr; - } + SAFE_RELEASE(_copyCommandAllocator[i]); + SAFE_RELEASE(_copyCommandList[i]); } } diff --git a/OptiScaler/framegen/dlssg/DLSSG_Dx12.cpp b/OptiScaler/framegen/dlssg/DLSSG_Dx12.cpp index 2b014ead..44746d83 100644 --- a/OptiScaler/framegen/dlssg/DLSSG_Dx12.cpp +++ b/OptiScaler/framegen/dlssg/DLSSG_Dx12.cpp @@ -621,35 +621,11 @@ void DLSSG_Dx12::ReleaseObjects() { for (size_t i = 0; i < BUFFER_COUNT; i++) { - if (_uiCommandAllocator[i] != nullptr) - { - _uiCommandAllocator[i]->Release(); - _uiCommandAllocator[i] = nullptr; - } - - if (_uiCommandList[i] != nullptr) - { - _uiCommandList[i]->Release(); - _uiCommandList[i] = nullptr; - } - - if (_scCommandAllocator[i] != nullptr) - { - _scCommandAllocator[i]->Release(); - _scCommandAllocator[i] = nullptr; - } - - if (_scCommandList[i] != nullptr) - { - _scCommandList[i]->Release(); - _scCommandList[i] = nullptr; - } - - if (dlssgFence[i] != nullptr) - { - dlssgFence[i]->Release(); - dlssgFence[i] = nullptr; - } + SAFE_RELEASE(_uiCommandAllocator[i]); + SAFE_RELEASE(_uiCommandList[i]); + SAFE_RELEASE(_scCommandAllocator[i]); + SAFE_RELEASE(_scCommandList[i]); + SAFE_RELEASE(dlssgFence[i]); } _renderUI.reset(); diff --git a/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp b/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp index 33d6b06b..4745ecff 100644 --- a/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp +++ b/OptiScaler/framegen/ffx/FSRFG_Dx12.cpp @@ -1285,41 +1285,12 @@ void FSRFG_Dx12::ReleaseObjects() { for (size_t i = 0; i < BUFFER_COUNT; i++) { - if (_fgCommandAllocator[i] != nullptr) - { - _fgCommandAllocator[i]->Release(); - _fgCommandAllocator[i] = nullptr; - } - - if (_fgCommandList[i] != nullptr) - { - _fgCommandList[i]->Release(); - _fgCommandList[i] = nullptr; - } - - if (_uiCommandAllocator[i] != nullptr) - { - _uiCommandAllocator[i]->Release(); - _uiCommandAllocator[i] = nullptr; - } - - if (_uiCommandList[i] != nullptr) - { - _uiCommandList[i]->Release(); - _uiCommandList[i] = nullptr; - } - - if (_scCommandAllocator[i] != nullptr) - { - _scCommandAllocator[i]->Release(); - _scCommandAllocator[i] = nullptr; - } - - if (_scCommandList[i] != nullptr) - { - _scCommandList[i]->Release(); - _scCommandList[i] = nullptr; - } + SAFE_RELEASE(_fgCommandAllocator[i]); + SAFE_RELEASE(_fgCommandList[i]); + SAFE_RELEASE(_uiCommandAllocator[i]); + SAFE_RELEASE(_uiCommandList[i]); + SAFE_RELEASE(_scCommandAllocator[i]); + SAFE_RELEASE(_scCommandList[i]); } _renderUI.reset(); diff --git a/OptiScaler/framegen/nvngx/Nvngx_FG.cpp b/OptiScaler/framegen/nvngx/Nvngx_FG.cpp index 73980e51..da5b2d2e 100644 --- a/OptiScaler/framegen/nvngx/Nvngx_FG.cpp +++ b/OptiScaler/framegen/nvngx/Nvngx_FG.cpp @@ -386,11 +386,7 @@ NVSDK_NGX_Result Nvngx_FG::D3D12_EvaluateFeature(ID3D12GraphicsCommandList* InCm D3D12_HEAP_FLAGS heapFlags; static ID3D12Resource* copiedDlssgDepth = nullptr; - if (copiedDlssgDepth != nullptr) - { - copiedDlssgDepth->Release(); - copiedDlssgDepth = nullptr; - } + SAFE_RELEASE(copiedDlssgDepth); if (dlssgDepth->GetHeapProperties(&heapProperties, &heapFlags) == S_OK) { diff --git a/OptiScaler/framegen/xefg/XeFG_Dx12.cpp b/OptiScaler/framegen/xefg/XeFG_Dx12.cpp index 36c401d4..518617c2 100644 --- a/OptiScaler/framegen/xefg/XeFG_Dx12.cpp +++ b/OptiScaler/framegen/xefg/XeFG_Dx12.cpp @@ -1083,29 +1083,10 @@ void XeFG_Dx12::ReleaseObjects() { for (size_t i = 0; i < BUFFER_COUNT; i++) { - if (_uiCommandAllocator[i] != nullptr) - { - _uiCommandAllocator[i]->Release(); - _uiCommandAllocator[i] = nullptr; - } - - if (_uiCommandList[i] != nullptr) - { - _uiCommandList[i]->Release(); - _uiCommandList[i] = nullptr; - } - - if (_scCommandAllocator[i] != nullptr) - { - _scCommandAllocator[i]->Release(); - _scCommandAllocator[i] = nullptr; - } - - if (_scCommandList[i] != nullptr) - { - _scCommandList[i]->Release(); - _scCommandList[i] = nullptr; - } + SAFE_RELEASE(_uiCommandAllocator[i]); + SAFE_RELEASE(_uiCommandList[i]); + SAFE_RELEASE(_scCommandAllocator[i]); + SAFE_RELEASE(_scCommandList[i]); } _renderUI.reset(); diff --git a/OptiScaler/hooks/FG_Hooks.cpp b/OptiScaler/hooks/FG_Hooks.cpp index 5d53e706..7e5a60f2 100644 --- a/OptiScaler/hooks/FG_Hooks.cpp +++ b/OptiScaler/hooks/FG_Hooks.cpp @@ -178,17 +178,8 @@ HRESULT FGHooks::CreateSwapChain(IDXGIFactory* pFactory, IUnknown* pDevice, DXGI { if (State::Instance().currentD3D12Device != nullptr) { - if (resizeFence != nullptr) - { - resizeFence->Release(); - resizeFence = nullptr; - } - - if (resizeFenceEvent != nullptr) - { - CloseHandle(resizeFenceEvent); - resizeFenceEvent = nullptr; - } + SAFE_RELEASE(resizeFence); + SAFE_CLOSE_HANDLE(resizeFenceEvent); State::Instance().currentD3D12Device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&resizeFence)); resizeFenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); @@ -306,17 +297,8 @@ HRESULT FGHooks::CreateSwapChainForHwnd(IDXGIFactory* pFactory, IUnknown* pDevic { if (State::Instance().currentD3D12Device != nullptr) { - if (resizeFence != nullptr) - { - resizeFence->Release(); - resizeFence = nullptr; - } - - if (resizeFenceEvent != nullptr) - { - CloseHandle(resizeFenceEvent); - resizeFenceEvent = nullptr; - } + SAFE_RELEASE(resizeFence); + SAFE_CLOSE_HANDLE(resizeFenceEvent); State::Instance().currentD3D12Device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&resizeFence)); resizeFenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); diff --git a/OptiScaler/menu/menu_dx11.cpp b/OptiScaler/menu/menu_dx11.cpp index fc0a8e14..0643d9be 100644 --- a/OptiScaler/menu/menu_dx11.cpp +++ b/OptiScaler/menu/menu_dx11.cpp @@ -138,15 +138,6 @@ Menu_Dx11::~Menu_Dx11() // hackzor std::this_thread::sleep_for(std::chrono::milliseconds(250)); - if (_renderTargetTexture) - { - _renderTargetTexture->Release(); - _renderTargetTexture = nullptr; - } - - if (_renderTargetView) - { - _renderTargetView->Release(); - _renderTargetView = nullptr; - } + SAFE_RELEASE(_renderTargetTexture); + SAFE_RELEASE(_renderTargetView); } diff --git a/OptiScaler/menu/menu_dx12.cpp b/OptiScaler/menu/menu_dx12.cpp index c7bd5304..8cac3c48 100644 --- a/OptiScaler/menu/menu_dx12.cpp +++ b/OptiScaler/menu/menu_dx12.cpp @@ -253,29 +253,10 @@ Menu_Dx12::~Menu_Dx12() ImGui_ImplDX12_Shutdown(true, !State::Instance().isShuttingDown); MenuCommon::Shutdown(); - if (_rtvDescHeap) - { - _rtvDescHeap->Release(); - _rtvDescHeap = nullptr; - } - - if (_srvDescHeap) - { - _srvDescHeap->Release(); - _srvDescHeap = nullptr; - } - - if (_renderTargetResource[0]) - { - _renderTargetResource[0]->Release(); - _renderTargetResource[0] = nullptr; - } - - if (_renderTargetResource[1]) - { - _renderTargetResource[1]->Release(); - _renderTargetResource[1] = nullptr; - } + SAFE_RELEASE(_rtvDescHeap); + SAFE_RELEASE(_srvDescHeap); + SAFE_RELEASE(_renderTargetResource[0]); + SAFE_RELEASE(_renderTargetResource[1]); } void Menu_Dx12::CreateRenderTarget(const D3D12_RESOURCE_DESC& InDesc) @@ -286,10 +267,8 @@ void Menu_Dx12::CreateRenderTarget(const D3D12_RESOURCE_DESC& InDesc) if (InDesc.Width != rtDesc.Width || InDesc.Height != rtDesc.Height || InDesc.Format != rtDesc.Format) { - _renderTargetResource[0]->Release(); - _renderTargetResource[0] = nullptr; - _renderTargetResource[1]->Release(); - _renderTargetResource[1] = nullptr; + SAFE_RELEASE(_renderTargetResource[0]); + SAFE_RELEASE(_renderTargetResource[1]); } else return; diff --git a/OptiScaler/menu/menu_overlay_dx.cpp b/OptiScaler/menu/menu_overlay_dx.cpp index f22022f2..d6277cb7 100644 --- a/OptiScaler/menu/menu_overlay_dx.cpp +++ b/OptiScaler/menu/menu_overlay_dx.cpp @@ -139,43 +139,22 @@ static void CleanupRenderTargetDx12(bool clearQueue) ImGui_ImplDX12_Shutdown(false); } - if (g_pd3dRtvDescHeap != nullptr) - { - g_pd3dRtvDescHeap->Release(); - g_pd3dRtvDescHeap = nullptr; - } - - if (g_pd3dSrvDescHeap != nullptr) - { - g_pd3dSrvDescHeap->Release(); - g_pd3dSrvDescHeap = nullptr; - } + SAFE_RELEASE(g_pd3dRtvDescHeap); + SAFE_RELEASE(g_pd3dSrvDescHeap); for (UINT i = 0; i < NUM_BACK_BUFFERS; ++i) { - if (g_commandAllocators[i] != nullptr) - { - g_commandAllocators[i]->Release(); - g_commandAllocators[i] = nullptr; - } + SAFE_RELEASE(g_commandAllocators[i]); } - if (g_pd3dCommandList != nullptr) - { - g_pd3dCommandList->Release(); - g_pd3dCommandList = nullptr; - } + SAFE_RELEASE(g_pd3dCommandList); if (g_pd3dCommandQueue != nullptr) g_pd3dCommandQueue = nullptr; g_pd3dSrvDescHeapAlloc.Destroy(); - // if (g_pd3dDeviceParam != nullptr) - //{ - // g_pd3dDeviceParam->Release(); - // g_pd3dDeviceParam = nullptr; - // } + // SAFE_RELEASE(g_pd3dDeviceParam); _dx12Device = false; _isInited = false; @@ -209,11 +188,7 @@ static void CleanupRenderTargetDx11(bool shutDown) if (!shutDown) LOG_FUNC(); - if (g_pd3dRenderTarget != nullptr) - { - g_pd3dRenderTarget->Release(); - g_pd3dRenderTarget = nullptr; - } + SAFE_RELEASE(g_pd3dRenderTarget); if (g_pd3dDevice != nullptr) g_pd3dDevice = nullptr; diff --git a/OptiScaler/misc/IdentifyGpu.cpp b/OptiScaler/misc/IdentifyGpu.cpp index 8498d257..b9e992fc 100644 --- a/OptiScaler/misc/IdentifyGpu.cpp +++ b/OptiScaler/misc/IdentifyGpu.cpp @@ -117,11 +117,7 @@ std::vector IdentifyGpu::checkGpuInfo() queryNvapi(gpuInfo); } - if (gpuInfo.d3d12device) - { - gpuInfo.d3d12device->Release(); - gpuInfo.d3d12device = nullptr; - } + SAFE_RELEASE(gpuInfo.d3d12device); } return localCachedInfo; diff --git a/OptiScaler/shaders/Shader_Dx12.cpp b/OptiScaler/shaders/Shader_Dx12.cpp index 6631a34b..7ea6553b 100644 --- a/OptiScaler/shaders/Shader_Dx12.cpp +++ b/OptiScaler/shaders/Shader_Dx12.cpp @@ -11,23 +11,9 @@ Shader_Dx12::~Shader_Dx12() if (!_init || State::Instance().isShuttingDown) return; - if (_pipelineState != nullptr) - { - _pipelineState->Release(); - _pipelineState = nullptr; - } - - if (_rootSignature != nullptr) - { - _rootSignature->Release(); - _rootSignature = nullptr; - } - - if (_constantBuffer != nullptr) - { - _constantBuffer->Release(); - _constantBuffer = nullptr; - } + SAFE_RELEASE(_pipelineState); + SAFE_RELEASE(_rootSignature); + SAFE_RELEASE(_constantBuffer); } DXGI_FORMAT Shader_Dx12::TranslateTypelessFormats(DXGI_FORMAT format) diff --git a/OptiScaler/shaders/Shader_Dx12Utils.h b/OptiScaler/shaders/Shader_Dx12Utils.h index 4540a67c..e5d7c550 100644 --- a/OptiScaler/shaders/Shader_Dx12Utils.h +++ b/OptiScaler/shaders/Shader_Dx12Utils.h @@ -122,11 +122,8 @@ class FrameDescriptorHeap // Also need to create shaders when they are used to prevent creating heaps when not used // return; - if (heapCSU) - heapCSU->Release(); - - if (heapRtv) - heapRtv->Release(); + SAFE_RELEASE(heapCSU); + SAFE_RELEASE(heapRtv); } ~FrameDescriptorHeap() { ReleaseHeaps(); } diff --git a/OptiScaler/shaders/bias/Bias_Dx11.cpp b/OptiScaler/shaders/bias/Bias_Dx11.cpp index bbccf6f2..eabf1587 100644 --- a/OptiScaler/shaders/bias/Bias_Dx11.cpp +++ b/OptiScaler/shaders/bias/Bias_Dx11.cpp @@ -83,8 +83,7 @@ bool Bias_Dx11::InitializeViews(ID3D11Texture2D* InResource, ID3D11Texture2D* Ou if (InResource != _currentInResource || _srvInput == nullptr) { - if (_srvInput != nullptr) - _srvInput->Release(); + SAFE_RELEASE(_srvInput); InResource->GetDesc(&desc); @@ -106,8 +105,7 @@ bool Bias_Dx11::InitializeViews(ID3D11Texture2D* InResource, ID3D11Texture2D* Ou if (OutResource != _currentOutResource || _uavOutput == nullptr) { - if (_uavOutput != nullptr) - _uavOutput->Release(); + SAFE_RELEASE(_uavOutput); OutResource->GetDesc(&desc); @@ -228,11 +226,7 @@ Bias_Dx11::Bias_Dx11(std::string InName, ID3D11Device* InDevice) : _name(InName) &_computeShader); } - if (shaderBlob != nullptr) - { - shaderBlob->Release(); - shaderBlob = nullptr; - } + SAFE_RELEASE(shaderBlob); if (FAILED(hr)) { @@ -262,18 +256,9 @@ Bias_Dx11::~Bias_Dx11() if (!_init || State::Instance().isShuttingDown) return; - if (_computeShader != nullptr) - _computeShader->Release(); - - if (_constantBuffer != nullptr) - _constantBuffer->Release(); - - if (_srvInput != nullptr) - _srvInput->Release(); - - if (_uavOutput != nullptr) - _uavOutput->Release(); - - if (_buffer != nullptr) - _buffer->Release(); + SAFE_RELEASE(_computeShader); + SAFE_RELEASE(_constantBuffer); + SAFE_RELEASE(_srvInput); + SAFE_RELEASE(_uavOutput); + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/bias/Bias_Dx12.cpp b/OptiScaler/shaders/bias/Bias_Dx12.cpp index 161c1b4b..a2c3d56c 100644 --- a/OptiScaler/shaders/bias/Bias_Dx12.cpp +++ b/OptiScaler/shaders/bias/Bias_Dx12.cpp @@ -119,9 +119,5 @@ Bias_Dx12::~Bias_Dx12() _frameHeaps[i].ReleaseHeaps(); } - if (_buffer != nullptr) - { - _buffer->Release(); - _buffer = nullptr; - } + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/depth_invert/DI_Dx12.cpp b/OptiScaler/shaders/depth_invert/DI_Dx12.cpp index 3f18fe07..833e8780 100644 --- a/OptiScaler/shaders/depth_invert/DI_Dx12.cpp +++ b/OptiScaler/shaders/depth_invert/DI_Dx12.cpp @@ -101,9 +101,5 @@ DI_Dx12::~DI_Dx12() _frameHeaps[i].ReleaseHeaps(); } - if (_buffer != nullptr) - { - _buffer->Release(); - _buffer = nullptr; - } + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/depth_scale/DS_Dx12.cpp b/OptiScaler/shaders/depth_scale/DS_Dx12.cpp index 93872ec3..a62beffe 100644 --- a/OptiScaler/shaders/depth_scale/DS_Dx12.cpp +++ b/OptiScaler/shaders/depth_scale/DS_Dx12.cpp @@ -135,9 +135,5 @@ DS_Dx12::~DS_Dx12() _frameHeaps[i].ReleaseHeaps(); } - if (_buffer != nullptr) - { - _buffer->Release(); - _buffer = nullptr; - } + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/depth_transfer/DT_Dx11.cpp b/OptiScaler/shaders/depth_transfer/DT_Dx11.cpp index b70e4c4f..8bcb0333 100644 --- a/OptiScaler/shaders/depth_transfer/DT_Dx11.cpp +++ b/OptiScaler/shaders/depth_transfer/DT_Dx11.cpp @@ -43,8 +43,7 @@ bool DepthTransfer_Dx11::InitializeViews(ID3D11Texture2D* InResource, ID3D11Text if (InResource != _currentInResource || _srvInput == nullptr) { - if (_srvInput != nullptr) - _srvInput->Release(); + SAFE_RELEASE(_srvInput); InResource->GetDesc(&desc); @@ -73,8 +72,7 @@ bool DepthTransfer_Dx11::InitializeViews(ID3D11Texture2D* InResource, ID3D11Text if (OutResource != _currentOutResource || _uavOutput == nullptr) { - if (_uavOutput != nullptr) - _uavOutput->Release(); + SAFE_RELEASE(_uavOutput); OutResource->GetDesc(&desc); @@ -174,11 +172,7 @@ DepthTransfer_Dx11::DepthTransfer_Dx11(std::string InName, ID3D11Device* InDevic hr = _device->CreateComputeShader(reinterpret_cast(dt_dx11_cso), sizeof(dt_dx11_cso), nullptr, &_computeShader); - if (shaderBlob != nullptr) - { - shaderBlob->Release(); - shaderBlob = nullptr; - } + SAFE_RELEASE(shaderBlob); if (FAILED(hr)) { @@ -195,18 +189,9 @@ DepthTransfer_Dx11::~DepthTransfer_Dx11() if (!_init || State::Instance().isShuttingDown) return; - if (_computeShader != nullptr) - _computeShader->Release(); - - if (_constantBuffer != nullptr) - _constantBuffer->Release(); - - if (_srvInput != nullptr) - _srvInput->Release(); - - if (_uavOutput != nullptr) - _uavOutput->Release(); - - if (_buffer != nullptr) - _buffer->Release(); + SAFE_RELEASE(_computeShader); + SAFE_RELEASE(_constantBuffer); + SAFE_RELEASE(_srvInput); + SAFE_RELEASE(_uavOutput); + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/format_transfer/FT_Dx12.cpp b/OptiScaler/shaders/format_transfer/FT_Dx12.cpp index fa1c3002..3f60caa9 100644 --- a/OptiScaler/shaders/format_transfer/FT_Dx12.cpp +++ b/OptiScaler/shaders/format_transfer/FT_Dx12.cpp @@ -139,9 +139,5 @@ FT_Dx12::~FT_Dx12() _frameHeaps[i].ReleaseHeaps(); } - if (_buffer != nullptr) - { - _buffer->Release(); - _buffer = nullptr; - } + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/hud_copy/HudCopy_Dx12.cpp b/OptiScaler/shaders/hud_copy/HudCopy_Dx12.cpp index e5b406c6..f21194c2 100644 --- a/OptiScaler/shaders/hud_copy/HudCopy_Dx12.cpp +++ b/OptiScaler/shaders/hud_copy/HudCopy_Dx12.cpp @@ -147,9 +147,5 @@ HudCopy_Dx12::~HudCopy_Dx12() _frameHeaps[i].ReleaseHeaps(); } - if (_buffer != nullptr) - { - _buffer->Release(); - _buffer = nullptr; - } + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/hudless_compare/HC_Dx12.cpp b/OptiScaler/shaders/hudless_compare/HC_Dx12.cpp index a06074b3..e9182903 100644 --- a/OptiScaler/shaders/hudless_compare/HC_Dx12.cpp +++ b/OptiScaler/shaders/hudless_compare/HC_Dx12.cpp @@ -256,20 +256,11 @@ HC_Dx12::~HC_Dx12() if (!_init || State::Instance().isShuttingDown) return; - if (_rootSignature != nullptr) - { - _rootSignature->Release(); - _rootSignature = nullptr; - } + SAFE_RELEASE(_rootSignature); + SAFE_RELEASE(_constantBuffer); for (int i = 0; i < HC_NUM_OF_HEAPS; i++) { _frameHeaps[i].ReleaseHeaps(); } - - if (_constantBuffer != nullptr) - { - _constantBuffer->Release(); - _constantBuffer = nullptr; - } } diff --git a/OptiScaler/shaders/hudless_compare_compute/HCC_Dx12.cpp b/OptiScaler/shaders/hudless_compare_compute/HCC_Dx12.cpp index d4966430..5398df42 100644 --- a/OptiScaler/shaders/hudless_compare_compute/HCC_Dx12.cpp +++ b/OptiScaler/shaders/hudless_compare_compute/HCC_Dx12.cpp @@ -147,9 +147,5 @@ HCC_Dx12::~HCC_Dx12() _frameHeaps[i].ReleaseHeaps(); } - if (_buffer != nullptr) - { - _buffer->Release(); - _buffer = nullptr; - } + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/output_scaling/OS_Dx11.cpp b/OptiScaler/shaders/output_scaling/OS_Dx11.cpp index 2ffc2e16..1a7910a3 100644 --- a/OptiScaler/shaders/output_scaling/OS_Dx11.cpp +++ b/OptiScaler/shaders/output_scaling/OS_Dx11.cpp @@ -424,11 +424,7 @@ OS_Dx11::OS_Dx11(std::string InName, ID3D11Device* InDevice, bool InUpsample) } } - if (shaderBlob != nullptr) - { - shaderBlob->Release(); - shaderBlob = nullptr; - } + SAFE_RELEASE(shaderBlob); if (FAILED(hr)) { @@ -464,18 +460,9 @@ OS_Dx11::~OS_Dx11() if (!_init || State::Instance().isShuttingDown) return; - if (_computeShader != nullptr) - _computeShader->Release(); - - if (_constantBuffer != nullptr) - _constantBuffer->Release(); - - if (_srvInput != nullptr) - _srvInput->Release(); - - if (_uavOutput != nullptr) - _uavOutput->Release(); - - if (_buffer != nullptr) - _buffer->Release(); + SAFE_RELEASE(_computeShader); + SAFE_RELEASE(_constantBuffer); + SAFE_RELEASE(_srvInput); + SAFE_RELEASE(_uavOutput); + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/output_scaling/OS_Dx12.cpp b/OptiScaler/shaders/output_scaling/OS_Dx12.cpp index c5ff6a47..2ee8a37e 100644 --- a/OptiScaler/shaders/output_scaling/OS_Dx12.cpp +++ b/OptiScaler/shaders/output_scaling/OS_Dx12.cpp @@ -301,11 +301,7 @@ OS_Dx12::OS_Dx12(std::string InName, ID3D12Device* InDevice, bool InUpsample) return; } - if (_recEncodeShader != nullptr) - { - _recEncodeShader->Release(); - _recEncodeShader = nullptr; - } + SAFE_RELEASE(_recEncodeShader); } _init = InitHeaps(InDevice, _frameHeaps, OS_NUM_OF_HEAPS); @@ -321,9 +317,5 @@ OS_Dx12::~OS_Dx12() _frameHeaps[i].ReleaseHeaps(); } - if (_buffer != nullptr) - { - _buffer->Release(); - _buffer = nullptr; - } + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/rcas/RCAS_Dx11.cpp b/OptiScaler/shaders/rcas/RCAS_Dx11.cpp index ea96796c..37a5b7ff 100644 --- a/OptiScaler/shaders/rcas/RCAS_Dx11.cpp +++ b/OptiScaler/shaders/rcas/RCAS_Dx11.cpp @@ -556,27 +556,12 @@ RCAS_Dx11::~RCAS_Dx11() if (!_init || State::Instance().isShuttingDown) return; - if (_computeShader != nullptr) - _computeShader->Release(); - - if (_computeShaderDA != nullptr) - _computeShaderDA->Release(); - - if (_constantBuffer != nullptr) - _constantBuffer->Release(); - - if (_srvInput != nullptr) - _srvInput->Release(); - - if (_srvMotionVectors != nullptr) - _srvMotionVectors->Release(); - - if (_srvDepth != nullptr) - _srvDepth->Release(); - - if (_uavOutput != nullptr) - _uavOutput->Release(); - - if (_buffer != nullptr) - _buffer->Release(); + SAFE_RELEASE(_computeShader); + SAFE_RELEASE(_computeShaderDA); + SAFE_RELEASE(_constantBuffer); + SAFE_RELEASE(_srvInput); + SAFE_RELEASE(_srvMotionVectors); + SAFE_RELEASE(_srvDepth); + SAFE_RELEASE(_uavOutput); + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/rcas/RCAS_Dx12.cpp b/OptiScaler/shaders/rcas/RCAS_Dx12.cpp index 9389d116..21705f0a 100644 --- a/OptiScaler/shaders/rcas/RCAS_Dx12.cpp +++ b/OptiScaler/shaders/rcas/RCAS_Dx12.cpp @@ -212,26 +212,13 @@ RCAS_Dx12::~RCAS_Dx12() if (!_init || State::Instance().isShuttingDown) return; - if (_pipelineStateDA != nullptr) - { - _pipelineStateDA->Release(); - _pipelineStateDA = nullptr; - } - - if (_pipelineStateLCDA != nullptr) - { - _pipelineStateLCDA->Release(); - _pipelineStateLCDA = nullptr; - } + SAFE_RELEASE(_pipelineStateDA); + SAFE_RELEASE(_pipelineStateLCDA); for (int i = 0; i < RCAS_NUM_OF_HEAPS; i++) { _frameHeaps[i].ReleaseHeaps(); } - if (_buffer != nullptr) - { - _buffer->Release(); - _buffer = nullptr; - } + SAFE_RELEASE(_buffer); } diff --git a/OptiScaler/shaders/render_ui/RUI_Dx12.cpp b/OptiScaler/shaders/render_ui/RUI_Dx12.cpp index d255cdb9..b6a09b97 100644 --- a/OptiScaler/shaders/render_ui/RUI_Dx12.cpp +++ b/OptiScaler/shaders/render_ui/RUI_Dx12.cpp @@ -264,20 +264,11 @@ RUI_Dx12::~RUI_Dx12() if (!_init || State::Instance().isShuttingDown) return; - if (_rootSignature != nullptr) - { - _rootSignature->Release(); - _rootSignature = nullptr; - } + SAFE_RELEASE(_rootSignature); + SAFE_RELEASE(_constantBuffer); for (int i = 0; i < HC_NUM_OF_HEAPS; i++) { _frameHeaps[i].ReleaseHeaps(); } - - if (_constantBuffer != nullptr) - { - _constantBuffer->Release(); - _constantBuffer = nullptr; - } } diff --git a/OptiScaler/upscalers/IFeature_Dx11.cpp b/OptiScaler/upscalers/IFeature_Dx11.cpp index 9fad45b4..d42f9cd8 100644 --- a/OptiScaler/upscalers/IFeature_Dx11.cpp +++ b/OptiScaler/upscalers/IFeature_Dx11.cpp @@ -7,27 +7,8 @@ IFeature_Dx11::~IFeature_Dx11() if (State::Instance().isShuttingDown) return; - if (Imgui != nullptr && Imgui.get() != nullptr) - { - Imgui.reset(); - Imgui = nullptr; - } - - if (OutputScaler != nullptr && OutputScaler.get() != nullptr) - { - OutputScaler.reset(); - OutputScaler = nullptr; - } - - if (RCAS != nullptr && RCAS.get() != nullptr) - { - RCAS.reset(); - RCAS = nullptr; - } - - if (Bias != nullptr && Bias.get() != nullptr) - { - Bias.reset(); - Bias = nullptr; - } + Imgui.reset(); + OutputScaler.reset(); + RCAS.reset(); + Bias.reset(); } diff --git a/OptiScaler/upscalers/IFeature_Dx11wDx12.cpp b/OptiScaler/upscalers/IFeature_Dx11wDx12.cpp index a0f3bdfb..a8c25257 100644 --- a/OptiScaler/upscalers/IFeature_Dx11wDx12.cpp +++ b/OptiScaler/upscalers/IFeature_Dx11wDx12.cpp @@ -14,16 +14,6 @@ dest.BindFlags = src.BindFlags; \ dest.MiscFlags = src.MiscFlags; -#define SAFE_RELEASE(p) \ - do \ - { \ - if (p && p != nullptr) \ - { \ - (p)->Release(); \ - (p) = nullptr; \ - } \ - } while ((void) 0, 0) - void IFeature_Dx11wDx12::ResourceBarrier(ID3D12GraphicsCommandList* commandList, ID3D12Resource* resource, D3D12_RESOURCE_STATES beforeState, D3D12_RESOURCE_STATES afterState) { @@ -276,11 +266,7 @@ void IFeature_Dx11wDx12::ReleaseSharedResources() SAFE_RELEASE(Dx12CommandQueue); SAFE_RELEASE(Dx12Fence); - if (Dx12FenceEvent) - { - CloseHandle(Dx12FenceEvent); - Dx12FenceEvent = nullptr; - } + SAFE_CLOSE_HANDLE(Dx12FenceEvent); // SAFE_RELEASE(Dx12Device); } @@ -290,11 +276,7 @@ void IFeature_Dx11wDx12::ReleaseSyncResources() SAFE_RELEASE(dx11FenceTextureCopy); SAFE_RELEASE(dx12FenceTextureCopy); - if (dx11SHForTextureCopy != NULL) - { - CloseHandle(dx11SHForTextureCopy); - dx11SHForTextureCopy = NULL; - } + SAFE_CLOSE_HANDLE(dx11SHForTextureCopy); } HRESULT IFeature_Dx11wDx12::CreateDx12Device(D3D_FEATURE_LEVEL InFeatureLevel) @@ -650,8 +632,7 @@ bool IFeature_Dx11wDx12::ProcessDx11Textures(const NVSDK_NGX_Parameter* InParame if (paramColor && dx11Color.Dx12Handle != dx11Color.Dx11Handle) { - if (dx11Color.Dx12Handle != NULL) - CloseHandle(dx11Color.Dx12Handle); + SAFE_CLOSE_HANDLE(dx11Color.Dx12Handle); result = _dx11on12Device->OpenSharedHandle(dx11Color.Dx11Handle, IID_PPV_ARGS(&dx11Color.Dx12Resource)); @@ -666,8 +647,7 @@ bool IFeature_Dx11wDx12::ProcessDx11Textures(const NVSDK_NGX_Parameter* InParame if (paramMv && dx11Mv.Dx12Handle != dx11Mv.Dx11Handle) { - if (dx11Mv.Dx12Handle != NULL) - CloseHandle(dx11Mv.Dx12Handle); + SAFE_CLOSE_HANDLE(dx11Mv.Dx12Handle); result = _dx11on12Device->OpenSharedHandle(dx11Mv.Dx11Handle, IID_PPV_ARGS(&dx11Mv.Dx12Resource)); @@ -682,8 +662,7 @@ bool IFeature_Dx11wDx12::ProcessDx11Textures(const NVSDK_NGX_Parameter* InParame if (paramOutput[frame] && dx11Out.Dx12Handle != dx11Out.Dx11Handle) { - if (dx11Out.Dx12Handle != NULL) - CloseHandle(dx11Out.Dx12Handle); + SAFE_CLOSE_HANDLE(dx11Out.Dx12Handle); result = _dx11on12Device->OpenSharedHandle(dx11Out.Dx11Handle, IID_PPV_ARGS(&dx11Out.Dx12Resource)); @@ -698,8 +677,7 @@ bool IFeature_Dx11wDx12::ProcessDx11Textures(const NVSDK_NGX_Parameter* InParame if (paramDepth && dx11Depth.Dx12Handle != dx11Depth.Dx11Handle) { - if (dx11Depth.Dx12Handle != NULL) - CloseHandle(dx11Depth.Dx12Handle); + SAFE_CLOSE_HANDLE(dx11Depth.Dx12Handle); result = _dx11on12Device->OpenSharedHandle(dx11Depth.Dx11Handle, IID_PPV_ARGS(&dx11Depth.Dx12Resource)); @@ -720,8 +698,7 @@ bool IFeature_Dx11wDx12::ProcessDx11Textures(const NVSDK_NGX_Parameter* InParame } else if (paramExposure && dx11Exp.Dx12Handle != dx11Exp.Dx11Handle) { - if (dx11Exp.Dx12Handle != NULL) - CloseHandle(dx11Exp.Dx12Handle); + SAFE_CLOSE_HANDLE(dx11Exp.Dx12Handle); result = _dx11on12Device->OpenSharedHandle(dx11Exp.Dx11Handle, IID_PPV_ARGS(&dx11Exp.Dx12Resource)); @@ -737,8 +714,7 @@ bool IFeature_Dx11wDx12::ProcessDx11Textures(const NVSDK_NGX_Parameter* InParame if (!Config::Instance()->DisableReactiveMask.value_or(false) && paramReactiveMask && dx11Reactive.Dx12Handle != dx11Reactive.Dx11Handle) { - if (dx11Reactive.Dx12Handle != NULL) - CloseHandle(dx11Reactive.Dx12Handle); + SAFE_CLOSE_HANDLE(dx11Reactive.Dx12Handle); result = _dx11on12Device->OpenSharedHandle(dx11Reactive.Dx11Handle, IID_PPV_ARGS(&dx11Reactive.Dx12Resource)); @@ -954,9 +930,5 @@ IFeature_Dx11wDx12::~IFeature_Dx11wDx12() ReleaseSharedResources(); - if (DT != nullptr && DT.get() != nullptr) - { - DT.reset(); - DT = nullptr; - } + DT.reset(); } diff --git a/OptiScaler/upscalers/IFeature_Dx12.cpp b/OptiScaler/upscalers/IFeature_Dx12.cpp index 3d8f9d5c..fb4b46e3 100644 --- a/OptiScaler/upscalers/IFeature_Dx12.cpp +++ b/OptiScaler/upscalers/IFeature_Dx12.cpp @@ -254,15 +254,8 @@ IFeature_Dx12::~IFeature_Dx12() if (State::Instance().isShuttingDown) return; - if (Imgui != nullptr && Imgui.get() != nullptr) - Imgui.reset(); - - if (OutputScaler != nullptr && OutputScaler.get() != nullptr) - OutputScaler.reset(); - - if (RCAS != nullptr && RCAS.get() != nullptr) - RCAS.reset(); - - if (Bias != nullptr && Bias.get() != nullptr) - Bias.reset(); + Imgui.reset(); + OutputScaler.reset(); + RCAS.reset(); + Bias.reset(); } diff --git a/OptiScaler/upscalers/IFeature_VkwDx12.cpp b/OptiScaler/upscalers/IFeature_VkwDx12.cpp index df0396a9..9a3e877e 100644 --- a/OptiScaler/upscalers/IFeature_VkwDx12.cpp +++ b/OptiScaler/upscalers/IFeature_VkwDx12.cpp @@ -24,16 +24,6 @@ dest.Height = height; \ dest.Format = format; -#define SAFE_RELEASE(p) \ - do \ - { \ - if (p && p != nullptr) \ - { \ - (p)->Release(); \ - (p) = nullptr; \ - } \ - } while ((void) 0, 0) - #define SAFE_DESTROY_VK(func, device, handle, allocator) \ do \ { \ @@ -656,17 +646,9 @@ bool IFeature_VkwDx12::CopyTextureFromVkToDx12(VkCommandBuffer InCmdBuffer, NVSD OutResource->VkSharedMemory = VK_NULL_HANDLE; } - if (OutResource->SharedHandle != NULL) - { - CloseHandle(OutResource->SharedHandle); - OutResource->SharedHandle = NULL; - } + SAFE_CLOSE_HANDLE(OutResource->SharedHandle); - if (OutResource->Dx12Resource != nullptr) - { - OutResource->Dx12Resource->Release(); - OutResource->Dx12Resource = nullptr; - } + SAFE_RELEASE(OutResource->Dx12Resource); ASSIGN_VK_DESC((*OutResource), (*OutResource), InParam->Resource.ImageViewInfo.Width, InParam->Resource.ImageViewInfo.Height, InParam->Resource.ImageViewInfo.Format); @@ -1781,36 +1763,12 @@ void IFeature_VkwDx12::ReleaseSharedResources() SAFE_RELEASE(vkExp.Dx12Resource); // Close handles - if (vkColor.SharedHandle != NULL) - { - CloseHandle(vkColor.SharedHandle); - vkColor.SharedHandle = NULL; - } - if (vkMv.SharedHandle != NULL) - { - CloseHandle(vkMv.SharedHandle); - vkMv.SharedHandle = NULL; - } - if (vkOut.SharedHandle != NULL) - { - CloseHandle(vkOut.SharedHandle); - vkOut.SharedHandle = NULL; - } - if (vkDepth.SharedHandle != NULL) - { - CloseHandle(vkDepth.SharedHandle); - vkDepth.SharedHandle = NULL; - } - if (vkReactive.SharedHandle != NULL) - { - CloseHandle(vkReactive.SharedHandle); - vkReactive.SharedHandle = NULL; - } - if (vkExp.SharedHandle != NULL) - { - CloseHandle(vkExp.SharedHandle); - vkExp.SharedHandle = NULL; - } + SAFE_CLOSE_HANDLE(vkColor.SharedHandle); + SAFE_CLOSE_HANDLE(vkMv.SharedHandle); + SAFE_CLOSE_HANDLE(vkOut.SharedHandle); + SAFE_CLOSE_HANDLE(vkDepth.SharedHandle); + SAFE_CLOSE_HANDLE(vkReactive.SharedHandle); + SAFE_CLOSE_HANDLE(vkExp.SharedHandle); // Cleanup Vulkan copy command buffer // Loop in VulkanQueueCommandBuffers instead of hardcoding 2 command buffers, in case we have more in the future @@ -1824,11 +1782,7 @@ void IFeature_VkwDx12::ReleaseSharedResources() b.VulkanBarrierCommandBuffer[i] = VK_NULL_HANDLE; } - if (b.VulkanBarrierCommandPool[i] != VK_NULL_HANDLE) - { - vkDestroyCommandPool(VulkanDevice, b.VulkanBarrierCommandPool[i], nullptr); - b.VulkanBarrierCommandPool[i] = VK_NULL_HANDLE; - } + SAFE_DESTROY_VK(vkDestroyCommandPool, VulkanDevice, b.VulkanBarrierCommandPool[i], nullptr); if (b.VulkanCopyCommandBuffer[i] != VK_NULL_HANDLE && b.VulkanCopyCommandPool[i] != VK_NULL_HANDLE) { @@ -1836,11 +1790,7 @@ void IFeature_VkwDx12::ReleaseSharedResources() b.VulkanCopyCommandBuffer[i] = VK_NULL_HANDLE; } - if (b.VulkanCopyCommandPool[i] != VK_NULL_HANDLE) - { - vkDestroyCommandPool(VulkanDevice, b.VulkanCopyCommandPool[i], nullptr); - b.VulkanCopyCommandPool[i] = VK_NULL_HANDLE; - } + SAFE_DESTROY_VK(vkDestroyCommandPool, VulkanDevice, b.VulkanCopyCommandPool[i], nullptr); } } @@ -1857,59 +1807,16 @@ void IFeature_VkwDx12::ReleaseSharedResources() SAFE_RELEASE(Dx12CommandQueue); SAFE_RELEASE(Dx12Fence); - if (Dx12FenceEvent) - { - CloseHandle(Dx12FenceEvent); - Dx12FenceEvent = nullptr; - } + SAFE_CLOSE_HANDLE(Dx12FenceEvent); - if (ColorCopy != nullptr && ColorCopy.get() != nullptr) - { - ColorCopy.reset(); - ColorCopy = nullptr; - } - - if (VelocityCopy != nullptr && VelocityCopy.get() != nullptr) - { - VelocityCopy.reset(); - VelocityCopy = nullptr; - } - - if (DT != nullptr && DT.get() != nullptr) - { - DT.reset(); - DT = nullptr; - } - - if (DepthCopy != nullptr && DepthCopy.get() != nullptr) - { - DepthCopy.reset(); - DepthCopy = nullptr; - } - - if (ReactiveCopy != nullptr && ReactiveCopy.get() != nullptr) - { - ReactiveCopy.reset(); - ReactiveCopy = nullptr; - } - - if (ExpCopy != nullptr && ExpCopy.get() != nullptr) - { - ExpCopy.reset(); - ExpCopy = nullptr; - } - - if (OutCopy != nullptr && OutCopy.get() != nullptr) - { - OutCopy.reset(); - OutCopy = nullptr; - } - - if (OutCopy2 != nullptr && OutCopy2.get() != nullptr) - { - OutCopy2.reset(); - OutCopy2 = nullptr; - } + ColorCopy.reset(); + VelocityCopy.reset(); + DT.reset(); + DepthCopy.reset(); + ReactiveCopy.reset(); + ExpCopy.reset(); + OutCopy.reset(); + OutCopy2.reset(); } void IFeature_VkwDx12::ReleaseSyncResources() @@ -1920,11 +1827,7 @@ void IFeature_VkwDx12::ReleaseSyncResources() SAFE_DESTROY_VK(vkDestroySemaphore, VulkanDevice, vkSemaphoreTextureCopy[i], nullptr); SAFE_RELEASE(dx12FenceTextureCopy[i]); - if (vkSHForTextureCopy[i] != NULL) - { - CloseHandle(vkSHForTextureCopy[i]); - vkSHForTextureCopy[i] = NULL; - } + SAFE_CLOSE_HANDLE(vkSHForTextureCopy[i]); SAFE_DESTROY_VK(vkDestroySemaphore, VulkanDevice, vkSemaphoreCopyBack[i], nullptr); } @@ -2149,29 +2052,10 @@ IFeature_VkwDx12::~IFeature_VkwDx12() ReleaseSharedResources(); - if (DT != nullptr && DT.get() != nullptr) - { - DT.reset(); - DT = nullptr; - } - - if (OutputScaler != nullptr && OutputScaler.get() != nullptr) - { - OutputScaler.reset(); - OutputScaler = nullptr; - } - - if (RCAS != nullptr && RCAS.get() != nullptr) - { - RCAS.reset(); - RCAS = nullptr; - } - - if (Bias != nullptr && Bias.get() != nullptr) - { - Bias.reset(); - Bias = nullptr; - } + DT.reset(); + OutputScaler.reset(); + RCAS.reset(); + Bias.reset(); } bool IFeature_VkwDx12::CreateSharedFenceSemaphore() diff --git a/OptiScaler/upscalers/fsr2/FSR2Feature_Dx11.cpp b/OptiScaler/upscalers/fsr2/FSR2Feature_Dx11.cpp index 11835441..23125a0e 100644 --- a/OptiScaler/upscalers/fsr2/FSR2Feature_Dx11.cpp +++ b/OptiScaler/upscalers/fsr2/FSR2Feature_Dx11.cpp @@ -12,16 +12,6 @@ using namespace OptiMath; dest.Format = src.Format; \ dest.BindFlags = src.BindFlags; -#define SAFE_RELEASE(p) \ - do \ - { \ - if (p && p != nullptr) \ - { \ - (p)->Release(); \ - (p) = nullptr; \ - } \ - } while ((void) 0, 0); - bool FSR2FeatureDx11::Init(ID3D11Device* InDevice, ID3D11DeviceContext* InContext, NVSDK_NGX_Parameter* InParameters) { LOG_FUNC(); diff --git a/OptiScaler/upscalers/fsr31/FSR31Feature_Dx11.cpp b/OptiScaler/upscalers/fsr31/FSR31Feature_Dx11.cpp index 8a54afdb..86be58ce 100644 --- a/OptiScaler/upscalers/fsr31/FSR31Feature_Dx11.cpp +++ b/OptiScaler/upscalers/fsr31/FSR31Feature_Dx11.cpp @@ -12,16 +12,6 @@ using namespace OptiMath; dest.Format = src.Format; \ dest.BindFlags = src.BindFlags; -#define SAFE_RELEASE(p) \ - do \ - { \ - if (p && p != nullptr) \ - { \ - (p)->Release(); \ - (p) = nullptr; \ - } \ - } while ((void) 0, 0); - FSR31FeatureDx11::FSR31FeatureDx11(unsigned int InHandleId, NVSDK_NGX_Parameter* InParameters) : FSR31Feature(InHandleId, InParameters), IFeature_Dx11(InHandleId, InParameters), IFeature(InHandleId, InParameters) diff --git a/OptiScaler/upscalers/xess/XeSSFeature.cpp b/OptiScaler/upscalers/xess/XeSSFeature.cpp index 024c1b39..bbfa3aa8 100644 --- a/OptiScaler/upscalers/xess/XeSSFeature.cpp +++ b/OptiScaler/upscalers/xess/XeSSFeature.cpp @@ -344,21 +344,7 @@ XeSSFeature::~XeSSFeature() _xessContext = nullptr; } - if (_localPipeline != nullptr) - { - _localPipeline->Release(); - _localPipeline = nullptr; - } - - if (_localBufferHeap != nullptr) - { - _localBufferHeap->Release(); - _localBufferHeap = nullptr; - } - - if (_localTextureHeap != nullptr) - { - _localTextureHeap->Release(); - _localTextureHeap = nullptr; - } + SAFE_RELEASE(_localPipeline); + SAFE_RELEASE(_localBufferHeap); + SAFE_RELEASE(_localTextureHeap); }