diff options
| -rw-r--r-- | src/video_core/memory_manager.h | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h index 533b415e9..53c8d122a 100644 --- a/src/video_core/memory_manager.h +++ b/src/video_core/memory_manager.h | |||
| @@ -31,19 +31,19 @@ public: | |||
| 31 | constexpr PageEntry(State state) : state{state} {} | 31 | constexpr PageEntry(State state) : state{state} {} |
| 32 | constexpr PageEntry(VAddr addr) : state{static_cast<State>(addr >> ShiftBits)} {} | 32 | constexpr PageEntry(VAddr addr) : state{static_cast<State>(addr >> ShiftBits)} {} |
| 33 | 33 | ||
| 34 | constexpr bool IsUnmapped() const { | 34 | [[nodiscard]] constexpr bool IsUnmapped() const { |
| 35 | return state == State::Unmapped; | 35 | return state == State::Unmapped; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | constexpr bool IsAllocated() const { | 38 | [[nodiscard]] constexpr bool IsAllocated() const { |
| 39 | return state == State::Allocated; | 39 | return state == State::Allocated; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | constexpr bool IsValid() const { | 42 | [[nodiscard]] constexpr bool IsValid() const { |
| 43 | return !IsUnmapped() && !IsAllocated(); | 43 | return !IsUnmapped() && !IsAllocated(); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | constexpr VAddr ToAddress() const { | 46 | [[nodiscard]] constexpr VAddr ToAddress() const { |
| 47 | if (!IsValid()) { | 47 | if (!IsValid()) { |
| 48 | return {}; | 48 | return {}; |
| 49 | } | 49 | } |
| @@ -51,7 +51,7 @@ public: | |||
| 51 | return static_cast<VAddr>(state) << ShiftBits; | 51 | return static_cast<VAddr>(state) << ShiftBits; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | constexpr PageEntry operator+(u64 offset) { | 54 | [[nodiscard]] constexpr PageEntry operator+(u64 offset) const { |
| 55 | // If this is a reserved value, offsets do not apply | 55 | // If this is a reserved value, offsets do not apply |
| 56 | if (!IsValid()) { | 56 | if (!IsValid()) { |
| 57 | return *this; | 57 | return *this; |
| @@ -74,16 +74,16 @@ public: | |||
| 74 | /// Binds a renderer to the memory manager. | 74 | /// Binds a renderer to the memory manager. |
| 75 | void BindRasterizer(VideoCore::RasterizerInterface& rasterizer); | 75 | void BindRasterizer(VideoCore::RasterizerInterface& rasterizer); |
| 76 | 76 | ||
| 77 | std::optional<VAddr> GpuToCpuAddress(GPUVAddr addr) const; | 77 | [[nodiscard]] std::optional<VAddr> GpuToCpuAddress(GPUVAddr addr) const; |
| 78 | 78 | ||
| 79 | template <typename T> | 79 | template <typename T> |
| 80 | T Read(GPUVAddr addr) const; | 80 | [[nodiscard]] T Read(GPUVAddr addr) const; |
| 81 | 81 | ||
| 82 | template <typename T> | 82 | template <typename T> |
| 83 | void Write(GPUVAddr addr, T data); | 83 | void Write(GPUVAddr addr, T data); |
| 84 | 84 | ||
| 85 | u8* GetPointer(GPUVAddr addr); | 85 | [[nodiscard]] u8* GetPointer(GPUVAddr addr); |
| 86 | const u8* GetPointer(GPUVAddr addr) const; | 86 | [[nodiscard]] const u8* GetPointer(GPUVAddr addr) const; |
| 87 | 87 | ||
| 88 | /** | 88 | /** |
| 89 | * ReadBlock and WriteBlock are full read and write operations over virtual | 89 | * ReadBlock and WriteBlock are full read and write operations over virtual |
| @@ -112,24 +112,24 @@ public: | |||
| 112 | /** | 112 | /** |
| 113 | * IsGranularRange checks if a gpu region can be simply read with a pointer. | 113 | * IsGranularRange checks if a gpu region can be simply read with a pointer. |
| 114 | */ | 114 | */ |
| 115 | bool IsGranularRange(GPUVAddr gpu_addr, std::size_t size) const; | 115 | [[nodiscard]] bool IsGranularRange(GPUVAddr gpu_addr, std::size_t size) const; |
| 116 | 116 | ||
| 117 | GPUVAddr Map(VAddr cpu_addr, GPUVAddr gpu_addr, std::size_t size); | 117 | [[nodiscard]] GPUVAddr Map(VAddr cpu_addr, GPUVAddr gpu_addr, std::size_t size); |
| 118 | GPUVAddr MapAllocate(VAddr cpu_addr, std::size_t size, std::size_t align); | 118 | [[nodiscard]] GPUVAddr MapAllocate(VAddr cpu_addr, std::size_t size, std::size_t align); |
| 119 | std::optional<GPUVAddr> AllocateFixed(GPUVAddr gpu_addr, std::size_t size); | 119 | [[nodiscard]] std::optional<GPUVAddr> AllocateFixed(GPUVAddr gpu_addr, std::size_t size); |
| 120 | GPUVAddr Allocate(std::size_t size, std::size_t align); | 120 | [[nodiscard]] GPUVAddr Allocate(std::size_t size, std::size_t align); |
| 121 | void Unmap(GPUVAddr gpu_addr, std::size_t size); | 121 | void Unmap(GPUVAddr gpu_addr, std::size_t size); |
| 122 | 122 | ||
| 123 | private: | 123 | private: |
| 124 | PageEntry GetPageEntry(GPUVAddr gpu_addr) const; | 124 | [[nodiscard]] PageEntry GetPageEntry(GPUVAddr gpu_addr) const; |
| 125 | void SetPageEntry(GPUVAddr gpu_addr, PageEntry page_entry, std::size_t size = page_size); | 125 | void SetPageEntry(GPUVAddr gpu_addr, PageEntry page_entry, std::size_t size = page_size); |
| 126 | GPUVAddr UpdateRange(GPUVAddr gpu_addr, PageEntry page_entry, std::size_t size); | 126 | GPUVAddr UpdateRange(GPUVAddr gpu_addr, PageEntry page_entry, std::size_t size); |
| 127 | std::optional<GPUVAddr> FindFreeRange(std::size_t size, std::size_t align) const; | 127 | [[nodiscard]] std::optional<GPUVAddr> FindFreeRange(std::size_t size, std::size_t align) const; |
| 128 | 128 | ||
| 129 | void TryLockPage(PageEntry page_entry, std::size_t size); | 129 | void TryLockPage(PageEntry page_entry, std::size_t size); |
| 130 | void TryUnlockPage(PageEntry page_entry, std::size_t size); | 130 | void TryUnlockPage(PageEntry page_entry, std::size_t size); |
| 131 | 131 | ||
| 132 | static constexpr std::size_t PageEntryIndex(GPUVAddr gpu_addr) { | 132 | [[nodiscard]] static constexpr std::size_t PageEntryIndex(GPUVAddr gpu_addr) { |
| 133 | return (gpu_addr >> page_bits) & page_table_mask; | 133 | return (gpu_addr >> page_bits) & page_table_mask; |
| 134 | } | 134 | } |
| 135 | 135 | ||