diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/gpu.h | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index cf5235a79..21410e125 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -17,11 +17,11 @@ | |||
| 17 | #include "video_core/dma_pusher.h" | 17 | #include "video_core/dma_pusher.h" |
| 18 | 18 | ||
| 19 | using CacheAddr = std::uintptr_t; | 19 | using CacheAddr = std::uintptr_t; |
| 20 | inline CacheAddr ToCacheAddr(const void* host_ptr) { | 20 | [[nodiscard]] inline CacheAddr ToCacheAddr(const void* host_ptr) { |
| 21 | return reinterpret_cast<CacheAddr>(host_ptr); | 21 | return reinterpret_cast<CacheAddr>(host_ptr); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | inline u8* FromCacheAddr(CacheAddr cache_addr) { | 24 | [[nodiscard]] inline u8* FromCacheAddr(CacheAddr cache_addr) { |
| 25 | return reinterpret_cast<u8*>(cache_addr); | 25 | return reinterpret_cast<u8*>(cache_addr); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| @@ -149,13 +149,13 @@ public: | |||
| 149 | u32 subchannel{}; | 149 | u32 subchannel{}; |
| 150 | u32 method_count{}; | 150 | u32 method_count{}; |
| 151 | 151 | ||
| 152 | bool IsLastCall() const { | ||
| 153 | return method_count <= 1; | ||
| 154 | } | ||
| 155 | |||
| 156 | MethodCall(u32 method, u32 argument, u32 subchannel = 0, u32 method_count = 0) | 152 | MethodCall(u32 method, u32 argument, u32 subchannel = 0, u32 method_count = 0) |
| 157 | : method(method), argument(argument), subchannel(subchannel), | 153 | : method(method), argument(argument), subchannel(subchannel), |
| 158 | method_count(method_count) {} | 154 | method_count(method_count) {} |
| 155 | |||
| 156 | [[nodiscard]] bool IsLastCall() const { | ||
| 157 | return method_count <= 1; | ||
| 158 | } | ||
| 159 | }; | 159 | }; |
| 160 | 160 | ||
| 161 | explicit GPU(Core::System& system, bool is_async, bool use_nvdec); | 161 | explicit GPU(Core::System& system, bool is_async, bool use_nvdec); |
| @@ -179,10 +179,10 @@ public: | |||
| 179 | virtual void OnCommandListEnd(); | 179 | virtual void OnCommandListEnd(); |
| 180 | 180 | ||
| 181 | /// Request a host GPU memory flush from the CPU. | 181 | /// Request a host GPU memory flush from the CPU. |
| 182 | u64 RequestFlush(VAddr addr, std::size_t size); | 182 | [[nodiscard]] u64 RequestFlush(VAddr addr, std::size_t size); |
| 183 | 183 | ||
| 184 | /// Obtains current flush request fence id. | 184 | /// Obtains current flush request fence id. |
| 185 | u64 CurrentFlushRequestFence() const { | 185 | [[nodiscard]] u64 CurrentFlushRequestFence() const { |
| 186 | return current_flush_fence.load(std::memory_order_relaxed); | 186 | return current_flush_fence.load(std::memory_order_relaxed); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| @@ -190,48 +190,52 @@ public: | |||
| 190 | void TickWork(); | 190 | void TickWork(); |
| 191 | 191 | ||
| 192 | /// Returns a reference to the Maxwell3D GPU engine. | 192 | /// Returns a reference to the Maxwell3D GPU engine. |
| 193 | Engines::Maxwell3D& Maxwell3D(); | 193 | [[nodiscard]] Engines::Maxwell3D& Maxwell3D(); |
| 194 | 194 | ||
| 195 | /// Returns a const reference to the Maxwell3D GPU engine. | 195 | /// Returns a const reference to the Maxwell3D GPU engine. |
| 196 | const Engines::Maxwell3D& Maxwell3D() const; | 196 | [[nodiscard]] const Engines::Maxwell3D& Maxwell3D() const; |
| 197 | 197 | ||
| 198 | /// Returns a reference to the KeplerCompute GPU engine. | 198 | /// Returns a reference to the KeplerCompute GPU engine. |
| 199 | Engines::KeplerCompute& KeplerCompute(); | 199 | [[nodiscard]] Engines::KeplerCompute& KeplerCompute(); |
| 200 | 200 | ||
| 201 | /// Returns a reference to the KeplerCompute GPU engine. | 201 | /// Returns a reference to the KeplerCompute GPU engine. |
| 202 | const Engines::KeplerCompute& KeplerCompute() const; | 202 | [[nodiscard]] const Engines::KeplerCompute& KeplerCompute() const; |
| 203 | 203 | ||
| 204 | /// Returns a reference to the GPU memory manager. | 204 | /// Returns a reference to the GPU memory manager. |
| 205 | Tegra::MemoryManager& MemoryManager(); | 205 | [[nodiscard]] Tegra::MemoryManager& MemoryManager(); |
| 206 | 206 | ||
| 207 | /// Returns a const reference to the GPU memory manager. | 207 | /// Returns a const reference to the GPU memory manager. |
| 208 | const Tegra::MemoryManager& MemoryManager() const; | 208 | [[nodiscard]] const Tegra::MemoryManager& MemoryManager() const; |
| 209 | 209 | ||
| 210 | /// Returns a reference to the GPU DMA pusher. | 210 | /// Returns a reference to the GPU DMA pusher. |
| 211 | Tegra::DmaPusher& DmaPusher(); | 211 | [[nodiscard]] Tegra::DmaPusher& DmaPusher(); |
| 212 | 212 | ||
| 213 | /// Returns a const reference to the GPU DMA pusher. | 213 | /// Returns a const reference to the GPU DMA pusher. |
| 214 | const Tegra::DmaPusher& DmaPusher() const; | 214 | [[nodiscard]] const Tegra::DmaPusher& DmaPusher() const; |
| 215 | 215 | ||
| 216 | /// Returns a reference to the GPU CDMA pusher. | 216 | /// Returns a reference to the GPU CDMA pusher. |
| 217 | Tegra::CDmaPusher& CDmaPusher(); | 217 | [[nodiscard]] Tegra::CDmaPusher& CDmaPusher(); |
| 218 | 218 | ||
| 219 | /// Returns a const reference to the GPU CDMA pusher. | 219 | /// Returns a const reference to the GPU CDMA pusher. |
| 220 | const Tegra::CDmaPusher& CDmaPusher() const; | 220 | [[nodiscard]] const Tegra::CDmaPusher& CDmaPusher() const; |
| 221 | 221 | ||
| 222 | VideoCore::RendererBase& Renderer() { | 222 | /// Returns a reference to the underlying renderer. |
| 223 | [[nodiscard]] VideoCore::RendererBase& Renderer() { | ||
| 223 | return *renderer; | 224 | return *renderer; |
| 224 | } | 225 | } |
| 225 | 226 | ||
| 226 | const VideoCore::RendererBase& Renderer() const { | 227 | /// Returns a const reference to the underlying renderer. |
| 228 | [[nodiscard]] const VideoCore::RendererBase& Renderer() const { | ||
| 227 | return *renderer; | 229 | return *renderer; |
| 228 | } | 230 | } |
| 229 | 231 | ||
| 230 | VideoCore::ShaderNotify& ShaderNotify() { | 232 | /// Returns a reference to the shader notifier. |
| 233 | [[nodiscard]] VideoCore::ShaderNotify& ShaderNotify() { | ||
| 231 | return *shader_notify; | 234 | return *shader_notify; |
| 232 | } | 235 | } |
| 233 | 236 | ||
| 234 | const VideoCore::ShaderNotify& ShaderNotify() const { | 237 | /// Returns a const reference to the shader notifier. |
| 238 | [[nodiscard]] const VideoCore::ShaderNotify& ShaderNotify() const { | ||
| 235 | return *shader_notify; | 239 | return *shader_notify; |
| 236 | } | 240 | } |
| 237 | 241 | ||
| @@ -243,23 +247,23 @@ public: | |||
| 243 | 247 | ||
| 244 | void IncrementSyncPoint(u32 syncpoint_id); | 248 | void IncrementSyncPoint(u32 syncpoint_id); |
| 245 | 249 | ||
| 246 | u32 GetSyncpointValue(u32 syncpoint_id) const; | 250 | [[nodiscard]] u32 GetSyncpointValue(u32 syncpoint_id) const; |
| 247 | 251 | ||
| 248 | void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value); | 252 | void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value); |
| 249 | 253 | ||
| 250 | bool CancelSyncptInterrupt(u32 syncpoint_id, u32 value); | 254 | [[nodiscard]] bool CancelSyncptInterrupt(u32 syncpoint_id, u32 value); |
| 251 | 255 | ||
| 252 | u64 GetTicks() const; | 256 | [[nodiscard]] u64 GetTicks() const; |
| 253 | 257 | ||
| 254 | std::unique_lock<std::mutex> LockSync() { | 258 | [[nodiscard]] std::unique_lock<std::mutex> LockSync() { |
| 255 | return std::unique_lock{sync_mutex}; | 259 | return std::unique_lock{sync_mutex}; |
| 256 | } | 260 | } |
| 257 | 261 | ||
| 258 | bool IsAsync() const { | 262 | [[nodiscard]] bool IsAsync() const { |
| 259 | return is_async; | 263 | return is_async; |
| 260 | } | 264 | } |
| 261 | 265 | ||
| 262 | bool UseNvdec() const { | 266 | [[nodiscard]] bool UseNvdec() const { |
| 263 | return use_nvdec; | 267 | return use_nvdec; |
| 264 | } | 268 | } |
| 265 | 269 | ||
| @@ -273,7 +277,7 @@ public: | |||
| 273 | BitField<0, 1, FenceOperation> op; | 277 | BitField<0, 1, FenceOperation> op; |
| 274 | BitField<8, 24, u32> syncpoint_id; | 278 | BitField<8, 24, u32> syncpoint_id; |
| 275 | 279 | ||
| 276 | static CommandHeader Build(FenceOperation op, u32 syncpoint_id) { | 280 | [[nodiscard]] static CommandHeader Build(FenceOperation op, u32 syncpoint_id) { |
| 277 | FenceAction result{}; | 281 | FenceAction result{}; |
| 278 | result.op.Assign(op); | 282 | result.op.Assign(op); |
| 279 | result.syncpoint_id.Assign(syncpoint_id); | 283 | result.syncpoint_id.Assign(syncpoint_id); |
| @@ -291,7 +295,7 @@ public: | |||
| 291 | u32 address_high; | 295 | u32 address_high; |
| 292 | u32 address_low; | 296 | u32 address_low; |
| 293 | 297 | ||
| 294 | GPUVAddr SemaphoreAddress() const { | 298 | [[nodiscard]] GPUVAddr SemaphoreAddress() const { |
| 295 | return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) | | 299 | return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) | |
| 296 | address_low); | 300 | address_low); |
| 297 | } | 301 | } |
| @@ -374,7 +378,7 @@ private: | |||
| 374 | u32 methods_pending); | 378 | u32 methods_pending); |
| 375 | 379 | ||
| 376 | /// Determines where the method should be executed. | 380 | /// Determines where the method should be executed. |
| 377 | bool ExecuteMethodOnEngine(u32 method); | 381 | [[nodiscard]] bool ExecuteMethodOnEngine(u32 method); |
| 378 | 382 | ||
| 379 | protected: | 383 | protected: |
| 380 | Core::System& system; | 384 | Core::System& system; |