summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp13
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h3
3 files changed, 11 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index c2cd89e54..3f2255e06 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -947,7 +947,7 @@ bool RasterizerOpenGL::AccelerateDisplay(const GPU::Regs::FramebufferConfig& con
947 src_params.addr = framebuffer_addr; 947 src_params.addr = framebuffer_addr;
948 src_params.width = config.width; 948 src_params.width = config.width;
949 src_params.height = config.height; 949 src_params.height = config.height;
950 src_params.stride = pixel_stride; 950 src_params.pixel_stride = pixel_stride;
951 src_params.is_tiled = false; 951 src_params.is_tiled = false;
952 src_params.pixel_format = CachedSurface::PixelFormatFromGPUPixelFormat(config.color_format); 952 src_params.pixel_format = CachedSurface::PixelFormatFromGPUPixelFormat(config.color_format);
953 953
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 9ee3bb2ac..61f6e767f 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -288,6 +288,9 @@ CachedSurface* RasterizerCacheOpenGL::GetSurface(const CachedSurface& params, bo
288 288
289 MICROPROFILE_SCOPE(OpenGL_SurfaceUpload); 289 MICROPROFILE_SCOPE(OpenGL_SurfaceUpload);
290 290
291 // Stride only applies to linear images.
292 ASSERT(params.pixel_stride == 0 || !params.is_tiled);
293
291 std::shared_ptr<CachedSurface> new_surface = std::make_shared<CachedSurface>(); 294 std::shared_ptr<CachedSurface> new_surface = std::make_shared<CachedSurface>();
292 295
293 new_surface->addr = params.addr; 296 new_surface->addr = params.addr;
@@ -296,7 +299,7 @@ CachedSurface* RasterizerCacheOpenGL::GetSurface(const CachedSurface& params, bo
296 new_surface->texture.Create(); 299 new_surface->texture.Create();
297 new_surface->width = params.width; 300 new_surface->width = params.width;
298 new_surface->height = params.height; 301 new_surface->height = params.height;
299 new_surface->stride = params.stride; 302 new_surface->pixel_stride = params.pixel_stride;
300 new_surface->res_scale_width = params.res_scale_width; 303 new_surface->res_scale_width = params.res_scale_width;
301 new_surface->res_scale_height = params.res_scale_height; 304 new_surface->res_scale_height = params.res_scale_height;
302 305
@@ -322,14 +325,15 @@ CachedSurface* RasterizerCacheOpenGL::GetSurface(const CachedSurface& params, bo
322 cur_state.Apply(); 325 cur_state.Apply();
323 glActiveTexture(GL_TEXTURE0); 326 glActiveTexture(GL_TEXTURE0);
324 327
325 glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint)new_surface->stride);
326 if (!new_surface->is_tiled) { 328 if (!new_surface->is_tiled) {
327 // TODO: Ensure this will always be a color format, not a depth or other format 329 // TODO: Ensure this will always be a color format, not a depth or other format
328 ASSERT((size_t)new_surface->pixel_format < fb_format_tuples.size()); 330 ASSERT((size_t)new_surface->pixel_format < fb_format_tuples.size());
329 const FormatTuple& tuple = fb_format_tuples[(unsigned int)params.pixel_format]; 331 const FormatTuple& tuple = fb_format_tuples[(unsigned int)params.pixel_format];
330 332
333 glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint)new_surface->pixel_stride);
331 glTexImage2D(GL_TEXTURE_2D, 0, tuple.internal_format, params.width, params.height, 0, 334 glTexImage2D(GL_TEXTURE_2D, 0, tuple.internal_format, params.width, params.height, 0,
332 tuple.format, tuple.type, texture_src_data); 335 tuple.format, tuple.type, texture_src_data);
336 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
333 } else { 337 } else {
334 SurfaceType type = CachedSurface::GetFormatType(new_surface->pixel_format); 338 SurfaceType type = CachedSurface::GetFormatType(new_surface->pixel_format);
335 if (type != SurfaceType::Depth && type != SurfaceType::DepthStencil) { 339 if (type != SurfaceType::Depth && type != SurfaceType::DepthStencil) {
@@ -388,7 +392,6 @@ CachedSurface* RasterizerCacheOpenGL::GetSurface(const CachedSurface& params, bo
388 0, tuple.format, tuple.type, temp_fb_depth_buffer.data()); 392 0, tuple.format, tuple.type, temp_fb_depth_buffer.data());
389 } 393 }
390 } 394 }
391 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
392 395
393 // If not 1x scale, blit 1x texture to a new scaled texture and replace texture in surface 396 // If not 1x scale, blit 1x texture to a new scaled texture and replace texture in surface
394 if (new_surface->res_scale_width != 1.f || new_surface->res_scale_height != 1.f) { 397 if (new_surface->res_scale_width != 1.f || new_surface->res_scale_height != 1.f) {
@@ -698,13 +701,14 @@ void RasterizerCacheOpenGL::FlushSurface(CachedSurface* surface) {
698 cur_state.Apply(); 701 cur_state.Apply();
699 glActiveTexture(GL_TEXTURE0); 702 glActiveTexture(GL_TEXTURE0);
700 703
701 glPixelStorei(GL_PACK_ROW_LENGTH, (GLint)surface->stride);
702 if (!surface->is_tiled) { 704 if (!surface->is_tiled) {
703 // TODO: Ensure this will always be a color format, not a depth or other format 705 // TODO: Ensure this will always be a color format, not a depth or other format
704 ASSERT((size_t)surface->pixel_format < fb_format_tuples.size()); 706 ASSERT((size_t)surface->pixel_format < fb_format_tuples.size());
705 const FormatTuple& tuple = fb_format_tuples[(unsigned int)surface->pixel_format]; 707 const FormatTuple& tuple = fb_format_tuples[(unsigned int)surface->pixel_format];
706 708
709 glPixelStorei(GL_PACK_ROW_LENGTH, (GLint)surface->pixel_stride);
707 glGetTexImage(GL_TEXTURE_2D, 0, tuple.format, tuple.type, dst_buffer); 710 glGetTexImage(GL_TEXTURE_2D, 0, tuple.format, tuple.type, dst_buffer);
711 glPixelStorei(GL_PACK_ROW_LENGTH, 0);
708 } else { 712 } else {
709 SurfaceType type = CachedSurface::GetFormatType(surface->pixel_format); 713 SurfaceType type = CachedSurface::GetFormatType(surface->pixel_format);
710 if (type != SurfaceType::Depth && type != SurfaceType::DepthStencil) { 714 if (type != SurfaceType::Depth && type != SurfaceType::DepthStencil) {
@@ -747,7 +751,6 @@ void RasterizerCacheOpenGL::FlushSurface(CachedSurface* surface) {
747 false); 751 false);
748 } 752 }
749 } 753 }
750 glPixelStorei(GL_PACK_ROW_LENGTH, 0);
751 754
752 surface->dirty = false; 755 surface->dirty = false;
753 756
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 849530d86..32abfbaf5 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -171,7 +171,8 @@ struct CachedSurface {
171 OGLTexture texture; 171 OGLTexture texture;
172 u32 width; 172 u32 width;
173 u32 height; 173 u32 height;
174 u32 stride = 0; 174 /// Stride between lines, in pixels. Only valid for images in linear format.
175 u32 pixel_stride = 0;
175 float res_scale_width = 1.f; 176 float res_scale_width = 1.f;
176 float res_scale_height = 1.f; 177 float res_scale_height = 1.f;
177 178