diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/wrapper.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/video_core/renderer_vulkan/wrapper.h b/src/video_core/renderer_vulkan/wrapper.h index 14dd792ed..686c2b9a1 100644 --- a/src/video_core/renderer_vulkan/wrapper.h +++ b/src/video_core/renderer_vulkan/wrapper.h | |||
| @@ -28,6 +28,16 @@ namespace Vulkan::vk { | |||
| 28 | template <typename T> | 28 | template <typename T> |
| 29 | class Span { | 29 | class Span { |
| 30 | public: | 30 | public: |
| 31 | using value_type = T; | ||
| 32 | using size_type = u32; | ||
| 33 | using difference_type = std::ptrdiff_t; | ||
| 34 | using reference = const T&; | ||
| 35 | using const_reference = const T&; | ||
| 36 | using pointer = const T*; | ||
| 37 | using const_pointer = const T*; | ||
| 38 | using iterator = const T*; | ||
| 39 | using const_iterator = const T*; | ||
| 40 | |||
| 31 | /// Construct an empty span. | 41 | /// Construct an empty span. |
| 32 | constexpr Span() noexcept = default; | 42 | constexpr Span() noexcept = default; |
| 33 | 43 | ||
| @@ -50,6 +60,7 @@ public: | |||
| 50 | } | 60 | } |
| 51 | 61 | ||
| 52 | /// Returns the number of elements in the span. | 62 | /// Returns the number of elements in the span. |
| 63 | /// @note Returns a 32 bits integer because most Vulkan functions expect this type. | ||
| 53 | constexpr u32 size() const noexcept { | 64 | constexpr u32 size() const noexcept { |
| 54 | return static_cast<u32>(num); | 65 | return static_cast<u32>(num); |
| 55 | } | 66 | } |
| @@ -75,6 +86,16 @@ public: | |||
| 75 | return ptr + num; | 86 | return ptr + num; |
| 76 | } | 87 | } |
| 77 | 88 | ||
| 89 | /// Returns an iterator to the beginning of the span. | ||
| 90 | constexpr const T* cbegin() const noexcept { | ||
| 91 | return ptr; | ||
| 92 | } | ||
| 93 | |||
| 94 | /// Returns an iterator to the end of the span. | ||
| 95 | constexpr const T* cend() const noexcept { | ||
| 96 | return ptr + num; | ||
| 97 | } | ||
| 98 | |||
| 78 | private: | 99 | private: |
| 79 | const T* ptr = nullptr; | 100 | const T* ptr = nullptr; |
| 80 | std::size_t num = 0; | 101 | std::size_t num = 0; |
| @@ -325,7 +346,7 @@ public: | |||
| 325 | /// Returns the address of the held object. | 346 | /// Returns the address of the held object. |
| 326 | /// Intended for Vulkan structures that expect a pointer to an array. | 347 | /// Intended for Vulkan structures that expect a pointer to an array. |
| 327 | const Type* address() const noexcept { | 348 | const Type* address() const noexcept { |
| 328 | return &handle; | 349 | return std::addressof(handle); |
| 329 | } | 350 | } |
| 330 | 351 | ||
| 331 | /// Returns the held Vulkan handle. | 352 | /// Returns the held Vulkan handle. |
| @@ -334,7 +355,7 @@ public: | |||
| 334 | } | 355 | } |
| 335 | 356 | ||
| 336 | /// Returns true when there's a held object. | 357 | /// Returns true when there's a held object. |
| 337 | operator bool() const noexcept { | 358 | explicit operator bool() const noexcept { |
| 338 | return handle != nullptr; | 359 | return handle != nullptr; |
| 339 | } | 360 | } |
| 340 | 361 | ||
| @@ -396,7 +417,7 @@ public: | |||
| 396 | /// Returns the address of the held object. | 417 | /// Returns the address of the held object. |
| 397 | /// Intended for Vulkan structures that expect a pointer to an array. | 418 | /// Intended for Vulkan structures that expect a pointer to an array. |
| 398 | const Type* address() const noexcept { | 419 | const Type* address() const noexcept { |
| 399 | return &handle; | 420 | return std::addressof(handle); |
| 400 | } | 421 | } |
| 401 | 422 | ||
| 402 | /// Returns the held Vulkan handle. | 423 | /// Returns the held Vulkan handle. |