diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-05-08 01:09:34 +0200 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-06-21 02:36:12 +0200 |
commit | 1af4414861fda5cad2549372e65ecda090caf2f8 (patch) | |
tree | 683e4a726b5009d3b39678c8d9fecb4e7a260bf5 | |
parent | Change texture_cache chaching from GPUAddr to CacheAddr (diff) | |
download | yuzu-1af4414861fda5cad2549372e65ecda090caf2f8.tar yuzu-1af4414861fda5cad2549372e65ecda090caf2f8.tar.gz yuzu-1af4414861fda5cad2549372e65ecda090caf2f8.tar.bz2 yuzu-1af4414861fda5cad2549372e65ecda090caf2f8.tar.lz yuzu-1af4414861fda5cad2549372e65ecda090caf2f8.tar.xz yuzu-1af4414861fda5cad2549372e65ecda090caf2f8.tar.zst yuzu-1af4414861fda5cad2549372e65ecda090caf2f8.zip |
-rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 44 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 12 | ||||
-rw-r--r-- | src/video_core/texture_cache/surface_base.h | 5 |
3 files changed, 29 insertions, 32 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 871608f6d..575608266 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp @@ -233,7 +233,8 @@ CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& param main.num_layers = params.is_layered ? params.depth : 1; main.target = params.target; main_view = CreateView(main); - main_view->DecorateViewName(gpu_addr, params.TargetName() + "V:" + std::to_string(view_count++)); + main_view->DecorateViewName(gpu_addr, + params.TargetName() + "V:" + std::to_string(view_count++)); } CachedSurface::~CachedSurface() { @@ -350,7 +351,7 @@ void CachedSurface::DecorateSurfaceName() { } void CachedSurfaceView::DecorateViewName(GPUVAddr gpu_addr, std::string prefix) { - LabelGLObject(GL_TEXTURE, texture_view.texture.handle, gpu_addr, prefix); + LabelGLObject(GL_TEXTURE, texture_view.handle, gpu_addr, prefix); } View CachedSurface::CreateView(const ViewParams& view_key) { @@ -364,6 +365,7 @@ CachedSurfaceView::CachedSurfaceView(CachedSurface& surface, const ViewParams& p : VideoCommon::ViewBase(params), surface{surface} { target = GetTextureTarget(params.target); texture_view = CreateTextureView(); + swizzle = EncodeSwizzle(SwizzleSource::R, SwizzleSource::G, SwizzleSource::B, SwizzleSource::A); } CachedSurfaceView::~CachedSurfaceView() = default; @@ -371,20 +373,24 @@ CachedSurfaceView::~CachedSurfaceView() = default; void CachedSurfaceView::Attach(GLenum attachment) const { ASSERT(params.num_layers == 1 && params.num_levels == 1); - switch (params.target) { + const auto& owner_params = surface.GetSurfaceParams(); + + switch (owner_params.target) { case SurfaceTarget::Texture1D: - glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, attachment, target, - surface.GetTexture(), params.base_level); + glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(), + surface.GetTexture(), + params.base_level); break; case SurfaceTarget::Texture2D: - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, target, - surface.GetTexture(), params.base_level); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(), + surface.GetTexture(), + params.base_level); break; case SurfaceTarget::Texture1DArray: case SurfaceTarget::Texture2DArray: case SurfaceTarget::TextureCubemap: case SurfaceTarget::TextureCubeArray: - glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, attachment, target, + glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTexture(), params.base_level, params.base_layer); break; default: @@ -394,22 +400,22 @@ void CachedSurfaceView::Attach(GLenum attachment) const { void CachedSurfaceView::ApplySwizzle(SwizzleSource x_source, SwizzleSource y_source, SwizzleSource z_source, SwizzleSource w_source) { - u32 swizzle = EncodeSwizzle(x_source, y_source, z_source, w_source); - if (swizzle == texture_view.swizzle) + u32 new_swizzle = EncodeSwizzle(x_source, y_source, z_source, w_source); + if (new_swizzle == swizzle) return; + swizzle = new_swizzle; const std::array<GLint, 4> gl_swizzle = {GetSwizzleSource(x_source), GetSwizzleSource(y_source), GetSwizzleSource(z_source), GetSwizzleSource(w_source)}; - glTextureParameteriv(texture_view.texture.handle, GL_TEXTURE_SWIZZLE_RGBA, gl_swizzle.data()); - texture_view.swizzle = swizzle; + glTextureParameteriv(texture_view.handle, GL_TEXTURE_SWIZZLE_RGBA, gl_swizzle.data()); } -CachedSurfaceView::TextureView CachedSurfaceView::CreateTextureView() const { +OGLTextureView CachedSurfaceView::CreateTextureView() const { const auto& owner_params = surface.GetSurfaceParams(); - TextureView texture_view; - texture_view.texture.Create(); + OGLTextureView tv; + tv.Create(); - const GLuint handle{texture_view.texture.handle}; + const GLuint handle{tv.handle}; const FormatTuple& tuple{ GetFormatTuple(owner_params.pixel_format, owner_params.component_type)}; @@ -418,11 +424,7 @@ CachedSurfaceView::TextureView CachedSurfaceView::CreateTextureView() const { ApplyTextureDefaults(owner_params, handle); - u32 swizzle = - EncodeSwizzle(SwizzleSource::R, SwizzleSource::G, SwizzleSource::B, SwizzleSource::A); - texture_view.swizzle = swizzle; - - return texture_view; + return tv; } TextureCacheOpenGL::TextureCacheOpenGL(Core::System& system, diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 1722c1bbc..083b5406b 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h @@ -74,7 +74,7 @@ public: void Attach(GLenum attachment) const; GLuint GetTexture() { - return texture_view.texture.handle; + return texture_view.handle; } const SurfaceParams& GetSurfaceParams() const { @@ -104,11 +104,6 @@ public: void DecorateViewName(GPUVAddr gpu_addr, std::string prefix); private: - struct TextureView { - OGLTextureView texture; - u32 swizzle; - }; - u32 EncodeSwizzle(Tegra::Texture::SwizzleSource x_source, Tegra::Texture::SwizzleSource y_source, Tegra::Texture::SwizzleSource z_source, @@ -117,12 +112,13 @@ private: (static_cast<u32>(z_source) << 8) | static_cast<u32>(w_source); } - TextureView CreateTextureView() const; + OGLTextureView CreateTextureView() const; CachedSurface& surface; GLenum target{}; - TextureView texture_view; + OGLTextureView texture_view; + u32 swizzle; }; class TextureCacheOpenGL final : public TextureCacheBase { diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h index 74be3237d..486585c9c 100644 --- a/src/video_core/texture_cache/surface_base.h +++ b/src/video_core/texture_cache/surface_base.h @@ -282,8 +282,7 @@ public: return {}; } const std::size_t size = view_params.GetGuestSizeInBytes(); - const GPUVAddr relative_address = view_addr - gpu_addr; - auto layer_mipmap = GetLayerMipmap(relative_address); + auto layer_mipmap = GetLayerMipmap(view_addr); if (!layer_mipmap) { return {}; } @@ -298,7 +297,7 @@ public: vp.num_layers = 1; vp.base_level = mipmap; vp.num_levels = 1; - vp.target = params.target; + vp.target = view_params.target; return {GetView(vp)}; } |