diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 65 |
1 files changed, 9 insertions, 56 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 9164d7f34..df2474ea2 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -169,60 +169,10 @@ static void AllocateSurfaceTexture(GLuint texture, const FormatTuple& format_tup | |||
| 169 | static bool BlitTextures(GLuint src_tex, const MathUtil::Rectangle<u32>& src_rect, GLuint dst_tex, | 169 | static bool BlitTextures(GLuint src_tex, const MathUtil::Rectangle<u32>& src_rect, GLuint dst_tex, |
| 170 | const MathUtil::Rectangle<u32>& dst_rect, SurfaceType type, | 170 | const MathUtil::Rectangle<u32>& dst_rect, SurfaceType type, |
| 171 | GLuint read_fb_handle, GLuint draw_fb_handle) { | 171 | GLuint read_fb_handle, GLuint draw_fb_handle) { |
| 172 | OpenGLState state = OpenGLState::GetCurState(); | ||
| 173 | |||
| 174 | OpenGLState prev_state = state; | ||
| 175 | SCOPE_EXIT({ prev_state.Apply(); }); | ||
| 176 | |||
| 177 | // Make sure textures aren't bound to texture units, since going to bind them to framebuffer | ||
| 178 | // components | ||
| 179 | state.ResetTexture(src_tex); | ||
| 180 | state.ResetTexture(dst_tex); | ||
| 181 | |||
| 182 | state.draw.read_framebuffer = read_fb_handle; | ||
| 183 | state.draw.draw_framebuffer = draw_fb_handle; | ||
| 184 | state.Apply(); | ||
| 185 | |||
| 186 | u32 buffers = 0; | ||
| 187 | |||
| 188 | if (type == SurfaceType::ColorTexture) { | ||
| 189 | glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, src_tex, | ||
| 190 | 0); | ||
| 191 | glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, | ||
| 192 | 0); | ||
| 193 | |||
| 194 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex, | ||
| 195 | 0); | ||
| 196 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, | ||
| 197 | 0); | ||
| 198 | |||
| 199 | buffers = GL_COLOR_BUFFER_BIT; | ||
| 200 | } else if (type == SurfaceType::Depth) { | ||
| 201 | glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); | ||
| 202 | glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, src_tex, 0); | ||
| 203 | glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); | ||
| 204 | |||
| 205 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); | ||
| 206 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, dst_tex, 0); | ||
| 207 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); | ||
| 208 | |||
| 209 | buffers = GL_DEPTH_BUFFER_BIT; | ||
| 210 | } else if (type == SurfaceType::DepthStencil) { | ||
| 211 | glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); | ||
| 212 | glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, | ||
| 213 | src_tex, 0); | ||
| 214 | |||
| 215 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); | ||
| 216 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, | ||
| 217 | dst_tex, 0); | ||
| 218 | |||
| 219 | buffers = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; | ||
| 220 | } | ||
| 221 | |||
| 222 | glBlitFramebuffer(src_rect.left, src_rect.bottom, src_rect.right, src_rect.top, dst_rect.left, | ||
| 223 | dst_rect.bottom, dst_rect.right, dst_rect.top, buffers, | ||
| 224 | buffers == GL_COLOR_BUFFER_BIT ? GL_LINEAR : GL_NEAREST); | ||
| 225 | 172 | ||
| 173 | glCopyImageSubData(src_tex, GL_TEXTURE_2D, 0, src_rect.left, src_rect.bottom, 0, dst_tex, | ||
| 174 | GL_TEXTURE_2D, 0, dst_rect.left, dst_rect.bottom, 0, src_rect.GetWidth(), | ||
| 175 | src_rect.GetHeight(), 0); | ||
| 226 | return true; | 176 | return true; |
| 227 | } | 177 | } |
| 228 | 178 | ||
| @@ -1102,16 +1052,19 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextu | |||
| 1102 | 1052 | ||
| 1103 | params.UpdateParams(); | 1053 | params.UpdateParams(); |
| 1104 | 1054 | ||
| 1105 | if (config.tic.Width() % 8 != 0 || config.tic.Height() % 8 != 0 || | 1055 | if (params.GetActualWidth() % 8 != 0 || params.GetActualHeight() % 8 != 0 || |
| 1106 | params.stride != params.width) { | 1056 | params.stride != params.width) { |
| 1107 | Surface src_surface; | 1057 | Surface src_surface; |
| 1108 | MathUtil::Rectangle<u32> rect; | 1058 | MathUtil::Rectangle<u32> rect; |
| 1109 | std::tie(src_surface, rect) = GetSurfaceSubRect(params, ScaleMatch::Ignore, true); | 1059 | std::tie(src_surface, rect) = GetSurfaceSubRect(params, ScaleMatch::Ignore, true); |
| 1110 | 1060 | ||
| 1061 | rect = rect.Scale(params.GetCompresssionFactor()); | ||
| 1062 | |||
| 1111 | params.res_scale = src_surface->res_scale; | 1063 | params.res_scale = src_surface->res_scale; |
| 1112 | Surface tmp_surface = CreateSurface(params); | 1064 | Surface tmp_surface = CreateSurface(params); |
| 1113 | BlitTextures(src_surface->texture.handle, rect, tmp_surface->texture.handle, | 1065 | |
| 1114 | tmp_surface->GetScaledRect(), | 1066 | auto dst_rect = tmp_surface->GetScaledRect().Scale(params.GetCompresssionFactor()); |
| 1067 | BlitTextures(src_surface->texture.handle, rect, tmp_surface->texture.handle, dst_rect, | ||
| 1115 | SurfaceParams::GetFormatType(params.pixel_format), read_framebuffer.handle, | 1068 | SurfaceParams::GetFormatType(params.pixel_format), read_framebuffer.handle, |
| 1116 | draw_framebuffer.handle); | 1069 | draw_framebuffer.handle); |
| 1117 | 1070 | ||