diff options
| author | 2020-09-22 17:31:53 -0400 | |
|---|---|---|
| committer | 2020-09-22 17:32:33 -0400 | |
| commit | ff45c3957858cdf189b73e11550da06fe4337b8e (patch) | |
| tree | 288ff1cc4677d6511ed8cc7e1b0db20ce2d2590f /src/video_core/texture_cache | |
| parent | Merge pull request #4697 from lioncash/copy5 (diff) | |
| download | yuzu-ff45c3957858cdf189b73e11550da06fe4337b8e.tar.gz yuzu-ff45c3957858cdf189b73e11550da06fe4337b8e.tar.xz yuzu-ff45c3957858cdf189b73e11550da06fe4337b8e.zip | |
General: Make use of std::nullopt where applicable
Allows some implementations to avoid completely zeroing out the internal
buffer of the optional, and instead only set the validity byte within
the structure.
This also makes it consistent how we return empty optionals.
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/surface_base.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/video_core/texture_cache/surface_base.cpp b/src/video_core/texture_cache/surface_base.cpp index dfcf36e0b..b44c09d71 100644 --- a/src/video_core/texture_cache/surface_base.cpp +++ b/src/video_core/texture_cache/surface_base.cpp | |||
| @@ -115,20 +115,24 @@ std::optional<std::pair<u32, u32>> SurfaceBaseImpl::GetLayerMipmap( | |||
| 115 | if (gpu_addr == candidate_gpu_addr) { | 115 | if (gpu_addr == candidate_gpu_addr) { |
| 116 | return {{0, 0}}; | 116 | return {{0, 0}}; |
| 117 | } | 117 | } |
| 118 | |||
| 118 | if (candidate_gpu_addr < gpu_addr) { | 119 | if (candidate_gpu_addr < gpu_addr) { |
| 119 | return {}; | 120 | return std::nullopt; |
| 120 | } | 121 | } |
| 122 | |||
| 121 | const auto relative_address{static_cast<GPUVAddr>(candidate_gpu_addr - gpu_addr)}; | 123 | const auto relative_address{static_cast<GPUVAddr>(candidate_gpu_addr - gpu_addr)}; |
| 122 | const auto layer{static_cast<u32>(relative_address / layer_size)}; | 124 | const auto layer{static_cast<u32>(relative_address / layer_size)}; |
| 123 | if (layer >= params.depth) { | 125 | if (layer >= params.depth) { |
| 124 | return {}; | 126 | return std::nullopt; |
| 125 | } | 127 | } |
| 128 | |||
| 126 | const GPUVAddr mipmap_address = relative_address - layer_size * layer; | 129 | const GPUVAddr mipmap_address = relative_address - layer_size * layer; |
| 127 | const auto mipmap_it = | 130 | const auto mipmap_it = |
| 128 | Common::BinaryFind(mipmap_offsets.begin(), mipmap_offsets.end(), mipmap_address); | 131 | Common::BinaryFind(mipmap_offsets.begin(), mipmap_offsets.end(), mipmap_address); |
| 129 | if (mipmap_it == mipmap_offsets.end()) { | 132 | if (mipmap_it == mipmap_offsets.end()) { |
| 130 | return {}; | 133 | return std::nullopt; |
| 131 | } | 134 | } |
| 135 | |||
| 132 | const auto level{static_cast<u32>(std::distance(mipmap_offsets.begin(), mipmap_it))}; | 136 | const auto level{static_cast<u32>(std::distance(mipmap_offsets.begin(), mipmap_it))}; |
| 133 | return std::make_pair(layer, level); | 137 | return std::make_pair(layer, level); |
| 134 | } | 138 | } |