summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp23
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.h16
2 files changed, 18 insertions, 21 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 2f7d98d8b..85a02d859 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -538,7 +538,7 @@ void TextureCacheRuntime::EmulateCopyImage(Image& dst, Image& src,
538 ASSERT(src.info.type == ImageType::e3D); 538 ASSERT(src.info.type == ImageType::e3D);
539 util_shaders.CopyBC4(dst, src, copies); 539 util_shaders.CopyBC4(dst, src, copies);
540 } else if (IsPixelFormatBGR(dst.info.format) || IsPixelFormatBGR(src.info.format)) { 540 } else if (IsPixelFormatBGR(dst.info.format) || IsPixelFormatBGR(src.info.format)) {
541 bgr_copy_pass.CopyBGR(dst, src, copies); 541 format_conversion_pass.ConvertImage(dst, src, copies);
542 } else { 542 } else {
543 UNREACHABLE(); 543 UNREACHABLE();
544 } 544 }
@@ -1286,32 +1286,29 @@ Framebuffer::Framebuffer(TextureCacheRuntime& runtime, std::span<ImageView*, NUM
1286 1286
1287Framebuffer::~Framebuffer() = default; 1287Framebuffer::~Framebuffer() = default;
1288 1288
1289void BGRCopyPass::CopyBGR(Image& dst_image, Image& src_image, 1289void FormatConversionPass::ConvertImage(Image& dst_image, Image& src_image,
1290 std::span<const VideoCommon::ImageCopy> copies) { 1290 std::span<const VideoCommon::ImageCopy> copies) {
1291 static constexpr VideoCommon::Offset3D zero_offset{0, 0, 0};
1292 const u32 img_bpp = BytesPerBlock(src_image.info.format); 1291 const u32 img_bpp = BytesPerBlock(src_image.info.format);
1293 for (const ImageCopy& copy : copies) { 1292 for (const ImageCopy& copy : copies) {
1294 ASSERT(copy.src_offset == zero_offset);
1295 ASSERT(copy.dst_offset == zero_offset);
1296 const u32 num_src_layers = static_cast<u32>(copy.src_subresource.num_layers); 1293 const u32 num_src_layers = static_cast<u32>(copy.src_subresource.num_layers);
1297 const u32 copy_size = copy.extent.width * copy.extent.height * num_src_layers * img_bpp; 1294 const u32 copy_size = copy.extent.width * copy.extent.height * num_src_layers * img_bpp;
1298 if (bgr_pbo_size < copy_size) { 1295 if (pbo_size < copy_size) {
1299 bgr_pbo.Create(); 1296 intermediate_pbo.Create();
1300 bgr_pbo_size = copy_size; 1297 pbo_size = copy_size;
1301 glNamedBufferData(bgr_pbo.handle, bgr_pbo_size, nullptr, GL_STREAM_COPY); 1298 glNamedBufferData(intermediate_pbo.handle, pbo_size, nullptr, GL_STREAM_COPY);
1302 } 1299 }
1303 // Copy from source to PBO 1300 // Copy from source to PBO
1304 glPixelStorei(GL_PACK_ALIGNMENT, 1); 1301 glPixelStorei(GL_PACK_ALIGNMENT, 1);
1305 glPixelStorei(GL_PACK_ROW_LENGTH, copy.extent.width); 1302 glPixelStorei(GL_PACK_ROW_LENGTH, copy.extent.width);
1306 glBindBuffer(GL_PIXEL_PACK_BUFFER, bgr_pbo.handle); 1303 glBindBuffer(GL_PIXEL_PACK_BUFFER, intermediate_pbo.handle);
1307 glGetTextureSubImage(src_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, 1304 glGetTextureSubImage(src_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height,
1308 num_src_layers, src_image.GlFormat(), src_image.GlType(), 1305 num_src_layers, src_image.GlFormat(), src_image.GlType(),
1309 static_cast<GLsizei>(bgr_pbo_size), nullptr); 1306 static_cast<GLsizei>(pbo_size), nullptr);
1310 1307
1311 // Copy from PBO to destination in desired GL format 1308 // Copy from PBO to destination in desired GL format
1312 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 1309 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1313 glPixelStorei(GL_UNPACK_ROW_LENGTH, copy.extent.width); 1310 glPixelStorei(GL_UNPACK_ROW_LENGTH, copy.extent.width);
1314 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, bgr_pbo.handle); 1311 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, intermediate_pbo.handle);
1315 glTextureSubImage3D(dst_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, 1312 glTextureSubImage3D(dst_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height,
1316 copy.dst_subresource.num_layers, dst_image.GlFormat(), 1313 copy.dst_subresource.num_layers, dst_image.GlFormat(),
1317 dst_image.GlType(), nullptr); 1314 dst_image.GlType(), nullptr);
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h
index 1bb762568..b89c183a9 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.h
+++ b/src/video_core/renderer_opengl/gl_texture_cache.h
@@ -52,17 +52,17 @@ struct FormatProperties {
52 bool is_compressed; 52 bool is_compressed;
53}; 53};
54 54
55class BGRCopyPass { 55class FormatConversionPass {
56public: 56public:
57 BGRCopyPass() = default; 57 FormatConversionPass() = default;
58 ~BGRCopyPass() = default; 58 ~FormatConversionPass() = default;
59 59
60 void CopyBGR(Image& dst_image, Image& src_image, 60 void ConvertImage(Image& dst_image, Image& src_image,
61 std::span<const VideoCommon::ImageCopy> copies); 61 std::span<const VideoCommon::ImageCopy> copies);
62 62
63private: 63private:
64 OGLBuffer bgr_pbo; 64 OGLBuffer intermediate_pbo;
65 size_t bgr_pbo_size{}; 65 size_t pbo_size{};
66}; 66};
67 67
68class TextureCacheRuntime { 68class TextureCacheRuntime {
@@ -144,7 +144,7 @@ private:
144 const Device& device; 144 const Device& device;
145 StateTracker& state_tracker; 145 StateTracker& state_tracker;
146 UtilShaders util_shaders; 146 UtilShaders util_shaders;
147 BGRCopyPass bgr_copy_pass; 147 FormatConversionPass format_conversion_pass;
148 148
149 std::array<std::unordered_map<GLenum, FormatProperties>, 3> format_properties; 149 std::array<std::unordered_map<GLenum, FormatProperties>, 3> format_properties;
150 bool has_broken_texture_view_formats = false; 150 bool has_broken_texture_view_formats = false;