diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 85a02d859..3bfd82cf0 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -1288,10 +1288,14 @@ Framebuffer::~Framebuffer() = default; | |||
| 1288 | 1288 | ||
| 1289 | void FormatConversionPass::ConvertImage(Image& dst_image, Image& src_image, | 1289 | void FormatConversionPass::ConvertImage(Image& dst_image, Image& src_image, |
| 1290 | std::span<const VideoCommon::ImageCopy> copies) { | 1290 | std::span<const VideoCommon::ImageCopy> copies) { |
| 1291 | const GLenum dst_target = ImageTarget(dst_image.info); | ||
| 1292 | const GLenum src_target = ImageTarget(src_image.info); | ||
| 1291 | const u32 img_bpp = BytesPerBlock(src_image.info.format); | 1293 | const u32 img_bpp = BytesPerBlock(src_image.info.format); |
| 1292 | for (const ImageCopy& copy : copies) { | 1294 | for (const ImageCopy& copy : copies) { |
| 1293 | const u32 num_src_layers = static_cast<u32>(copy.src_subresource.num_layers); | 1295 | const auto src_origin = MakeCopyOrigin(copy.src_offset, copy.src_subresource, src_target); |
| 1294 | const u32 copy_size = copy.extent.width * copy.extent.height * num_src_layers * img_bpp; | 1296 | const auto dst_origin = MakeCopyOrigin(copy.dst_offset, copy.dst_subresource, dst_target); |
| 1297 | const auto region = MakeCopyRegion(copy.extent, copy.dst_subresource, dst_target); | ||
| 1298 | const u32 copy_size = region.width * region.height * region.depth * img_bpp; | ||
| 1295 | if (pbo_size < copy_size) { | 1299 | if (pbo_size < copy_size) { |
| 1296 | intermediate_pbo.Create(); | 1300 | intermediate_pbo.Create(); |
| 1297 | pbo_size = copy_size; | 1301 | pbo_size = copy_size; |
| @@ -1301,17 +1305,18 @@ void FormatConversionPass::ConvertImage(Image& dst_image, Image& src_image, | |||
| 1301 | glPixelStorei(GL_PACK_ALIGNMENT, 1); | 1305 | glPixelStorei(GL_PACK_ALIGNMENT, 1); |
| 1302 | glPixelStorei(GL_PACK_ROW_LENGTH, copy.extent.width); | 1306 | glPixelStorei(GL_PACK_ROW_LENGTH, copy.extent.width); |
| 1303 | glBindBuffer(GL_PIXEL_PACK_BUFFER, intermediate_pbo.handle); | 1307 | glBindBuffer(GL_PIXEL_PACK_BUFFER, intermediate_pbo.handle); |
| 1304 | glGetTextureSubImage(src_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, | 1308 | glGetTextureSubImage(src_image.Handle(), src_origin.level, src_origin.x, src_origin.y, |
| 1305 | num_src_layers, src_image.GlFormat(), src_image.GlType(), | 1309 | src_origin.z, region.width, region.height, region.depth, |
| 1310 | src_image.GlFormat(), src_image.GlType(), | ||
| 1306 | static_cast<GLsizei>(pbo_size), nullptr); | 1311 | static_cast<GLsizei>(pbo_size), nullptr); |
| 1307 | 1312 | ||
| 1308 | // Copy from PBO to destination in desired GL format | 1313 | // Copy from PBO to destination in desired GL format |
| 1309 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | 1314 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 1310 | glPixelStorei(GL_UNPACK_ROW_LENGTH, copy.extent.width); | 1315 | glPixelStorei(GL_UNPACK_ROW_LENGTH, copy.extent.width); |
| 1311 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, intermediate_pbo.handle); | 1316 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, intermediate_pbo.handle); |
| 1312 | glTextureSubImage3D(dst_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, | 1317 | glTextureSubImage3D(dst_image.Handle(), dst_origin.level, dst_origin.x, dst_origin.y, |
| 1313 | copy.dst_subresource.num_layers, dst_image.GlFormat(), | 1318 | dst_origin.z, region.width, region.height, region.depth, |
| 1314 | dst_image.GlType(), nullptr); | 1319 | dst_image.GlFormat(), dst_image.GlType(), nullptr); |
| 1315 | } | 1320 | } |
| 1316 | } | 1321 | } |
| 1317 | 1322 | ||