[D3D12] Cleanup object destruction in Shutdown functions
This commit is contained in:
parent
ff014d47d4
commit
791c275fab
|
@ -666,10 +666,7 @@ void D3D12CommandProcessor::ShutdownContext() {
|
|||
auto context = GetD3D12Context();
|
||||
context->AwaitAllFramesCompletion();
|
||||
|
||||
if (scratch_buffer_ != nullptr) {
|
||||
scratch_buffer_->Release();
|
||||
scratch_buffer_ = nullptr;
|
||||
}
|
||||
ui::d3d12::util::ReleaseAndNull(scratch_buffer_);
|
||||
scratch_buffer_size_ = 0;
|
||||
|
||||
for (auto& buffer_for_deletion : buffers_for_deletion_) {
|
||||
|
@ -688,14 +685,8 @@ void D3D12CommandProcessor::ShutdownContext() {
|
|||
swap_texture_srv_descriptor_heap_->Release();
|
||||
swap_texture_srv_descriptor_heap_ = nullptr;
|
||||
}
|
||||
if (swap_texture_rtv_descriptor_heap_ != nullptr) {
|
||||
swap_texture_rtv_descriptor_heap_->Release();
|
||||
swap_texture_rtv_descriptor_heap_ = nullptr;
|
||||
}
|
||||
if (swap_texture_ != nullptr) {
|
||||
swap_texture_->Release();
|
||||
swap_texture_ = nullptr;
|
||||
}
|
||||
ui::d3d12::util::ReleaseAndNull(swap_texture_rtv_descriptor_heap_);
|
||||
ui::d3d12::util::ReleaseAndNull(swap_texture_);
|
||||
|
||||
sampler_heap_pool_.reset();
|
||||
view_heap_pool_.reset();
|
||||
|
@ -801,10 +792,7 @@ void D3D12CommandProcessor::PerformSwap(uint32_t frontbuffer_ptr,
|
|||
cache_clear_requested_ = false;
|
||||
GetD3D12Context()->AwaitAllFramesCompletion();
|
||||
|
||||
if (scratch_buffer_ != nullptr) {
|
||||
scratch_buffer_->Release();
|
||||
scratch_buffer_ = nullptr;
|
||||
}
|
||||
ui::d3d12::util::ReleaseAndNull(scratch_buffer_);
|
||||
scratch_buffer_size_ = 0;
|
||||
|
||||
sampler_heap_pool_->ClearCache();
|
||||
|
|
|
@ -116,14 +116,8 @@ X_STATUS D3D12GraphicsSystem::Setup(cpu::Processor* processor,
|
|||
}
|
||||
|
||||
void D3D12GraphicsSystem::Shutdown() {
|
||||
if (stretch_pipeline_ != nullptr) {
|
||||
stretch_pipeline_->Release();
|
||||
stretch_pipeline_ = nullptr;
|
||||
}
|
||||
if (stretch_root_signature_ != nullptr) {
|
||||
stretch_root_signature_->Release();
|
||||
stretch_root_signature_ = nullptr;
|
||||
}
|
||||
ui::d3d12::util::ReleaseAndNull(stretch_pipeline_);
|
||||
ui::d3d12::util::ReleaseAndNull(stretch_root_signature_);
|
||||
|
||||
GraphicsSystem::Shutdown();
|
||||
}
|
||||
|
|
|
@ -283,46 +283,17 @@ void RenderTargetCache::Shutdown() {
|
|||
resolve_pipeline.pipeline->Release();
|
||||
}
|
||||
resolve_pipelines_.clear();
|
||||
if (resolve_root_signature_ != nullptr) {
|
||||
resolve_root_signature_->Release();
|
||||
resolve_root_signature_ = nullptr;
|
||||
}
|
||||
|
||||
if (edram_tile_sample_32bpp_pipeline_ != nullptr) {
|
||||
edram_tile_sample_32bpp_pipeline_->Release();
|
||||
edram_tile_sample_32bpp_pipeline_ = nullptr;
|
||||
}
|
||||
if (edram_clear_depth_float_pipeline_ != nullptr) {
|
||||
edram_clear_depth_float_pipeline_->Release();
|
||||
edram_clear_depth_float_pipeline_ = nullptr;
|
||||
}
|
||||
if (edram_clear_32bpp_pipeline_ != nullptr) {
|
||||
edram_clear_32bpp_pipeline_->Release();
|
||||
edram_clear_32bpp_pipeline_ = nullptr;
|
||||
}
|
||||
ui::d3d12::util::ReleaseAndNull(resolve_root_signature_);
|
||||
ui::d3d12::util::ReleaseAndNull(edram_tile_sample_32bpp_pipeline_);
|
||||
ui::d3d12::util::ReleaseAndNull(edram_clear_depth_float_pipeline_);
|
||||
ui::d3d12::util::ReleaseAndNull(edram_clear_32bpp_pipeline_);
|
||||
for (uint32_t i = 0; i < uint32_t(EDRAMLoadStoreMode::kCount); ++i) {
|
||||
if (edram_load_pipelines_[i] != nullptr) {
|
||||
edram_load_pipelines_[i]->Release();
|
||||
edram_load_pipelines_[i] = nullptr;
|
||||
}
|
||||
if (edram_store_pipelines_[i] != nullptr) {
|
||||
edram_store_pipelines_[i]->Release();
|
||||
edram_store_pipelines_[i] = nullptr;
|
||||
}
|
||||
}
|
||||
if (edram_clear_root_signature_ != nullptr) {
|
||||
edram_clear_root_signature_->Release();
|
||||
edram_clear_root_signature_ = nullptr;
|
||||
}
|
||||
if (edram_load_store_root_signature_ != nullptr) {
|
||||
edram_load_store_root_signature_->Release();
|
||||
edram_load_store_root_signature_ = nullptr;
|
||||
}
|
||||
|
||||
if (edram_buffer_ != nullptr) {
|
||||
edram_buffer_->Release();
|
||||
edram_buffer_ = nullptr;
|
||||
ui::d3d12::util::ReleaseAndNull(edram_store_pipelines_[i]);
|
||||
ui::d3d12::util::ReleaseAndNull(edram_load_pipelines_[i]);
|
||||
}
|
||||
ui::d3d12::util::ReleaseAndNull(edram_clear_root_signature_);
|
||||
ui::d3d12::util::ReleaseAndNull(edram_load_store_root_signature_);
|
||||
ui::d3d12::util::ReleaseAndNull(edram_buffer_);
|
||||
}
|
||||
|
||||
void RenderTargetCache::ClearCache() {
|
||||
|
|
|
@ -291,25 +291,13 @@ void TextureCache::Shutdown() {
|
|||
ClearCache();
|
||||
|
||||
for (uint32_t i = 0; i < uint32_t(TileMode::kCount); ++i) {
|
||||
if (tile_pipelines_[i] != nullptr) {
|
||||
tile_pipelines_[i]->Release();
|
||||
tile_pipelines_[i] = nullptr;
|
||||
}
|
||||
}
|
||||
if (tile_root_signature_ != nullptr) {
|
||||
tile_root_signature_->Release();
|
||||
tile_root_signature_ = nullptr;
|
||||
ui::d3d12::util::ReleaseAndNull(tile_pipelines_[i]);
|
||||
}
|
||||
ui::d3d12::util::ReleaseAndNull(tile_root_signature_);
|
||||
for (uint32_t i = 0; i < uint32_t(LoadMode::kCount); ++i) {
|
||||
if (load_pipelines_[i] != nullptr) {
|
||||
load_pipelines_[i]->Release();
|
||||
load_pipelines_[i] = nullptr;
|
||||
}
|
||||
}
|
||||
if (load_root_signature_ != nullptr) {
|
||||
load_root_signature_->Release();
|
||||
load_root_signature_ = nullptr;
|
||||
ui::d3d12::util::ReleaseAndNull(load_pipelines_[i]);
|
||||
}
|
||||
ui::d3d12::util::ReleaseAndNull(load_root_signature_);
|
||||
}
|
||||
|
||||
void TextureCache::ClearCache() {
|
||||
|
|
|
@ -17,7 +17,8 @@ namespace ui {
|
|||
namespace d3d12 {
|
||||
namespace util {
|
||||
|
||||
inline bool ReleaseAndNull(IUnknown*& object) {
|
||||
template <typename T>
|
||||
inline bool ReleaseAndNull(T& object) {
|
||||
if (object != nullptr) {
|
||||
object->Release();
|
||||
object = nullptr;
|
||||
|
|
Loading…
Reference in New Issue