diff options
| author | 2019-05-07 21:28:31 -0300 | |
|---|---|---|
| committer | 2019-06-20 21:36:12 -0300 | |
| commit | 03d10ea3b420c923c14a11c86b47e2f00bc30e00 (patch) | |
| tree | c91e72f41edadac641a0b2609c05fbdf436ee6d5 /src/video_core/texture_cache | |
| parent | Correct Mipmaps View method in Texture Cache (diff) | |
| download | yuzu-03d10ea3b420c923c14a11c86b47e2f00bc30e00.tar.gz yuzu-03d10ea3b420c923c14a11c86b47e2f00bc30e00.tar.xz yuzu-03d10ea3b420c923c14a11c86b47e2f00bc30e00.zip | |
copy_params: Use constructor instead of C-like initialization
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/copy_params.h | 10 | ||||
| -rw-r--r-- | src/video_core/texture_cache/surface_base.h | 53 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 23 |
3 files changed, 39 insertions, 47 deletions
diff --git a/src/video_core/texture_cache/copy_params.h b/src/video_core/texture_cache/copy_params.h index 75c2b1f05..8cf010142 100644 --- a/src/video_core/texture_cache/copy_params.h +++ b/src/video_core/texture_cache/copy_params.h | |||
| @@ -9,6 +9,16 @@ | |||
| 9 | namespace VideoCommon { | 9 | namespace VideoCommon { |
| 10 | 10 | ||
| 11 | struct CopyParams { | 11 | struct CopyParams { |
| 12 | CopyParams(u32 source_x, u32 source_y, u32 source_z, u32 dest_x, u32 dest_y, u32 dest_z, | ||
| 13 | u32 source_level, u32 dest_level, u32 width, u32 height, u32 depth) | ||
| 14 | : source_x{source_x}, source_y{source_y}, source_z{source_z}, dest_x{dest_x}, | ||
| 15 | dest_y{dest_y}, dest_z{dest_z}, source_level{source_level}, | ||
| 16 | dest_level{dest_level}, width{width}, height{height}, depth{depth} {} | ||
| 17 | |||
| 18 | CopyParams(u32 width, u32 height, u32 depth, u32 level) | ||
| 19 | : source_x{}, source_y{}, source_z{}, dest_x{}, dest_y{}, dest_z{}, source_level{level}, | ||
| 20 | dest_level{level}, width{width}, height{height}, depth{depth} {} | ||
| 21 | |||
| 12 | u32 source_x; | 22 | u32 source_x; |
| 13 | u32 source_y; | 23 | u32 source_y; |
| 14 | u32 source_z; | 24 | u32 source_z; |
diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h index 486585c9c..029cfb055 100644 --- a/src/video_core/texture_cache/surface_base.h +++ b/src/video_core/texture_cache/surface_base.h | |||
| @@ -149,45 +149,32 @@ public: | |||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | std::vector<CopyParams> BreakDown(const SurfaceParams& in_params) const { | 151 | std::vector<CopyParams> BreakDown(const SurfaceParams& in_params) const { |
| 152 | auto set_up_copy = [](CopyParams& cp, const u32 width, const u32 height, const u32 depth, | 152 | std::vector<CopyParams> result; |
| 153 | const u32 level) { | 153 | const u32 layers{params.depth}; |
| 154 | cp.source_x = 0; | 154 | const u32 mipmaps{params.num_levels}; |
| 155 | cp.source_y = 0; | 155 | |
| 156 | cp.source_z = 0; | ||
| 157 | cp.dest_x = 0; | ||
| 158 | cp.dest_y = 0; | ||
| 159 | cp.dest_z = 0; | ||
| 160 | cp.source_level = level; | ||
| 161 | cp.dest_level = level; | ||
| 162 | cp.width = width; | ||
| 163 | cp.height = height; | ||
| 164 | cp.depth = depth; | ||
| 165 | }; | ||
| 166 | const u32 layers = params.depth; | ||
| 167 | const u32 mipmaps = params.num_levels; | ||
| 168 | if (params.is_layered) { | 156 | if (params.is_layered) { |
| 169 | std::vector<CopyParams> result{layers * mipmaps}; | 157 | result.reserve(static_cast<std::size_t>(layers) * static_cast<std::size_t>(mipmaps)); |
| 170 | for (std::size_t layer = 0; layer < layers; layer++) { | 158 | for (u32 layer = 0; layer < layers; layer++) { |
| 171 | const u32 layer_offset = layer * mipmaps; | 159 | const u32 layer_offset{layer * mipmaps}; |
| 172 | for (std::size_t level = 0; level < mipmaps; level++) { | 160 | for (u32 level = 0; level < mipmaps; level++) { |
| 173 | CopyParams& cp = result[layer_offset + level]; | 161 | const u32 width{ |
| 174 | const u32 width = | 162 | std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))}; |
| 175 | std::min(params.GetMipWidth(level), in_params.GetMipWidth(level)); | 163 | const u32 height{ |
| 176 | const u32 height = | 164 | std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))}; |
| 177 | std::min(params.GetMipHeight(level), in_params.GetMipHeight(level)); | 165 | result.emplace_back(width, height, layer, level); |
| 178 | set_up_copy(cp, width, height, layer, level); | ||
| 179 | } | 166 | } |
| 180 | } | 167 | } |
| 181 | return result; | 168 | return result; |
| 169 | |||
| 182 | } else { | 170 | } else { |
| 183 | std::vector<CopyParams> result{mipmaps}; | 171 | result.reserve(mipmaps); |
| 184 | for (std::size_t level = 0; level < mipmaps; level++) { | 172 | for (std::size_t level = 0; level < mipmaps; level++) { |
| 185 | CopyParams& cp = result[level]; | 173 | const u32 width{std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))}; |
| 186 | const u32 width = std::min(params.GetMipWidth(level), in_params.GetMipWidth(level)); | 174 | const u32 height{ |
| 187 | const u32 height = | 175 | std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))}; |
| 188 | std::min(params.GetMipHeight(level), in_params.GetMipHeight(level)); | 176 | const u32 depth{std::min(params.GetMipDepth(level), in_params.GetMipDepth(level))}; |
| 189 | const u32 depth = std::min(params.GetMipDepth(level), in_params.GetMipDepth(level)); | 177 | result.emplace_back(width, height, depth, level); |
| 190 | set_up_copy(cp, width, height, depth, level); | ||
| 191 | } | 178 | } |
| 192 | return result; | 179 | return result; |
| 193 | } | 180 | } |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 43aaec011..c9a648bbd 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -283,7 +283,7 @@ private: | |||
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | std::pair<TSurface, TView> RebuildSurface(TSurface current_surface, | 285 | std::pair<TSurface, TView> RebuildSurface(TSurface current_surface, |
| 286 | const SurfaceParams& params) { | 286 | const SurfaceParams& params) { |
| 287 | const auto gpu_addr = current_surface->GetGpuAddr(); | 287 | const auto gpu_addr = current_surface->GetGpuAddr(); |
| 288 | TSurface new_surface = GetUncachedSurface(gpu_addr, params); | 288 | TSurface new_surface = GetUncachedSurface(gpu_addr, params); |
| 289 | std::vector<CopyParams> bricks = current_surface->BreakDown(params); | 289 | std::vector<CopyParams> bricks = current_surface->BreakDown(params); |
| @@ -323,26 +323,21 @@ private: | |||
| 323 | return {}; | 323 | return {}; |
| 324 | } | 324 | } |
| 325 | const std::size_t candidate_size = src_params.GetGuestSizeInBytes(); | 325 | const std::size_t candidate_size = src_params.GetGuestSizeInBytes(); |
| 326 | auto mipmap_layer = new_surface->GetLayerMipmap(surface->GetGpuAddr()); | 326 | auto mipmap_layer{new_surface->GetLayerMipmap(surface->GetGpuAddr())}; |
| 327 | if (!mipmap_layer) { | 327 | if (!mipmap_layer) { |
| 328 | return {}; | 328 | return {}; |
| 329 | } | 329 | } |
| 330 | const u32 layer = (*mipmap_layer).first; | 330 | const u32 layer{mipmap_layer->first}; |
| 331 | const u32 mipmap = (*mipmap_layer).second; | 331 | const u32 mipmap{mipmap_layer->second}; |
| 332 | if (new_surface->GetMipmapSize(mipmap) != candidate_size) { | 332 | if (new_surface->GetMipmapSize(mipmap) != candidate_size) { |
| 333 | return {}; | 333 | return {}; |
| 334 | } | 334 | } |
| 335 | // Now we got all the data set up | 335 | // Now we got all the data set up |
| 336 | CopyParams copy_params{}; | 336 | const u32 dst_width{params.GetMipWidth(mipmap)}; |
| 337 | const u32 dst_width = params.GetMipWidth(mipmap); | 337 | const u32 dst_height{params.GetMipHeight(mipmap)}; |
| 338 | const u32 dst_height = params.GetMipHeight(mipmap); | 338 | const CopyParams copy_params(0, 0, 0, 0, 0, layer, 0, mipmap, |
| 339 | copy_params.width = std::min(src_params.width, dst_width); | 339 | std::min(src_params.width, dst_width), |
| 340 | copy_params.height = std::min(src_params.height, dst_height); | 340 | std::min(src_params.height, dst_height), 1); |
| 341 | copy_params.depth = 1; | ||
| 342 | copy_params.source_level = 0; | ||
| 343 | copy_params.dest_level = mipmap; | ||
| 344 | copy_params.source_z = 0; | ||
| 345 | copy_params.dest_z = layer; | ||
| 346 | ImageCopy(surface, new_surface, copy_params); | 341 | ImageCopy(surface, new_surface, copy_params); |
| 347 | } | 342 | } |
| 348 | for (auto surface : overlaps) { | 343 | for (auto surface : overlaps) { |