summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-08-21 01:04:46 -0400
committerGravatar bunnei2018-08-23 11:27:00 -0400
commitebf57683405c12ce7c56d07bed1c040b149ef31f (patch)
tree24df579d43cb9fbc5e694ad69f1f3e9e5a12d2fa /src
parentMerge pull request #1157 from lioncash/vec (diff)
downloadyuzu-ebf57683405c12ce7c56d07bed1c040b149ef31f.tar.gz
yuzu-ebf57683405c12ce7c56d07bed1c040b149ef31f.tar.xz
yuzu-ebf57683405c12ce7c56d07bed1c040b149ef31f.zip
gl_rasterizer_cache: Implement compressed texture copies.
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index b1769c99b..dc582b2df 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -800,8 +800,6 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& surface,
800 // Verify surface is compatible for blitting 800 // Verify surface is compatible for blitting
801 const auto& params{surface->GetSurfaceParams()}; 801 const auto& params{surface->GetSurfaceParams()};
802 ASSERT(params.type == new_params.type); 802 ASSERT(params.type == new_params.type);
803 ASSERT_MSG(params.GetCompressionFactor(params.pixel_format) == 1,
804 "Compressed texture reinterpretation is not supported");
805 803
806 // Create a new surface with the new parameters, and blit the previous surface to it 804 // Create a new surface with the new parameters, and blit the previous surface to it
807 Surface new_surface{std::make_shared<CachedSurface>(new_params)}; 805 Surface new_surface{std::make_shared<CachedSurface>(new_params)};
@@ -818,9 +816,13 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& surface,
818 816
819 glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo.handle); 817 glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo.handle);
820 glBufferData(GL_PIXEL_PACK_BUFFER, buffer_size, nullptr, GL_STREAM_DRAW_ARB); 818 glBufferData(GL_PIXEL_PACK_BUFFER, buffer_size, nullptr, GL_STREAM_DRAW_ARB);
821 glGetTextureImage(surface->Texture().handle, 0, source_format.format, source_format.type, 819 if (source_format.compressed) {
822 params.SizeInBytes(), nullptr); 820 glGetCompressedTextureImage(surface->Texture().handle, 0,
823 821 static_cast<GLsizei>(params.SizeInBytes()), nullptr);
822 } else {
823 glGetTextureImage(surface->Texture().handle, 0, source_format.format, source_format.type,
824 static_cast<GLsizei>(params.SizeInBytes()), nullptr);
825 }
824 // If the new texture is bigger than the previous one, we need to fill in the rest with data 826 // If the new texture is bigger than the previous one, we need to fill in the rest with data
825 // from the CPU. 827 // from the CPU.
826 if (params.SizeInBytes() < new_params.SizeInBytes()) { 828 if (params.SizeInBytes() < new_params.SizeInBytes()) {
@@ -846,9 +848,17 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& surface,
846 const auto& dest_rect{new_params.GetRect()}; 848 const auto& dest_rect{new_params.GetRect()};
847 849
848 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo.handle); 850 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo.handle);
849 glTextureSubImage2D( 851 if (dest_format.compressed) {
850 new_surface->Texture().handle, 0, 0, 0, static_cast<GLsizei>(dest_rect.GetWidth()), 852 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
851 static_cast<GLsizei>(dest_rect.GetHeight()), dest_format.format, dest_format.type, nullptr); 853 static_cast<GLsizei>(dest_rect.GetWidth()),
854 static_cast<GLsizei>(dest_rect.GetHeight()), dest_format.format,
855 static_cast<GLsizei>(new_params.SizeInBytes()), nullptr);
856 } else {
857 glTextureSubImage2D(new_surface->Texture().handle, 0, 0, 0,
858 static_cast<GLsizei>(dest_rect.GetWidth()),
859 static_cast<GLsizei>(dest_rect.GetHeight()), dest_format.format,
860 dest_format.type, nullptr);
861 }
852 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); 862 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
853 863
854 pbo.Release(); 864 pbo.Release();