diff options
Diffstat (limited to 'src/video_core/fence_manager.h')
| -rw-r--r-- | src/video_core/fence_manager.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/video_core/fence_manager.h b/src/video_core/fence_manager.h index 1e9832ddd..d658e038d 100644 --- a/src/video_core/fence_manager.h +++ b/src/video_core/fence_manager.h | |||
| @@ -4,12 +4,13 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <algorithm> | 6 | #include <algorithm> |
| 7 | #include <cstring> | ||
| 8 | #include <memory> | ||
| 7 | #include <queue> | 9 | #include <queue> |
| 8 | 10 | ||
| 9 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 10 | #include "video_core/delayed_destruction_ring.h" | 12 | #include "video_core/delayed_destruction_ring.h" |
| 11 | #include "video_core/gpu.h" | 13 | #include "video_core/gpu.h" |
| 12 | #include "video_core/memory_manager.h" | ||
| 13 | #include "video_core/rasterizer_interface.h" | 14 | #include "video_core/rasterizer_interface.h" |
| 14 | 15 | ||
| 15 | namespace VideoCommon { | 16 | namespace VideoCommon { |
| @@ -19,10 +20,10 @@ public: | |||
| 19 | explicit FenceBase(u32 payload_, bool is_stubbed_) | 20 | explicit FenceBase(u32 payload_, bool is_stubbed_) |
| 20 | : address{}, payload{payload_}, is_semaphore{false}, is_stubbed{is_stubbed_} {} | 21 | : address{}, payload{payload_}, is_semaphore{false}, is_stubbed{is_stubbed_} {} |
| 21 | 22 | ||
| 22 | explicit FenceBase(GPUVAddr address_, u32 payload_, bool is_stubbed_) | 23 | explicit FenceBase(u8* address_, u32 payload_, bool is_stubbed_) |
| 23 | : address{address_}, payload{payload_}, is_semaphore{true}, is_stubbed{is_stubbed_} {} | 24 | : address{address_}, payload{payload_}, is_semaphore{true}, is_stubbed{is_stubbed_} {} |
| 24 | 25 | ||
| 25 | GPUVAddr GetAddress() const { | 26 | u8* GetAddress() const { |
| 26 | return address; | 27 | return address; |
| 27 | } | 28 | } |
| 28 | 29 | ||
| @@ -35,7 +36,7 @@ public: | |||
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | private: | 38 | private: |
| 38 | GPUVAddr address; | 39 | u8* address; |
| 39 | u32 payload; | 40 | u32 payload; |
| 40 | bool is_semaphore; | 41 | bool is_semaphore; |
| 41 | 42 | ||
| @@ -57,7 +58,7 @@ public: | |||
| 57 | buffer_cache.AccumulateFlushes(); | 58 | buffer_cache.AccumulateFlushes(); |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | void SignalSemaphore(GPUVAddr addr, u32 value) { | 61 | void SignalSemaphore(u8* addr, u32 value) { |
| 61 | TryReleasePendingFences(); | 62 | TryReleasePendingFences(); |
| 62 | const bool should_flush = ShouldFlush(); | 63 | const bool should_flush = ShouldFlush(); |
| 63 | CommitAsyncFlushes(); | 64 | CommitAsyncFlushes(); |
| @@ -91,8 +92,9 @@ public: | |||
| 91 | } | 92 | } |
| 92 | PopAsyncFlushes(); | 93 | PopAsyncFlushes(); |
| 93 | if (current_fence->IsSemaphore()) { | 94 | if (current_fence->IsSemaphore()) { |
| 94 | gpu_memory.template Write<u32>(current_fence->GetAddress(), | 95 | char* address = reinterpret_cast<char*>(current_fence->GetAddress()); |
| 95 | current_fence->GetPayload()); | 96 | auto payload = current_fence->GetPayload(); |
| 97 | std::memcpy(address, &payload, sizeof(payload)); | ||
| 96 | } else { | 98 | } else { |
| 97 | gpu.IncrementSyncPoint(current_fence->GetPayload()); | 99 | gpu.IncrementSyncPoint(current_fence->GetPayload()); |
| 98 | } | 100 | } |
| @@ -104,8 +106,8 @@ protected: | |||
| 104 | explicit FenceManager(VideoCore::RasterizerInterface& rasterizer_, Tegra::GPU& gpu_, | 106 | explicit FenceManager(VideoCore::RasterizerInterface& rasterizer_, Tegra::GPU& gpu_, |
| 105 | TTextureCache& texture_cache_, TTBufferCache& buffer_cache_, | 107 | TTextureCache& texture_cache_, TTBufferCache& buffer_cache_, |
| 106 | TQueryCache& query_cache_) | 108 | TQueryCache& query_cache_) |
| 107 | : rasterizer{rasterizer_}, gpu{gpu_}, gpu_memory{gpu.MemoryManager()}, | 109 | : rasterizer{rasterizer_}, gpu{gpu_}, texture_cache{texture_cache_}, |
| 108 | texture_cache{texture_cache_}, buffer_cache{buffer_cache_}, query_cache{query_cache_} {} | 110 | buffer_cache{buffer_cache_}, query_cache{query_cache_} {} |
| 109 | 111 | ||
| 110 | virtual ~FenceManager() = default; | 112 | virtual ~FenceManager() = default; |
| 111 | 113 | ||
| @@ -113,7 +115,7 @@ protected: | |||
| 113 | /// true | 115 | /// true |
| 114 | virtual TFence CreateFence(u32 value, bool is_stubbed) = 0; | 116 | virtual TFence CreateFence(u32 value, bool is_stubbed) = 0; |
| 115 | /// Creates a Semaphore Fence Interface, does not create a backend fence if 'is_stubbed' is true | 117 | /// Creates a Semaphore Fence Interface, does not create a backend fence if 'is_stubbed' is true |
| 116 | virtual TFence CreateFence(GPUVAddr addr, u32 value, bool is_stubbed) = 0; | 118 | virtual TFence CreateFence(u8* addr, u32 value, bool is_stubbed) = 0; |
| 117 | /// Queues a fence into the backend if the fence isn't stubbed. | 119 | /// Queues a fence into the backend if the fence isn't stubbed. |
| 118 | virtual void QueueFence(TFence& fence) = 0; | 120 | virtual void QueueFence(TFence& fence) = 0; |
| 119 | /// Notifies that the backend fence has been signaled/reached in host GPU. | 121 | /// Notifies that the backend fence has been signaled/reached in host GPU. |
| @@ -123,7 +125,6 @@ protected: | |||
| 123 | 125 | ||
| 124 | VideoCore::RasterizerInterface& rasterizer; | 126 | VideoCore::RasterizerInterface& rasterizer; |
| 125 | Tegra::GPU& gpu; | 127 | Tegra::GPU& gpu; |
| 126 | Tegra::MemoryManager& gpu_memory; | ||
| 127 | TTextureCache& texture_cache; | 128 | TTextureCache& texture_cache; |
| 128 | TTBufferCache& buffer_cache; | 129 | TTBufferCache& buffer_cache; |
| 129 | TQueryCache& query_cache; | 130 | TQueryCache& query_cache; |
| @@ -137,8 +138,9 @@ private: | |||
| 137 | } | 138 | } |
| 138 | PopAsyncFlushes(); | 139 | PopAsyncFlushes(); |
| 139 | if (current_fence->IsSemaphore()) { | 140 | if (current_fence->IsSemaphore()) { |
| 140 | gpu_memory.template Write<u32>(current_fence->GetAddress(), | 141 | char* address = reinterpret_cast<char*>(current_fence->GetAddress()); |
| 141 | current_fence->GetPayload()); | 142 | const auto payload = current_fence->GetPayload(); |
| 143 | std::memcpy(address, &payload, sizeof(payload)); | ||
| 142 | } else { | 144 | } else { |
| 143 | gpu.IncrementSyncPoint(current_fence->GetPayload()); | 145 | gpu.IncrementSyncPoint(current_fence->GetPayload()); |
| 144 | } | 146 | } |