qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Patch: Precautionary glBindTexture in surface_gl_update_texture
@ 2019-05-06  7:50 Hou Qiming
  2019-05-06  8:22 ` Marcel Apfelbaum
  2019-05-09  0:15 ` [Qemu-devel] [PATCH] Multiple ramfb enhancements Hou Qiming
  0 siblings, 2 replies; 25+ messages in thread
From: Hou Qiming @ 2019-05-06  7:50 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

From 48d1f092a7960d711fb2c77ab8d3f9d0a0ca0d5c Mon Sep 17 00:00:00 2001
From: HQM <hqm03ster@gmail.com>
Date: Mon, 6 May 2019 15:37:59 +0800
Subject: [PATCH] Precautionary glBindTexture and surface->texture validation
 in surface_gl_update_texture

In a GVT-g setup with dmabuf and GTK GUI, the current 2D texture at
surface_gl_update_texture is not necessarily
surface->texture. Adding a glBindTexture fixes related crashes and
artifacts, and is generally more secure.

Signed-off-by: HQM <hqm03ster@gmail.com>
---
 ui/console-gl.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/ui/console-gl.c b/ui/console-gl.c
index a56e1cd..c1cb3bd 100644
--- a/ui/console-gl.c
+++ b/ui/console-gl.c
@@ -92,13 +92,17 @@ void surface_gl_update_texture(QemuGLShader *gls,

     assert(gls);

-    glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
-                  surface_stride(surface) /
surface_bytes_per_pixel(surface));
-    glTexSubImage2D(GL_TEXTURE_2D, 0,
-                    x, y, w, h,
-                    surface->glformat, surface->gltype,
-                    data + surface_stride(surface) * y
-                    + surface_bytes_per_pixel(surface) * x);
+    if (surface->texture) {
+        glBindTexture(GL_TEXTURE_2D, surface->texture);
+        glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
+                      surface_stride(surface)
+                      / surface_bytes_per_pixel(surface));
+        glTexSubImage2D(GL_TEXTURE_2D, 0,
+                        x, y, w, h,
+                        surface->glformat, surface->gltype,
+                        data + surface_stride(surface) * y
+                        + surface_bytes_per_pixel(surface) * x);
+    }
 }

 void surface_gl_render_texture(QemuGLShader *gls,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2019-05-10 16:43 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-06  7:50 [Qemu-devel] Patch: Precautionary glBindTexture in surface_gl_update_texture Hou Qiming
2019-05-06  8:22 ` Marcel Apfelbaum
2019-05-09  0:15 ` [Qemu-devel] [PATCH] Multiple ramfb enhancements Hou Qiming
2019-05-09  6:48   ` Gerd Hoffmann
2019-05-09  7:43     ` Hou Qiming
2019-05-09  7:57       ` [Qemu-devel] [PATCH 1/3] ramfb enhancement Hou Qiming
2019-05-09 10:44         ` Marcel Apfelbaum
2019-05-10  4:59         ` Gerd Hoffmann
2019-05-09  7:58       ` [Qemu-devel] [PATCH 2/3] " Hou Qiming
2019-05-09 10:50         ` Marcel Apfelbaum
2019-05-10  5:01         ` Gerd Hoffmann
2019-05-10  6:41           ` Hou Qiming
2019-05-10  8:54             ` Gerd Hoffmann
2019-05-09  7:58       ` [Qemu-devel] [PATCH 3/3] " Hou Qiming
2019-05-09 10:58         ` Marcel Apfelbaum
2019-05-10  2:20           ` Hou Qiming
2019-05-10  6:20             ` Marcel Apfelbaum
2019-05-10  8:59               ` Gerd Hoffmann
2019-05-10  9:20                 ` Marcel Apfelbaum
2019-05-10 10:39                   ` Gerd Hoffmann
2019-05-10 10:52                     ` Marcel Apfelbaum
2019-05-10 16:28                       ` [Qemu-devel] [PATCH v2 1/3] hw/display/ramfb: fix guest memory un-mapping Hou Qiming
2019-05-10 16:29                         ` [Qemu-devel] [PATCH v2 2/3] hw/display/ramfb: lock guest resolution after it's set Hou Qiming
2019-05-10 16:29                         ` [Qemu-devel] [PATCH v2 3/3] hw/display/ramfb: initialize fw-config space with xres / yres Hou Qiming
2019-05-10  5:07         ` [Qemu-devel] [PATCH 3/3] ramfb enhancement Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).