diff --git a/src/xenia/gpu/d3d12/d3d12_command_processor.cc b/src/xenia/gpu/d3d12/d3d12_command_processor.cc index b869513bc..9e549d19b 100644 --- a/src/xenia/gpu/d3d12/d3d12_command_processor.cc +++ b/src/xenia/gpu/d3d12/d3d12_command_processor.cc @@ -862,6 +862,13 @@ bool D3D12CommandProcessor::SetupContext() { draw_resolution_scale_x, draw_resolution_scale_y); } + shared_memory_ = + std::make_unique(*this, *memory_, trace_writer_); + if (!shared_memory_->Initialize()) { + XELOGE("Failed to initialize shared memory"); + return false; + } + // Initialize the render target cache before configuring binding - need to // know if using rasterizer-ordered views for the bindless root signature. render_target_cache_ = std::make_unique( @@ -1144,13 +1151,6 @@ bool D3D12CommandProcessor::SetupContext() { } } - shared_memory_ = - std::make_unique(*this, *memory_, trace_writer_); - if (!shared_memory_->Initialize()) { - XELOGE("Failed to initialize shared memory"); - return false; - } - primitive_processor_ = std::make_unique( *register_file_, *memory_, trace_writer_, *shared_memory_, *this); if (!primitive_processor_->Initialize()) { @@ -1615,13 +1615,11 @@ void D3D12CommandProcessor::ShutdownContext() { gamma_ramp_upload_buffer_.Reset(); gamma_ramp_buffer_.Reset(); - pipeline_cache_.reset(); - texture_cache_.reset(); - primitive_processor_.reset(); + pipeline_cache_.reset(); - shared_memory_.reset(); + primitive_processor_.reset(); // Shut down binding - bindless descriptors may be owned by subsystems like // the texture cache. @@ -1654,6 +1652,8 @@ void D3D12CommandProcessor::ShutdownContext() { render_target_cache_.reset(); + shared_memory_.reset(); + deferred_command_list_.Reset(); ui::d3d12::util::ReleaseAndNull(command_list_1_); ui::d3d12::util::ReleaseAndNull(command_list_); @@ -2787,10 +2787,10 @@ void D3D12CommandProcessor::CheckSubmissionFence(uint64_t await_submission) { shared_memory_->CompletedSubmissionUpdated(); - primitive_processor_->CompletedSubmissionUpdated(); - render_target_cache_->CompletedSubmissionUpdated(); + primitive_processor_->CompletedSubmissionUpdated(); + texture_cache_->CompletedSubmissionUpdated(submission_completed_); } @@ -2870,10 +2870,10 @@ bool D3D12CommandProcessor::BeginSubmission(bool is_guest_command) { } primitive_topology_ = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; - primitive_processor_->BeginSubmission(); - render_target_cache_->BeginSubmission(); + primitive_processor_->BeginSubmission(); + texture_cache_->BeginSubmission(submission_current_); } @@ -3043,12 +3043,10 @@ bool D3D12CommandProcessor::EndSubmission(bool is_swap) { } constant_buffer_pool_->ClearCache(); - pipeline_cache_->ClearCache(); - - render_target_cache_->ClearCache(); - texture_cache_->ClearCache(); + pipeline_cache_->ClearCache(); + for (auto it : root_signatures_bindful_) { it.second->Release(); } @@ -3056,6 +3054,8 @@ bool D3D12CommandProcessor::EndSubmission(bool is_swap) { primitive_processor_->ClearCache(); + render_target_cache_->ClearCache(); + shared_memory_->ClearCache(); } } diff --git a/src/xenia/gpu/d3d12/d3d12_command_processor.h b/src/xenia/gpu/d3d12/d3d12_command_processor.h index e9cefb337..0b1e8fa53 100644 --- a/src/xenia/gpu/d3d12/d3d12_command_processor.h +++ b/src/xenia/gpu/d3d12/d3d12_command_processor.h @@ -427,6 +427,8 @@ class D3D12CommandProcessor : public CommandProcessor { // of UpdateBindings time, and that's outside the emulator's control even). bool bindless_resources_used_ = false; + std::unique_ptr shared_memory_; + std::unique_ptr render_target_cache_; std::unique_ptr constant_buffer_pool_; @@ -491,8 +493,6 @@ class D3D12CommandProcessor : public CommandProcessor { ID3D12RootSignature* root_signature_bindless_vs_ = nullptr; ID3D12RootSignature* root_signature_bindless_ds_ = nullptr; - std::unique_ptr shared_memory_; - std::unique_ptr primitive_processor_; std::unique_ptr pipeline_cache_;