From 2081ed7db22d62b82acfddcd4b7c10a03bb3daaf Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Tue, 4 Sep 2018 13:54:50 +0200 Subject: [PATCH 1/2] command_processor: Use std::array for bound_engines. subchannel is a 3 bit field. So there must not be more than 8 bound engines. And using a hashmap for up to 8 values is a bit overpowered. --- src/video_core/command_processor.cpp | 4 ++-- src/video_core/gpu.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index dc485e811..d5831e752 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -34,6 +34,8 @@ void GPU::WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params) "{:08X} remaining params {}", method, subchannel, value, remaining_params); + ASSERT(subchannel < bound_engines.size()); + if (method == static_cast(BufferMethods::BindObject)) { // Bind the current subchannel to the desired engine id. LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", subchannel, value); @@ -47,8 +49,6 @@ void GPU::WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params) return; } - ASSERT(bound_engines.find(subchannel) != bound_engines.end()); - const EngineID engine = bound_engines[subchannel]; switch (engine) { diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 2c3dbd97b..d29f31f52 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -4,8 +4,8 @@ #pragma once +#include #include -#include #include "common/common_types.h" #include "core/hle/service/nvflinger/buffer_queue.h" #include "video_core/memory_manager.h" @@ -136,7 +136,7 @@ private: std::unique_ptr memory_manager; /// Mapping of command subchannels to their bound engine ids. - std::unordered_map bound_engines; + std::array bound_engines = {}; /// 3D engine std::unique_ptr maxwell_3d; From dce624e3f12f1fb8bab66a3e974037501653b3ed Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Tue, 4 Sep 2018 14:06:52 +0200 Subject: [PATCH 2/2] core: Use a raw pointer in GetGPUDebugContext. This helper is called very often. The memory ownership shall not be transfered, so just return the raw pointer. --- src/core/core.cpp | 4 ++-- src/core/core.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 29983b9b4..cbab80881 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -441,8 +441,8 @@ void System::SetGPUDebugContext(std::shared_ptr context) { impl->debug_context = std::move(context); } -std::shared_ptr System::GetGPUDebugContext() const { - return impl->debug_context; +Tegra::DebugContext* System::GetGPUDebugContext() const { + return impl->debug_context.get(); } void System::SetFilesystem(std::shared_ptr vfs) { diff --git a/src/core/core.h b/src/core/core.h index eee1fecc1..5c3c0e2a1 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -209,7 +209,7 @@ public: void SetGPUDebugContext(std::shared_ptr context); - std::shared_ptr GetGPUDebugContext() const; + Tegra::DebugContext* GetGPUDebugContext() const; void SetFilesystem(std::shared_ptr vfs);