summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-03 12:55:58 -0400
committerGravatar Lioncash2018-08-04 02:36:57 -0400
commit6030c5ce412e44ddcfe0a31c6747a017166bf33d (patch)
tree2b79fa019f07e601b5170e92e93b69788ffde949 /src/core/hle
parentMerge pull request #911 from lioncash/prototype (diff)
downloadyuzu-6030c5ce412e44ddcfe0a31c6747a017166bf33d.tar.gz
yuzu-6030c5ce412e44ddcfe0a31c6747a017166bf33d.tar.xz
yuzu-6030c5ce412e44ddcfe0a31c6747a017166bf33d.zip
video_core: Eliminate the g_renderer global variable
We move the initialization of the renderer to the core class, while keeping the creation of it and any other specifics in video_core. This way we can ensure that the renderer is initialized and doesn't give unfettered access to the renderer. This also makes dependencies on types more explicit. For example, the GPU class doesn't need to depend on the existence of a renderer, it only needs to care about whether or not it has a rasterizer, but since it was accessing the global variable, it was also making the renderer a part of its dependency chain. By adjusting the interface, we can get rid of this dependency.
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp6
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp11
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp6
3 files changed, 13 insertions, 10 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
index ed69a4325..2b74e6a33 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
@@ -30,9 +30,9 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3
30 addr, offset, width, height, stride, static_cast<PixelFormat>(format), 30 addr, offset, width, height, stride, static_cast<PixelFormat>(format),
31 transform, crop_rect}; 31 transform, crop_rect};
32 32
33 Core::System::GetInstance().perf_stats.EndGameFrame(); 33 auto& instance = Core::System::GetInstance();
34 34 instance.perf_stats.EndGameFrame();
35 VideoCore::g_renderer->SwapBuffers(framebuffer); 35 instance.Renderer().SwapBuffers(framebuffer);
36} 36}
37 37
38} // namespace Service::Nvidia::Devices 38} // namespace Service::Nvidia::Devices
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
index 57b128b40..06151a1ea 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
@@ -150,15 +150,16 @@ u32 nvhost_as_gpu::UnmapBuffer(const std::vector<u8>& input, std::vector<u8>& ou
150 150
151 LOG_DEBUG(Service_NVDRV, "called, offset=0x{:X}", params.offset); 151 LOG_DEBUG(Service_NVDRV, "called, offset=0x{:X}", params.offset);
152 152
153 auto& gpu = Core::System::GetInstance().GPU(); 153 const auto itr = buffer_mappings.find(params.offset);
154
155 auto itr = buffer_mappings.find(params.offset);
156
157 ASSERT_MSG(itr != buffer_mappings.end(), "Tried to unmap invalid mapping"); 154 ASSERT_MSG(itr != buffer_mappings.end(), "Tried to unmap invalid mapping");
158 155
156 auto& system_instance = Core::System::GetInstance();
157
159 // Remove this memory region from the rasterizer cache. 158 // Remove this memory region from the rasterizer cache.
160 VideoCore::g_renderer->Rasterizer()->FlushAndInvalidateRegion(params.offset, itr->second.size); 159 system_instance.Renderer().Rasterizer()->FlushAndInvalidateRegion(params.offset,
160 itr->second.size);
161 161
162 auto& gpu = system_instance.GPU();
162 params.offset = gpu.memory_manager->UnmapBuffer(params.offset, itr->second.size); 163 params.offset = gpu.memory_manager->UnmapBuffer(params.offset, itr->second.size);
163 164
164 buffer_mappings.erase(itr->second.offset); 165 buffer_mappings.erase(itr->second.offset);
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index 5344441e1..0bf51062c 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -127,9 +127,11 @@ void NVFlinger::Compose() {
127 MicroProfileFlip(); 127 MicroProfileFlip();
128 128
129 if (buffer == boost::none) { 129 if (buffer == boost::none) {
130 auto& system_instance = Core::System::GetInstance();
131
130 // There was no queued buffer to draw, render previous frame 132 // There was no queued buffer to draw, render previous frame
131 Core::System::GetInstance().perf_stats.EndGameFrame(); 133 system_instance.perf_stats.EndGameFrame();
132 VideoCore::g_renderer->SwapBuffers({}); 134 system_instance.Renderer().SwapBuffers({});
133 continue; 135 continue;
134 } 136 }
135 137