diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-05-26 07:17:17 +0200 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-05-26 22:50:08 +0200 |
commit | b17fe82973009cc204a298bf8c345ea6eec37a17 (patch) | |
tree | 543ae26fad2f4198f7682b44086b8dc6338f8ea0 /src/video_core/renderer_opengl/gl_texture_cache.cpp | |
parent | texture_cache: Implement depth stencil texture swizzles (diff) | |
download | yuzu-b17fe82973009cc204a298bf8c345ea6eec37a17.tar yuzu-b17fe82973009cc204a298bf8c345ea6eec37a17.tar.gz yuzu-b17fe82973009cc204a298bf8c345ea6eec37a17.tar.bz2 yuzu-b17fe82973009cc204a298bf8c345ea6eec37a17.tar.lz yuzu-b17fe82973009cc204a298bf8c345ea6eec37a17.tar.xz yuzu-b17fe82973009cc204a298bf8c345ea6eec37a17.tar.zst yuzu-b17fe82973009cc204a298bf8c345ea6eec37a17.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 7e0ffe3cd..4faa8b90c 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp @@ -35,7 +35,7 @@ MICROPROFILE_DEFINE(OpenGL_Texture_Buffer_Copy, "OpenGL", "Texture Buffer Copy", namespace { struct FormatTuple { - GLint internal_format; + GLenum internal_format; GLenum format = GL_NONE; GLenum type = GL_NONE; }; @@ -387,7 +387,7 @@ void CachedSurface::DecorateSurfaceName() { } void CachedSurfaceView::DecorateViewName(GPUVAddr gpu_addr, std::string prefix) { - LabelGLObject(GL_TEXTURE, texture_view.handle, gpu_addr, prefix); + LabelGLObject(GL_TEXTURE, main_view.handle, gpu_addr, prefix); } View CachedSurface::CreateView(const ViewParams& view_key) { @@ -403,15 +403,13 @@ View CachedSurface::CreateViewInner(const ViewParams& view_key, const bool is_pr } CachedSurfaceView::CachedSurfaceView(CachedSurface& surface, const ViewParams& params, - const bool is_proxy) - : VideoCommon::ViewBase(params), surface{surface}, is_proxy{is_proxy} { - target = GetTextureTarget(params.target); - format = GetFormatTuple(surface.GetSurfaceParams().pixel_format).internal_format; + bool is_proxy) + : VideoCommon::ViewBase(params), surface{surface}, + format{GetFormatTuple(surface.GetSurfaceParams().pixel_format).internal_format}, + target{GetTextureTarget(params.target)}, is_proxy{is_proxy} { if (!is_proxy) { - texture_view = CreateTextureView(); + main_view = CreateTextureView(); } - current_swizzle = - EncodeSwizzle(SwizzleSource::R, SwizzleSource::G, SwizzleSource::B, SwizzleSource::A); } CachedSurfaceView::~CachedSurfaceView() = default; @@ -454,23 +452,34 @@ void CachedSurfaceView::Attach(GLenum attachment, GLenum target) const { } } -void CachedSurfaceView::ApplySwizzle(SwizzleSource x_source, SwizzleSource y_source, +GLuint CachedSurfaceView::GetTexture(SwizzleSource x_source, SwizzleSource y_source, SwizzleSource z_source, SwizzleSource w_source) { + if (GetSurfaceParams().IsBuffer()) { + return GetTexture(); + } const u32 new_swizzle = EncodeSwizzle(x_source, y_source, z_source, w_source); if (current_swizzle == new_swizzle) { - return; + return current_view; } current_swizzle = new_swizzle; + const auto [entry, is_cache_miss] = view_cache.try_emplace(new_swizzle); + OGLTextureView& view = entry->second; + if (!is_cache_miss) { + current_view = view.handle; + return view.handle; + } + view = CreateTextureView(); + current_view = view.handle; + std::array swizzle{x_source, y_source, z_source, w_source}; - const GLuint handle = GetTexture(); - switch (const PixelFormat format = surface.GetSurfaceParams().pixel_format) { - case PixelFormat::S8Z24: + switch (const PixelFormat format = GetSurfaceParams().pixel_format) { case PixelFormat::Z24S8: case PixelFormat::Z32FS8: + case PixelFormat::S8Z24: UNIMPLEMENTED_IF(x_source != SwizzleSource::R && x_source != SwizzleSource::G); - glTextureParameteri(handle, GL_DEPTH_STENCIL_TEXTURE_MODE, + glTextureParameteri(view.handle, GL_DEPTH_STENCIL_TEXTURE_MODE, GetComponent(format, x_source == SwizzleSource::R)); // Make sure we sample the first component @@ -481,10 +490,11 @@ void CachedSurfaceView::ApplySwizzle(SwizzleSource x_source, SwizzleSource y_sou default: { const std::array gl_swizzle = {GetSwizzleSource(swizzle[0]), GetSwizzleSource(swizzle[1]), GetSwizzleSource(swizzle[2]), GetSwizzleSource(swizzle[3])}; - glTextureParameteriv(handle, GL_TEXTURE_SWIZZLE_RGBA, gl_swizzle.data()); + glTextureParameteriv(view.handle, GL_TEXTURE_SWIZZLE_RGBA, gl_swizzle.data()); break; } } + return view.handle; } OGLTextureView CachedSurfaceView::CreateTextureView() const { |