Re: [Qemu-devel] [PULL 3/6] console-gl: add opengl rendering helper functions

2015-05-12 Thread Gerd Hoffmann
On Mo, 2015-05-11 at 22:32 +0200, Alexander Graf wrote:
 But I see the same error on openSUSE 12.3 x86_64 now:

Ah, cool, I have an iso for that laying around.

/me goes install.

thanks,
  Gerd





Re: [Qemu-devel] [PULL 3/6] console-gl: add opengl rendering helper functions

2015-05-11 Thread Alexander Graf


On 08.05.15 08:24, Gerd Hoffmann wrote:
 On Fr, 2015-05-08 at 00:28 +0200, Alexander Graf wrote:

 On 05.05.15 11:43, Gerd Hoffmann wrote:
 Signed-off-by: Gerd Hoffmann kra...@redhat.com
 Reviewed-by: Max Reitz mre...@redhat.com
 ---

 [...]

 +void surface_gl_create_texture(ConsoleGLState *gls,
 +   DisplaySurface *surface)
 +{
 +assert(gls);
 +assert(surface_stride(surface) % surface_bytes_per_pixel(surface) == 
 0);
 +
 +switch (surface-format) {
 +case PIXMAN_BE_b8g8r8x8:
 +case PIXMAN_BE_b8g8r8a8:
 +surface-glformat = GL_BGRA_EXT;
 +surface-gltype = GL_UNSIGNED_BYTE;
 +break;
 +case PIXMAN_r5g6b5:
 +surface-glformat = GL_RGB;
 +surface-gltype = GL_UNSIGNED_SHORT_5_6_5;
 +break;
 +default:
 +g_assert_not_reached();
 +}
 +
 +glGenTextures(1, surface-texture);
 +glEnable(GL_TEXTURE_2D);
 +glBindTexture(GL_TEXTURE_2D, surface-texture);
 +glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,

 This doesn't compile for me on SLES11:

 ui/console-gl.c: In function ‘surface_gl_create_texture’:
 ui/console-gl.c:97:19: error: ‘GL_UNPACK_ROW_LENGTH_EXT’ undeclared
 (first use in this function)
 ui/console-gl.c:97:19: note: each undeclared identifier is reported only
 once for each function it appears in
 ui/console-gl.c: In function ‘surface_gl_update_texture’:
 ui/console-gl.c:117:19: error: ‘GL_UNPACK_ROW_LENGTH_EXT’ undeclared
 (first use in this function)
 make: *** [ui/console-gl.o] Error 1
 make: *** Waiting for unfinished jobs
 
 Which mesa version is this?

The one I first saw it on is a PPC SLES11 system:

$ rpm -qa | grep -i mesa
Mesa-libGLESv2-2-9.0.2-34.3.1.ppc64
Mesa-9.0.2-34.3.1.ppc64
Mesa-libEGL1-32bit-9.0.2-34.3.1.ppc64
Mesa-libGL1-32bit-9.0.2-34.3.1.ppc64
Mesa-libglapi-devel-9.0.2-34.3.1.ppc64
Mesa-libGLESv2-2-32bit-9.0.2-34.3.1.ppc64
Mesa-32bit-9.0.2-34.3.1.ppc64
DirectFB-Mesa-1.6.2-3.1.1.ppc64
Mesa-libGLESv2-devel-9.0.2-34.3.1.ppc64
Mesa-libglapi0-9.0.2-34.3.1.ppc64
Mesa-libGL1-9.0.2-34.3.1.ppc64
Mesa-libGL-devel-9.0.2-34.3.1.ppc64
Mesa-libGLESv1_CM-devel-9.0.2-34.3.1.ppc64
Mesa-devel-9.0.2-34.3.1.ppc64
Mesa-libGLESv1_CM1-9.0.2-34.3.1.ppc64
Mesa-libglapi0-32bit-9.0.2-34.3.1.ppc64
libOSMesa9-9.0.2-34.3.1.ppc64
Mesa-libIndirectGL1-9.0.2-34.3.1.ppc64
libOSMesa-devel-9.0.2-34.3.1.ppc64
Mesa-libIndirectGL-devel-9.0.2-34.3.1.ppc64
Mesa-demo-x-8.0.1-8.1.1.ppc64
Mesa-libEGL1-9.0.2-34.3.1.ppc64
Mesa-libEGL-devel-9.0.2-34.3.1.ppc64

But I see the same error on openSUSE 12.3 x86_64 now:

x86:~ # rpm -qa | grep -i mesa
Mesa-libGLESv2-2-9.0.2-34.3.1.x86_64
Mesa-libGL1-9.0.2-34.3.1.x86_64
Mesa-libGLESv2-devel-9.0.2-34.3.1.x86_64
Mesa-libglapi0-9.0.2-34.3.1.x86_64
libOSMesa9-9.0.2-34.3.1.x86_64
Mesa-libEGL1-9.0.2-34.3.1.x86_64
Mesa-9.0.2-34.3.1.x86_64
Mesa-devel-9.0.2-34.3.1.x86_64
Mesa-libIndirectGL-devel-9.0.2-34.3.1.x86_64
Mesa-libEGL-devel-9.0.2-34.3.1.x86_64
Mesa-libglapi-devel-9.0.2-34.3.1.x86_64
libOSMesa-devel-9.0.2-34.3.1.x86_64
Mesa-libGL-devel-9.0.2-34.3.1.x86_64
Mesa-libGLESv1_CM-devel-9.0.2-34.3.1.x86_64
Mesa-libIndirectGL1-9.0.2-34.3.1.x86_64
Mesa-libGLESv1_CM1-9.0.2-34.3.1.x86_64


Alex



Re: [Qemu-devel] [PULL 3/6] console-gl: add opengl rendering helper functions

2015-05-08 Thread Gerd Hoffmann
On Fr, 2015-05-08 at 00:28 +0200, Alexander Graf wrote:
 
 On 05.05.15 11:43, Gerd Hoffmann wrote:
  Signed-off-by: Gerd Hoffmann kra...@redhat.com
  Reviewed-by: Max Reitz mre...@redhat.com
  ---
 
 [...]
 
  +void surface_gl_create_texture(ConsoleGLState *gls,
  +   DisplaySurface *surface)
  +{
  +assert(gls);
  +assert(surface_stride(surface) % surface_bytes_per_pixel(surface) == 
  0);
  +
  +switch (surface-format) {
  +case PIXMAN_BE_b8g8r8x8:
  +case PIXMAN_BE_b8g8r8a8:
  +surface-glformat = GL_BGRA_EXT;
  +surface-gltype = GL_UNSIGNED_BYTE;
  +break;
  +case PIXMAN_r5g6b5:
  +surface-glformat = GL_RGB;
  +surface-gltype = GL_UNSIGNED_SHORT_5_6_5;
  +break;
  +default:
  +g_assert_not_reached();
  +}
  +
  +glGenTextures(1, surface-texture);
  +glEnable(GL_TEXTURE_2D);
  +glBindTexture(GL_TEXTURE_2D, surface-texture);
  +glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
 
 This doesn't compile for me on SLES11:
 
 ui/console-gl.c: In function ‘surface_gl_create_texture’:
 ui/console-gl.c:97:19: error: ‘GL_UNPACK_ROW_LENGTH_EXT’ undeclared
 (first use in this function)
 ui/console-gl.c:97:19: note: each undeclared identifier is reported only
 once for each function it appears in
 ui/console-gl.c: In function ‘surface_gl_update_texture’:
 ui/console-gl.c:117:19: error: ‘GL_UNPACK_ROW_LENGTH_EXT’ undeclared
 (first use in this function)
 make: *** [ui/console-gl.o] Error 1
 make: *** Waiting for unfinished jobs

Which mesa version is this?

cheers,
  Gerd





Re: [Qemu-devel] [PULL 3/6] console-gl: add opengl rendering helper functions

2015-05-07 Thread Alexander Graf


On 05.05.15 11:43, Gerd Hoffmann wrote:
 Signed-off-by: Gerd Hoffmann kra...@redhat.com
 Reviewed-by: Max Reitz mre...@redhat.com
 ---

[...]

 +void surface_gl_create_texture(ConsoleGLState *gls,
 +   DisplaySurface *surface)
 +{
 +assert(gls);
 +assert(surface_stride(surface) % surface_bytes_per_pixel(surface) == 0);
 +
 +switch (surface-format) {
 +case PIXMAN_BE_b8g8r8x8:
 +case PIXMAN_BE_b8g8r8a8:
 +surface-glformat = GL_BGRA_EXT;
 +surface-gltype = GL_UNSIGNED_BYTE;
 +break;
 +case PIXMAN_r5g6b5:
 +surface-glformat = GL_RGB;
 +surface-gltype = GL_UNSIGNED_SHORT_5_6_5;
 +break;
 +default:
 +g_assert_not_reached();
 +}
 +
 +glGenTextures(1, surface-texture);
 +glEnable(GL_TEXTURE_2D);
 +glBindTexture(GL_TEXTURE_2D, surface-texture);
 +glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,

This doesn't compile for me on SLES11:

ui/console-gl.c: In function ‘surface_gl_create_texture’:
ui/console-gl.c:97:19: error: ‘GL_UNPACK_ROW_LENGTH_EXT’ undeclared
(first use in this function)
ui/console-gl.c:97:19: note: each undeclared identifier is reported only
once for each function it appears in
ui/console-gl.c: In function ‘surface_gl_update_texture’:
ui/console-gl.c:117:19: error: ‘GL_UNPACK_ROW_LENGTH_EXT’ undeclared
(first use in this function)
make: *** [ui/console-gl.o] Error 1
make: *** Waiting for unfinished jobs

Didn't we have buildbots to catch these things early?


Alex



[Qemu-devel] [PULL 3/6] console-gl: add opengl rendering helper functions

2015-05-05 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
Reviewed-by: Max Reitz mre...@redhat.com
---
 Makefile|   3 +
 configure   |   2 +-
 include/ui/console.h|  31 
 include/ui/shader.h |   2 +
 ui/Makefile.objs|   3 +
 ui/console-gl.c | 168 
 ui/shader.c |  19 +
 ui/shader/texture-blit.frag |  10 +++
 ui/shader/texture-blit.vert |  10 +++
 9 files changed, 247 insertions(+), 1 deletion(-)
 create mode 100644 ui/console-gl.c
 create mode 100644 ui/shader/texture-blit.frag
 create mode 100644 ui/shader/texture-blit.vert

diff --git a/Makefile b/Makefile
index 49e4567..f032158 100644
--- a/Makefile
+++ b/Makefile
@@ -455,6 +455,9 @@ ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag 
$(SRC_PATH)/scripts/shaderinclu
perl $(SRC_PATH)/scripts/shaderinclude.pl $  $@,\
  FRAG  $@)
 
+ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \
+   ui/shader/texture-blit-vert.h ui/shader/texture-blit-frag.h
+
 # documentation
 MAKEINFO=makeinfo
 MAKEINFOFLAGS=--no-headers --no-split --number-sections
diff --git a/configure b/configure
index 255d85b..b18aa9e 100755
--- a/configure
+++ b/configure
@@ -3142,7 +3142,7 @@ else
 fi
 
 if test $opengl != no ; then
-  opengl_pkgs=gl
+  opengl_pkgs=gl glesv2
   if $pkg_config $opengl_pkgs x11  test $have_glx = yes; then
 opengl_cflags=$($pkg_config --cflags $opengl_pkgs) $x11_cflags
 opengl_libs=$($pkg_config --libs $opengl_pkgs) $x11_libs
diff --git a/include/ui/console.h b/include/ui/console.h
index 03cd665..ee00fc5 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -9,6 +9,11 @@
 #include qapi-types.h
 #include qapi/error.h
 
+#ifdef CONFIG_OPENGL
+# include GLES2/gl2.h
+# include GLES2/gl2ext.h
+#endif
+
 /* keyboard/mouse support */
 
 #define MOUSE_EVENT_LBUTTON 0x01
@@ -117,6 +122,11 @@ struct DisplaySurface {
 pixman_format_code_t format;
 pixman_image_t *image;
 uint8_t flags;
+#ifdef CONFIG_OPENGL
+GLenum glformat;
+GLenum gltype;
+GLuint texture;
+#endif
 };
 
 typedef struct QemuUIInfo {
@@ -322,6 +332,27 @@ void qemu_console_copy(QemuConsole *con, int src_x, int 
src_y,
int dst_x, int dst_y, int w, int h);
 DisplaySurface *qemu_console_surface(QemuConsole *con);
 
+/* console-gl.c */
+typedef struct ConsoleGLState ConsoleGLState;
+#ifdef CONFIG_OPENGL
+ConsoleGLState *console_gl_init_context(void);
+void console_gl_fini_context(ConsoleGLState *gls);
+bool console_gl_check_format(DisplayChangeListener *dcl,
+ pixman_format_code_t format);
+void surface_gl_create_texture(ConsoleGLState *gls,
+   DisplaySurface *surface);
+void surface_gl_update_texture(ConsoleGLState *gls,
+   DisplaySurface *surface,
+   int x, int y, int w, int h);
+void surface_gl_render_texture(ConsoleGLState *gls,
+   DisplaySurface *surface);
+void surface_gl_destroy_texture(ConsoleGLState *gls,
+   DisplaySurface *surface);
+void surface_gl_setup_viewport(ConsoleGLState *gls,
+   DisplaySurface *surface,
+   int ww, int wh);
+#endif
+
 /* sdl.c */
 void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
 
diff --git a/include/ui/shader.h b/include/ui/shader.h
index e1b0caf..1ff926c 100644
--- a/include/ui/shader.h
+++ b/include/ui/shader.h
@@ -3,6 +3,8 @@
 # include GLES2/gl2ext.h
 #endif
 
+void qemu_gl_run_texture_blit(GLint texture_blit_prog);
+
 GLuint qemu_gl_create_compile_shader(GLenum type, const GLchar *src);
 GLuint qemu_gl_create_link_program(GLuint vert, GLuint frag);
 GLuint qemu_gl_create_compile_link_program(const GLchar *vert_src,
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index 7a76df5..67fe278 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -26,9 +26,12 @@ sdl.mo-cflags := $(SDL_CFLAGS)
 
 ifeq ($(CONFIG_OPENGL),y)
 common-obj-y += shader.o
+common-obj-y += console-gl.o
 endif
 
 gtk.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
 shader.o-cflags += $(OPENGL_CFLAGS)
+console-gl.o-cflags += $(OPENGL_CFLAGS)
 
 shader.o-libs += $(OPENGL_LIBS)
+console-gl.o-libs += $(OPENGL_LIBS)
diff --git a/ui/console-gl.c b/ui/console-gl.c
new file mode 100644
index 000..cb45cf8
--- /dev/null
+++ b/ui/console-gl.c
@@ -0,0 +1,168 @@
+/*
+ * QEMU graphical console -- opengl helper bits
+ *
+ * Copyright (c) 2014 Red Hat
+ *
+ * Authors:
+ *Gerd Hoffmann kra...@redhat.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the