summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp42
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h2
2 files changed, 39 insertions, 5 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index b77768c79..126dcbbb3 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -125,6 +125,9 @@ std::size_t SurfaceParams::InnerMemorySize(bool force_gl, bool layer_only,
125 125
126 params.width = Common::AlignUp(config.tic.Width(), GetCompressionFactor(params.pixel_format)); 126 params.width = Common::AlignUp(config.tic.Width(), GetCompressionFactor(params.pixel_format));
127 params.height = Common::AlignUp(config.tic.Height(), GetCompressionFactor(params.pixel_format)); 127 params.height = Common::AlignUp(config.tic.Height(), GetCompressionFactor(params.pixel_format));
128 if (!params.is_tiled) {
129 params.pitch = config.tic.Pitch();
130 }
128 params.unaligned_height = config.tic.Height(); 131 params.unaligned_height = config.tic.Height();
129 params.target = SurfaceTargetFromTextureType(config.tic.texture_type); 132 params.target = SurfaceTargetFromTextureType(config.tic.texture_type);
130 params.identity = SurfaceClass::Uploaded; 133 params.identity = SurfaceClass::Uploaded;
@@ -191,7 +194,13 @@ std::size_t SurfaceParams::InnerMemorySize(bool force_gl, bool layer_only,
191 config.format == Tegra::RenderTargetFormat::RGBA8_SRGB; 194 config.format == Tegra::RenderTargetFormat::RGBA8_SRGB;
192 params.component_type = ComponentTypeFromRenderTarget(config.format); 195 params.component_type = ComponentTypeFromRenderTarget(config.format);
193 params.type = GetFormatType(params.pixel_format); 196 params.type = GetFormatType(params.pixel_format);
194 params.width = config.width; 197 if (params.is_tiled) {
198 params.width = config.width;
199 } else {
200 params.pitch = config.width;
201 const u32 bpp = params.GetFormatBpp() / 8;
202 params.width = params.pitch / bpp;
203 }
195 params.height = config.height; 204 params.height = config.height;
196 params.unaligned_height = config.height; 205 params.unaligned_height = config.height;
197 params.target = SurfaceTarget::Texture2D; 206 params.target = SurfaceTarget::Texture2D;
@@ -688,9 +697,20 @@ void CachedSurface::LoadGLBuffer() {
688 for (u32 i = 0; i < params.max_mip_level; i++) 697 for (u32 i = 0; i < params.max_mip_level; i++)
689 SwizzleFunc(MortonSwizzleMode::MortonToLinear, params, gl_buffer[i], i); 698 SwizzleFunc(MortonSwizzleMode::MortonToLinear, params, gl_buffer[i], i);
690 } else { 699 } else {
691 const auto texture_src_data{Memory::GetPointer(params.addr)}; 700 const u32 bpp = params.GetFormatBpp() / 8;
692 const auto texture_src_data_end{texture_src_data + params.size_in_bytes_gl}; 701 const u32 copy_size = params.width * bpp;
693 gl_buffer[0].assign(texture_src_data, texture_src_data_end); 702 if (params.pitch == copy_size) {
703 std::memcpy(gl_buffer[0].data(), Memory::GetPointer(params.addr),
704 params.size_in_bytes_gl);
705 } else {
706 const u8* start = Memory::GetPointer(params.addr);
707 u8* write_to = gl_buffer[0].data();
708 for (u32 h = params.height; h > 0; h--) {
709 std::memcpy(write_to, start, copy_size);
710 start += params.pitch;
711 write_to += copy_size;
712 }
713 }
694 } 714 }
695 for (u32 i = 0; i < params.max_mip_level; i++) { 715 for (u32 i = 0; i < params.max_mip_level; i++) {
696 ConvertFormatAsNeeded_LoadGLBuffer(gl_buffer[i], params.pixel_format, params.MipWidth(i), 716 ConvertFormatAsNeeded_LoadGLBuffer(gl_buffer[i], params.pixel_format, params.MipWidth(i),
@@ -727,7 +747,19 @@ void CachedSurface::FlushGLBuffer() {
727 747
728 SwizzleFunc(MortonSwizzleMode::LinearToMorton, params, gl_buffer[0], 0); 748 SwizzleFunc(MortonSwizzleMode::LinearToMorton, params, gl_buffer[0], 0);
729 } else { 749 } else {
730 std::memcpy(Memory::GetPointer(GetAddr()), gl_buffer[0].data(), GetSizeInBytes()); 750 const u32 bpp = params.GetFormatBpp() / 8;
751 const u32 copy_size = params.width * bpp;
752 if (params.pitch == copy_size) {
753 std::memcpy(Memory::GetPointer(params.addr), gl_buffer[0].data(), GetSizeInBytes());
754 } else {
755 u8* start = Memory::GetPointer(params.addr);
756 const u8* read_to = gl_buffer[0].data();
757 for (u32 h = params.height; h > 0; h--) {
758 std::memcpy(start, read_to, copy_size);
759 start += params.pitch;
760 read_to += copy_size;
761 }
762 }
731 } 763 }
732} 764}
733 765
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 490b8252e..49ff99e2f 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -8,6 +8,7 @@
8#include <map> 8#include <map>
9#include <memory> 9#include <memory>
10#include <string> 10#include <string>
11#include <unordered_set>
11#include <vector> 12#include <vector>
12 13
13#include "common/alignment.h" 14#include "common/alignment.h"
@@ -272,6 +273,7 @@ struct SurfaceParams {
272 u32 height; 273 u32 height;
273 u32 depth; 274 u32 depth;
274 u32 unaligned_height; 275 u32 unaligned_height;
276 u32 pitch;
275 SurfaceTarget target; 277 SurfaceTarget target;
276 SurfaceClass identity; 278 SurfaceClass identity;
277 u32 max_mip_level; 279 u32 max_mip_level;