diff options
| author | 2018-06-06 23:25:24 -0500 | |
|---|---|---|
| committer | 2018-06-06 23:25:24 -0500 | |
| commit | 218a08df9328993f90a2807b0afc3a53357eec2a (patch) | |
| tree | 4b84b0f1639853bdbf9cae1bf9f4bf13d76700ff | |
| parent | Merge pull request #534 from Subv/multitexturing (diff) | |
| download | yuzu-218a08df9328993f90a2807b0afc3a53357eec2a.tar.gz yuzu-218a08df9328993f90a2807b0afc3a53357eec2a.tar.xz yuzu-218a08df9328993f90a2807b0afc3a53357eec2a.zip | |
GLCache: Simplify the logic to copy from one texture to another in BlitTextures.
We now use glCopyImageSubData, this should avoid errors with trying to attach a compressed texture as a framebuffer's color attachment and then blitting to it.
Maybe in the future we can change this to glCopyTextureSubImage which only requires GL_ARB_direct_state_access.
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 56 |
1 files changed, 3 insertions, 53 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..c860485c3 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 | ||