From 84139586c9e6c95a7f3faaa09d04eb11b2bcd70c Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sun, 14 Apr 2019 18:16:27 -0300 Subject: gl_texture_cache: Attach surface textures instead of views --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index cea268f1e..07c28357e 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -83,10 +83,10 @@ struct FramebufferCacheKey { bool stencil_enable = false; std::array color_attachments{}; - std::array colors{}; + std::array colors{}; u32 colors_count = 0; - GLuint zeta = 0; + CachedSurfaceView* zeta = nullptr; auto Tie() const { return std::tie(is_single_buffer, stencil_enable, color_attachments, colors, colors_count, @@ -367,25 +367,21 @@ void RasterizerOpenGL::SetupCachedFramebuffer(const FramebufferCacheKey& fbkey, if (fbkey.is_single_buffer) { if (fbkey.color_attachments[0] != GL_NONE) { - glFramebufferTexture(GL_DRAW_FRAMEBUFFER, fbkey.color_attachments[0], fbkey.colors[0], - 0); + fbkey.colors[0]->Attach(fbkey.color_attachments[0]); } glDrawBuffer(fbkey.color_attachments[0]); } else { for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) { if (fbkey.colors[index]) { - glFramebufferTexture(GL_DRAW_FRAMEBUFFER, - GL_COLOR_ATTACHMENT0 + static_cast(index), - fbkey.colors[index], 0); + fbkey.colors[index]->Attach(GL_COLOR_ATTACHMENT0 + static_cast(index)); } } glDrawBuffers(fbkey.colors_count, fbkey.color_attachments.data()); } if (fbkey.zeta) { - GLenum zeta_attachment = - fbkey.stencil_enable ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT; - glFramebufferTexture(GL_DRAW_FRAMEBUFFER, zeta_attachment, fbkey.zeta, 0); + fbkey.zeta->Attach(fbkey.stencil_enable ? GL_DEPTH_STENCIL_ATTACHMENT + : GL_DEPTH_ATTACHMENT); } } @@ -509,7 +505,7 @@ std::pair RasterizerOpenGL::ConfigureFramebuffers( fbkey.is_single_buffer = true; fbkey.color_attachments[0] = GL_COLOR_ATTACHMENT0 + static_cast(*single_color_target); - fbkey.colors[0] = color_surface != nullptr ? color_surface->GetTexture() : 0; + fbkey.colors[0] = color_surface; } else { // Multiple color attachments are enabled for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) { @@ -529,7 +525,7 @@ std::pair RasterizerOpenGL::ConfigureFramebuffers( fbkey.color_attachments[index] = GL_COLOR_ATTACHMENT0 + regs.rt_control.GetMap(index); - fbkey.colors[index] = color_surface != nullptr ? color_surface->GetTexture() : 0; + fbkey.colors[index] = color_surface; } fbkey.is_single_buffer = false; fbkey.colors_count = regs.rt_control.count; @@ -544,7 +540,7 @@ std::pair RasterizerOpenGL::ConfigureFramebuffers( // the shader doesn't actually write to it. depth_surface->MarkAsModified(true); - fbkey.zeta = depth_surface->GetTexture(); + fbkey.zeta = depth_surface; fbkey.stencil_enable = regs.stencil_enable && depth_surface->GetSurfaceParams().GetType() == SurfaceType::DepthStencil; } -- cgit v1.2.3