From b0b185112dd75e774abdd0252fd0dbe6d601b1ba Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Tue, 7 May 2024 23:04:04 +1000 Subject: [PATCH] glmemory: use the GL stride calculation also for downloading into sysmem Allows writing into sysmem with arbitrary strides. Part-of: --- .../gst-plugins-base/gst-libs/gst/gl/gstglmemory.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglmemory.c b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglmemory.c index 7658ea1f32..331c1fec46 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglmemory.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglmemory.c @@ -71,6 +71,10 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_MEMORY); #define GL_UNPACK_ROW_LENGTH 0x0CF2 #endif +#ifndef GL_PACK_ROW_LENGTH +#define GL_PACK_ROW_LENGTH 0x0D02 +#endif + #ifndef GL_TEXTURE_RECTANGLE #define GL_TEXTURE_RECTANGLE 0x84F5 #endif @@ -459,6 +463,13 @@ gst_gl_memory_read_pixels (GstGLMemory * gl_mem, gpointer write_pointer) } } + if (USING_OPENGL (context) || USING_GLES3 (context) + || USING_OPENGL3 (context)) { + gl->PixelStorei (GL_PACK_ROW_LENGTH, gl_mem->unpack_length); + } else if (USING_GLES2 (context)) { + gl->PixelStorei (GL_PACK_ALIGNMENT, gl_mem->unpack_length); + } + _gst_gl_memory_start_log (gl_mem, "glReadPixels"); gl->ReadPixels (0, 0, gl_mem->tex_width, GL_MEM_HEIGHT (gl_mem), format, type, write_pointer);