diff options
Diffstat (limited to 'src/video_core/gpu.h')
| -rw-r--r-- | src/video_core/gpu.h | 55 |
1 files changed, 19 insertions, 36 deletions
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 660641d04..a2bb4d82d 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | #include "core/hle/service/nvflinger/buffer_queue.h" | 15 | #include "core/hle/service/nvflinger/buffer_queue.h" |
| 16 | #include "video_core/cdma_pusher.h" | 16 | #include "video_core/cdma_pusher.h" |
| 17 | #include "video_core/dma_pusher.h" | 17 | #include "video_core/dma_pusher.h" |
| 18 | #include "video_core/framebuffer_config.h" | ||
| 19 | #include "video_core/gpu_thread.h" | ||
| 18 | 20 | ||
| 19 | using CacheAddr = std::uintptr_t; | 21 | using CacheAddr = std::uintptr_t; |
| 20 | [[nodiscard]] inline CacheAddr ToCacheAddr(const void* host_ptr) { | 22 | [[nodiscard]] inline CacheAddr ToCacheAddr(const void* host_ptr) { |
| @@ -101,28 +103,6 @@ enum class DepthFormat : u32 { | |||
| 101 | struct CommandListHeader; | 103 | struct CommandListHeader; |
| 102 | class DebugContext; | 104 | class DebugContext; |
| 103 | 105 | ||
| 104 | /** | ||
| 105 | * Struct describing framebuffer configuration | ||
| 106 | */ | ||
| 107 | struct FramebufferConfig { | ||
| 108 | enum class PixelFormat : u32 { | ||
| 109 | A8B8G8R8_UNORM = 1, | ||
| 110 | RGB565_UNORM = 4, | ||
| 111 | B8G8R8A8_UNORM = 5, | ||
| 112 | }; | ||
| 113 | |||
| 114 | VAddr address; | ||
| 115 | u32 offset; | ||
| 116 | u32 width; | ||
| 117 | u32 height; | ||
| 118 | u32 stride; | ||
| 119 | PixelFormat pixel_format; | ||
| 120 | |||
| 121 | using TransformFlags = Service::NVFlinger::BufferQueue::BufferTransformFlags; | ||
| 122 | TransformFlags transform_flags; | ||
| 123 | Common::Rectangle<int> crop_rect; | ||
| 124 | }; | ||
| 125 | |||
| 126 | namespace Engines { | 106 | namespace Engines { |
| 127 | class Fermi2D; | 107 | class Fermi2D; |
| 128 | class Maxwell3D; | 108 | class Maxwell3D; |
| @@ -141,7 +121,7 @@ enum class EngineID { | |||
| 141 | 121 | ||
| 142 | class MemoryManager; | 122 | class MemoryManager; |
| 143 | 123 | ||
| 144 | class GPU { | 124 | class GPU final { |
| 145 | public: | 125 | public: |
| 146 | struct MethodCall { | 126 | struct MethodCall { |
| 147 | u32 method{}; | 127 | u32 method{}; |
| @@ -159,7 +139,7 @@ public: | |||
| 159 | }; | 139 | }; |
| 160 | 140 | ||
| 161 | explicit GPU(Core::System& system_, bool is_async_, bool use_nvdec_); | 141 | explicit GPU(Core::System& system_, bool is_async_, bool use_nvdec_); |
| 162 | virtual ~GPU(); | 142 | ~GPU(); |
| 163 | 143 | ||
| 164 | /// Binds a renderer to the GPU. | 144 | /// Binds a renderer to the GPU. |
| 165 | void BindRenderer(std::unique_ptr<VideoCore::RendererBase> renderer); | 145 | void BindRenderer(std::unique_ptr<VideoCore::RendererBase> renderer); |
| @@ -176,7 +156,7 @@ public: | |||
| 176 | /// Synchronizes CPU writes with Host GPU memory. | 156 | /// Synchronizes CPU writes with Host GPU memory. |
| 177 | void SyncGuestHost(); | 157 | void SyncGuestHost(); |
| 178 | /// Signal the ending of command list. | 158 | /// Signal the ending of command list. |
| 179 | virtual void OnCommandListEnd(); | 159 | void OnCommandListEnd(); |
| 180 | 160 | ||
| 181 | /// Request a host GPU memory flush from the CPU. | 161 | /// Request a host GPU memory flush from the CPU. |
| 182 | [[nodiscard]] u64 RequestFlush(VAddr addr, std::size_t size); | 162 | [[nodiscard]] u64 RequestFlush(VAddr addr, std::size_t size); |
| @@ -240,7 +220,7 @@ public: | |||
| 240 | } | 220 | } |
| 241 | 221 | ||
| 242 | // Waits for the GPU to finish working | 222 | // Waits for the GPU to finish working |
| 243 | virtual void WaitIdle() const = 0; | 223 | void WaitIdle() const; |
| 244 | 224 | ||
| 245 | /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame. | 225 | /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame. |
| 246 | void WaitFence(u32 syncpoint_id, u32 value); | 226 | void WaitFence(u32 syncpoint_id, u32 value); |
| @@ -330,34 +310,34 @@ public: | |||
| 330 | /// Performs any additional setup necessary in order to begin GPU emulation. | 310 | /// Performs any additional setup necessary in order to begin GPU emulation. |
| 331 | /// This can be used to launch any necessary threads and register any necessary | 311 | /// This can be used to launch any necessary threads and register any necessary |
| 332 | /// core timing events. | 312 | /// core timing events. |
| 333 | virtual void Start() = 0; | 313 | void Start(); |
| 334 | 314 | ||
| 335 | /// Obtain the CPU Context | 315 | /// Obtain the CPU Context |
| 336 | virtual void ObtainContext() = 0; | 316 | void ObtainContext(); |
| 337 | 317 | ||
| 338 | /// Release the CPU Context | 318 | /// Release the CPU Context |
| 339 | virtual void ReleaseContext() = 0; | 319 | void ReleaseContext(); |
| 340 | 320 | ||
| 341 | /// Push GPU command entries to be processed | 321 | /// Push GPU command entries to be processed |
| 342 | virtual void PushGPUEntries(Tegra::CommandList&& entries) = 0; | 322 | void PushGPUEntries(Tegra::CommandList&& entries); |
| 343 | 323 | ||
| 344 | /// Push GPU command buffer entries to be processed | 324 | /// Push GPU command buffer entries to be processed |
| 345 | virtual void PushCommandBuffer(Tegra::ChCommandHeaderList& entries) = 0; | 325 | void PushCommandBuffer(Tegra::ChCommandHeaderList& entries); |
| 346 | 326 | ||
| 347 | /// Swap buffers (render frame) | 327 | /// Swap buffers (render frame) |
| 348 | virtual void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) = 0; | 328 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer); |
| 349 | 329 | ||
| 350 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory | 330 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory |
| 351 | virtual void FlushRegion(VAddr addr, u64 size) = 0; | 331 | void FlushRegion(VAddr addr, u64 size); |
| 352 | 332 | ||
| 353 | /// Notify rasterizer that any caches of the specified region should be invalidated | 333 | /// Notify rasterizer that any caches of the specified region should be invalidated |
| 354 | virtual void InvalidateRegion(VAddr addr, u64 size) = 0; | 334 | void InvalidateRegion(VAddr addr, u64 size); |
| 355 | 335 | ||
| 356 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated | 336 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated |
| 357 | virtual void FlushAndInvalidateRegion(VAddr addr, u64 size) = 0; | 337 | void FlushAndInvalidateRegion(VAddr addr, u64 size); |
| 358 | 338 | ||
| 359 | protected: | 339 | protected: |
| 360 | virtual void TriggerCpuInterrupt(u32 syncpoint_id, u32 value) const = 0; | 340 | void TriggerCpuInterrupt(u32 syncpoint_id, u32 value) const; |
| 361 | 341 | ||
| 362 | private: | 342 | private: |
| 363 | void ProcessBindMethod(const MethodCall& method_call); | 343 | void ProcessBindMethod(const MethodCall& method_call); |
| @@ -426,6 +406,9 @@ private: | |||
| 426 | u64 last_flush_fence{}; | 406 | u64 last_flush_fence{}; |
| 427 | std::mutex flush_request_mutex; | 407 | std::mutex flush_request_mutex; |
| 428 | 408 | ||
| 409 | VideoCommon::GPUThread::ThreadManager gpu_thread; | ||
| 410 | std::unique_ptr<Core::Frontend::GraphicsContext> cpu_context; | ||
| 411 | |||
| 429 | const bool is_async; | 412 | const bool is_async; |
| 430 | }; | 413 | }; |
| 431 | 414 | ||