YaGL: Support GL_EXT_unpack_subimage and GL_NV_pack_subimage 84/15584/1
authorStanislav Vorobiov <s.vorobiov@samsung.com>
Thu, 23 Jan 2014 16:49:32 +0000 (20:49 +0400)
committerStanislav Vorobiov <s.vorobiov@samsung.com>
Thu, 23 Jan 2014 16:49:32 +0000 (20:49 +0400)
Change-Id: I0dfd41ecae60e1dfffb4b9feea4e289c9f139dda

hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c
hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_context.c

index 0f85d5f5db77067f3e825c457310b0e649fb8e47..5e16e3092707334a6213212d07aeec8034d0ed1a 100644 (file)
@@ -2804,7 +2804,7 @@ void yagl_host_glUpdateOffscreenImageYAGL(GLuint texture,
 {
     GLenum format = 0;
     GLuint cur_tex = 0;
-    GLsizei unpack_alignment = 0;
+    GLsizei unpack[3];
 
     YAGL_LOG_FUNC_SET(glUpdateOffscreenImageYAGL);
 
@@ -2823,10 +2823,13 @@ void yagl_host_glUpdateOffscreenImageYAGL(GLuint texture,
     gles_api_ts->driver->GetIntegerv(GL_TEXTURE_BINDING_2D,
                                      (GLint*)&cur_tex);
 
-    gles_api_ts->driver->GetIntegerv(GL_UNPACK_ALIGNMENT,
-                                     &unpack_alignment);
+    gles_api_ts->driver->GetIntegerv(GL_UNPACK_ALIGNMENT, &unpack[0]);
+    gles_api_ts->driver->GetIntegerv(GL_UNPACK_ROW_LENGTH, &unpack[1]);
+    gles_api_ts->driver->GetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &unpack[2]);
 
     gles_api_ts->driver->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    gles_api_ts->driver->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+    gles_api_ts->driver->PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
 
     gles_api_ts->driver->BindTexture(GL_TEXTURE_2D,
                                      yagl_gles_object_get(texture));
@@ -2844,8 +2847,9 @@ void yagl_host_glUpdateOffscreenImageYAGL(GLuint texture,
                                     GL_UNSIGNED_INT_8_8_8_8_REV,
                                     pixels);
 
-    gles_api_ts->driver->PixelStorei(GL_UNPACK_ALIGNMENT,
-                                     unpack_alignment);
+    gles_api_ts->driver->PixelStorei(GL_UNPACK_ALIGNMENT, unpack[0]);
+    gles_api_ts->driver->PixelStorei(GL_UNPACK_ROW_LENGTH, unpack[1]);
+    gles_api_ts->driver->PixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack[2]);
 
     gles_api_ts->driver->BindTexture(GL_TEXTURE_2D, cur_tex);
 }
index e832324ba72c028a2e682a9b7df6feccb6f7e729..b7e31ff28c7a4d7f374f4130de0932298942fdc0 100644 (file)
@@ -115,7 +115,7 @@ bool yagl_egl_offscreen_context_read_pixels(struct yagl_egl_offscreen_context *c
         ((struct yagl_egl_offscreen*)ctx->base.dpy->backend)->gles_driver;
     bool ret = false;
     GLuint current_fb = 0;
-    GLint current_pack_alignment = 0;
+    GLint current_pack[3];
     GLuint current_pbo = 0;
     uint32_t rp_line_size = width * bpp;
     uint32_t rp_size = rp_line_size * height;
@@ -129,11 +129,12 @@ bool yagl_egl_offscreen_context_read_pixels(struct yagl_egl_offscreen_context *c
     gles_driver->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING,
                              (GLint*)&current_fb);
 
-    gles_driver->GetIntegerv(GL_PACK_ALIGNMENT,
-                             &current_pack_alignment);
-
     gles_driver->BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
 
+    gles_driver->GetIntegerv(GL_PACK_ALIGNMENT, &current_pack[0]);
+    gles_driver->GetIntegerv(GL_PACK_ROW_LENGTH, &current_pack[1]);
+    gles_driver->GetIntegerv(GL_PACK_IMAGE_HEIGHT, &current_pack[2]);
+
     if (!ctx->rp_pbo) {
         /*
          * No buffer yet, create one.
@@ -186,6 +187,8 @@ bool yagl_egl_offscreen_context_read_pixels(struct yagl_egl_offscreen_context *c
     }
 
     gles_driver->PixelStorei(GL_PACK_ALIGNMENT, 1);
+    gles_driver->PixelStorei(GL_PACK_ROW_LENGTH, 0);
+    gles_driver->PixelStorei(GL_PACK_IMAGE_HEIGHT, 0);
 
     gles_driver->ReadPixels(0, 0,
                             width, height, format, GL_UNSIGNED_INT_8_8_8_8_REV,
@@ -215,7 +218,9 @@ out:
     if (mapped_pixels) {
         gles_driver->UnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);
     }
-    gles_driver->PixelStorei(GL_PACK_ALIGNMENT, current_pack_alignment);
+    gles_driver->PixelStorei(GL_PACK_ALIGNMENT, current_pack[0]);
+    gles_driver->PixelStorei(GL_PACK_ROW_LENGTH, current_pack[1]);
+    gles_driver->PixelStorei(GL_PACK_IMAGE_HEIGHT, current_pack[2]);
     gles_driver->BindBuffer(GL_PIXEL_PACK_BUFFER_ARB,
                             current_pbo);
     gles_driver->BindFramebuffer(GL_READ_FRAMEBUFFER, current_fb);