summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp44
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.h12
2 files changed, 27 insertions, 29 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 {