From 7943d937215cb512b5aab6aa5bfffeb463ea9a9a Mon Sep 17 00:00:00 2001 From: Stanislav Vorobiov Date: Thu, 9 Jan 2014 20:28:21 +0400 Subject: [PATCH] VIGS: Use GL_PACK_ALIGNMENT/GL_UNPACK_ALIGNMENT 1 instead of 4 With some GPUs (like Intel HD Graphics 2000) GL_PACK_ALIGNMENT == 4 may introduce glReadPixels stalls even when it's used with PBO, so use GL_PACK_ALIGNMENT == 1 - it's the same thing and it doesn't stall glReadPixels Change-Id: Id34e7f0d00a9e65813859b4e9ad931db7149fa0d --- hw/vigs/vigs_gl_backend.c | 12 ++++-------- .../egl_offscreen/yagl_egl_offscreen_context.c | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/hw/vigs/vigs_gl_backend.c b/hw/vigs/vigs_gl_backend.c index 65ace1b88c..1b15747e7f 100644 --- a/hw/vigs/vigs_gl_backend.c +++ b/hw/vigs/vigs_gl_backend.c @@ -73,7 +73,6 @@ struct vigs_winsys_gl_surface GLint tex_internalformat; GLenum tex_format; GLenum tex_type; - GLint tex_bpp; /* * @} @@ -301,8 +300,7 @@ static struct vigs_winsys_gl_surface uint32_t height, GLint tex_internalformat, GLenum tex_format, - GLenum tex_type, - GLint tex_bpp) + GLenum tex_type) { struct vigs_winsys_gl_surface *ws_sfc; @@ -317,7 +315,6 @@ static struct vigs_winsys_gl_surface ws_sfc->tex_internalformat = tex_internalformat; ws_sfc->tex_format = tex_format; ws_sfc->tex_type = tex_type; - ws_sfc->tex_bpp = tex_bpp; ws_sfc->backend = backend; ws_sfc->parent = parent; @@ -429,7 +426,7 @@ static void vigs_gl_surface_read_pixels(struct vigs_surface *sfc, gl_backend->DisableClientState(GL_TEXTURE_COORD_ARRAY); gl_backend->DisableClientState(GL_VERTEX_ARRAY); - gl_backend->PixelStorei(GL_PACK_ALIGNMENT, ws_sfc->tex_bpp); + gl_backend->PixelStorei(GL_PACK_ALIGNMENT, 1); gl_backend->ReadPixels(0, 0, sfc_w, sfc_h, ws_sfc->tex_format, ws_sfc->tex_type, pixels); @@ -466,7 +463,7 @@ static void vigs_gl_surface_draw_pixels(struct vigs_surface *sfc, GL_TEXTURE_2D, ws_sfc->tex, 0); gl_backend->PixelZoom(1.0f, -1.0f); - gl_backend->PixelStorei(GL_UNPACK_ALIGNMENT, ws_sfc->tex_bpp); + gl_backend->PixelStorei(GL_UNPACK_ALIGNMENT, 1); gl_backend->PixelStorei(GL_UNPACK_ROW_LENGTH, ws_sfc->base.base.width); for (i = 0; i < num_entries; ++i) { @@ -799,8 +796,7 @@ static struct vigs_surface *vigs_gl_backend_create_surface(struct vigs_backend * height, tex_internalformat, tex_format, - tex_type, - tex_bpp); + tex_type); vigs_surface_init(&gl_sfc->base, &ws_sfc->base.base, diff --git a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_context.c b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_context.c index dc9fb3d1bb..3b517a1acf 100644 --- a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_context.c +++ b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_context.c @@ -189,8 +189,7 @@ bool yagl_egl_offscreen_context_read_pixels(struct yagl_egl_offscreen_context *c pop_attrib = true; - gles_driver->PixelStorei(GL_PACK_ALIGNMENT, - ((bpp == 4) ? 4 : 1)); + gles_driver->PixelStorei(GL_PACK_ALIGNMENT, 1); gles_driver->ReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, -- 2.34.1