YaGL: glTexSubImage2D workaround for GL_ALPHA format in nvidia Windows drivers
authorIgor Mitsyanko <i.mitsyanko@samsung.com>
Wed, 21 Nov 2012 10:41:31 +0000 (14:41 +0400)
committerEvgeny Voevodin <e.voevodin@samsung.com>
Mon, 26 Nov 2012 09:25:37 +0000 (13:25 +0400)
Nvidia Windows openGL drivers doesn't account for GL_UNPACK_ALIGNMENT parameter
when glTexSubImage2D function is called with format GL_ALPHA. Looks like, for some
reason, GL_ALPHA format data always treated by NVIDIA driver as 1-byte aligned.

This commit works around this problem.

Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
hw/yagl_apis/gles/yagl_host_gles_calls.c

index 86927e3..af01f8e 100644 (file)
@@ -1533,6 +1533,17 @@ bool yagl_host_glTexSubImage2D(GLenum target,
         }
     }
 
+    /*
+     * Nvidia Windows openGL drivers doesn't account for GL_UNPACK_ALIGNMENT
+     * parameter when glTexSubImage2D function is called with format GL_ALPHA.
+     * Work around this by manually setting line stride.
+     */
+    if (format == GL_ALPHA) {
+        ctx->driver_ps->PixelStorei(ctx->driver_ps,
+                                    GL_UNPACK_ROW_LENGTH,
+                                    stride);
+    }
+
     ctx->driver_ps->TexSubImage2D(ctx->driver_ps,
                                   target,
                                   level,
@@ -1544,6 +1555,12 @@ bool yagl_host_glTexSubImage2D(GLenum target,
                                   type,
                                   pixels);
 
+    if (format == GL_ALPHA) {
+        ctx->driver_ps->PixelStorei(ctx->driver_ps,
+                                    GL_UNPACK_ROW_LENGTH,
+                                    0);
+    }
+
 out:
     return res;
 }