summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-05-08 03:03:33 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-06-21 02:36:12 +0200
commit549fd18ac44c6bcefdf6584484d775f0129e3fe3 (patch)
tree2b5db68561fb1b31dc143686b2fea3f2359d4629 /src/video_core
parentsurface_base: Split BreakDown into layered and non-layered variants (diff)
downloadyuzu-549fd18ac44c6bcefdf6584484d775f0129e3fe3.tar
yuzu-549fd18ac44c6bcefdf6584484d775f0129e3fe3.tar.gz
yuzu-549fd18ac44c6bcefdf6584484d775f0129e3fe3.tar.bz2
yuzu-549fd18ac44c6bcefdf6584484d775f0129e3fe3.tar.lz
yuzu-549fd18ac44c6bcefdf6584484d775f0129e3fe3.tar.xz
yuzu-549fd18ac44c6bcefdf6584484d775f0129e3fe3.tar.zst
yuzu-549fd18ac44c6bcefdf6584484d775f0129e3fe3.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp15
-rw-r--r--src/video_core/texture_cache/surface_base.h39
-rw-r--r--src/video_core/texture_cache/surface_view.h8
3 files changed, 23 insertions, 39 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 575608266..c6990ad21 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -226,13 +226,8 @@ CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& param
target = GetTextureTarget(params.target);
texture = CreateTexture(params, target, internal_format);
DecorateSurfaceName();
- ViewParams main{};
- main.num_levels = params.num_levels;
- main.base_level = 0;
- main.base_layer = 0;
- main.num_layers = params.is_layered ? params.depth : 1;
- main.target = params.target;
- main_view = CreateView(main);
+ main_view = CreateView(
+ ViewParams(params.target, 0, params.is_layered ? params.depth : 1, 0, params.num_levels));
main_view->DecorateViewName(gpu_addr,
params.TargetName() + "V:" + std::to_string(view_count++));
}
@@ -378,13 +373,11 @@ void CachedSurfaceView::Attach(GLenum attachment) const {
switch (owner_params.target) {
case SurfaceTarget::Texture1D:
glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(),
- surface.GetTexture(),
- params.base_level);
+ surface.GetTexture(), params.base_level);
break;
case SurfaceTarget::Texture2D:
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(),
- surface.GetTexture(),
- params.base_level);
+ surface.GetTexture(), params.base_level);
break;
case SurfaceTarget::Texture1DArray:
case SurfaceTarget::Texture2DArray:
diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h
index 0cfb835d9..f469ab498 100644
--- a/src/video_core/texture_cache/surface_base.h
+++ b/src/video_core/texture_cache/surface_base.h
@@ -253,45 +253,30 @@ public:
}
TView EmplaceOverview(const SurfaceParams& overview_params) {
- ViewParams vp{};
- vp.base_level = 0;
- vp.num_levels = params.num_levels;
- vp.target = overview_params.target;
- if (params.is_layered && !overview_params.is_layered) {
- vp.base_layer = 0;
- vp.num_layers = 1;
- } else {
- vp.base_layer = 0;
- vp.num_layers = params.depth;
- }
- return GetView(vp);
+ const u32 num_layers{params.is_layered && !overview_params.is_layered ? 1 : params.depth};
+ const ViewParams view_params(overview_params.target, 0, num_layers, 0, params.num_levels);
+ return GetView(view_params);
}
std::optional<TView> EmplaceView(const SurfaceParams& view_params, const GPUVAddr view_addr) {
- if (view_addr < gpu_addr)
- return {};
- if (params.target == SurfaceTarget::Texture3D ||
+ if (view_addr < gpu_addr || params.target == SurfaceTarget::Texture3D ||
view_params.target == SurfaceTarget::Texture3D) {
return {};
}
- const std::size_t size = view_params.GetGuestSizeInBytes();
- auto layer_mipmap = GetLayerMipmap(view_addr);
+ const std::size_t size{view_params.GetGuestSizeInBytes()};
+ const auto layer_mipmap{GetLayerMipmap(view_addr)};
if (!layer_mipmap) {
return {};
}
- const u32 layer = (*layer_mipmap).first;
- const u32 mipmap = (*layer_mipmap).second;
+ const u32 layer{layer_mipmap->first};
+ const u32 mipmap{layer_mipmap->second};
if (GetMipmapSize(mipmap) != size) {
- // TODO: the view may cover many mimaps, this case can still go on
+ // TODO: The view may cover many mimaps, this case can still go on.
+ // This edge-case can be safely be ignored since it will just result in worse
+ // performance.
return {};
}
- ViewParams vp{};
- vp.base_layer = layer;
- vp.num_layers = 1;
- vp.base_level = mipmap;
- vp.num_levels = 1;
- vp.target = view_params.target;
- return {GetView(vp)};
+ return GetView(ViewParams(params.target, layer, 1, mipmap, 1));
}
TView GetMainView() const {
diff --git a/src/video_core/texture_cache/surface_view.h b/src/video_core/texture_cache/surface_view.h
index c122800a6..1ef4509ce 100644
--- a/src/video_core/texture_cache/surface_view.h
+++ b/src/video_core/texture_cache/surface_view.h
@@ -13,15 +13,21 @@
namespace VideoCommon {
struct ViewParams {
+ ViewParams(VideoCore::Surface::SurfaceTarget target, u32 base_layer, u32 num_layers,
+ u32 base_level, u32 num_levels)
+ : target{target}, base_layer{base_layer}, num_layers{num_layers}, base_level{base_level},
+ num_levels{num_levels} {}
+
std::size_t Hash() const;
bool operator==(const ViewParams& rhs) const;
+ VideoCore::Surface::SurfaceTarget target{};
u32 base_layer{};
u32 num_layers{};
u32 base_level{};
u32 num_levels{};
- VideoCore::Surface::SurfaceTarget target;
+
bool IsLayered() const {
switch (target) {
case VideoCore::Surface::SurfaceTarget::Texture1DArray: