summaryrefslogtreecommitdiff
path: root/hw/yagl
diff options
context:
space:
mode:
authorStanislav Vorobiov <s.vorobiov@samsung.com>2014-02-24 14:53:08 +0400
committerStanislav Vorobiov <s.vorobiov@samsung.com>2014-02-24 14:57:05 +0400
commit0d61650494f6b06e394c089568bc91b29e206118 (patch)
treedb74468ea5b16e5d83a3252a45041490054258df /hw/yagl
parent8c5753884718e761b5e19cfd9f6a740a489d6a18 (diff)
downloadqemu-0d61650494f6b06e394c089568bc91b29e206118.tar.gz
qemu-0d61650494f6b06e394c089568bc91b29e206118.tar.bz2
qemu-0d61650494f6b06e394c089568bc91b29e206118.zip
YaGL: Return nVidia GL_UNPACK_ALIGNMENT bug workaround
Since we will use GL_ALPHA format after all we must return that nVidia GL_UNPACK_ALIGNMENT bug workaround Change-Id: I5cac6722e4358178d27accf30b4d2b56417482be
Diffstat (limited to 'hw/yagl')
-rw-r--r--hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c b/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c
index 2b9e866bbf..17b9b4791c 100644
--- a/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c
+++ b/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c
@@ -1164,6 +1164,27 @@ void yagl_host_glTexSubImage2DData(GLenum target,
GLenum type,
const GLvoid *pixels, int32_t pixels_count)
{
+ GLint row_length;
+
+ /*
+ * Nvidia Windows OpenGL drivers don't account for GL_UNPACK_ALIGNMENT
+ * parameter when glTexSubImage2D function is called with format GL_ALPHA.
+ * Work around this by setting row length.
+ */
+ if (format == GL_ALPHA) {
+ GLint alignment;
+
+ gles_api_ts->driver->GetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length);
+ gles_api_ts->driver->GetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+
+ if (alignment == 0) {
+ alignment = 1;
+ }
+
+ gles_api_ts->driver->PixelStorei(GL_UNPACK_ROW_LENGTH,
+ (((row_length == 0) ? width : row_length) + alignment - 1) & ~(alignment - 1));
+ }
+
gles_api_ts->driver->TexSubImage2D(target,
level,
xoffset,
@@ -1173,6 +1194,10 @@ void yagl_host_glTexSubImage2DData(GLenum target,
format,
type,
pixels);
+
+ if (format == GL_ALPHA) {
+ gles_api_ts->driver->PixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
+ }
}
void yagl_host_glTexSubImage2DOffset(GLenum target,
@@ -1185,6 +1210,27 @@ void yagl_host_glTexSubImage2DOffset(GLenum target,
GLenum type,
GLsizei pixels)
{
+ GLint row_length;
+
+ /*
+ * Nvidia Windows OpenGL drivers don't account for GL_UNPACK_ALIGNMENT
+ * parameter when glTexSubImage2D function is called with format GL_ALPHA.
+ * Work around this by setting row length.
+ */
+ if (format == GL_ALPHA) {
+ GLint alignment;
+
+ gles_api_ts->driver->GetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length);
+ gles_api_ts->driver->GetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+
+ if (alignment == 0) {
+ alignment = 1;
+ }
+
+ gles_api_ts->driver->PixelStorei(GL_UNPACK_ROW_LENGTH,
+ (((row_length == 0) ? width : row_length) + alignment - 1) & ~(alignment - 1));
+ }
+
gles_api_ts->driver->TexSubImage2D(target,
level,
xoffset,
@@ -1194,6 +1240,10 @@ void yagl_host_glTexSubImage2DOffset(GLenum target,
format,
type,
(const GLvoid*)(uintptr_t)pixels);
+
+ if (format == GL_ALPHA) {
+ gles_api_ts->driver->PixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
+ }
}
void yagl_host_glClientActiveTexture(GLenum texture)