summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/texture_cache/surface_base.cpp3
-rw-r--r--src/video_core/texture_cache/surface_base.h25
2 files changed, 24 insertions, 4 deletions
diff --git a/src/video_core/texture_cache/surface_base.cpp b/src/video_core/texture_cache/surface_base.cpp
index 8c6edb04f..97bf9ad7a 100644
--- a/src/video_core/texture_cache/surface_base.cpp
+++ b/src/video_core/texture_cache/surface_base.cpp
@@ -100,6 +100,9 @@ MatchStructureResult SurfaceBaseImpl::MatchesStructure(const SurfaceParams& rhs)
100 100
101std::optional<std::pair<u32, u32>> SurfaceBaseImpl::GetLayerMipmap( 101std::optional<std::pair<u32, u32>> SurfaceBaseImpl::GetLayerMipmap(
102 const GPUVAddr candidate_gpu_addr) const { 102 const GPUVAddr candidate_gpu_addr) const {
103 if (gpu_addr == candidate_gpu_addr) {
104 return {{0,0}};
105 }
103 if (candidate_gpu_addr < gpu_addr) { 106 if (candidate_gpu_addr < gpu_addr) {
104 return {}; 107 return {};
105 } 108 }
diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h
index 58265e9d3..662221adc 100644
--- a/src/video_core/texture_cache/surface_base.h
+++ b/src/video_core/texture_cache/surface_base.h
@@ -238,6 +238,26 @@ public:
238 return GetView(ViewParams(overview_params.target, 0, num_layers, 0, params.num_levels)); 238 return GetView(ViewParams(overview_params.target, 0, num_layers, 0, params.num_levels));
239 } 239 }
240 240
241 std::optional<TView> EmplaceIrregularView(const SurfaceParams& view_params,
242 const GPUVAddr view_addr,
243 const std::size_t candidate_size, const u32 mipmap,
244 const u32 layer) {
245 const auto layer_mipmap{GetLayerMipmap(view_addr + candidate_size)};
246 if (!layer_mipmap) {
247 return {};
248 }
249 const u32 end_layer{layer_mipmap->first};
250 const u32 end_mipmap{layer_mipmap->second};
251 if (layer != end_layer) {
252 if (mipmap == 0 && end_mipmap == 0) {
253 return GetView(ViewParams(view_params.target, layer, end_layer - layer + 1, 0, 1));
254 }
255 return {};
256 } else {
257 return GetView(ViewParams(view_params.target, layer, 1, mipmap, end_mipmap - mipmap + 1));
258 }
259 }
260
241 std::optional<TView> EmplaceView(const SurfaceParams& view_params, const GPUVAddr view_addr, 261 std::optional<TView> EmplaceView(const SurfaceParams& view_params, const GPUVAddr view_addr,
242 const std::size_t candidate_size) { 262 const std::size_t candidate_size) {
243 if (params.target == SurfaceTarget::Texture3D || 263 if (params.target == SurfaceTarget::Texture3D ||
@@ -252,10 +272,7 @@ public:
252 const u32 layer{layer_mipmap->first}; 272 const u32 layer{layer_mipmap->first};
253 const u32 mipmap{layer_mipmap->second}; 273 const u32 mipmap{layer_mipmap->second};
254 if (GetMipmapSize(mipmap) != candidate_size) { 274 if (GetMipmapSize(mipmap) != candidate_size) {
255 // TODO: The view may cover many mimaps, this case can still go on. 275 return EmplaceIrregularView(view_params, view_addr, candidate_size, mipmap, layer);
256 // This edge-case can be safely be ignored since it will just result in worse
257 // performance.
258 return {};
259 } 276 }
260 return GetView(ViewParams(view_params.target, layer, 1, mipmap, 1)); 277 return GetView(ViewParams(view_params.target, layer, 1, mipmap, 1));
261 } 278 }