Re: [PATCH] ephyr: Repaint entire screen when colormap is updated

2014-02-06 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 Eric Anholt e...@anholt.net writes:

 I expected DamageReportDamage() to be used instead, but this is safe
 because we're using DamageReportNone (and leaving the blockhandler to do
 our paint).

 I didn't want other root damage trackers to receive damage though, this
 avoids that. We could also expose a new per-damage damage api. It could
 be called DamageDamageDamage, which has a certain ring to it...

That appears to be what DamageReportDamage() does.  (As opposed to
DamageDamageRegion(), which I suspect you were thinking of).


pgpsnX8bRErkv.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] Stop defining GL_GLEXT_PROTOTYPES

2014-02-04 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 It looks like GL_GLEXT_PROTOTYPES is just a trap for the unwary,
 causing glext.h to define a pile of functions which are also defined
 in gl.h.

 However, there is *one* function used in the server which is not
 defined in gl.h and is only defined in glext.h when
 GL_GLEXT_PROTOTYPES is defined, glGetCompressedTexImageARB.

 I've explicitly defined that and added a warning message to the
 compiler output as I don't know what the right fix is, but I suspect
 it involves looking the function up with GetProcAddress, and I suspect
 Eric will fix this by moving the server to libepoxy.

 Signed-off-by: Keith Packard kei...@keithp.com

You can't actually use the prototype in indirect_texture_compression.c.
See my patch series I sent earlier.  And this would conflict with my
glamor series I'd already sent out for review, too.  So I don't want
this patch to go in as is.


pgpTtkGHp3t7_.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] dri3: Don't enable the DRI3 extension unless some screen supports it

2014-02-03 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 There's no reason to advertise this extension unless one of the
 hardware drivers actually supports it. Not listing it means it's
 slightly easier for users to tell what's going on.

 On the other hand, not listing it means we may have applications that
 only check for the extension and not for appropriate per-screen
 support. I don't think that's a real risk as DRI3 is only useful for
 systems with deep knowledge of the hardware.

Reviewed-by: Eric Anholt e...@anholt.net


pgpOxA4icIVRP.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 6/8] xephyr: Build support for rendering with glamor using a -glamor option.

2014-02-03 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 configure.ac   |   3 +
 glamor/glamor.c|  11 ++
 glamor/glamor.h|   2 +
 hw/kdrive/ephyr/Makefile.am|  20 ++-
 hw/kdrive/ephyr/ephyr.c|  36 +++--
 hw/kdrive/ephyr/ephyr.h|  14 ++
 hw/kdrive/ephyr/ephyr_glamor_glx.c | 292 +
 hw/kdrive/ephyr/ephyr_glamor_glx.h |  62 
 hw/kdrive/ephyr/ephyrinit.c|  14 ++
 hw/kdrive/ephyr/hostx.c|  97 +++-
 10 files changed, 538 insertions(+), 13 deletions(-)
 create mode 100644 hw/kdrive/ephyr/ephyr_glamor_glx.c
 create mode 100644 hw/kdrive/ephyr/ephyr_glamor_glx.h

diff --git a/configure.ac b/configure.ac
index 5946fe7..ad66f61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2319,6 +2319,9 @@ if test $KDRIVE = yes; then
 if test x$DRI = xyes  test x$GLX = xyes; then
 XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS libdrm xcb-glx xcb-xf86dri 
 1.6
 fi
+if test x$GLAMOR = xyes; then
+XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS x11-xcb
+fi
 
 if test x$XEPHYR = xauto; then
 PKG_CHECK_MODULES(XEPHYR, $XEPHYR_REQUIRED_LIBS, [XEPHYR=yes], 
[XEPHYR=no])
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 65fabc2..f1c71ea 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -140,6 +140,17 @@ glamor_set_screen_pixmap(PixmapPtr screen_pixmap, 
PixmapPtr *back_pixmap)
 glamor_priv-back_pixmap = back_pixmap;
 }
 
+uint32_t
+glamor_get_pixmap_texture(PixmapPtr pixmap)
+{
+glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+if (pixmap_priv-type != GLAMOR_TEXTURE_ONLY)
+return 0;
+
+return pixmap_priv-base.fbo-tex;
+}
+
 PixmapPtr
 glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
  unsigned int usage)
diff --git a/glamor/glamor.h b/glamor/glamor.h
index eec6872..08ffd26 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -124,6 +124,8 @@ extern _X_EXPORT Bool glamor_close_screen(ScreenPtr screen);
 extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap,
PixmapPtr *back_pixmap);
 
+extern _X_EXPORT uint32_t glamor_get_pixmap_texture(PixmapPtr pixmap);
+
 /* @glamor_glyphs_init: Initialize glyphs internal data structures.
  *
  * @pScreen: Current screen pointer.
diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am
index 6b790fd..040993c 100644
--- a/hw/kdrive/ephyr/Makefile.am
+++ b/hw/kdrive/ephyr/Makefile.am
@@ -27,12 +27,20 @@ AM_CPPFLAGS =   \
@XEPHYR_INCS@   \
@XEPHYR_CFLAGS@ \
-I$(top_srcdir) \
+   -I$(top_srcdir)/glamor  \
-I$(top_srcdir)/exa
 
 if XV
 XV_SRCS = ephyrvideo.c
 endif
 
+if GLAMOR
+GLAMOR_SRCS = \
+   ephyr_glamor_glx.c \
+   ephyr_glamor_glx.h \
+   ()
+endif
+
 if DRI
 DRI_SRCS = \
ephyrdriext.c   \
@@ -59,14 +67,24 @@ Xephyr_SOURCES = \
hostx.h \
$(XV_SRCS) \
$(DRI_SRCS) \
+   $(GLAMOR_SRCS) \
$()
 
+if GLAMOR
+AM_CPPFLAGS += $(XLIB_CFLAGS)
+XEPHYR_GLAMOR_LIB = \
+   $(top_builddir)/glamor/libglamor.la \
+   $(top_builddir)/glamor/libglamor_egl_stubs.la \
+   $()
+endif
+
 Xephyr_LDADD = \
$(top_builddir)/exa/libexa.la   \
+   $(XEPHYR_GLAMOR_LIB)\
@KDRIVE_LIBS@   \
@XEPHYR_LIBS@
 
-Xephyr_DEPENDENCIES = @KDRIVE_LOCAL_LIBS@
+Xephyr_DEPENDENCIES = @KDRIVE_LOCAL_LIBS@ $(XEPHYR_GLAMOR_LIB)
 
 Xephyr_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
 
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index da80c95..e799b6e 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -43,9 +43,15 @@
 #include ephyrglxext.h
 #endif  /* XF86DRI */
 
+#ifdef GLAMOR
+#include glamor.h
+#endif
+#include ephyr_glamor_glx.h
+
 #include xkbsrv.h
 
 extern int KdTsPhyScreen;
+extern Bool ephyr_glamor;
 
 KdKeyboardInfo *ephyrKbd;
 KdPointerInfo *ephyrMouse;
@@ -326,15 +332,19 @@ ephyrInternalDamageRedisplay(ScreenPtr pScreen)
 int nbox;
 BoxPtr pbox;
 
-nbox = RegionNumRects(pRegion);
-pbox = RegionRects(pRegion);
-
-while (nbox--) {
-hostx_paint_rect(screen,
- pbox-x1, pbox-y1,
- pbox-x1, pbox-y1,
- pbox-x2 - pbox-x1, pbox-y2 - pbox-y1);
-pbox++;
+if (ephyr_glamor) {
+ephyr_glamor_damage_redisplay(scrpriv-glamor, pRegion);
+} else {
+nbox = RegionNumRects(pRegion);
+pbox = RegionRects(pRegion);
+
+while (nbox--) {
+hostx_paint_rect(screen,
+ pbox-x1, pbox-y1

[PATCH 4/8] glamor: Fix attempting to compile shaders with no active context.

2014-02-03 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 5246c98..5883809 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -215,6 +215,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
 char *source;
 
 glamor_priv = glamor_get_screen_private(screen);
+glamor_get_context(glamor_priv);
 glamor_priv-finish_access_prog[0] = glCreateProgram();
 glamor_priv-finish_access_prog[1] = glCreateProgram();
 
@@ -234,7 +235,6 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
   source);
 free(source);
 
-glamor_get_context(glamor_priv);
 glAttachShader(glamor_priv-finish_access_prog[1], avs_prog);
 glAttachShader(glamor_priv-finish_access_prog[1], set_alpha_prog);
 
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 5/8] glamor: Promote the screen pixmap to a texture when it starts as MEMORY.

2014-02-03 Thread Eric Anholt
If you're building a new X Server and trying to light up glamor, one
of the first things you want to do is get it rendering the screen to a
texture so you can later draw that to some real output (or possibly
not draw it at all, if it's Xvfb-like).  Don't just leave it in a
segfaulting MEMORY state.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 5947d7f..65fabc2 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -115,6 +115,23 @@ glamor_set_screen_pixmap(PixmapPtr screen_pixmap, 
PixmapPtr *back_pixmap)
 
 glamor_priv = glamor_get_screen_private(screen_pixmap-drawable.pScreen);
 pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
+
+/* If the screen pixmap hasn't already been set up to be some special
+ * pixmap type, then promote it to GLAMOR_TEXTURE_ONLY now.
+ */
+if (pixmap_priv-type == GLAMOR_MEMORY) {
+GLenum format;
+glamor_pixmap_fbo *fbo;
+
+gl_iformat_for_depth(screen_pixmap-drawable.depth, format);
+glamor_set_pixmap_type(screen_pixmap, GLAMOR_TEXTURE_ONLY);
+fbo = glamor_create_fbo(glamor_priv,
+screen_pixmap-drawable.width,
+screen_pixmap-drawable.height,
+format, 0);
+glamor_pixmap_attach_fbo(screen_pixmap, fbo);
+}
+
 glamor_priv-screen_fbo = pixmap_priv-base.fbo-fb;
 
 pixmap_priv-base.fbo-width = screen_pixmap-drawable.width;
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 3/8] glamor: Put in a pluggable context switcher for GLX versus EGL.

2014-02-03 Thread Eric Anholt
The GLX side just gets the context from the current state.  That's
also something I want to do for EGL, so that the making a context is
separate from initializing glamor, but I think I need the modesetting
driver in the server before I think about hacking on that more.

The previous code was rather incestuous, along with pulling in xf86
dependencies to our dix code.  The new code just initializes itself
from the current state.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/Makefile.am|  2 ++
 glamor/glamor.c   |  8 +++--
 glamor/glamor.h   |  7 ++--
 glamor/glamor_context.h   | 56 
 glamor/glamor_egl.c   | 58 ++---
 glamor/glamor_egl_stubs.c | 12 +--
 glamor/glamor_glx.c   | 82 +++
 glamor/glamor_priv.h  |  6 
 glamor/glamor_utils.h | 18 ++-
 9 files changed, 189 insertions(+), 60 deletions(-)
 create mode 100644 glamor/glamor_context.h
 create mode 100644 glamor/glamor_glx.c

diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 17cae97..12a57c4 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -6,6 +6,7 @@ AM_CFLAGS = $(CWARNFLAGS) $(DIX_CFLAGS) $(GLAMOR_CFLAGS)
 
 libglamor_la_SOURCES = \
glamor.c \
+   glamor_context.h \
glamor_copyarea.c \
glamor_copywindow.c \
glamor_core.c \
@@ -13,6 +14,7 @@ libglamor_la_SOURCES = \
glamor_fill.c \
glamor_fillspans.c \
glamor_getspans.c \
+   glamor_glx.c \
glamor_glyphs.c \
glamor_polyfillrect.c \
glamor_polylines.c \
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 410ebd2..5947d7f 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -340,8 +340,12 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 #endif
 /* If we are using egl screen, call egl screen init to
  * register correct close screen function. */
-if (flags  GLAMOR_USE_EGL_SCREEN)
-glamor_egl_screen_init(screen);
+if (flags  GLAMOR_USE_EGL_SCREEN) {
+glamor_egl_screen_init(screen, glamor_priv-ctx);
+} else {
+if (!glamor_glx_screen_init(glamor_priv-ctx))
+goto fail;
+}
 
 glamor_priv-saved_procs.close_screen = screen-CloseScreen;
 screen-CloseScreen = glamor_close_screen;
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 05f565b..eec6872 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -36,6 +36,8 @@
 #include fb.h
 #include fbpict.h
 
+struct glamor_context;
+
 /*
  * glamor_pixmap_type : glamor pixmap's type.
  * @MEMORY: pixmap is in memory.
@@ -142,11 +144,6 @@ extern _X_EXPORT void glamor_block_handler(ScreenPtr 
screen);
 extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
 int depth, unsigned int usage);
 
-extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen);
-
-extern _X_EXPORT void glamor_egl_make_current(ScreenPtr screen);
-extern _X_EXPORT void glamor_egl_restore_context(ScreenPtr screen);
-
 /* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR 
image,fbo).
  *
  * @front: front pixmap.
diff --git a/glamor/glamor_context.h b/glamor/glamor_context.h
new file mode 100644
index 000..8781afc
--- /dev/null
+++ b/glamor/glamor_context.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * 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 Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * @file glamor_context.h
+ *
+ * This is the struct of state required for context switching in
+ * glamor.  It has to use types that don't require including either
+ * server headers or Xlib headers, since it will be included by both
+ * the server and the GLX (xlib) code.
+ */
+
+struct glamor_context {
+/** Either an EGLDisplay or an Xlib Display */
+void *display;
+
+/** Either a GLXContext or an EGLContext. */
+void

[PATCH 8/8] xephyr: Use GLX swap events to reduce repaints.

2014-02-03 Thread Eric Anholt
If there's a swap already outstanding, don't bother queueing another
one until this one has completed.  The assumption here is that our
screen paints are cheap compared to everything else going on, so we
don't need to queue them up way ahead of time.  The swap events also
give us information we can use to avoid full screen repaints when the
swap is a copy.

Signed-off-by: Eric Anholt e...@anholt.net
---
 hw/kdrive/ephyr/ephyr.c|  1 +
 hw/kdrive/ephyr/ephyr_glamor_glx.c | 95 +-
 hw/kdrive/ephyr/ephyr_glamor_glx.h |  1 +
 hw/kdrive/ephyr/hostx.c|  8 
 4 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index aaa9bb9..460d804 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -35,6 +35,7 @@
 #include inputstr.h
 #include scrnintstr.h
 #include ephyrlog.h
+#include ephyr_glamor_glx.h
 
 #ifdef XF86DRI
 #include xcb/xf86dri.h
diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.c 
b/hw/kdrive/ephyr/ephyr_glamor_glx.c
index d56907f..7086c23 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -52,6 +52,9 @@
 static Display *dpy;
 static XVisualInfo *visual_info;
 static GLXFBConfig fb_config;
+static int glx_swap_event = -1;
+struct ephyr_glamor *glamor_screens[MAXSCREENS];
+static int num_glamor_screens;
 /** @} */
 
 /**
@@ -67,6 +70,12 @@ struct ephyr_glamor {
 GLuint texture_shader;
 GLuint texture_shader_position_loc;
 GLuint texture_shader_texcoord_loc;
+
+Bool use_swap_events;
+Bool swap_outstanding;
+Bool needs_repaint;
+
+pixman_region16_t pending_damage;
 };
 
 static GLint
@@ -201,6 +210,17 @@ ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
 0, 0,
 };
 
+/* If our last swap hasn't hit the screen yet, then wait for it
+ * and repaint then.
+ */
+if (glamor-use_swap_events  glamor-swap_outstanding) {
+glamor-needs_repaint = true;
+pixman_region_union(glamor-pending_damage,
+glamor-pending_damage,
+damage);
+return;
+}
+
 glXMakeCurrent(dpy, glamor-glx_win, glamor-ctx);
 
 glBindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -221,6 +241,26 @@ ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
 glDisableVertexAttribArray(glamor-texture_shader_texcoord_loc);
 
 glXSwapBuffers(dpy, glamor-glx_win);
+glamor-swap_outstanding = True;
+pixman_region_clear(glamor-pending_damage);
+}
+
+static void
+ephyr_glamor_handle_swap_event(Window win, int type)
+{
+for (int i = 0; i  num_glamor_screens; i++) {
+struct ephyr_glamor *glamor = glamor_screens[i];
+
+if (win != glamor-glx_win  win != glamor-win)
+continue;
+
+glamor-swap_outstanding = False;
+
+if (glamor-needs_repaint) {
+ephyr_glamor_damage_redisplay(glamor, glamor-pending_damage);
+glamor-needs_repaint = False;
+}
+}
 }
 
 /**
@@ -229,11 +269,13 @@ ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
  * We need to let the Xlib event filtering run on the event so that
  * Mesa's dri2_glx.c userspace event mangling gets run, and we
  * correctly get our invalidate events propagated into the driver.
+ * Since we need to consume mangled events for GLXBufferSwapComplete
+ * on DRI2, we need to do that here instead of in the main XCB event
+ * loop.
  */
 void
 ephyr_glamor_process_event(xcb_generic_event_t *xev)
 {
-
 uint32_t response_type = xev-response_type  0x7f;
 /* Note the types on wire_to_event: there's an Xlib XEvent (with
  * the broken types) that it returns, and a protocol xEvent that
@@ -246,15 +288,38 @@ ephyr_glamor_process_event(xcb_generic_event_t *xev)
 wire_to_event = XESetWireToEvent(dpy, response_type, NULL);
 if (wire_to_event) {
 XEvent processed_event;
+int x_response_type;
+Bool result;
 
 /* OK they had an event handler.  Plug it back in, and call
  * through to it.
  */
 XESetWireToEvent(dpy, response_type, wire_to_event);
 xev-sequence = LastKnownRequestProcessed(dpy);
+result = wire_to_event(dpy, processed_event, (xEvent *)xev);
 wire_to_event(dpy, processed_event, (xEvent *)xev);
+XUnlockDisplay(dpy);
+
+x_response_type = processed_event.type  0x7f;
+
+if (result) {
+if (x_response_type == glx_swap_event) {
+GLXBufferSwapComplete *swap =
+(GLXBufferSwapComplete *)processed_event;
+ephyr_glamor_handle_swap_event(swap-drawable,
+   swap-event_type);
+return;
+}
+}
+} else {
+XUnlockDisplay(dpy);
+}
+
+if (response_type == glx_swap_event) {
+xcb_glx_buffer_swap_complete_event_t *swap

[PATCH 7/8] xephyr: Pass incoming XCB events to the Xlib event filter.

2014-02-03 Thread Eric Anholt
This is the same thing that Qt ended up doing to get DRI2's event
mangling to happen despite using an XCB event loop.

Signed-off-by: Eric Anholt e...@anholt.net
---
 hw/kdrive/ephyr/ephyr.c|  3 +++
 hw/kdrive/ephyr/ephyr_glamor_glx.c | 39 ++
 hw/kdrive/ephyr/ephyr_glamor_glx.h | 15 +--
 3 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index e799b6e..aaa9bb9 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -1217,6 +1217,9 @@ ephyrPoll(void)
 break;
 }
 
+if (ephyr_glamor)
+ephyr_glamor_process_event(xev);
+
 free(xev);
 }
 }
diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.c 
b/hw/kdrive/ephyr/ephyr_glamor_glx.c
index a937c1a..d56907f 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -29,12 +29,17 @@
 
 #include stdlib.h
 #include X11/Xlib.h
+#include X11/Xlibint.h
+#undef Xcalloc
+#undef Xrealloc
+#undef Xfree
 #include X11/Xlib-xcb.h
 #include xcb/xcb_aux.h
 #include pixman.h
 #include epoxy/glx.h
 #include ephyr_glamor_glx.h
 #include os.h
+#include X11/Xproto.h
 
 /** @{
  *
@@ -218,6 +223,40 @@ ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
 glXSwapBuffers(dpy, glamor-glx_win);
 }
 
+/**
+ * Xlib-based handling of xcb events for glamor.
+ *
+ * We need to let the Xlib event filtering run on the event so that
+ * Mesa's dri2_glx.c userspace event mangling gets run, and we
+ * correctly get our invalidate events propagated into the driver.
+ */
+void
+ephyr_glamor_process_event(xcb_generic_event_t *xev)
+{
+
+uint32_t response_type = xev-response_type  0x7f;
+/* Note the types on wire_to_event: there's an Xlib XEvent (with
+ * the broken types) that it returns, and a protocol xEvent that
+ * it inspects.
+ */
+Bool (*wire_to_event)(Display *dpy, XEvent *ret, xEvent *event);
+
+XLockDisplay(dpy);
+/* Set the event handler to NULL to get access to the current one. */
+wire_to_event = XESetWireToEvent(dpy, response_type, NULL);
+if (wire_to_event) {
+XEvent processed_event;
+
+/* OK they had an event handler.  Plug it back in, and call
+ * through to it.
+ */
+XESetWireToEvent(dpy, response_type, wire_to_event);
+xev-sequence = LastKnownRequestProcessed(dpy);
+wire_to_event(dpy, processed_event, (xEvent *)xev);
+}
+XUnlockDisplay(dpy);
+}
+
 struct ephyr_glamor *
 ephyr_glamor_glx_screen_init(xcb_window_t win)
 {
diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.h 
b/hw/kdrive/ephyr/ephyr_glamor_glx.h
index 950beff..8995e1e 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.h
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.h
@@ -53,10 +53,21 @@ ephyr_glamor_glx_screen_fini(struct ephyr_glamor *glamor);
 void
 ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
   struct pixman_region16 *damage);
-#else
+
+void
+ephyr_glamor_process_event(xcb_generic_event_t *xev);
+
+#else /* !GLAMOR */
+
 static inline void
 ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
   struct pixman_region16 *damage)
 {
 }
-#endif
+
+static inline void
+ephyr_glamor_process_event(xcb_generic_event_t *xev)
+{
+}
+
+#endif /* !GLAMOR */
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 2/8] glamor: Rename glamor_get/put_dispatch to glamor_get/put_context.

2014-02-03 Thread Eric Anholt
It used to be the thing that returned your dispatch table and happeend
to set up the context, but now it just sets up the context.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor.c   |  8 
 glamor/glamor_copyarea.c  | 18 +-
 glamor/glamor_core.c  | 12 ++--
 glamor/glamor_fbo.c   | 16 
 glamor/glamor_fill.c  | 18 +-
 glamor/glamor_glyphs.c|  4 ++--
 glamor/glamor_gradient.c  | 30 +++---
 glamor/glamor_pixmap.c| 26 +-
 glamor/glamor_render.c| 32 
 glamor/glamor_tile.c  | 18 +-
 glamor/glamor_trapezoid.c | 24 
 glamor/glamor_utils.h |  4 ++--
 glamor/glamor_xv.c| 12 ++--
 13 files changed, 111 insertions(+), 111 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 74ae150..410ebd2 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -219,11 +219,11 @@ glamor_block_handler(ScreenPtr screen)
 {
 glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
 
-glamor_get_dispatch(glamor_priv);
+glamor_get_context(glamor_priv);
 glamor_priv-tick++;
 glFlush();
 glamor_fbo_expire(glamor_priv);
-glamor_put_dispatch(glamor_priv);
+glamor_put_context(glamor_priv);
 if (glamor_priv-state == RENDER_STATE
  glamor_priv-render_idle_cnt++  RENDER_IDEL_MAX) {
 glamor_priv-state = IDLE_STATE;
@@ -236,9 +236,9 @@ _glamor_block_handler(void *data, OSTimePtr timeout, void 
*last_select_mask)
 {
 glamor_screen_private *glamor_priv = data;
 
-glamor_get_dispatch(glamor_priv);
+glamor_get_context(glamor_priv);
 glFlush();
-glamor_put_dispatch(glamor_priv);
+glamor_put_context(glamor_priv);
 }
 
 static void
diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c
index 6eb0d98..7279d34 100644
--- a/glamor/glamor_copyarea.c
+++ b/glamor/glamor_copyarea.c
@@ -71,7 +71,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
 pixmap_priv_get_fbo_off(dst_pixmap_priv, fbo_x_off, fbo_y_off);
 pixmap_priv_get_fbo_off(src_pixmap_priv, src_fbo_x_off, src_fbo_y_off);
 
-glamor_get_dispatch(glamor_priv);
+glamor_get_context(glamor_priv);
 glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, src_pixmap_priv-base.fbo-fb);
 glamor_get_drawable_deltas(dst, dst_pixmap, dst_x_off, dst_y_off);
 glamor_get_drawable_deltas(src, src_pixmap, src_x_off, src_y_off);
@@ -113,7 +113,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
   GL_COLOR_BUFFER_BIT, GL_NEAREST);
 }
 }
-glamor_put_dispatch(glamor_priv);
+glamor_put_context(glamor_priv);
 glamor_priv-state = BLIT_STATE;
 return TRUE;
 }
@@ -157,7 +157,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
 
 glamor_get_drawable_deltas(dst, dst_pixmap, dst_x_off, dst_y_off);
 
-glamor_get_dispatch(glamor_priv);
+glamor_get_context(glamor_priv);
 
 glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
 glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
@@ -213,7 +213,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
 #endif
 glUseProgram(0);
 /* The source texture is bound to a fbo, we have to flush it here. */
-glamor_put_dispatch(glamor_priv);
+glamor_put_context(glamor_priv);
 glamor_priv-state = RENDER_STATE;
 glamor_priv-render_idle_cnt = 0;
 return TRUE;
@@ -374,12 +374,12 @@ _glamor_copy_n_to_n(DrawablePtr src,
 if (gc) {
 if (!glamor_set_planemask(dst_pixmap, gc-planemask))
 goto fall_back;
-glamor_get_dispatch(glamor_priv);
+glamor_get_context(glamor_priv);
 if (!glamor_set_alu(gc-alu)) {
-glamor_put_dispatch(glamor_priv);
+glamor_put_context(glamor_priv);
 goto fail;
 }
-glamor_put_dispatch(glamor_priv);
+glamor_put_context(glamor_priv);
 }
 
 if (!src_pixmap_priv) {
@@ -552,9 +552,9 @@ _glamor_copy_n_to_n(DrawablePtr src,
 }
 
  fail:
-glamor_get_dispatch(glamor_priv);
+glamor_get_context(glamor_priv);
 glamor_set_alu(GXcopy);
-glamor_put_dispatch(glamor_priv);
+glamor_put_context(glamor_priv);
 
 if (ok)
 return TRUE;
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index b69d092..5246c98 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -234,7 +234,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
   source);
 free(source);
 
-glamor_get_dispatch(glamor_priv);
+glamor_get_context(glamor_priv);
 glAttachShader(glamor_priv-finish_access_prog[1], avs_prog);
 glAttachShader(glamor_priv-finish_access_prog[1], set_alpha_prog);
 
@@ -274,7 +274,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
 glUniform1i(sampler_uniform_location, 0);
 glUniform1i(glamor_priv

xephyr-glamor series

2014-02-03 Thread Eric Anholt
Additionally, there's a rendering bug when you run some Render-using
applications (cairogears -xrender TRAP shows it off very well) that I
think is fallback-related but I haven't quite tracked it down yet.
You can see some fallback fixes in glamor-server I wrote while trying
to fix this.

This code is on the glamor-xephyr branch of my server tree.


___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 02/15] glamor: Drop fixed function transformation matrix setup.

2014-02-03 Thread Eric Anholt
gl_ModelViewProjection and friends aren't used in our shaders, so this
setup didn't do anything.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_pixmap.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 9fe2b2e..41d5f5a 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -69,12 +69,6 @@ glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo *fbo, 
int x0, int y0,
 glamor_get_context(fbo-glamor_priv);
 
 glBindFramebuffer(GL_FRAMEBUFFER, fbo-fb);
-#ifndef GLAMOR_GLES2
-glMatrixMode(GL_PROJECTION);
-glLoadIdentity();
-glMatrixMode(GL_MODELVIEW);
-glLoadIdentity();
-#endif
 glViewport(x0, y0, width, height);
 
 glamor_put_context(fbo-glamor_priv);
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 03/15] glamor: yInverted is a boolean value, so use the Bool type.

2014-02-03 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor.c  | 4 ++--
 glamor/glamor_priv.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index f1c71ea..ba2a1f4 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -308,10 +308,10 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 return FALSE;
 
 if (flags  GLAMOR_INVERTED_Y_AXIS) {
-glamor_priv-yInverted = 1;
+glamor_priv-yInverted = TRUE;
 }
 else
-glamor_priv-yInverted = 0;
+glamor_priv-yInverted = FALSE;
 
 if (!dixRegisterPrivateKey(glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
 LogMessage(X_WARNING,
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index f2bc002..53af353 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -215,7 +215,7 @@ struct glamor_saved_procs {
 #define RENDER_IDEL_MAX 32
 
 typedef struct glamor_screen_private {
-int yInverted;
+Bool yInverted;
 unsigned int tick;
 enum glamor_gl_flavor gl_flavor;
 int has_pack_invert;
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 04/15] glamor: Drop a bunch of GLES2 ifdefs.

2014-02-03 Thread Eric Anholt
Now that we're using epoxy, we can write code using both desktop and
ES symbols and decide what to use at runtime.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor.c   | 40 +++-
 glamor/glamor_copyarea.c  | 15 ++-
 glamor/glamor_fill.c  | 16 +---
 glamor/glamor_render.c| 34 ++
 glamor/glamor_trapezoid.c | 20 ++--
 5 files changed, 62 insertions(+), 63 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index ba2a1f4..a91c3ff 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -329,26 +329,29 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 goto fail;;
 }
 
+if (epoxy_is_desktop_gl())
+glamor_priv-gl_flavor = GLAMOR_GL_DESKTOP;
+else
+glamor_priv-gl_flavor = GLAMOR_GL_ES2;
+
 gl_version = glamor_gl_get_version();
 
-#ifndef GLAMOR_GLES2
-if (gl_version  GLAMOR_GL_VERSION_ENCODE(1, 3)) {
-ErrorF(Require OpenGL version 1.3 or latter.\n);
-goto fail;
-}
-#else
-if (gl_version  GLAMOR_GL_VERSION_ENCODE(2, 0)) {
-ErrorF(Require Open GLES2.0 or latter.\n);
-goto fail;
-}
-#endif
+if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP) {
+if (gl_version  GLAMOR_GL_VERSION_ENCODE(1, 3)) {
+ErrorF(Require OpenGL version 1.3 or latter.\n);
+goto fail;
+}
+} else {
+if (gl_version  GLAMOR_GL_VERSION_ENCODE(2, 0)) {
+ErrorF(Require Open GLES2.0 or latter.\n);
+goto fail;
+}
 
-#ifdef GLAMOR_GLES2
-if (!glamor_gl_has_extension(GL_EXT_texture_format_BGRA)) {
-ErrorF(GL_EXT_texture_format_BGRA required\n);
-goto fail;
+if (!glamor_gl_has_extension(GL_EXT_texture_format_BGRA)) {
+ErrorF(GL_EXT_texture_format_BGRA required\n);
+goto fail;
+}
 }
-#endif
 
 glamor_priv-has_pack_invert =
 glamor_gl_has_extension(GL_MESA_pack_invert);
@@ -361,11 +364,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 
 glamor_set_debug_level(glamor_debug_level);
 
-#ifdef GLAMOR_GLES2
-glamor_priv-gl_flavor = GLAMOR_GL_ES2;
-#else
-glamor_priv-gl_flavor = GLAMOR_GL_DESKTOP;
-#endif
 /* If we are using egl screen, call egl screen init to
  * register correct close screen function. */
 if (flags  GLAMOR_USE_EGL_SCREEN) {
diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c
index 498a06e..8cc7cad 100644
--- a/glamor/glamor_copyarea.c
+++ b/glamor/glamor_copyarea.c
@@ -31,7 +31,6 @@
  *
  * GC CopyArea implementation
  */
-#ifndef GLAMOR_GLES2
 static Bool
 glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
 DrawablePtr dst,
@@ -117,7 +116,6 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
 glamor_priv-state = BLIT_STATE;
 return TRUE;
 }
-#endif
 
 static Bool
 glamor_copy_n_to_n_textured(DrawablePtr src,
@@ -170,10 +168,10 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
 
 glActiveTexture(GL_TEXTURE0);
 glBindTexture(GL_TEXTURE_2D, src_pixmap_priv-base.fbo-tex);
-#ifndef GLAMOR_GLES2
-glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
-glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
-#endif
+if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP) {
+glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
+glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
+}
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
@@ -266,15 +264,14 @@ __glamor_copy_n_to_n(DrawablePtr src,
box[0].x1, box[0].y1,
box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
dx, dy, src_pixmap, dst_pixmap);
-#ifndef GLAMOR_GLES2
-if (!overlaped 
+if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP 
+!overlaped 
 (glamor_priv-state != RENDER_STATE
  || !src_pixmap_priv-base.gl_tex || !dst_pixmap_priv-base.gl_tex)
  glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) {
 ret = TRUE;
 goto done;
 }
-#endif
 glamor_calculate_boxes_bound(bound, box, nbox);
 
 /*  Overlaped indicate the src and dst are the same pixmap. */
diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c
index c9bd519..d1c16ad 100644
--- a/glamor/glamor_fill.c
+++ b/glamor/glamor_fill.c
@@ -240,13 +240,15 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int 
nbox, float *color)
 }
 if (box_cnt == 1)
 glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
-else
-#ifndef GLAMOR_GLES2
-glDrawRangeElements(GL_TRIANGLES, 0, box_cnt * 4, box_cnt * 6,
-GL_UNSIGNED_SHORT, NULL);
-#else
-glDrawElements(GL_TRIANGLES, box_cnt * 6, GL_UNSIGNED_SHORT, NULL

[PATCH 14/15] glamor: Move the EGL DRI3 code to GLAMOR_HAS_GBM.

2014-02-03 Thread Eric Anholt
There's nothing dependent on the presence of DRI3 code in the server
for this, but it does rely on GBM.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_egl.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 81e697b..9dcba71 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -190,7 +190,7 @@ glamor_egl_create_argb_based_texture(ScreenPtr screen, 
int w, int h)
 EGLImageKHR image;
 GLuint texture;
 
-#ifdef GLAMOR_HAS_DRI3_SUPPORT
+#ifdef GLAMOR_HAS_GBM
 struct gbm_bo *bo;
 EGLNativePixmapType native_pixmap;
 
@@ -356,7 +356,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap, void *bo)
 return ret;
 }
 
-#ifdef GLAMOR_HAS_DRI3_SUPPORT
+#ifdef GLAMOR_HAS_GBM
 int glamor_get_fd_from_bo(int gbm_fd, struct gbm_bo *bo, int *fd);
 void glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name);
 int
@@ -391,7 +391,7 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
  unsigned int tex,
  Bool want_name, CARD16 *stride, CARD32 *size)
 {
-#ifdef GLAMOR_HAS_DRI3_SUPPORT
+#ifdef GLAMOR_HAS_GBM
 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 struct glamor_screen_private *glamor_priv =
 glamor_get_screen_private(screen);
@@ -460,7 +460,7 @@ glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
CARD16 height,
CARD16 stride, CARD8 depth, CARD8 bpp)
 {
-#ifdef GLAMOR_HAS_DRI3_SUPPORT
+#ifdef GLAMOR_HAS_GBM
 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 struct glamor_egl_screen_private *glamor_egl;
 struct gbm_bo *bo;
@@ -735,7 +735,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 KHR_surfaceless_opengl);
 #endif
 
-#ifdef GLAMOR_HAS_DRI3_SUPPORT
+#ifdef GLAMOR_HAS_GBM
 if (glamor_egl_has_extension(glamor_egl, EGL_KHR_gl_texture_2D_image) 
 glamor_egl_has_extension(glamor_egl, EGL_EXT_image_dma_buf_import))
 glamor_egl-dri3_capable = TRUE;
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 01/15] glamor: Drop useless glEnable/glDisable(GL_TEXTURE_2D) calls.

2014-02-03 Thread Eric Anholt
Those calls are only for enabling texture handling in the fixed
function pipeline, while everything we do is with shaders.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_copyarea.c  | 4 
 glamor/glamor_pixmap.c| 6 --
 glamor/glamor_putimage.c  | 2 --
 glamor/glamor_render.c| 9 -
 glamor/glamor_tile.c  | 6 --
 glamor/glamor_trapezoid.c | 6 --
 6 files changed, 33 deletions(-)

diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c
index 7279d34..498a06e 100644
--- a/glamor/glamor_copyarea.c
+++ b/glamor/glamor_copyarea.c
@@ -171,7 +171,6 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
 glActiveTexture(GL_TEXTURE0);
 glBindTexture(GL_TEXTURE_2D, src_pixmap_priv-base.fbo-tex);
 #ifndef GLAMOR_GLES2
-glEnable(GL_TEXTURE_2D);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
 #endif
@@ -208,9 +207,6 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
 
 glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-#ifndef GLAMOR_GLES2
-glDisable(GL_TEXTURE_2D);
-#endif
 glUseProgram(0);
 /* The source texture is bound to a fbo, we have to flush it here. */
 glamor_put_context(glamor_priv);
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 4012755..9fe2b2e 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -538,18 +538,12 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
 
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-#ifndef GLAMOR_GLES2
-glEnable(GL_TEXTURE_2D);
-#endif
 glUseProgram(glamor_priv-finish_access_prog[no_alpha]);
 glUniform1i(glamor_priv-finish_access_revert[no_alpha], revert);
 glUniform1i(glamor_priv-finish_access_swap_rb[no_alpha], swap_rb);
 
 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 
-#ifndef GLAMOR_GLES2
-glDisable(GL_TEXTURE_2D);
-#endif
 glUseProgram(0);
 glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
diff --git a/glamor/glamor_putimage.c b/glamor/glamor_putimage.c
index 60ccd67..702e89f 100644
--- a/glamor/glamor_putimage.c
+++ b/glamor/glamor_putimage.c
@@ -170,7 +170,6 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
 
 glGenTextures(1, tex);
 glActiveTexture(GL_TEXTURE0);
-glEnable(GL_TEXTURE_2D);
 glBindTexture(GL_TEXTURE_2D, tex);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -220,7 +219,6 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
 glamor_set_alu(GXcopy);
 glamor_set_planemask(pixmap, ~0);
 glDeleteTextures(1, tex);
-glDisable(GL_TEXTURE_2D);
 glDisableClientState(GL_VERTEX_ARRAY);
 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 return;
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 34530f3..ecc4606 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -572,9 +572,6 @@ glamor_set_composite_texture(glamor_screen_private 
*glamor_priv, int unit,
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 break;
 }
-#ifndef GLAMOR_GLES2
-glEnable(GL_TEXTURE_2D);
-#endif
 
 /*
  *  GLES2 doesn't support RepeatNone. We need to fix it anyway.
@@ -1409,12 +1406,6 @@ glamor_composite_with_shader(CARD8 op,
 glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
 glDisable(GL_BLEND);
-#ifndef GLAMOR_GLES2
-glActiveTexture(GL_TEXTURE0);
-glDisable(GL_TEXTURE_2D);
-glActiveTexture(GL_TEXTURE1);
-glDisable(GL_TEXTURE_2D);
-#endif
 DEBUGF(finish rendering.\n);
 glUseProgram(0);
 glamor_priv-state = RENDER_STATE;
diff --git a/glamor/glamor_tile.c b/glamor/glamor_tile.c
index 5b58e80..9abb95d 100644
--- a/glamor/glamor_tile.c
+++ b/glamor/glamor_tile.c
@@ -135,9 +135,6 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
-#ifndef GLAMOR_GLES2
-glEnable(GL_TEXTURE_2D);
-#endif
 glamor_set_repeat_normalize_tcoords
 (src_pixmap_priv, RepeatNormal,
  src_xscale, src_yscale,
@@ -158,9 +155,6 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 
 glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-#ifndef GLAMOR_GLES2
-glDisable(GL_TEXTURE_2D);
-#endif
 glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 glUseProgram(0);
 glamor_put_context(glamor_priv);
diff --git a/glamor/glamor_trapezoid.c b/glamor/glamor_trapezoid.c
index 6ef0c1d

[PATCH 07/15] glamor: Unifdef the cache format indices.

2014-02-03 Thread Eric Anholt
We only ask for GL_RGB on desktop GL as far as I can see, but now if
GLES2 did happen to ask for GL_RGB it would return a cache index
instead of -1.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_priv.h  |  4 
 glamor/glamor_utils.h | 18 ++
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index a6cdf64..81b46b6 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -197,11 +197,7 @@ struct glamor_saved_procs {
 SetWindowPixmapProcPtr set_window_pixmap;
 };
 
-#ifdef GLAMOR_GLES2
 #define CACHE_FORMAT_COUNT 3
-#else
-#define CACHE_FORMAT_COUNT 2
-#endif
 
 #define CACHE_BUCKET_WCOUNT 4
 #define CACHE_BUCKET_HCOUNT 4
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 29f1586..581f8b9 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -1020,20 +1020,6 @@ 
glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
 return 0;
 }
 
-/* Currently, we use RGBA to represent all formats. */
-inline static int
-cache_format(GLenum format)
-{
-switch (format) {
-case GL_ALPHA:
-return 1;
-case GL_RGBA:
-return 0;
-default:
-return -1;
-}
-}
-
 #else
 #define IS_LITTLE_ENDIAN  (IMAGE_BYTE_ORDER == LSBFirst)
 
@@ -1206,6 +1192,8 @@ 
glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
 return 0;
 }
 
+#endif
+
 inline static int
 cache_format(GLenum format)
 {
@@ -1221,8 +1209,6 @@ cache_format(GLenum format)
 }
 }
 
-#endif
-
 static inline int
 glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
GLenum * format,
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 15/15] xephyr: Allow initializing glamor with gles2 (on GLX).

2014-02-03 Thread Eric Anholt
This should be useful for glamor development, so you can test both
paths (which are significantly different, and apparently
glamor_gradient.c was broken on GLES2 as of the import).

Signed-off-by: Eric Anholt e...@anholt.net
---
 hw/kdrive/ephyr/ephyr_glamor_glx.c | 24 +++-
 hw/kdrive/ephyr/ephyrinit.c| 12 +++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.c 
b/hw/kdrive/ephyr/ephyr_glamor_glx.c
index 7086c23..762ce6c 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -55,6 +55,7 @@ static GLXFBConfig fb_config;
 static int glx_swap_event = -1;
 struct ephyr_glamor *glamor_screens[MAXSCREENS];
 static int num_glamor_screens;
+Bool ephyr_glamor_gles2;
 /** @} */
 
 /**
@@ -151,6 +152,10 @@ ephyr_glamor_setup_texturing_shader(struct ephyr_glamor 
*glamor)
 }\n;
 
 const char *fs_source =
+#ifdef GL_ES\n
+precision mediump float;\n
+#endif\n
+\n
 varying vec2 t;\n
 uniform sampler2D s; /* initially 0 */\n
 \n
@@ -337,7 +342,24 @@ ephyr_glamor_glx_screen_init(xcb_window_t win)
 
 glx_win = glXCreateWindow(dpy, fb_config, win, NULL);
 
-ctx = glXCreateContext(dpy, visual_info, NULL, True);
+if (ephyr_glamor_gles2) {
+static const int context_attribs[] = {
+GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
+GLX_CONTEXT_MINOR_VERSION_ARB, 0,
+GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES_PROFILE_BIT_EXT,
+0,
+};
+if (epoxy_has_glx_extension(dpy, DefaultScreen(dpy),
+GLX_EXT_create_context_es2_profile)) {
+ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
+ context_attribs);
+} else {
+FatalError(Xephyr -glamor_gles2 rquires 
+   GLX_EXT_create_context_es2_profile\n);
+}
+} else {
+ctx = glXCreateContext(dpy, visual_info, NULL, True);
+}
 if (ctx == NULL)
 FatalError(glXCreateContext failed\n);
 
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index 807e717..0499302 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -35,7 +35,7 @@ extern Bool EphyrWantGrayScale;
 extern Bool EphyrWantResize;
 extern Bool kdHasPointer;
 extern Bool kdHasKbd;
-extern Bool ephyr_glamor;
+extern Bool ephyr_glamor, ephyr_glamor_gles2;
 
 #ifdef GLXEXT
 extern Bool ephyrNoDRI;
@@ -141,6 +141,7 @@ ddxUseMsg(void)
 ErrorF(-resizeable  Make Xephyr windows resizeable\n);
 #ifdef GLAMOR
 ErrorF(-glamor  Enable 2D acceleration using glamor\n);
+ErrorF(-glamor_gles2Enable 2D acceleration using glamor (with 
GLES2 only)\n);
 #endif
 ErrorF
 (-fakexa  Simulate acceleration using software 
rendering\n);
@@ -254,6 +255,15 @@ ddxProcessArgument(int argc, char **argv, int i)
 ephyrFuncs.finiAccel = ephyr_glamor_fini;
 return 1;
 }
+else if (!strcmp (argv[i], -glamor_gles2)) {
+ephyr_glamor = TRUE;
+ephyr_glamor_gles2 = TRUE;
+ephyrFuncs.initAccel = ephyr_glamor_init;
+ephyrFuncs.enableAccel = ephyr_glamor_enable;
+ephyrFuncs.disableAccel = ephyr_glamor_disable;
+ephyrFuncs.finiAccel = ephyr_glamor_fini;
+return 1;
+}
 #endif
 else if (!strcmp(argv[i], -fakexa)) {
 ephyrFuncs.initAccel = ephyrDrawInit;
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 09/15] glamor: Unifdef the picture-format-to-format-and-type functions.

2014-02-03 Thread Eric Anholt
There's no way these should be in a header file, but I'll leave that
cleanup until later.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_pixmap.c | 50 +-
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 1dbeb04..77197b5 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -194,14 +194,13 @@ glamor_set_alu(ScreenPtr screen, unsigned char alu)
  *
  * Return 0 if find a matched texture type. Otherwise return -1.
  **/
-#ifndef GLAMOR_GLES2
 static int
-glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
-   GLenum *tex_format,
-   GLenum *tex_type,
-   int *no_alpha,
-   int *revert,
-   int *swap_rb, int is_upload)
+glamor_get_tex_format_type_from_pictformat_gl(PictFormatShort format,
+  GLenum *tex_format,
+  GLenum *tex_type,
+  int *no_alpha,
+  int *revert,
+  int *swap_rb, int is_upload)
 {
 *no_alpha = 0;
 *revert = REVERT_NONE;
@@ -291,16 +290,15 @@ 
glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
 return 0;
 }
 
-#else
 #define IS_LITTLE_ENDIAN  (IMAGE_BYTE_ORDER == LSBFirst)
 
 static int
-glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
-   GLenum *tex_format,
-   GLenum *tex_type,
-   int *no_alpha,
-   int *revert,
-   int *swap_rb, int is_upload)
+glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
+ GLenum *tex_format,
+ GLenum *tex_type,
+ int *no_alpha,
+ int *revert,
+ int *swap_rb, int is_upload)
 {
 int need_swap_rb = 0;
 
@@ -463,8 +461,6 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort 
format,
 return 0;
 }
 
-#endif
-
 static int
 glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
GLenum *format,
@@ -474,6 +470,8 @@ glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
 {
 glamor_pixmap_private *pixmap_priv;
 PictFormatShort pict_format;
+glamor_screen_private *glamor_priv =
+glamor_get_screen_private(pixmap-drawable.pScreen);
 
 pixmap_priv = glamor_get_pixmap_private(pixmap);
 if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
@@ -481,11 +479,21 @@ glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
 else
 pict_format = format_for_depth(pixmap-drawable.depth);
 
-return glamor_get_tex_format_type_from_pictformat(pict_format,
-  format, type,
-  no_alpha,
-  revert,
-  swap_rb, is_upload);
+if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP) {
+return glamor_get_tex_format_type_from_pictformat_gl(pict_format,
+ format, type,
+ no_alpha,
+ revert,
+ swap_rb,
+ is_upload);
+} else {
+return glamor_get_tex_format_type_from_pictformat_gles2(pict_format,
+format, type,
+no_alpha,
+revert,
+swap_rb,
+is_upload);
+}
 }
 
 static void *
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 10/15] glamor: Move shader precision stuff from build time to shader compile time.

2014-02-03 Thread Eric Anholt
This is the last desktop-versus-ES2 build ifdef in core glamor.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_priv.h | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 81b46b6..e28a021 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -37,11 +37,10 @@
 
 #include epoxy/gl.h
 
-#ifdef GLAMOR_GLES2
-#define GLAMOR_DEFAULT_PRECISION   precision mediump float;\n
-#else
-#define GLAMOR_DEFAULT_PRECISION
-#endif
+#define GLAMOR_DEFAULT_PRECISION  \
+#ifdef GL_ES\n  \
+precision mediump float;\n  \
+#endif\n
 
 #ifdef RENDER
 #include glyphstr.h
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 11/15] glamor: Fix typo in setting v_position's attrib location.

2014-02-03 Thread Eric Anholt
Assuming it was the first attribute assigned by the GL, it would have
ended up with location 0 anyway.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_gradient.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index 4ea441e..9460199 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -395,7 +395,7 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, 
int stops_count,
 glAttachShader(gradient_prog, fs_getcolor_prog);
 glAttachShader(gradient_prog, fs_main_prog);
 
-glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, v_positionsition);
+glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, v_position);
 glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, v_texcoord);
 
 glamor_link_glsl_prog(gradient_prog);
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 08/15] glamor: Move glamor_get_tex_format_type_from_pictformat to a .c file.

2014-02-03 Thread Eric Anholt
A pair of 150 lines of inlined switch statements in a header file is
crazy.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_pixmap.c | 303 +
 glamor/glamor_utils.h  | 303 -
 2 files changed, 303 insertions(+), 303 deletions(-)

diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 30aeebe..1dbeb04 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -185,6 +185,309 @@ glamor_set_alu(ScreenPtr screen, unsigned char alu)
 return TRUE;
 }
 
+/*
+ * Map picture's format to the correct gl texture format and type.
+ * no_alpha is used to indicate whehter we need to wire alpha to 1.
+ *
+ * Although opengl support A1/GL_BITMAP, we still don't use it
+ * here, it seems that mesa has bugs when uploading a A1 bitmap.
+ *
+ * Return 0 if find a matched texture type. Otherwise return -1.
+ **/
+#ifndef GLAMOR_GLES2
+static int
+glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
+   GLenum *tex_format,
+   GLenum *tex_type,
+   int *no_alpha,
+   int *revert,
+   int *swap_rb, int is_upload)
+{
+*no_alpha = 0;
+*revert = REVERT_NONE;
+*swap_rb = is_upload ? SWAP_NONE_UPLOADING : SWAP_NONE_DOWNLOADING;
+switch (format) {
+case PICT_a1:
+*tex_format = GL_ALPHA;
+*tex_type = GL_UNSIGNED_BYTE;
+*revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1;
+break;
+case PICT_b8g8r8x8:
+*no_alpha = 1;
+case PICT_b8g8r8a8:
+*tex_format = GL_BGRA;
+*tex_type = GL_UNSIGNED_INT_8_8_8_8;
+break;
+
+case PICT_x8r8g8b8:
+*no_alpha = 1;
+case PICT_a8r8g8b8:
+*tex_format = GL_BGRA;
+*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+break;
+case PICT_x8b8g8r8:
+*no_alpha = 1;
+case PICT_a8b8g8r8:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+break;
+case PICT_x2r10g10b10:
+*no_alpha = 1;
+case PICT_a2r10g10b10:
+*tex_format = GL_BGRA;
+*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
+break;
+case PICT_x2b10g10r10:
+*no_alpha = 1;
+case PICT_a2b10g10r10:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
+break;
+
+case PICT_r5g6b5:
+*tex_format = GL_RGB;
+*tex_type = GL_UNSIGNED_SHORT_5_6_5;
+break;
+case PICT_b5g6r5:
+*tex_format = GL_RGB;
+*tex_type = GL_UNSIGNED_SHORT_5_6_5_REV;
+break;
+case PICT_x1b5g5r5:
+*no_alpha = 1;
+case PICT_a1b5g5r5:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+break;
+
+case PICT_x1r5g5b5:
+*no_alpha = 1;
+case PICT_a1r5g5b5:
+*tex_format = GL_BGRA;
+*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+break;
+case PICT_a8:
+*tex_format = GL_ALPHA;
+*tex_type = GL_UNSIGNED_BYTE;
+break;
+case PICT_x4r4g4b4:
+*no_alpha = 1;
+case PICT_a4r4g4b4:
+*tex_format = GL_BGRA;
+*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+break;
+
+case PICT_x4b4g4r4:
+*no_alpha = 1;
+case PICT_a4b4g4r4:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+break;
+
+default:
+LogMessageVerb(X_INFO, 0,
+   fail to get matched format for %x \n, format);
+return -1;
+}
+return 0;
+}
+
+#else
+#define IS_LITTLE_ENDIAN  (IMAGE_BYTE_ORDER == LSBFirst)
+
+static int
+glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
+   GLenum *tex_format,
+   GLenum *tex_type,
+   int *no_alpha,
+   int *revert,
+   int *swap_rb, int is_upload)
+{
+int need_swap_rb = 0;
+
+*no_alpha = 0;
+*revert = IS_LITTLE_ENDIAN ? REVERT_NONE : REVERT_NORMAL;
+
+switch (format) {
+case PICT_b8g8r8x8:
+*no_alpha = 1;
+case PICT_b8g8r8a8:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_BYTE;
+need_swap_rb = 1;
+*revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE;
+break;
+
+case PICT_x8r8g8b8:
+*no_alpha = 1;
+case PICT_a8r8g8b8:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_BYTE;
+need_swap_rb = 1;
+break;
+
+case PICT_x8b8g8r8:
+*no_alpha = 1;
+case PICT_a8b8g8r8:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_BYTE;
+break;
+
+case

[PATCH 12/15] glamor: Don't bother keeping references to shader stages for gradients.

2014-02-03 Thread Eric Anholt
They never get reattached to any other program, so saving them to
unreference later is a waste of code.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_gradient.c | 88 
 glamor/glamor_priv.h |  9 -
 2 files changed, 6 insertions(+), 91 deletions(-)

diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index 9460199..9ecaf03 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -356,20 +356,6 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, 
int stops_count,
 glamor_get_context(glamor_priv);
 
 if (dyn_gen  glamor_priv-gradient_prog[SHADER_GRADIENT_RADIAL][2]) {
-glDeleteShader(glamor_priv-radial_gradient_shaders
-   [SHADER_GRADIENT_VS_PROG][2]);
-glamor_priv-radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][2] = 0;
-
-glDeleteShader(glamor_priv-radial_gradient_shaders
-   [SHADER_GRADIENT_FS_MAIN_PROG][2]);
-glamor_priv-radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2] =
-0;
-
-glDeleteShader(glamor_priv-radial_gradient_shaders
-   [SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
-glamor_priv-
-radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2] = 0;
-
 glDeleteProgram(glamor_priv-gradient_prog[SHADER_GRADIENT_RADIAL][2]);
 glamor_priv-gradient_prog[SHADER_GRADIENT_RADIAL][2] = 0;
 }
@@ -394,6 +380,9 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, 
int stops_count,
 glAttachShader(gradient_prog, vs_prog);
 glAttachShader(gradient_prog, fs_getcolor_prog);
 glAttachShader(gradient_prog, fs_main_prog);
+glDeleteShader(vs_prog);
+glDeleteShader(fs_getcolor_prog);
+glDeleteShader(fs_main_prog);
 
 glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, v_position);
 glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, v_texcoord);
@@ -414,13 +403,6 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, 
int stops_count,
 }
 
 glamor_priv-gradient_prog[SHADER_GRADIENT_RADIAL][index] = gradient_prog;
-glamor_priv-radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][index] =
-vs_prog;
-glamor_priv-radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][index] =
-fs_main_prog;
-glamor_priv-
-radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][index] =
-fs_getcolor_prog;
 
 glamor_put_context(glamor_priv);
 }
@@ -588,20 +570,6 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, 
int stops_count,
 
 glamor_get_context(glamor_priv);
 if (dyn_gen  glamor_priv-gradient_prog[SHADER_GRADIENT_LINEAR][2]) {
-glDeleteShader(glamor_priv-linear_gradient_shaders
-   [SHADER_GRADIENT_VS_PROG][2]);
-glamor_priv-linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][2] = 0;
-
-glDeleteShader(glamor_priv-linear_gradient_shaders
-   [SHADER_GRADIENT_FS_MAIN_PROG][2]);
-glamor_priv-linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2] =
-0;
-
-glDeleteShader(glamor_priv-linear_gradient_shaders
-   [SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
-glamor_priv-
-linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2] = 0;
-
 glDeleteProgram(glamor_priv-gradient_prog[SHADER_GRADIENT_LINEAR][2]);
 glamor_priv-gradient_prog[SHADER_GRADIENT_LINEAR][2] = 0;
 }
@@ -624,6 +592,9 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, 
int stops_count,
 glAttachShader(gradient_prog, vs_prog);
 glAttachShader(gradient_prog, fs_getcolor_prog);
 glAttachShader(gradient_prog, fs_main_prog);
+glDeleteShader(vs_prog);
+glDeleteShader(fs_getcolor_prog);
+glDeleteShader(fs_main_prog);
 
 glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, v_position);
 glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, v_texcoord);
@@ -644,13 +615,6 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, 
int stops_count,
 }
 
 glamor_priv-gradient_prog[SHADER_GRADIENT_LINEAR][index] = gradient_prog;
-glamor_priv-linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][index] =
-vs_prog;
-glamor_priv-linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][index] =
-fs_main_prog;
-glamor_priv-
-linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][index] =
-fs_getcolor_prog;
 
 glamor_put_context(glamor_priv);
 }
@@ -665,18 +629,7 @@ glamor_init_gradient_shader(ScreenPtr screen)
 
 for (i = 0; i  3; i++) {
 glamor_priv-gradient_prog[SHADER_GRADIENT_LINEAR][i] = 0;
-glamor_priv-linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][i] = 0;
-glamor_priv-linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i] =
-0;
-glamor_priv-
-linear_gradient_shaders

[PATCH 05/15] glamor: Add a screen argument to drop an ifdef from glamor_set_alu().

2014-02-03 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_copyarea.c |  7 ---
 glamor/glamor_fill.c |  4 ++--
 glamor/glamor_pixmap.c   | 17 +++--
 glamor/glamor_priv.h |  2 +-
 glamor/glamor_tile.c |  4 ++--
 5 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c
index 8cc7cad..d6bcacd 100644
--- a/glamor/glamor_copyarea.c
+++ b/glamor/glamor_copyarea.c
@@ -338,6 +338,7 @@ _glamor_copy_n_to_n(DrawablePtr src,
 Bool upsidedown, Pixel bitplane,
 void *closure, Bool fallback)
 {
+ScreenPtr screen = dst-pScreen;
 PixmapPtr dst_pixmap, src_pixmap;
 glamor_pixmap_private *dst_pixmap_priv, *src_pixmap_priv;
 glamor_screen_private *glamor_priv;
@@ -354,7 +355,7 @@ _glamor_copy_n_to_n(DrawablePtr src,
 src_pixmap = glamor_get_drawable_pixmap(src);
 src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
 
-glamor_priv = glamor_get_screen_private(dst-pScreen);
+glamor_priv = glamor_get_screen_private(screen);
 
 DEBUGF(Copy %d %d %dx%d dx %d dy %d from %p to %p \n,
box[0].x1, box[0].y1,
@@ -368,7 +369,7 @@ _glamor_copy_n_to_n(DrawablePtr src,
 if (!glamor_set_planemask(dst_pixmap, gc-planemask))
 goto fall_back;
 glamor_get_context(glamor_priv);
-if (!glamor_set_alu(gc-alu)) {
+if (!glamor_set_alu(screen, gc-alu)) {
 glamor_put_context(glamor_priv);
 goto fail;
 }
@@ -546,7 +547,7 @@ _glamor_copy_n_to_n(DrawablePtr src,
 
  fail:
 glamor_get_context(glamor_priv);
-glamor_set_alu(GXcopy);
+glamor_set_alu(screen, GXcopy);
 glamor_put_context(glamor_priv);
 
 if (ok)
diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c
index d1c16ad..dda55ea 100644
--- a/glamor/glamor_fill.c
+++ b/glamor/glamor_fill.c
@@ -330,7 +330,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int 
height,
 }
 
 glamor_get_context(glamor_priv);
-if (!glamor_set_alu(alu)) {
+if (!glamor_set_alu(screen, alu)) {
 if (alu == GXclear)
 fg_pixel = 0;
 else {
@@ -345,7 +345,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int 
height,
 box.y2 = y + height;
 glamor_solid_boxes(pixmap, box, 1, fg_pixel);
 
-glamor_set_alu(GXcopy);
+glamor_set_alu(screen, GXcopy);
 glamor_put_context(glamor_priv);
 
 return TRUE;
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 41d5f5a..5442c90 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -115,9 +115,17 @@ glamor_set_planemask(PixmapPtr pixmap, unsigned long 
planemask)
 }
 
 Bool
-glamor_set_alu(unsigned char alu)
+glamor_set_alu(ScreenPtr screen, unsigned char alu)
 {
-#ifndef GLAMOR_GLES2
+glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+if (glamor_priv-gl_flavor == GLAMOR_GL_ES2) {
+if (alu != GXcopy)
+return FALSE;
+else
+return TRUE;
+}
+
 if (alu == GXcopy) {
 glDisable(GL_COLOR_LOGIC_OP);
 return TRUE;
@@ -173,10 +181,7 @@ glamor_set_alu(unsigned char alu)
 glamor_fallback(unsupported alu %x\n, alu);
 return FALSE;
 }
-#else
-if (alu != GXcopy)
-return FALSE;
-#endif
+
 return TRUE;
 }
 
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 53af353..a6cdf64 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -599,7 +599,7 @@ glamor_pixmap_fbo *glamor_es2_pixmap_read_prepare(PixmapPtr 
source, int x,
   int no_alpha, int revert,
   int swap_rb);
 
-Bool glamor_set_alu(unsigned char alu);
+Bool glamor_set_alu(ScreenPtr screen, unsigned char alu);
 Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
 Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
 RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
diff --git a/glamor/glamor_tile.c b/glamor/glamor_tile.c
index 9abb95d..7288af3 100644
--- a/glamor/glamor_tile.c
+++ b/glamor/glamor_tile.c
@@ -196,7 +196,7 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
 }
 
 glamor_get_context(glamor_priv);
-if (!glamor_set_alu(alu)) {
+if (!glamor_set_alu(screen, alu)) {
 glamor_fallback(unsupported alu %x\n, alu);
 glamor_put_context(glamor_priv);
 goto fail;
@@ -291,7 +291,7 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
 else
 _glamor_tile(pixmap, tile, x, y, width, height, tile_x, tile_y);
 
-glamor_set_alu(GXcopy);
+glamor_set_alu(screen, GXcopy);
 glamor_put_context(glamor_priv);
 return TRUE;
  fail:
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 06/15] glamor: Pass pixmaps around to unifdef glamor_iformat_for_depth().

2014-02-03 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor.c |  6 +++---
 glamor/glamor_picture.c |  3 +--
 glamor/glamor_pixmap.c  |  4 ++--
 glamor/glamor_utils.h   | 26 --
 4 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index a91c3ff..616ad5b 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -95,7 +95,7 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
 glamor_destroy_fbo(fbo);
 }
 
-gl_iformat_for_depth(pixmap-drawable.depth, format);
+format = gl_iformat_for_pixmap(pixmap);
 fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap-drawable.width,
  pixmap-drawable.height, format, tex, 0);
 
@@ -123,7 +123,7 @@ glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr 
*back_pixmap)
 GLenum format;
 glamor_pixmap_fbo *fbo;
 
-gl_iformat_for_depth(screen_pixmap-drawable.depth, format);
+format = gl_iformat_for_pixmap(screen_pixmap);
 glamor_set_pixmap_type(screen_pixmap, GLAMOR_TEXTURE_ONLY);
 fbo = glamor_create_fbo(glamor_priv,
 screen_pixmap-drawable.width,
@@ -190,7 +190,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int 
depth,
 pixmap_priv-base.pixmap = pixmap;
 pixmap_priv-base.glamor_priv = glamor_priv;
 
-gl_iformat_for_depth(depth, format);
+format = gl_iformat_for_pixmap(pixmap);
 
 pitch = (((w * pixmap-drawable.bitsPerPixel + 7) / 8) + 3)  ~3;
 screen-ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index f51a7e4..0d8f697 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -93,8 +93,7 @@ glamor_create_picture(PicturePtr picture)
  * we have to mark this pixmap as a separated texture, and don't
  * fallback to DDX layer. */
 if (pixmap_priv-type == GLAMOR_TEXTURE_DRM
- !glamor_pict_format_is_compatible(picture-format,
- pixmap-drawable.depth))
+ !glamor_pict_format_is_compatible(picture-format, pixmap))
 glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
 }
 }
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 5442c90..30aeebe 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -403,7 +403,7 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, 
unsigned int *tex,
 if (*tex == 0) {
 glGenTextures(1, tex);
 if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP)
-gl_iformat_for_depth(pixmap-drawable.depth, iformat);
+iformat = gl_iformat_for_pixmap(pixmap);
 else
 iformat = format;
 non_sub = 1;
@@ -603,7 +603,7 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum 
format, int no_alpha,
 return 0;
 
 if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP)
-gl_iformat_for_depth(pixmap-drawable.depth, iformat);
+iformat = gl_iformat_for_pixmap(pixmap);
 else
 iformat = format;
 
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index eafd2bc..29f1586 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -869,19 +869,17 @@ format_for_depth(int depth)
 }
 }
 
-static inline void
-gl_iformat_for_depth(int depth, GLenum * format)
+static inline GLenum
+gl_iformat_for_pixmap(PixmapPtr pixmap)
 {
-switch (depth) {
-#ifndef GLAMOR_GLES2
-case 1:
-case 8:
-*format = GL_ALPHA;
-break;
-#endif
-default:
-*format = GL_RGBA;
-break;
+glamor_screen_private *glamor_priv =
+glamor_get_screen_private(pixmap-drawable.pScreen);
+
+if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP 
+(pixmap-drawable.depth == 1 || pixmap-drawable.depth == 8)) {
+return GL_ALPHA;
+} else {
+return GL_RGBA;
 }
 }
 
@@ -1319,11 +1317,11 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
 }
 
 inline static Bool
-glamor_pict_format_is_compatible(PictFormatShort pict_format, int depth)
+glamor_pict_format_is_compatible(PictFormatShort pict_format, PixmapPtr pixmap)
 {
 GLenum iformat;
 
-gl_iformat_for_depth(depth, iformat);
+iformat = gl_iformat_for_pixmap(pixmap);
 switch (iformat) {
 case GL_RGBA:
 return (pict_format == PICT_a8r8g8b8 || pict_format == PICT_x8r8g8b8);
-- 
1.9.rc1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 13/15] glamor: Fix linking of the gradient shaders on GLES2.

2014-02-03 Thread Eric Anholt
GLES2 sensibly doesn't allow you to attach multiple shaders for the
same stage to a single program.  This means we have to attach the
whole thing in one glShaderSource call.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_gradient.c | 68 +++-
 1 file changed, 32 insertions(+), 36 deletions(-)

diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index 9ecaf03..9f6f1b1 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -42,14 +42,13 @@
 
 #ifdef GLAMOR_GRADIENT_SHADER
 
-static GLint
-_glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count,
-   int use_array)
+static const char *
+_glamor_create_getcolor_fs_source(ScreenPtr screen, int stops_count,
+  int use_array)
 {
 glamor_screen_private *glamor_priv;
 
 char *gradient_fs = NULL;
-GLint fs_getcolor_prog;
 
 #define gradient_fs_getcolor\
GLAMOR_DEFAULT_PRECISION\
@@ -181,17 +180,11 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int 
stops_count,
 if (use_array) {
 XNFasprintf(gradient_fs,
 gradient_fs_getcolor, stops_count, stops_count);
-fs_getcolor_prog =
-glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, gradient_fs);
-free(gradient_fs);
+return gradient_fs;
 }
 else {
-fs_getcolor_prog =
-glamor_compile_glsl_prog(GL_FRAGMENT_SHADER,
- gradient_fs_getcolor_no_array);
+return XNFstrdup(gradient_fs_getcolor_no_array);
 }
-
-return fs_getcolor_prog;
 }
 
 static void
@@ -203,7 +196,7 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, 
int stops_count,
 
 GLint gradient_prog = 0;
 char *gradient_fs = NULL;
-GLint fs_main_prog, fs_getcolor_prog, vs_prog;
+GLint fs_prog, vs_prog;
 
 const char *gradient_vs =
 GLAMOR_DEFAULT_PRECISION
@@ -344,7 +337,10 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, 
int stops_count,
} else {\n\
gl_FragColor = get_color(stop_len);\n\
}\n\
-   }\n
+   }\n\
+   \n\
+%s\n /* fs_getcolor_source */
+const char *fs_getcolor_source;
 
 glamor_priv = glamor_get_screen_private(screen);
 
@@ -364,25 +360,24 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, 
int stops_count,
 
 vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, gradient_vs);
 
+fs_getcolor_source =
+_glamor_create_getcolor_fs_source(screen, stops_count,
+  (stops_count  0));
+
 XNFasprintf(gradient_fs,
 gradient_radial_fs_template,
 PIXMAN_REPEAT_NONE, PIXMAN_REPEAT_NORMAL,
-PIXMAN_REPEAT_REFLECT);
+PIXMAN_REPEAT_REFLECT,
+fs_getcolor_source);
 
-fs_main_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, gradient_fs);
+fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, gradient_fs);
 
 free(gradient_fs);
 
-fs_getcolor_prog =
-_glamor_create_getcolor_fs_program(screen, stops_count,
-   (stops_count  0));
-
 glAttachShader(gradient_prog, vs_prog);
-glAttachShader(gradient_prog, fs_getcolor_prog);
-glAttachShader(gradient_prog, fs_main_prog);
+glAttachShader(gradient_prog, fs_prog);
 glDeleteShader(vs_prog);
-glDeleteShader(fs_getcolor_prog);
-glDeleteShader(fs_main_prog);
+glDeleteShader(fs_prog);
 
 glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, v_position);
 glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, v_texcoord);
@@ -416,7 +411,7 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, 
int stops_count,
 int index = 0;
 GLint gradient_prog = 0;
 char *gradient_fs = NULL;
-GLint fs_main_prog, fs_getcolor_prog, vs_prog;
+GLint fs_prog, vs_prog;
 
 const char *gradient_vs =
 GLAMOR_DEFAULT_PRECISION
@@ -559,7 +554,10 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, 
int stops_count,
{\n\
float stop_len = get_stop_len();\n\
gl_FragColor = get_color(stop_len);\n\
-   }\n
+   }\n\
+   \n\
+%s /* fs_getcolor_source */
+const char *fs_getcolor_source;
 
 glamor_priv = glamor_get_screen_private(screen);
 
@@ -578,23 +576,21 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, 
int stops_count,
 
 vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, gradient_vs);
 
+fs_getcolor_source =
+_glamor_create_getcolor_fs_source(screen, stops_count, stops_count  
0);
+
 XNFasprintf(gradient_fs,
 gradient_fs_template,
-PIXMAN_REPEAT_NORMAL, PIXMAN_REPEAT_REFLECT);
+PIXMAN_REPEAT_NORMAL, PIXMAN_REPEAT_REFLECT

Re: [PATCH 5/5] test: Fix compiler warning on 64-bit.

2014-02-03 Thread Eric Anholt
Mark Kettenis mark.kette...@xs4all.nl writes:

 From: Eric Anholt e...@anholt.net
 Date: Mon, 27 Jan 2014 11:36:09 -0800
 
 We all know that XIDs are 32 bits, even if 32-bit headers call them
 long.
 ---
  test/hashtabletest.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/test/hashtabletest.c b/test/hashtabletest.c
 index ceadfa7..a37dfb5 100644
 --- a/test/hashtabletest.c
 +++ b/test/hashtabletest.c
 @@ -12,7 +12,7 @@ static void
  print_xid(void* ptr, void* v)
  {
  XID *x = v;
 -printf(%ld, *x);
 +printf(%d, (uint32_t)*x);
  }

 There is no guarantee that uint32_t isn't long either!  And of course
 using %d to print an unsigned integer isn't quite right either.

That's super pedantic.  Do you know of a platform where that's the
case?

Regardless, I've changed it to cast to int.


pgpKf9BtOsne9.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PULL] glamor-reformat

2014-01-27 Thread Eric Anholt
The following changes since commit c1ce807d9f18f215332d7eeb844e8c640f71c53c:

  dix: Praise clients which haven't run for a while, rather than idle clients 
(2014-01-23 10:10:28 -0800)

are available in the git repository at:

  git://people.freedesktop.org/~anholt/xserver glamor-reformat

for you to fetch changes up to b98e49379c8d7cecce991207048489f51b10028c:

  glamor: Remove more out-of-tree compat code. (2014-01-27 09:30:47 -0800)


Adam Jackson (3):
  glamor: Remove copy of sna's compiler.h
  glamor/egl: Remove glapi awareness
  glamor: Use dix-config.h not project config.h

Eric Anholt (14):
  glamor: Touch up some code so indent doesn't get confused.
  glamor: Apply x-indent.sh.
  glamor: Fix some mangling of shader strings by indent.
  glamor: Fix some indent damage of putting a ' ' after the '*' for 
pointers.
  glamor: Fix up some indentation damage on header prototypes.
  glamor: Remove compat code for building out of tree.
  glamor: Disable the XV code for now.
  glamor: Drop xfree86 dependencies from this dix module.
  glamor: Disable definitions of GL extension prototypes to avoid warnings.
  glamor: Silence warnings for non-debug builds.
  glamor: Convert use of the old pointer typedef to void *.
  glamor: Hook the module back up to the build.
  glamor: Remove an extra copy of RegionNil().
  glamor: Remove more out-of-tree compat code.

 Makefile.am   |6 +
 configure.ac  |   10 +
 glamor/Makefile.am|   36 +-
 glamor/compat-api.h   |  107 -
 glamor/glamor.c   |  809 +++
 glamor/glamor.h   |  259 +-
 glamor/glamor_addtraps.c  |   34 +-
 glamor/glamor_compositerects.c|  458 ++--
 glamor/glamor_copyarea.c  | 1161 +
 glamor/glamor_copyplane.c |   50 +-
 glamor/glamor_copywindow.c|   34 +-
 glamor/glamor_core.c  |  827 ---
 glamor/glamor_debug.h |9 -
 glamor/glamor_egl.c   | 1181 +
 glamor/{compiler.h = glamor_egl_stubs.c} |   83 +-
 glamor/glamor_eglmodule.c |   24 +-
 glamor/glamor_fbo.c   |  849 +++
 glamor/glamor_fill.c  |  589 +++--
 glamor/glamor_fillspans.c |  121 +-
 glamor/glamor_getimage.c  |   97 +-
 glamor/glamor_getspans.c  |   91 +-
 glamor/glamor_gl_dispatch.c   |  138 +-
 glamor/glamor_gl_dispatch.h   |  244 +-
 glamor/glamor_glext.h |1 -
 glamor/glamor_glyphblt.c  |   83 +-
 glamor/glamor_glyphs.c| 2945 ---
 glamor/glamor_gradient.c  | 2608 ++--
 glamor/glamor_largepixmap.c   | 2429 ++-
 glamor/glamor_picture.c   |  111 +-
 glamor/glamor_pixmap.c| 2245 +
 glamor/glamor_polyfillrect.c  |  135 +-
 glamor/glamor_polylines.c |  155 +-
 glamor/glamor_polyops.c   |   43 +-
 glamor/glamor_priv.h  |  927 ---
 glamor/glamor_putimage.c  |  559 ++---
 glamor/glamor_render.c| 3724 ++---
 glamor/glamor_setspans.c  |  119 +-
 glamor/glamor_tile.c  |  514 ++--
 glamor/glamor_trapezoid.c | 3230 -
 glamor/glamor_triangles.c |   61 +-
 glamor/glamor_utils.h | 1756 +++---
 glamor/glamor_window.c|  102 +-
 glamor/glamor_xv.c| 1022 
 glamor/glapi.h|  121 -
 include/dix-config.h.in   |3 +
 45 files changed, 14938 insertions(+), 15172 deletions(-)
 delete mode 100644 glamor/compat-api.h
 rename glamor/{compiler.h = glamor_egl_stubs.c} (50%)
 delete mode 100644 glamor/glapi.h


pgp59TvFJbwVq.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 5/5] test: Fix compiler warning on 64-bit.

2014-01-27 Thread Eric Anholt
We all know that XIDs are 32 bits, even if 32-bit headers call them
long.
---
 test/hashtabletest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/hashtabletest.c b/test/hashtabletest.c
index ceadfa7..a37dfb5 100644
--- a/test/hashtabletest.c
+++ b/test/hashtabletest.c
@@ -12,7 +12,7 @@ static void
 print_xid(void* ptr, void* v)
 {
 XID *x = v;
-printf(%ld, *x);
+printf(%d, (uint32_t)*x);
 }
 
 static void
-- 
1.8.5.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 4/5] xfree86: Fix a compiler warning on 64-bit.

2014-01-27 Thread Eric Anholt
asm/mtrr.h makes this an unsigned long on 32, but a u64 on 64.  Cast
it to a long to win.
---
 hw/xfree86/os-support/linux/lnx_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/xfree86/os-support/linux/lnx_video.c 
b/hw/xfree86/os-support/linux/lnx_video.c
index 824003d..47f5abc 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -204,7 +204,7 @@ mtrr_cull_wc_region(int screenNum, unsigned long base, 
unsigned long size,
 xf86DrvMsgVerb(screenNum, X_WARNING, 0,
Failed to remove MMIO 
write-combining range (0x%lx,0x%lx)\n,
-   gent.base, (unsigned long) gent.size);
+   (unsigned long)gent.base, (unsigned long) 
gent.size);
 }
 }
 return wcreturn;
-- 
1.8.5.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 1/5] glx: Stop relying on libGL ABI bugs for glGetCompressedTexImage().

2014-01-27 Thread Eric Anholt
In theory, the linux libGL ABI exposes just GL 1.2 plus GLX 1.3.  But,
thanks to libglapi, we're letting glGetCompressedTexImageARB() be
exposed too.  The GLX code was inappropriately relying on it by using
GL_GLEXT_PROTOTYPES.
---
 glx/indirect_texture_compression.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/glx/indirect_texture_compression.c 
b/glx/indirect_texture_compression.c
index 94de47d..2018de6 100644
--- a/glx/indirect_texture_compression.c
+++ b/glx/indirect_texture_compression.c
@@ -54,9 +54,11 @@ __glXDisp_GetCompressedTexImage(struct __GLXclientStateRec 
*cl, GLbyte * pc)
  compsize);
 
 if (compsize != 0) {
+PFNGLGETCOMPRESSEDTEXIMAGEARBPROC GetCompressedTexImageARB =
+__glGetProcAddress(glGetCompressedTexImageARB);
 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
 __glXClearErrorOccured();
-glGetCompressedTexImageARB(target, level, answer);
+GetCompressedTexImageARB(target, level, answer);
 }
 
 if (__glXErrorOccured()) {
@@ -96,9 +98,11 @@ __glXDispSwap_GetCompressedTexImage(struct 
__GLXclientStateRec *cl, GLbyte * pc)
  compsize);
 
 if (compsize != 0) {
+PFNGLGETCOMPRESSEDTEXIMAGEARBPROC GetCompressedTexImageARB =
+__glGetProcAddress(glGetCompressedTexImageARB);
 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
 __glXClearErrorOccured();
-glGetCompressedTexImageARB(target, level, answer);
+GetCompressedTexImageARB(target, level, answer);
 }
 
 if (__glXErrorOccured()) {
-- 
1.8.5.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 2/5] glx: Reduce compiler warnings by not requesting GL extension prototypes.

2014-01-27 Thread Eric Anholt
They're not officially in the ABI, so you shouldn't use them anyway.
---
 glx/glxserver.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/glx/glxserver.h b/glx/glxserver.h
index 7f36e5f..3f2ae35 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -46,7 +46,6 @@
 #include resource.h
 #include scrnintstr.h
 
-#define GL_GLEXT_PROTOTYPES /* we want prototypes */
 #include GL/gl.h
 #include GL/glext.h
 #include GL/glxproto.h
-- 
1.8.5.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 3/5] glx: Delete dead NV program string functions.

2014-01-27 Thread Eric Anholt
These have been throwing a compiler warning about missing prototypes,
since the generated code to define the prototypes stopped being
generated (possibly because the code was dead).
---
 glx/indirect_program.c | 22 --
 1 file changed, 22 deletions(-)

diff --git a/glx/indirect_program.c b/glx/indirect_program.c
index fa4a240..d503262 100644
--- a/glx/indirect_program.c
+++ b/glx/indirect_program.c
@@ -122,25 +122,3 @@ __glXDispSwap_GetProgramStringARB(struct 
__GLXclientStateRec *cl, GLbyte * pc)
 
 return DoGetProgramString(cl, pc, get_program, get_program_string, True);
 }
-
-int
-__glXDisp_GetProgramStringNV(struct __GLXclientStateRec *cl, GLbyte * pc)
-{
-PFNGLGETPROGRAMIVARBPROC get_program =
-__glGetProcAddress(glGetProgramivARB);
-PFNGLGETPROGRAMSTRINGARBPROC get_program_string =
-__glGetProcAddress(glGetProgramStringARB);
-
-return DoGetProgramString(cl, pc, get_program, get_program_string, False);
-}
-
-int
-__glXDispSwap_GetProgramStringNV(struct __GLXclientStateRec *cl, GLbyte * pc)
-{
-PFNGLGETPROGRAMIVARBPROC get_program =
-__glGetProcAddress(glGetProgramivARB);
-PFNGLGETPROGRAMSTRINGARBPROC get_program_string =
-__glGetProcAddress(glGetProgramStringARB);
-
-return DoGetProgramString(cl, pc, get_program, get_program_string, True);
-}
-- 
1.8.5.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH] glamor: Disable definitions of GL extension prototypes to avoid warnings.

2014-01-24 Thread Eric Anholt
We're not using the extension prototypes, since you have to dlsym them
anyway.  Disabling their definitions prevents them from being defined
twice (once by gl.h, once by glext.h).

Signed-off-by: Eric Anholt e...@anholt.net
---

I was about to send the pull req for the glamor reformat and initial
build work, but realized I was running with some default warnings
disabled.  This fixes those.

(It also would have gone away with the epoxy changes that come later).

 glamor/glamor_priv.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 9f0c558..8ccf4fa 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -35,8 +35,6 @@
 #endif
 #include glamor.h
 
-#define GL_GLEXT_PROTOTYPES
-
 #ifdef GLAMOR_GLES2
 #include GLES2/gl2.h
 #include GLES2/gl2ext.h
-- 
1.8.5.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: warning-fixes review.

2014-01-23 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 Eric Anholt e...@anholt.net writes:

 Patch 1 - NAK due to changes to DO NOT EDIT files.

 I've removed the changes to indirect_dispatch_swap.c and indirect_program.c

 Yeah, any suggestions on how we can fix the generated files to not have
 warnings?

Fix the generator in Mesa and re-gen, or just pull generation into the
server.  Really want to get around to putting the generator into the
server based on the current xml.


pgpyAYLqiMhsG.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH:libXfont 1/3] Correct comment in configure.ac about scalable font support

2014-01-22 Thread Eric Anholt
Alan Coopersmith alan.coopersm...@oracle.com writes:

 Bitstream Speedo support was removed in commit d50de26430c1a114a.
 All scalable font support now goes through FreeType, which can
 also handle some bitmap font formats as well.

This series is:

Reviewed-by: Eric Anholt e...@anholt.net


pgpQ0g3_2f7QU.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] inputproto: Allow library users to avoid having the 'Pointer' typedef declared

2014-01-22 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 'Pointer' collides with too many other application names, so stop
 using it locally and allow applications to avoid having it in the API.

Some googling didn't find anyone using Pointer with a 'P', so:

Reviewed-by: Eric Anholt e...@anholt.net


pgpOkR3VnvBLT.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] glx: Remove left-over glthread.c

2014-01-22 Thread Eric Anholt
Jon TURNEY jon.tur...@dronecode.org.uk writes:

 Commit be668096 glx: convert to direct GL dispatch (v2) removes glthread.c
 from Makefile.am along with the rest of the dispatch table code, but doesn't
 remove glthread.c itself.

 Signed-off-by: Jon TURNEY jon.tur...@dronecode.org.uk
 Cc: Adam Jackson a...@redhat.com

Reviewed-by: Eric Anholt e...@anholt.net


pgpjxbem0xQwT.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 10/15] glamor: Disable the XV code for now.

2014-01-16 Thread Eric Anholt
Michel Dänzer mic...@daenzer.net writes:

 On Fre, 2014-01-10 at 09:26 +0800, Eric Anholt wrote:
 We're going to want to make this DIX code instead of XF86 if at all
 possible, but for now just disable it so we can work on the rest of
 the build.

 The radeon driver can't really use the in-tree glamor unless it supports
 Xv. What's your plan for phasing out the standalone glamor in favour of
 the in-tree one?

There's a later set of patches for building the xf86 module and turning
on the current XV code.  (I still want to rewrite the XV to be dix,
which I think involves pulling down the current two identical DDX
implementations to mi so that I don't have to write yet annother one).

If in-tree glamor isn't better than external glamor by 1.16, the
something has gone horribly wrong.


pgpNuwpLBP8Nk.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 0/4] fb support for 8bpp bitmaps

2014-01-15 Thread Eric Anholt
Michel Dänzer mic...@daenzer.net writes:

 On Die, 2014-01-14 at 05:34 -0800, Keith Packard wrote:
 Michel Dänzer mic...@daenzer.net writes:
 
  Didn't SNA prove though that sharing the same pixel storage for GPU and
  CPU doesn't give the overall best performance even with Intel GPUs? It
  certainly doesn't with most other GPUs.
 
 Yes, and strangely enough, this change is designed to *help* with that
 transition. We want to switch to a pure hardware accelerated design, but
 current hardware can't deal with 1bpp surfaces. That leaves us with two
 choices for depth 1 objects:
 
  1) Never draw them with the GPU and leave them formatted 1bpp.
 
  2) Always draw them with the GPU and format them 8bpp.

 3) Given there is no point in sharing storage between CPU and GPU, keep
 them formatted 1bpp for the CPU and convert them to 1bpp for the GPU
 (and back to 1bpp for CPU readback).

One of keithp's assumptions has been that you have
reasonable-performance access to the texture memory for doing fallbacks.
It's how intel's uxa/glamor code manages decent performance with glamor
without running into some of the problems that radeon has faced (Like,
wow, diagonal lines.  That was amazingly bad).

I'd like to see glamor do better at rendering without fallbacks, and I
think ajax is also interested in pushing on that front.  It's certainly
not there yet, though, so you need fallbacks and they need to be less
awful if we want glamor to compare to native acceleration within this
year.  There are a couple of GL extensions related to this, such as
GL_INTEL_map_texture (which does't solve telling you how the texture
data is laid out in memory, plus has some very divergent mapping behavor
to the GL_ARB_mbr/GL_ARB_vbo-related MapTextureImage hook we have in
Mesa right now), or EGL_KHR_lock_surface3 (why EGL?  I want to map GL
textures, not EGL crap).  I think the right answer is to define a spec
that basically gives you Mesa's MapTextureImage hook, with format
definitions.

If you assume native mapping of texture buffers for fallbacks, then
having the X Server be able to operate directly on those textures makes
sense.


pgpfqBuodSQHb.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

glamor cleanup series: reindent and connect to the build

2014-01-09 Thread Eric Anholt
Here's my first patch series for review on glamor -- mostly boring
stuff just trying to get things to a consistent style with the rest of
the server.  The end result is a building module we can start doing
interesting things to, with no compiler warnings on my system.

Note that x-indent.sh did horrible things to string literals, and
produced a line (present in two patches) that made git-send-email
choke.  I just dropped the boring output of x-indent.sh patch
contents, and hacked out that line of patch 3.  You can find the real
series up at git://people.freedesktop.org/~anholt/xserver on the
glamor-reformat branch.  (once again, more things, some of them
unpolished, are also on the glamor-server branch).

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 08/15] glamor/egl: Remove glapi awareness

2014-01-09 Thread Eric Anholt
From: Adam Jackson a...@redhat.com

We only needed this because glx was directly bashing glapi tables.
Since that's not the case anymore, we should just MakeCurrent like a
real GL app.

v2: Hand-resolve against rebase onto newer server (by anholt)

Signed-off-by: Adam Jackson a...@redhat.com
Signed-off-by: Eric Anholt e...@anholt.net
Reviewed-by: Eric Anholt e...@anholt.net
---
 glamor/Makefile.am|   3 +-
 glamor/glamor_egl.c   |  24 ++-
 glamor/glamor_utils.h |  15 ---
 glamor/glapi.h| 116 --
 4 files changed, 4 insertions(+), 154 deletions(-)
 delete mode 100644 glamor/glapi.h

diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 6c80f24..15a8b74 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -46,8 +46,7 @@ libglamor_la_SOURCES = \
glamor_compositerects.c\
glamor_xv.c\
glamor_utils.h\
-   glamor.h\
-   glapi.h
+   glamor.h
 
 sdk_HEADERS = glamor.h
 
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 4257808..b30eeec 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -61,9 +61,6 @@
 
 #include glamor.h
 #include glamor_gl_dispatch.h
-#ifdef GLX_USE_SHARED_DISPATCH
-#include glapi.h
-#endif
 
 static const char glamor_name[] = glamor;
 
@@ -93,8 +90,6 @@ struct glamor_egl_screen_private {
 struct gbm_device *gbm;
 #endif
 int has_gem;
-void *glamor_context;
-void *current_context;
 int gl_context_depth;
 int dri3_capable;
 
@@ -115,7 +110,6 @@ glamor_egl_get_screen_private(ScrnInfoPtr scrn)
 scrn-privates[xf86GlamorEGLPrivateIndex].ptr;
 }
 
-#ifdef GLX_USE_SHARED_DISPATCH
 _X_EXPORT void
 glamor_egl_make_current(ScreenPtr screen)
 {
@@ -126,9 +120,7 @@ glamor_egl_make_current(ScreenPtr screen)
 if (glamor_egl-gl_context_depth++)
 return;
 
-GET_CURRENT_CONTEXT(glamor_egl-current_context);
-
-if (glamor_egl-glamor_context != glamor_egl-current_context) {
+if (glamor_egl-context != eglGetCurrentContext()) {
 eglMakeCurrent(glamor_egl-display, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
 if (!eglMakeCurrent(glamor_egl-display,
@@ -149,14 +141,9 @@ glamor_egl_restore_context(ScreenPtr screen)
 if (--glamor_egl-gl_context_depth)
 return;
 
-if (glamor_egl-current_context 
-glamor_egl-glamor_context != glamor_egl-current_context)
-SET_CURRENT_CONTEXT(glamor_egl-current_context);
+eglMakeCurrent(glamor_egl-display, EGL_NO_SURFACE,
+   EGL_NO_SURFACE, EGL_NO_CONTEXT);
 }
-#else
-#define glamor_egl_make_current(x)
-#define glamor_egl_restore_context(s)
-#endif
 
 static EGLImageKHR
 _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
@@ -796,19 +783,14 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
Failed to make EGL context current\n);
 return FALSE;
 }
-#ifdef GLX_USE_SHARED_DISPATCH
-GET_CURRENT_CONTEXT(glamor_egl-glamor_context);
-#endif
 glamor_egl-saved_free_screen = scrn-FreeScreen;
 scrn-FreeScreen = glamor_egl_free_screen;
 #ifdef GLAMOR_GLES2
 xf86DrvMsg(scrn-scrnIndex, X_INFO, Using GLES2.\n);
-#ifdef GLX_USE_SHARED_DISPATCH
 xf86DrvMsg(scrn-scrnIndex, X_WARNING,
Glamor is using GLES2 but GLX needs GL. 
Indirect GLX may not work correctly.\n);
 #endif
-#endif
 return TRUE;
 }
 
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 49d2ff7..151a65e 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -1834,7 +1834,6 @@ glamor_restore_current(ScreenPtr screen)
 glamor_egl_restore_context(screen);
 }
 
-#ifdef GLX_USE_SHARED_DISPATCH
 static inline glamor_gl_dispatch *
 glamor_get_dispatch(glamor_screen_private * glamor_priv)
 {
@@ -1850,19 +1849,5 @@ glamor_put_dispatch(glamor_screen_private * glamor_priv)
 if (glamor_priv-flags  GLAMOR_USE_EGL_SCREEN)
 glamor_restore_current(glamor_priv-screen);
 }
-#else
-#warning Indirect GLX may be broken, need to implement context switch.
-static inline glamor_gl_dispatch *
-glamor_get_dispatch(glamor_screen_private * glamor_priv)
-{
-return glamor_priv-_dispatch;
-}
-
-static inline void
-glamor_put_dispatch(glamor_screen_private * glamor_priv)
-{
-}
-
-#endif
 
 #endif
diff --git a/glamor/glapi.h b/glamor/glapi.h
deleted file mode 100644
index f61fc84..000
--- a/glamor/glapi.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  7.1
- *
- * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
- *
- * 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 Software, and to permit persons to whom the
- * Software

[PATCH 07/15] glamor: Remove compat code for building out of tree.

2014-01-09 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/Makefile.am   |   1 -
 glamor/compat-api.h  | 107 ---
 glamor/glamor.c  |   4 +-
 glamor/glamor.h  |   4 --
 glamor/glamor_egl.c  |  16 ++--
 glamor/glamor_priv.h |   1 -
 6 files changed, 6 insertions(+), 127 deletions(-)
 delete mode 100644 glamor/compat-api.h

diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 5eefd8e..6c80f24 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -11,7 +11,6 @@ AM_CFLAGS = $(CWARNFLAGS) $(XORG_CFLAGS) $(LIBDRM_CFLAGS)
 libglamor_la_LDFLAGS = -version-info 0:0:0
 
 libglamor_la_SOURCES = \
-   compat-api.h \
glamor.c \
glamor_copyarea.c \
glamor_copywindow.c \
diff --git a/glamor/compat-api.h b/glamor/compat-api.h
deleted file mode 100644
index 1608478..000
--- a/glamor/compat-api.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * 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 Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Author: Dave Airlie airl...@redhat.com
- */
-
-/* this file provides API compat between server post 1.13 and pre it,
-   it should be reused inside as many drivers as possible */
-#ifndef COMPAT_API_H
-#define COMPAT_API_H
-
-#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
-#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)-myNum]
-#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)-myNum] = p
-#endif
-
-#ifndef XF86_HAS_SCRN_CONV
-#define xf86ScreenToScrn(s) xf86Screens[(s)-myNum]
-#define xf86ScrnToScreen(s) screenInfo.screens[(s)-scrnIndex]
-#endif
-
-#ifndef XF86_SCRN_INTERFACE
-
-#define SCRN_ARG_TYPE int
-#define SCRN_INFO_PTR(arg1) ScrnInfoPtr scrn = xf86Screens[(arg1)]
-
-#define SCREEN_ARG_TYPE int
-#define SCREEN_PTR(arg1) ScreenPtr screen = screenInfo.screens[(arg1)]
-
-#define SCREEN_INIT_ARGS_DECL int scrnIndex, ScreenPtr screen, int argc, char 
**argv
-
-#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer timeout, 
pointer read_mask
-#define BLOCKHANDLER_ARGS arg, blockData, timeout, read_mask
-
-#define WAKEUPHANDLER_ARGS_DECL int arg, pointer wakeupData, unsigned long 
result, pointer read_mask
-#define WAKEUPHANDLER_ARGS arg, wakeupData, result, read_mask
-
-#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr screen
-#define CLOSE_SCREEN_ARGS scrnIndex, screen
-
-#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
-#define ADJUST_FRAME_ARGS(arg, x, y) (arg)-scrnIndex, x, y, 0
-
-#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
-#define SWITCH_MODE_ARGS(arg, m) (arg)-scrnIndex, m, 0
-
-#define FREE_SCREEN_ARGS_DECL int arg, int flags
-#define FREE_SCREEN_ARGS   arg, flags
-
-#define VT_FUNC_ARGS_DECL int arg, int flags
-#define VT_FUNC_ARGS(flags) scrn-scrnIndex, (flags)
-
-#define XF86_ENABLEDISABLEFB_ARG(x) ((x)-scrnIndex)
-
-#else
-#define SCRN_ARG_TYPE ScrnInfoPtr
-#define SCRN_INFO_PTR(arg1) ScrnInfoPtr scrn = (arg1)
-
-#define SCREEN_ARG_TYPE ScreenPtr
-#define SCREEN_PTR(arg1) ScreenPtr screen = (arg1)
-
-#define SCREEN_INIT_ARGS_DECL ScreenPtr screen, int argc, char **argv
-
-#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer timeout, pointer 
read_mask
-#define BLOCKHANDLER_ARGS arg, timeout, read_mask
-
-#define WAKEUPHANDLER_ARGS_DECL ScreenPtr arg, unsigned long result, pointer 
read_mask
-#define WAKEUPHANDLER_ARGS arg, result, read_mask
-
-#define CLOSE_SCREEN_ARGS_DECL ScreenPtr screen
-#define CLOSE_SCREEN_ARGS screen
-
-#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
-#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y
-
-#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
-#define SWITCH_MODE_ARGS(arg, m) arg, m
-
-#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
-#define FREE_SCREEN_ARGS   arg
-
-#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
-#define VT_FUNC_ARGS(flags) scrn
-
-#define XF86_ENABLEDISABLEFB_ARG(x) (x)
-
-#endif
-#endif
diff --git

[PATCH 03/15] glamor: Fix some mangling of shader strings by indent.

2014-01-09 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---

Once again, git-send-email refused due to x-indent's output being too
long, so this isn't a real patch because I replaced that line with
THE STRINGS BELOW ALL SMASHED INTO ONE LINE.  Look at the git tree
for real patches.


 glamor/glamor_core.c  |  9 +++--
 glamor/glamor_fill.c  | 13 +--
 glamor/glamor_gradient.c  | 89 ---
 glamor/glamor_putimage.c  | 23 
 glamor/glamor_render.c| 60 +++-
 glamor/glamor_tile.c  |  6 ++--
 glamor/glamor_trapezoid.c | 13 ---
 glamor/glamor_xv.c| 14 +---
 8 files changed, 183 insertions(+), 44 deletions(-)

diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 4213961..4eac856 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -151,7 +151,8 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
 void main()\n
 {\n
   gl_Position = v_position;\n
-  source_texture = v_texcoord0.xy;\n }\n;
+  source_texture = v_texcoord0.xy;\n
+}\n;
 
 const char *common_source =
 GLAMOR_DEFAULT_PRECISION
@@ -186,7 +187,8 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
   gl_FragColor = texture2D(sampler, 
source_texture).gbar;\n
  else if (swap_rb == SWAP_NONE_UPLOADING)\n
   gl_FragColor = texture2D(sampler, 
source_texture).abgr;\n
-} \n }\n;
+} \n
+}\n;
 
 const char *set_alpha_source =
 void main()\n
@@ -208,7 +210,8 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
   gl_FragColor = vec4(texture2D(sampler, 
source_texture).gba, 1);\n
  else if (swap_rb == SWAP_NONE_UPLOADING)\n
   gl_FragColor = vec4(texture2D(sampler, 
source_texture).abg, 1);\n
-} \n }\n;
+} \n
+}\n;
 GLint fs_prog, vs_prog, avs_prog, set_alpha_prog;
 GLint sampler_uniform_location;
 char *source;
diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c
index 47d27bc..3aef7fc 100644
--- a/glamor/glamor_fill.c
+++ b/glamor/glamor_fill.c
@@ -140,10 +140,17 @@ glamor_init_solid_shader(ScreenPtr screen)
 glamor_gl_dispatch *dispatch;
 const char *solid_vs =
 attribute vec4 v_position;
-void main()\n {\ngl_Position = v_position;\n }\n;
+void main()\n
+{\n
+   gl_Position = v_position;\n
+}\n;
 const char *solid_fs =
-GLAMOR_DEFAULT_PRECISION uniform vec4 color;\n
-void main()\n {\n gl_FragColor = color;\n }\n;
+GLAMOR_DEFAULT_PRECISION
+uniform vec4 color;\n
+void main()\n
+{\n
+  gl_FragColor = color;\n
+}\n;
 GLint fs_prog, vs_prog;
 
 glamor_priv = glamor_get_screen_private(screen);
diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index df6c3bb..e7c872d 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -85,7 +85,84 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int 
stops_count,
 
 /* Because the array access for shader is very slow, the performance is 
very low
if use array. So use global uniform to replace for it if the number of 
n_stops is small. */
-THE STRINGS BELOW ALL SMASHED INTO ONE LINE
+const char *gradient_fs_getcolor_no_array =
+GLAMOR_DEFAULT_PRECISION
+uniform int n_stop;\n
+uniform float stop0;\n
+uniform float stop1;\n
+uniform float stop2;\n
+uniform float stop3;\n
+uniform float stop4;\n
+uniform float stop5;\n
+uniform float stop6;\n
+uniform float stop7;\n
+uniform vec4 stop_color0;\n
+uniform vec4 stop_color1;\n
+uniform vec4 stop_color2;\n
+uniform vec4 stop_color3;\n
+uniform vec4 stop_color4;\n
+uniform vec4 stop_color5;\n
+uniform vec4 stop_color6;\n
+uniform vec4 stop_color7;\n
+\n
+vec4 get_color(float stop_len)\n
+{\n
+float stop_after;\n
+float stop_before;\n
+vec4 stop_color_before;\n
+vec4 stop_color_after;\n
+float new_alpha; \n
+vec4 gradient_color;\n
+float percentage; \n
+\n
+if((stop_len  stop0)  (n_stop = 1)) {\n
+stop_color_before = stop_color0;\n
+stop_color_after = stop_color0;\n
+stop_after = stop0;\n
+stop_before = stop0;\n
+} else if((stop_len  stop1)  (n_stop = 2)) {\n
+stop_color_before = stop_color0;\n
+stop_color_after = stop_color1;\n
+stop_after = stop1;\n
+stop_before = stop0;\n
+} else if((stop_len  stop2)  (n_stop = 3)) {\n
+stop_color_before = stop_color1

[PATCH 11/15] glamor: Drop xfree86 dependencies from this dix module.

2014-01-09 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/Makefile.am | 2 +-
 glamor/glamor.h| 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 15a8b74..90d80a7 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -6,7 +6,7 @@ else
 libglamor_la_LIBADD = $(GL_LIBS)
 endif
 
-AM_CFLAGS = $(CWARNFLAGS) $(XORG_CFLAGS) $(LIBDRM_CFLAGS)
+AM_CFLAGS = $(CWARNFLAGS) $(DIX_CFLAGS) $(LIBDRM_CFLAGS)
 
 libglamor_la_LDFLAGS = -version-info 0:0:0
 
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 7dc2973..f1805e0 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -30,14 +30,12 @@
 #define GLAMOR_H
 
 #include scrnintstr.h
-#include xf86.h
-#include xf86str.h
 #include pixmapstr.h
 #include gcstruct.h
 #include picturestr.h
 #include fb.h
 #include fbpict.h
-#include xf86xv.h
+
 /*
  * glamor_pixmap_type : glamor pixmap's type.
  * @MEMORY: pixmap is in memory.
-- 
1.8.5.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 01/15] glamor: Touch up some code so indent doesn't get confused.

2014-01-09 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_pixmap.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 84694ec..be7aa3d 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -248,7 +248,7 @@ _glamor_color_convert_a1_a8(void *src_bits, void *dst_bits, 
int w, int h, int st
  b_shift, b_bits,  \
  g_shift, g_bits,  \
  r_shift, r_bits)  \
-   {   \
+   do {\
typeof(src) a,b,g,r;\
typeof(src) a_mask_src, b_mask_src, g_mask_src, r_mask_src;\
a_mask_src = (((1  (a_bits_src)) - 1)  a_shift_src);\
@@ -270,7 +270,7 @@ _glamor_color_convert_a1_a8(void *src_bits, void *dst_bits, 
int w, int h, int st
(*dst) = ((a)  (a_shift)) | ((b)  (b_shift)) | ((g) 
 (g_shift)) | ((r)  (r_shift)); \
else
\
(*dst) = ((a)  (a_shift)) | ((r)  (b_shift)) | ((g) 
 (g_shift)) | ((b)  (r_shift)); \
-   }
+   } while (0)
 
 static void *
 _glamor_color_revert_x2b10g10r10(void *src_bits, void *dst_bits, int w, int h, 
int stride, int no_alpha, int revert, int swap_rb)
@@ -293,7 +293,7 @@ _glamor_color_revert_x2b10g10r10(void *src_bits, void 
*dst_bits, int w, int h, i
if (revert == REVERT_DOWNLOADING_2_10_10_10)
GLAMOR_DO_CONVERT(pixel, words[x], no_alpha, 
swap,
  24, 8, 16, 8, 8, 8, 0, 8,
- 30, 2, 20, 10, 10, 10, 0, 10)
+ 30, 2, 20, 10, 10, 10, 0, 10);
else
GLAMOR_DO_CONVERT(pixel, words[x], no_alpha, 
swap,
  30, 2, 20, 10, 10, 10, 0, 10,
@@ -330,7 +330,7 @@ _glamor_color_revert_x1b5g5r5(void *src_bits, void 
*dst_bits, int w, int h, int
if (revert == REVERT_DOWNLOADING_1_5_5_5)
GLAMOR_DO_CONVERT(pixel, words[x], no_alpha, 
swap,
  0, 1, 1, 5, 6, 5, 11, 5,
- 15, 1, 10, 5, 5, 5, 0, 5)
+ 15, 1, 10, 5, 5, 5, 0, 5);
else
GLAMOR_DO_CONVERT(pixel, words[x], no_alpha, 
swap,
  15, 1, 10, 5, 5, 5, 0, 5,
-- 
1.8.5.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 04/15] glamor: Fix some indent damage of putting a ' ' after the '*' for pointers.

2014-01-09 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor.c |  4 +--
 glamor/glamor.h | 16 -
 glamor/glamor_addtraps.c|  6 ++--
 glamor/glamor_fbo.c | 32 +-
 glamor/glamor_glyphblt.c| 12 +++
 glamor/glamor_glyphs.c  | 30 -
 glamor/glamor_gradient.c| 10 +++---
 glamor/glamor_largepixmap.c | 22 ++---
 glamor/glamor_picture.c |  2 +-
 glamor/glamor_pixmap.c  |  8 ++---
 glamor/glamor_polyops.c |  6 ++--
 glamor/glamor_priv.h| 80 ++---
 glamor/glamor_render.c  | 52 ++---
 glamor/glamor_trapezoid.c   | 22 ++---
 glamor/glamor_xv.c  |  2 +-
 15 files changed, 152 insertions(+), 152 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 216fab4..37136af 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -206,7 +206,7 @@ Bool
 glamor_destroy_pixmap(PixmapPtr pixmap)
 {
 glamor_screen_private
-* glamor_priv = glamor_get_screen_private(pixmap-drawable.pScreen);
+*glamor_priv = glamor_get_screen_private(pixmap-drawable.pScreen);
 if (glamor_priv-dri3_enabled)
 glamor_egl_destroy_textured_pixmap(pixmap);
 else
@@ -473,7 +473,7 @@ glamor_release_screen_priv(ScreenPtr screen)
 }
 
 _X_EXPORT void
-glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private * priv)
+glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
 {
 glamor_pixmap_private *old_priv;
 glamor_pixmap_fbo *fbo;
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 1507565..4e47523 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -366,7 +366,7 @@ extern _X_EXPORT Bool glamor_trapezoids_nf(CARD8 op,
PicturePtr src, PicturePtr dst,
PictFormatPtr mask_format,
INT16 x_src, INT16 y_src,
-   int ntrap, xTrapezoid * traps);
+   int ntrap, xTrapezoid *traps);
 
 extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
PicturePtr src,
@@ -374,14 +374,14 @@ extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
PictFormatPtr mask_format,
INT16 x_src,
INT16 y_src, int nlist,
-   GlyphListPtr list, GlyphPtr * glyphs);
+   GlyphListPtr list, GlyphPtr *glyphs);
 
 extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
   PicturePtr pSrc,
   PicturePtr pDst,
   PictFormatPtr maskFormat,
   INT16 xSrc, INT16 ySrc,
-  int ntris, xTriangle * tris);
+  int ntris, xTriangle *tris);
 
 extern _X_EXPORT void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
 
@@ -395,7 +395,7 @@ extern _X_EXPORT Bool glamor_get_spans_nf(DrawablePtr 
drawable, int wmax,
 
 extern _X_EXPORT Bool glamor_composite_rects_nf(CARD8 op,
 PicturePtr pDst,
-xRenderColor * color,
+xRenderColor *color,
 int nRect, xRectangle *rects);
 
 extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y,
@@ -405,7 +405,7 @@ extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr 
pDrawable, int x, int y,
 extern _X_EXPORT Bool glamor_add_traps_nf(PicturePtr pPicture,
   INT16 x_off,
   INT16 y_off, int ntrap,
-  xTrap * traps);
+  xTrap *traps);
 
 extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst,
GCPtr pGC, int srcx, int srcy, int 
w,
@@ -416,13 +416,13 @@ extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr 
pSrc, DrawablePtr pDst,
 extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable,
 GCPtr pGC, int x, int y,
 unsigned int nglyph,
-CharInfoPtr * ppci,
+CharInfoPtr *ppci,
 pointer pglyphBase);
 
 extern _X_EXPORT Bool glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr 
pGC,
int x, int y

[PATCH 12/15] glamor: Silence warnings for non-debug builds.

2014-01-09 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_getspans.c | 1 +
 glamor/glamor_render.c   | 5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/glamor/glamor_getspans.c b/glamor/glamor_getspans.c
index afb76f6..ff58725 100644
--- a/glamor/glamor_getspans.c
+++ b/glamor/glamor_getspans.c
@@ -54,6 +54,7 @@ _glamor_get_spans(DrawablePtr drawable,
   depth),
  readpixels_dst, 0,
  GLAMOR_ACCESS_RO);
+(void)data;
 assert(data == readpixels_dst);
 readpixels_dst += PixmapBytePad(widths[i], drawable-depth);
 }
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 52bcf43..4a3a97c 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -869,7 +869,7 @@ combine_pict_format(PictFormatShort * des, const 
PictFormatShort src,
 const PictFormatShort mask, enum shader_in in_ca)
 {
 PictFormatShort new_vis;
-int src_type, mask_type, src_bpp, mask_bpp;
+int src_type, mask_type, src_bpp;
 int i;
 
 if (src == mask) {
@@ -877,9 +877,8 @@ combine_pict_format(PictFormatShort * des, const 
PictFormatShort src,
 return TRUE;
 }
 src_bpp = PICT_FORMAT_BPP(src);
-mask_bpp = PICT_FORMAT_BPP(mask);
 
-assert(src_bpp == mask_bpp);
+assert(src_bpp == PICT_FORMAT_BPP(mask));
 
 new_vis = PICT_FORMAT_VIS(src) | PICT_FORMAT_VIS(mask);
 
-- 
1.8.5.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 02/15] glamor: Apply x-indent.sh.

2014-01-09 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---

I've entirely trimmed this patch -- it was strictly applying
x-indent.sh with no other changes, and the next patches are fixups
that follow it.  I was going to just send it out, but git-send-email
fatal errored because one of the lines was too long (998 characters).
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 10/15] glamor: Disable the XV code for now.

2014-01-09 Thread Eric Anholt
We're going to want to make this DIX code instead of XF86 if at all
possible, but for now just disable it so we can work on the rest of
the build.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor.h| 2 ++
 glamor/glamor_xv.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/glamor/glamor.h b/glamor/glamor.h
index da1ad3d..7dc2973 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -437,7 +437,9 @@ extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr 
pDrawable, GCPtr pGC,
 extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
int mode, int n, DDXPointPtr 
points);
 
+#if 0
 extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen,
 int num_texture_ports);
+#endif
 
 #endif  /* GLAMOR_H */
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index bdc4c73..6e91a0c 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -627,9 +627,11 @@ glamor_xv_init(ScreenPtr screen, int num_texture_ports)
 return adapt;
 }
 #else
+#if 0
 XF86VideoAdaptorPtr
 glamor_xv_init(ScreenPtr screen, int num_texture_ports)
 {
 return NULL;
 }
 #endif
+#endif
-- 
1.8.5.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 06/15] glamor: Remove copy of sna's compiler.h

2014-01-09 Thread Eric Anholt
From: Adam Jackson a...@redhat.com

Xfuncproto.h has equivalents for these already.

v2: Adjust a couple more likelies after the rebase (anholt)

Signed-off-by: Adam Jackson a...@redhat.com
Signed-off-by: Eric Anholt e...@anholt.net
Reviewed-by: Eric Anholt e...@anholt.net
---
 glamor/Makefile.am |  1 -
 glamor/compiler.h  | 59 --
 glamor/glamor_compositerects.c |  2 +-
 glamor/glamor_fill.c   |  4 +--
 glamor/glamor_glyphs.c |  8 +++---
 glamor/glamor_priv.h   |  2 --
 glamor/glamor_utils.h  | 34 
 glamor/glapi.h |  6 ++---
 8 files changed, 27 insertions(+), 89 deletions(-)
 delete mode 100644 glamor/compiler.h

diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 2fd521f..5eefd8e 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -12,7 +12,6 @@ libglamor_la_LDFLAGS = -version-info 0:0:0
 
 libglamor_la_SOURCES = \
compat-api.h \
-   compiler.h \
glamor.c \
glamor_copyarea.c \
glamor_copywindow.c \
diff --git a/glamor/compiler.h b/glamor/compiler.h
deleted file mode 100644
index 5f2d4ea..000
--- a/glamor/compiler.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2011 Intel Corporation
- *
- * 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 Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
- * SOFTWARE.
- *
- * Authors:
- *Chris Wilson ch...@chris-wilson.co.uk
- *
- *Copied from sna 
- *
- */
-
-#ifndef _GLAMOR_COMPILER_H_
-#define _GLAMOR_COMPILER_H_
-
-#if defined(__GNUC__)  (__GNUC__  2)  defined(__OPTIMIZE__)
-#define likely(expr) (__builtin_expect (!!(expr), 1))
-#define unlikely(expr) (__builtin_expect (!!(expr), 0))
-#define noinline __attribute__((noinline))
-#define fastcall __attribute__((regparm(3)))
-#define must_check __attribute__((warn_unused_result))
-#define constant __attribute__((const))
-#else
-#define likely(expr) (expr)
-#define unlikely(expr) (expr)
-#define noinline
-#define fastcall
-#define must_check
-#define constant
-#endif
-
-#ifdef HAVE_VALGRIND
-#define VG(x) x
-#else
-#define VG(x)
-#endif
-
-#define VG_CLEAR(s) VG(memset(s, 0, sizeof(s)))
-
-#define COMPILE_TIME_ASSERT(E) ((void)sizeof(char[1 - 2*!(E)]))
-
-#endif  /* _SNA_COMPILER_H_ */
diff --git a/glamor/glamor_compositerects.c b/glamor/glamor_compositerects.c
index a0d5980..967e228 100644
--- a/glamor/glamor_compositerects.c
+++ b/glamor/glamor_compositerects.c
@@ -246,7 +246,7 @@ glamor_composite_rectangles(CARD8 op,
 goto done;
 }
 else {
-if (likely(priv-type != GLAMOR_TEXTURE_LARGE)) {
+if (_X_LIKELY(priv-type != GLAMOR_TEXTURE_LARGE)) {
 int error;
 
 source = CreateSolidPicture(0, color, error);
diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c
index 3aef7fc..d59e620 100644
--- a/glamor/glamor_fill.c
+++ b/glamor/glamor_fill.c
@@ -203,7 +203,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, 
float *color)
 
 pixmap_priv_get_dest_scale(pixmap_priv, xscale, yscale);
 
-if (unlikely(nbox * 4 * 2  ARRAY_SIZE(vertices))) {
+if (_X_UNLIKELY(nbox * 4 * 2  ARRAY_SIZE(vertices))) {
 int allocated_box;
 
 if (nbox * 6  GLAMOR_COMPOSITE_VBO_VERT_CNT) {
@@ -220,7 +220,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, 
float *color)
 }
 }
 
-if (unlikely(nbox  1))
+if (_X_UNLIKELY(nbox  1))
 dispatch-glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv-ebo);
 
 dispatch-glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c
index 1c0f9f5..3586b33 100644
--- a/glamor/glamor_glyphs.c
+++ b/glamor/glamor_glyphs.c
@@ -191,7 +191,7 @@ find_continuous_bits(unsigned int bits, int bits_cnt, 
unsigned int *pbits_mask)
 
 bits_mask = ((1LL  bits_cnt) - 1);
 
-if (unlikely(bits_cnt  56)) {
+if (_X_UNLIKELY

[PATCH 15/15] glamor: Remove more out-of-tree compat code.

2014-01-09 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_priv.h | 13 -
 1 file changed, 13 deletions(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 9f0c558..9bd88e0 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -56,19 +56,6 @@
 #include glamor_debug.h
 
 #include list.h
-/* The list.h rename all the function to add xorg_ prefix.
-   We add hack here to avoid the compile error when using
-   old version xserver header file.
-   These will be removed in future. */
-#ifndef xorg_list_entry
-#define xorg_list list
-#define xorg_list_for_each_entry list_for_each_entry
-#define xorg_list_for_each_entry_safe list_for_each_entry_safe
-#define xorg_list_del list_del
-#define xorg_list_add list_add
-#define xorg_list_append list_append
-#define xorg_list_init list_init
-#endif
 
 struct glamor_pixmap_private;
 
-- 
1.8.5.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 05/15] glamor: Fix up some indentation damage on header prototypes.

2014-01-09 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_priv.h | 292 +--
 1 file changed, 118 insertions(+), 174 deletions(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 96fb404..d4f5371 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -641,10 +641,8 @@ Bool glamor_fill(DrawablePtr drawable,
 Bool glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
   unsigned char alu, unsigned long planemask,
   unsigned long fg_pixel);
-Bool
-
-glamor_solid_boxes(PixmapPtr pixmap,
-   BoxPtr box, int nbox, unsigned long fg_pixel);
+Bool glamor_solid_boxes(PixmapPtr pixmap,
+BoxPtr box, int nbox, unsigned long fg_pixel);
 
 /* glamor_fillspans.c */
 void glamor_fill_spans(DrawablePtr drawable,
@@ -655,12 +653,9 @@ void glamor_init_solid_shader(ScreenPtr screen);
 void glamor_fini_solid_shader(ScreenPtr screen);
 
 /* glamor_getspans.c */
-void
-
-
-glamor_get_spans(DrawablePtr drawable,
- int wmax,
- DDXPointPtr points, int *widths, int nspans, char *dst_start);
+void glamor_get_spans(DrawablePtr drawable,
+  int wmax, DDXPointPtr points, int *widths,
+  int nspans, char *dst_start);
 
 /* glamor_glyphs.c */
 void glamor_glyphs_fini(ScreenPtr screen);
@@ -676,41 +671,32 @@ void glamor_set_spans(DrawablePtr drawable, GCPtr gc, 
char *src,
   DDXPointPtr points, int *widths, int n, int sorted);
 
 /* glamor_polyfillrect.c */
-void
-
-glamor_poly_fill_rect(DrawablePtr drawable,
-  GCPtr gc, int nrect, xRectangle *prect);
+void glamor_poly_fill_rect(DrawablePtr drawable,
+   GCPtr gc, int nrect, xRectangle *prect);
 
 /* glamor_polylines.c */
-void
-
-
-glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
-  DDXPointPtr points);
+void glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
+   DDXPointPtr points);
 
 /* glamor_putimage.c */
-void
-
-
-glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
- int w, int h, int leftPad, int format, char *bits);
+void glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
+  int w, int h, int leftPad, int format, char *bits);
 void glamor_init_putimage_shaders(ScreenPtr screen);
 void glamor_fini_putimage_shaders(ScreenPtr screen);
 
 /* glamor_render.c */
-Bool
-
-glamor_composite_clipped_region(CARD8 op,
-PicturePtr source,
-PicturePtr mask,
-PicturePtr dest,
-glamor_pixmap_private *soruce_pixmap_priv,
-glamor_pixmap_private *mask_pixmap_priv,
-glamor_pixmap_private *dest_pixmap_priv,
-RegionPtr region,
-int x_source,
-int y_source,
-int x_mask, int y_mask, int x_dest, int 
y_dest);
+Bool glamor_composite_clipped_region(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ glamor_pixmap_private *soruce_pixmap_priv,
+ glamor_pixmap_private *mask_pixmap_priv,
+ glamor_pixmap_private *dest_pixmap_priv,
+ RegionPtr region,
+ int x_source,
+ int y_source,
+ int x_mask, int y_mask,
+ int x_dest, int y_dest);
 
 void glamor_composite(CARD8 op,
   PicturePtr pSrc,
@@ -750,12 +736,10 @@ Bool glamor_composite_choose_shader(CARD8 op,
 struct blendinfo *op_info,
 PictFormatShort *psaved_source_format);
 
-void
-
-glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv,
-  struct shader_key *key,
-  glamor_composite_shader *shader,
-  struct blendinfo *op_info);
+void glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv,
+   struct shader_key *key,
+   glamor_composite_shader *shader,
+   struct blendinfo *op_info);
 
 void glamor_setup_composite_vbo(ScreenPtr screen, int n_verts);
 void glamor_emit_composite_vert(ScreenPtr screen,
@@ -792,14 +776,11 @@ PicturePtr 
glamor_generate_radial_gradient_picture(ScreenPtr

[PATCH 14/15] glamor: Remove an extra copy of RegionNil().

2014-01-09 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_compositerects.c | 4 ++--
 glamor/glamor_utils.h  | 6 --
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/glamor/glamor_compositerects.c b/glamor/glamor_compositerects.c
index 967e228..3b6b2ed 100644
--- a/glamor/glamor_compositerects.c
+++ b/glamor/glamor_compositerects.c
@@ -123,7 +123,7 @@ glamor_composite_rectangles(CARD8 op,
 if (!num_rects)
 return;
 
-if (region_is_empty(dst-pCompositeClip)) {
+if (RegionNil(dst-pCompositeClip)) {
 DEBUGF(%s: empty clip, skipping\n, __FUNCTION__);
 return;
 }
@@ -212,7 +212,7 @@ glamor_composite_rectangles(CARD8 op,
 
 if (dst-pCompositeClip-data 
 (!pixman_region_intersect(region, region, dst-pCompositeClip) ||
- region_is_empty(region))) {
+ RegionNil(region))) {
 DEBUGF(%s: zero-intersection between rectangles and clip\n,
__FUNCTION__);
 pixman_region_fini(region);
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 151a65e..ea827df 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -815,12 +815,6 @@ glamor_translate_boxes(BoxPtr boxes, int nbox, int dx, int 
dy)
 }
 }
 
-static inline Bool
-region_is_empty(pixman_region16_t * region)
-{
-return region-data  region-data-numRects == 0;
-}
-
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 #endif
-- 
1.8.5.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 09/15] glamor: Use dix-config.h not project config.h

2014-01-09 Thread Eric Anholt
From: Adam Jackson a...@redhat.com

v2: Also edit the one in glamor_egl.c (by anholt)
v3: Also edit the one in glamor_eglmodule.c (by anholt)

Signed-off-by: Adam Jackson a...@redhat.com
Signed-off-by: Eric Anholt e...@anholt.net
Reviewed-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_egl.c   | 4 +---
 glamor/glamor_eglmodule.c | 4 +---
 glamor/glamor_priv.h  | 4 +---
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index b30eeec..2f97a83 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -27,9 +27,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include config.h
-#endif
+#include dix-config.h
 
 #define GLAMOR_FOR_XORG
 #include xorg-server.h
diff --git a/glamor/glamor_eglmodule.c b/glamor/glamor_eglmodule.c
index e7c8eda..5ddd602 100644
--- a/glamor/glamor_eglmodule.c
+++ b/glamor/glamor_eglmodule.c
@@ -27,9 +27,7 @@
  *Zhigang Gong zhigang.g...@gmail.com
  */
 
-#ifdef HAVE_CONFIG_H
-#include config.h
-#endif
+#include dix-config.h
 
 #include xorg-server.h
 #define GLAMOR_FOR_XORG
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index c733b90..9f0c558 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -27,9 +27,7 @@
 #ifndef GLAMOR_PRIV_H
 #define GLAMOR_PRIV_H
 
-#ifdef HAVE_CONFIG_H
-#include config.h
-#endif
+#include dix-config.h
 
 #include xorg-server.h
 #ifndef DEBUG
-- 
1.8.5.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 13/15] glamor: Hook the module back up to the build.

2014-01-09 Thread Eric Anholt
For now we're just building an uninstalled library.  The extra EGL
stubs are required so that we can get the DIX building and usable
without pulling in the xf86 DDX code in glamor_egl.c.

Signed-off-by: Eric Anholt e...@anholt.net
---
 Makefile.am   |  6 +
 configure.ac  | 10 
 glamor/Makefile.am| 31 ---
 glamor/glamor.c   |  1 +
 glamor/glamor_egl_stubs.c | 64 +++
 include/dix-config.h.in   |  3 +++
 6 files changed, 89 insertions(+), 26 deletions(-)
 create mode 100644 glamor/glamor_egl_stubs.c

diff --git a/Makefile.am b/Makefile.am
index 5bf760b..876c8a6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,6 +25,10 @@ if PRESENT
 PRESENT_DIR=present
 endif
 
+if GLAMOR
+GLAMOR_DIR=glamor
+endif
+
 SUBDIRS = \
doc \
man \
@@ -49,6 +53,7 @@ SUBDIRS = \
$(PRESENT_DIR) \
$(DRI3_DIR) \
exa \
+   $(GLAMOR_DIR) \
config \
hw \
test
@@ -100,6 +105,7 @@ DIST_SUBDIRS = \
composite \
glx \
exa \
+   $(GLAMOR_DIR) \
config \
dri3 \
present \
diff --git a/configure.ac b/configure.ac
index 51ac30b..bc9aaec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -638,6 +638,7 @@ AC_ARG_ENABLE(xnest,  
AS_HELP_STRING([--enable-xnest], [Build Xnest serv
 AC_ARG_ENABLE(xquartz,AS_HELP_STRING([--enable-xquartz], [Build 
Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
 AC_ARG_ENABLE(standalone-xpbproxy, 
AS_HELP_STRING([--enable-standalone-xpbproxy], [Build a standalone xpbproxy (in 
addition to the one integrated into Xquartz as a separate thread) (default: 
no)]), [STANDALONE_XPBPROXY=$enableval], [STANDALONE_XPBPROXY=no])
 AC_ARG_ENABLE(xwin,  AS_HELP_STRING([--enable-xwin], [Build 
XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
+AC_ARG_ENABLE(glamor, AS_HELP_STRING([--enable-glamor], [Build glamor 
dix module (default: no)]), [GLAMOR=$enableval], [GLAMOR=no])
 dnl kdrive and its subsystems
 AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive 
servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no])
 AC_ARG_ENABLE(xephyr, AS_HELP_STRING([--enable-xephyr], [Build the 
kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto])
@@ -2065,6 +2066,14 @@ AM_CONDITIONAL([SOLARIS_VT], [test x$solaris_vt = 
xyes])
 AM_CONDITIONAL([DGA], [test x$DGA = xyes])
 AM_CONDITIONAL([XF86VIDMODE], [test x$XF86VIDMODE = xyes])
 AM_CONDITIONAL([XORG_BUS_PLATFORM], [test x$CONFIG_UDEV_KMS = xyes])
+
+dnl glamor
+AM_CONDITIONAL([GLAMOR], [test x$GLAMOR = xyes])
+if test x$GLAMOR = xyes; then
+   AC_DEFINE(GLAMOR, 1, [Build glamor])
+   PKG_CHECK_MODULES([GLAMOR], [egl gl])
+fi
+
 dnl XWin DDX
 
 AC_MSG_CHECKING([whether to build XWin DDX])
@@ -2434,6 +2443,7 @@ doc/Makefile
 doc/dtrace/Makefile
 man/Makefile
 fb/Makefile
+glamor/Makefile
 record/Makefile
 config/Makefile
 mi/Makefile
diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 90d80a7..3fe2530 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -1,14 +1,8 @@
-lib_LTLIBRARIES = libglamor.la
+noinst_LTLIBRARIES = libglamor.la libglamor_egl_stubs.la
 
-if GLAMOR_GLES2
-libglamor_la_LIBADD = $(GLESV2_LIBS)
-else
-libglamor_la_LIBADD = $(GL_LIBS)
-endif
+libglamor_la_LIBADD = $(GLAMOR_LIBS)
 
-AM_CFLAGS = $(CWARNFLAGS) $(DIX_CFLAGS) $(LIBDRM_CFLAGS)
-
-libglamor_la_LDFLAGS = -version-info 0:0:0
+AM_CFLAGS = $(CWARNFLAGS) $(DIX_CFLAGS) $(GLAMOR_CFLAGS)
 
 libglamor_la_SOURCES = \
glamor.c \
@@ -48,21 +42,6 @@ libglamor_la_SOURCES = \
glamor_utils.h\
glamor.h
 
-sdk_HEADERS = glamor.h
-
-if EGL
-LIBGLAMOREGL = libglamoregl.la
-module_LTLIBRARIES = $(LIBGLAMOREGL)
-libglamoregl_la_DEPENDENCIES = libglamor.la
-libglamoregl_la_LDFLAGS = -avoid-version -module
-libglamoregl_la_LIBADD = $(EGL_LIBS) $(GLX_SYS_LIBS) $(GBM_LIBS) libglamor.la
-libglamoregl_la_SOURCES = glamor_eglmodule.c glamor_egl.c
-libglamoregl_la_CFLAGS = \
-   $(AM_CFLAGS) \
-   $(GLX_DEFINES) \
-   $(LIBDRM_CFLAGS) \
-   $(EGL_CFLAGS) \
-   $(GBM_CFLAGS)
-endif
-
+libglamor_egl_stubs_la_SOURCES = glamor_egl_stubs.c
 
+sdk_HEADERS = glamor.h
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 188aef5..feb110a 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -261,6 +261,7 @@ glamor_set_debug_level(int *debug_level)
 
 int glamor_debug_level;
 
+
 /** Set up glamor for an already-configured GL context. */
 Bool
 glamor_init(ScreenPtr screen, unsigned int flags)
diff --git a/glamor/glamor_egl_stubs.c b/glamor/glamor_egl_stubs.c
new file mode 100644
index 000..1449d08
--- /dev/null
+++ b/glamor/glamor_egl_stubs.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated

[PULL] glamor import

2013-12-30 Thread Eric Anholt
Background: I'm picking the glamor work back up, trying to bring it in
tree so it's useful beyond just the Xorg DDX.  I don't think we can do
review on all of the past history, so I'm hoping to do a merge and
then get reviewed cleanups to that code.

Here's a pull request for the glamor series I originally wrote, plus
the code Zhigang Gong wrote inside the X Server tree that I was able
to find, plus a rebase of the external glamor tree onto that so that
it's all inside of the X Server with the most complete history I could
come up with.

For the internal code, I chose not to filter-branch -- instead, the
outside-of-glamor-core changes just get reverted in commit
7982eca622bbc4b6a4845801a77da8a16138004a so that we don't merge to a
broken tree state.  I think I used a no-commit revert of the revert when
first generating the new Xephyr changes, so I think it's useful like
this.

The external tree code contains everything up to
fb4d046c04002851a5e895726461509983f633e7 with everything outside of
the src/ tree filter-branched out:

git filter-branch -f --tree-filter find . -type f | grep -v src/
| xargs rm; mv src glamor

I didn't want to have the changes for the external README, or the
external configure.ac included.

If we decide that this is the pull request for the core code we want,
I have some other commits ready to get into the review pipeline for
bringing the code in line with the current coding style, then a series
for making Xephyr work with glamor, then a series for building a
usable Xorg module (tested with the modesetting driver with partial
DRI2 and DRI3 support so far)

I think I've got some significant improvements in the pipeline to the
glamor - driver API, too.  There's still a lot to be done, but my goal
is for accelerated rendering for your X Server to be trivial to set up,
because it *should* be.

The following changes since commit 4d62646142718024b0981eb4f1fd0131e829161f:

  Merge remote-tracking branch 'jeremyhu/master' (2013-12-16 09:27:57 -0800)

are available in the git repository at:

  git://people.freedesktop.org/~anholt/xserver glamor-external-rebase

for you to fetch changes up to 4dd62d7807b47efbc9065ae8f17f73e1ec6e9d26:

  libglamoregl: remove -I$(top_srcdir)/src (2013-12-18 11:23:54 -0800)


Armin K (3):
  Silence Automake 1.13 warnings
  Properly dist necesary headers
  First attempt to make libglamor.so shared versioned library

Axel Davy (2):
  Allow to create textured pixmaps from gbm_bo without using gem names
  Add DRI3 support to glamor

Brian Paul (3):
  Fix _glamor_set_spans() bug (re-used 'n' variable)
  Remove redundant dispatch-glEnable(GL_TEXTURE_2D)
  Remove useless return statement

Chris Wilson (3):
  Do not reduce a composite to a copy if we need to sample outside of the 
source
  Use CLAMP_TO_BORDER in copy_n_to_n so we can sample outside of the source
  Fixup glx support

Christian König (1):
  Use GBM_LIBS and GBM_CFLAGS

Dave Airlie (5):
  glamor: fix make distcheck part 1
  glamor: add compiler.h
  glamor_utils: fix unlikely define use
  glamor: add initial Xv support
  glamor: fix leak in xv code.

Eric Anholt (102):
  Add build infrastructure for glamor.
  More ephyr/glamor glue.
  Add exa/glamor to _DEPENDENCIES so the bin gets rebuilt with the libs.
  glamor: Use -lgl for Xephyr if GLX is unset.
  glamor: Start trying to hook up the rendering bits
  glamor: Use a nicer struct initializer for gcops.
  glamor: glFlush from the blockhandler so rendering happens.
  glamor: first real attempt at rendering.
  ephyr: merge the host glamor bits into hostx.
  add fill files, merge with first real attempt at rendering.
  ephyr: Make sure a glamor-using window is created with a glx visual.
  ephyr: Use GLEW.
  glamor: Fix up block/wakeup handler.
  glamor: remove gratuitous flush.
  glamor: Fix up DrawPixels arguments to bear some relation to reality.
  glamor: Move to using shader objects.
  glamor: Add getspans implementation.
  glamor: Maybe fix up the format/type for setspans.
  glamor: Create FBOs for pixmaps.
  glamor: Fill out glamor_get_color_4f_from_pixel() a bit.
  glamor: Add untested support for tile filling.
  glamor: Free resources when destroying pixmaps.
  glamor: Add stub Composite support.
  glamor: Fill in 1 and 24-bit getspans.
  glamor: Add more solid_fail_regions for software fallbacks.
  glamor: Add trapezoids code.
  glamor: Add 8bpp to get/setspans.
  glamor: Add untested putimage support.
  glamor: Add ALU support to solid, tile, and putimage.
  glamor: Hook up miGetImage to fix some invalid accesses.
  glamor: Move setspans to a separate file.
  glamor: Fix memory leak in getspans.
  glamor: Fix bad fallthrough in getspans (accessing invalid memory).
  glamor: Give

[PULL] glx loader unifdeffing.

2013-12-30 Thread Eric Anholt
Now, some nice easy reviewed changes to pull.

The following changes since commit 2ea973e12f5d954211e1d10085a4c74581b43aca:

  Bump version to 1.15.0 (2013-12-27 09:50:55 -0800)

are available in the git repository at:

  git://people.freedesktop.org/~anholt/xserver xserver-unifdef

for you to fetch changes up to 295d41fa2aa97b74c1b9ffd7ef4ccf52f3e97dde:

  glx: unifdef swrast dri_interface.h values from Mesa 7.1. (2013-12-30 
23:10:34 -0800)


Eric Anholt (2):
  glx: unifdef for DRI2 dri_interface.h things in mesa 9.2.
  glx: unifdef swrast dri_interface.h values from Mesa 7.1.

 glx/glxdri2.c  | 59 --
 glx/glxdriswrast.c | 25 +--
 2 files changed, 1 insertion(+), 83 deletions(-)


pgpSsRJfKNthH.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 01/10] Replace 'pointer' type with 'void *'

2013-12-29 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer'
 is used throughout the X server for other things, and having duplicate
 names generates compiler warnings.

Review to follow.  I definitely don't want to read a v2.  But a v2 ready
to push could probably use a spot-check on the diff looking for \+.*
/\*.*void \* (or for * instead of /*), \+.*pointer=, and \+.*void
\*/\* to catch some of the common failure patterns I missed.

Also, I suspect a built tree with stripped binaries should be the same
before and after, and would have caught a few of the code bugs present.

With all of these changes, this patch is:

Reviewed-by: Eric Anholt e...@anholt.net

 diff --git a/Xext/hashtable.h b/Xext/hashtable.h
 index 8a65732..780d5d2 100644
 --- a/Xext/hashtable.h
 +++ b/Xext/hashtable.h
 @@ -55,27 +55,27 @@ extern _X_EXPORT HashTable ht_create(int 
 keySize,
   int dataSize,
   HashFunchash,
   HashCompareFunc compare,
 - pointer cdata);
 + void*cdata);
  /** @brief  HtDestruct deinitializes the structure. It does not free the
  memory allocated to HashTableRec
  */
  extern _X_EXPORT void ht_destroy(HashTable ht);
  
  /** @brief  Adds a new key to the hash table. The key will be copied
 -and a pointer to the value will be returned. The data will
 +and a void *to the value will be returned. The data will
  be initialized with zeroes.
  
@param[in/out] ht  The hash table
@param[key] keyThe key. The contents of the key will be copied.
  
 -  @return On error NULL is returned, otherwise a pointer to the data
 +  @return On error NULL is returned, otherwise a void *to the data
associated with the newly inserted key.
  
 -  @note  If dataSize is 0, a pointer to the end of the key may be returned
 +  @note  If dataSize is 0, a void *to the end of the key may be returned
   to avoid returning NULL. Obviously the data pointed cannot be
   modified, as implied by dataSize being 0.

I don't think these comments wanted to change.

 diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
 index 6f8939f..1494ec4 100644
 --- a/Xext/panoramiX.c
 +++ b/Xext/panoramiX.c
 @@ -130,7 +130,7 @@ static void XineramaValidateGC(GCPtr, unsigned long, 
 DrawablePtr);
  static void XineramaChangeGC(GCPtr, unsigned long);
  static void XineramaCopyGC(GCPtr, unsigned long, GCPtr);
  static void XineramaDestroyGC(GCPtr);
 -static void XineramaChangeClip(GCPtr, int, pointer, int);
 +static void XineramaChangeClip(GCPtr, int, void *, int);
  static void XineramaDestroyClip(GCPtr);
  static void XineramaCopyClip(GCPtr, GCPtr);
  
 @@ -160,7 +160,7 @@ XineramaCloseScreen(ScreenPtr pScreen)
  if (pScreen-myNum == 0)
  RegionUninit(PanoramiXScreenRegion);
  
 -free((pointer) pScreenPriv);
 +free((void *) pScreenPriv);

Casting to void * to pass to a function taking void *?  I guess cleanups
of that can be left to a coccinelle patch later.

 diff --git a/Xext/saver.c b/Xext/saver.c
 index e06f408..03f28bb 100644
 --- a/Xext/saver.c
 +++ b/Xext/saver.c
 @@ -107,7 +107,7 @@ typedef struct _ScreenSaverSuspension {
  int count;
  } ScreenSaverSuspensionRec;
  
 -static int ScreenSaverFreeSuspend(pointer /*value */ ,
 +static int ScreenSaverFreeSuspend(void */*value */ ,

space got lost.  But these protos are hideous anyway.

 @@ -168,7 +168,7 @@ typedef struct _ScreenSaverAttr {
  unsigned long *values;
  } ScreenSaverAttrRec, *ScreenSaverAttrPtr;
  
 -static int ScreenSaverFreeAttr(pointer /* value */ ,
 +static int ScreenSaverFreeAttr(void */* value */ ,
 XID  /* id */
  );

same

 diff --git a/Xext/shm.c b/Xext/shm.c
 index 1957a95..34545ec 100644
 --- a/Xext/shm.c
 +++ b/Xext/shm.c
 @@ -99,7 +99,7 @@ typedef struct _ShmScrPrivateRec {
  } ShmScrPrivateRec;
  
  static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS);
 -static int ShmDetachSegment(pointer /* value */ ,
 +static int ShmDetachSegment(void */* value */ ,

lost space

 diff --git a/Xext/xselinux_hooks.c b/Xext/xselinux_hooks.c
 index e9c7e93..5453cbb 100644
 --- a/Xext/xselinux_hooks.c
 +++ b/Xext/xselinux_hooks.c
 @@ -74,10 +74,10 @@ static Atom atom_client_ctx;
  static security_id_t unlabeled_sid;
  
  /* forward declarations */
 -static void SELinuxScreen(CallbackListPtr *, pointer, pointer);
 +static void SELinuxScreen(CallbackListPtr *, void *, void *);
  
 -/* true pointer value for use as callback data */
 -static pointer truep = (pointer) 1;
 +/* true void *value for use as callback data */

unintentional comment change.

 diff --git a/Xi/chgptr.c b/Xi/chgptr.c
 index f99d1aa..aaebc9f 100644
 --- a/Xi/chgptr.c
 +++ b/Xi/chgptr.c
 @@ -46,7

[PATCH 2/2] glx: unifdef swrast dri_interface.h values from Mesa 7.1.

2013-12-16 Thread Eric Anholt
We can't remove all the ifdefs (__DRI_TEX_BUFFER_VERSION) because
configure.ac is only checking for that version of Mesa in the absence
of dri2.
---
 glx/glxdriswrast.c | 25 +
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index cbc109a..6fa3288 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -170,8 +170,6 @@ __glXDRIcontextCopy(__GLXcontext * baseDst, __GLXcontext * 
baseSrc,
  src-driContext, mask);
 }
 
-#ifdef __DRI_TEX_BUFFER
-
 static int
 __glXDRIbindTexImage(__GLXcontext * baseContext,
  int buffer, __GLXdrawable * glxPixmap)
@@ -205,24 +203,6 @@ __glXDRIreleaseTexImage(__GLXcontext * baseContext,
 return Success;
 }
 
-#else
-
-static int
-__glXDRIbindTexImage(__GLXcontext * baseContext,
- int buffer, __GLXdrawable * glxPixmap)
-{
-return Success;
-}
-
-static int
-__glXDRIreleaseTexImage(__GLXcontext * baseContext,
-int buffer, __GLXdrawable * pixmap)
-{
-return Success;
-}
-
-#endif
-
 static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
 __glXDRIbindTexImage,
 __glXDRIreleaseTexImage
@@ -407,20 +387,17 @@ initializeExtensions(__GLXDRIscreen * screen)
 extensions = screen-core-getExtensions(screen-driScreen);
 
 for (i = 0; extensions[i]; i++) {
-#ifdef __DRI_COPY_SUB_BUFFER
 if (strcmp(extensions[i]-name, __DRI_COPY_SUB_BUFFER) == 0) {
 screen-copySubBuffer =
 (const __DRIcopySubBufferExtension *) extensions[i];
 /* GLX_MESA_copy_sub_buffer is always enabled. */
 }
-#endif
 
-#ifdef __DRI_TEX_BUFFER
 if (strcmp(extensions[i]-name, __DRI_TEX_BUFFER) == 0) {
 screen-texBuffer = (const __DRItexBufferExtension *) 
extensions[i];
 /* GLX_EXT_texture_from_pixmap is always enabled. */
 }
-#endif
+
 /* Ignore unknown extensions */
 }
 }
-- 
1.8.5.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 1/2] glx: unifdef for DRI2 dri_interface.h things in mesa 9.2.

2013-12-16 Thread Eric Anholt
Thanks to configure.ac's check, we know that we have a new enough
dri_interface.h that we don't need to conditionalize all this code.
---
 glx/glxdri2.c | 59 ---
 1 file changed, 59 deletions(-)

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index b2f3d6e..8c10586 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -55,14 +55,9 @@ typedef struct __GLXDRIscreen __GLXDRIscreen;
 typedef struct __GLXDRIcontext __GLXDRIcontext;
 typedef struct __GLXDRIdrawable __GLXDRIdrawable;
 
-#ifdef __DRI2_ROBUSTNESS
 #define ALL_DRI_CTX_FLAGS (__DRI_CTX_FLAG_DEBUG \
| __DRI_CTX_FLAG_FORWARD_COMPATIBLE  \
| __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS)
-#else
-#define ALL_DRI_CTX_FLAGS (__DRI_CTX_FLAG_DEBUG \
-   | __DRI_CTX_FLAG_FORWARD_COMPATIBLE)
-#endif
 
 struct __GLXDRIscreen {
 __GLXscreen base;
@@ -210,15 +205,10 @@ __glXDRIdrawableSwapBuffers(ClientPtr client, 
__GLXdrawable * drawable)
 __GLXDRIscreen *screen = priv-screen;
 CARD64 unused;
 
-#if __DRI2_FLUSH_VERSION = 3
 if (screen-flush) {
 (*screen-flush-flush) (priv-driDrawable);
 (*screen-flush-invalidate) (priv-driDrawable);
 }
-#else
-if (screen-flush)
-(*screen-flush-flushInvalidate) (priv-driDrawable);
-#endif
 
 if (DRI2SwapBuffers(client, drawable-pDraw, 0, 0, 0, unused,
 __glXdriSwapEvent, drawable) != Success)
@@ -294,8 +284,6 @@ __glXDRIcontextWait(__GLXcontext * baseContext,
 return FALSE;
 }
 
-#ifdef __DRI_TEX_BUFFER
-
 static int
 __glXDRIbindTexImage(__GLXcontext * baseContext,
  int buffer, __GLXdrawable * glxPixmap)
@@ -307,14 +295,12 @@ __glXDRIbindTexImage(__GLXcontext * baseContext,
 if (texBuffer == NULL)
 return Success;
 
-#if __DRI_TEX_BUFFER_VERSION = 2
 if (texBuffer-base.version = 2  texBuffer-setTexBuffer2 != NULL) {
 (*texBuffer-setTexBuffer2) (context-driContext,
  glxPixmap-target,
  glxPixmap-format, drawable-driDrawable);
 }
 else
-#endif
 {
 texBuffer-setTexBuffer(context-driContext,
 glxPixmap-target, drawable-driDrawable);
@@ -331,24 +317,6 @@ __glXDRIreleaseTexImage(__GLXcontext * baseContext,
 return Success;
 }
 
-#else
-
-static int
-__glXDRIbindTexImage(__GLXcontext * baseContext,
- int buffer, __GLXdrawable * glxPixmap)
-{
-return Success;
-}
-
-static int
-__glXDRIreleaseTexImage(__GLXcontext * baseContext,
-int buffer, __GLXdrawable * pixmap)
-{
-return Success;
-}
-
-#endif
-
 static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
 __glXDRIbindTexImage,
 __glXDRIreleaseTexImage
@@ -398,11 +366,7 @@ dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned 
num_attribs,
 
 *major_ver = 1;
 *minor_ver = 0;
-#ifdef __DRI2_ROBUSTNESS
 *reset = __DRI_CTX_RESET_NO_NOTIFICATION;
-#else
-(void) reset;
-#endif
 
 for (i = 0; i  num_attribs; i++) {
 switch (attribs[i * 2]) {
@@ -433,7 +397,6 @@ dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned 
num_attribs,
 return False;
 }
 break;
-#ifdef __DRI2_ROBUSTNESS
 case GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB:
 if (screen-dri2-base.version = 4) {
 *error = BadValue;
@@ -452,7 +415,6 @@ dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned 
num_attribs,
 return False;
 }
 break;
-#endif
 default:
 /* If an unknown attribute is received, fail.
  */
@@ -493,7 +455,6 @@ create_driver_context(__GLXDRIcontext * context,
 {
 context-driContext = NULL;
 
-#if __DRI_DRI2_VERSION = 3
 if (screen-dri2-base.version = 3) {
 uint32_t ctx_attribs[3 * 2];
 unsigned num_ctx_attribs = 0;
@@ -525,13 +486,11 @@ create_driver_context(__GLXDRIcontext * context,
 ctx_attribs[num_ctx_attribs++] = flags;
 }
 
-#ifdef __DRI2_ROBUSTNESS
 if (reset != __DRI_CTX_RESET_NO_NOTIFICATION) {
 ctx_attribs[num_ctx_attribs++] =
 __DRI_CTX_ATTRIB_RESET_STRATEGY;
 ctx_attribs[num_ctx_attribs++] = reset;
 }
-#endif
 }
 
 context-driContext =
@@ -567,7 +526,6 @@ create_driver_context(__GLXDRIcontext * context,
 
 return;
 }
-#endif
 
 if (num_attribs != 0) {
 *error = BadValue;
@@ -625,13 +583,11 @@ __glXDRIscreenCreateContext(__GLXscreen * baseScreen,
 static void
 __glXDRIinvalidateBuffers(DrawablePtr pDraw, void *priv, XID id)
 {
-#if __DRI2_FLUSH_VERSION = 3
 __GLXDRIdrawable *private = priv;
 __GLXDRIscreen *screen = private-screen;
 
 if (screen-flush)
 

Re: [PATCH] glx: Add null pointer protection to __glGetProcAddress

2013-12-10 Thread Eric Anholt
Adam Jackson a...@redhat.com writes:

 This can't happen when GLX is the backing window system, but can
 elsewhere.  We may as well protect against it at a high level.

(where elsewhere is both egl and wgl, each with different sets of
functions that will return NULL.  What a delightful API)

An ErrorF when returning NoopDDA to warn that we're papering over a bug
in implementing some function would be pretty nice.  Either way,

Reviewed-by: Eric Anholt e...@anholt.net



pgppr2J9Bj6GK.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] present: Send GLX_BufferSwapComplete events from present extension

2013-11-25 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 This allows GL to support the GLX_INTEL_swap_event extension

 Signed-off-by: Keith Packard kei...@keithp.com

There's a minor behavior change that the event now gets sent to the
drawable owner rather than the caller of DRI2SwapBuffers.

I don't expect it to matter in practice (I expect that the
swap-requesting client using this GLX extension is also the
drawable-creating one), and either choice seems wrong compared to send
the event to everyone listening for the event on this drawable.  That
would be a separate change, anyway.

Reviewed-by: Eric Anholt e...@anholt.net


pgph_nWjayvkj.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] hw/xfree86: Make strings in DriverRec and ScrnInfoRec const

2013-11-15 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 This avoids compiler warnings when initializing with string constants.

 Signed-off-by: Keith Packard kei...@keithp.com

I've apparently misplaced my patch that did the same thing.

Reviewed-by: Eric Anholt e...@anholt.net


pgpf7MVcX5gyJ.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] xfree86: Prefer fbdev to vesa

2013-11-15 Thread Eric Anholt
Adam Jackson a...@redhat.com writes:

 On UEFI machines you'd prefer fbdev to grab efifb instead of vesa trying
 to initialize and failing in a way we can't unwind from.  On BIOS
 machines this is harmless: either there is an fbdev driver and it'll
 probably be more capable, or there's not and vesa will kick in anyway.

Reviewed-by: Eric Anholt e...@anholt.net


pgp_byZJGLpcI.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 1/2] glx: Fix incorrect use of dri_interface.h version defines in extensions.

2013-11-14 Thread Eric Anholt
Those defines are so you can compile-time check do I have a
dri_interface.h that defines this new field of the struct?  You don't
want the server to claim it implements the new struct just because you
installed a new copy of Mesa.
---
 glx/glxdri2.c  | 4 ++--
 glx/glxdricommon.c | 2 +-
 glx/glxdriswrast.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 1d74c8f..5034bb1 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -780,7 +780,7 @@ dri2FlushFrontBuffer(__DRIdrawable * driDrawable, void 
*loaderPrivate)
 }
 
 static const __DRIdri2LoaderExtension loaderExtension = {
-{__DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION},
+{__DRI_DRI2_LOADER, 3},
 dri2GetBuffers,
 dri2FlushFrontBuffer,
 dri2GetBuffersWithFormat,
@@ -788,7 +788,7 @@ static const __DRIdri2LoaderExtension loaderExtension = {
 
 #ifdef __DRI_USE_INVALIDATE
 static const __DRIuseInvalidateExtension dri2UseInvalidate = {
-{__DRI_USE_INVALIDATE, __DRI_USE_INVALIDATE_VERSION}
+{__DRI_USE_INVALIDATE, 1}
 };
 #endif
 
diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index 1022c00..fc90272 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -59,7 +59,7 @@ getUST(int64_t * ust)
 }
 
 const __DRIsystemTimeExtension systemTimeExtension = {
-{__DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION},
+{__DRI_SYSTEM_TIME, 1},
 getUST,
 NULL,
 };
diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index c9962dc..aa083e0 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -386,7 +386,7 @@ swrastGetImage(__DRIdrawable * draw,
 }
 
 static const __DRIswrastLoaderExtension swrastLoaderExtension = {
-{__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION},
+{__DRI_SWRAST_LOADER, 1},
 swrastGetDrawableInfo,
 swrastPutImage,
 swrastGetImage
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 2/2] glx: Fix incorrect use of dri_interface.h version defines in driver probing.

2013-11-14 Thread Eric Anholt
If we extend __DRI_CORE or __DRI_SWRAST in dri_interface.h to allow a
new version, it shouldn't make old server code retroactively require
the new version from swrast drivers.

Notably, new Mesa defines __DRI_SWRAST version 4, but we still want to
be able to probe version 1 drivers, since we don't use any features
beyond version 1 of the struct.
---
 glx/glxdriswrast.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index aa083e0..2d5efa0 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -443,9 +443,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 
 screen-driver = glxProbeDriver(driverName,
 (void **) screen-core,
-__DRI_CORE, __DRI_CORE_VERSION,
+__DRI_CORE, 1,
 (void **) screen-swrast,
-__DRI_SWRAST, __DRI_SWRAST_VERSION);
+__DRI_SWRAST, 1);
 if (screen-driver == NULL) {
 goto handle_error;
 }
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH] Add correct dependency on libxtrans.

2013-11-06 Thread Eric Anholt
The 1.3 release is when the new FD passing bits landed.

Signed-off-by: Eric Anholt e...@anholt.net
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 6925df8..32b7f64 100644
--- a/configure.ac
+++ b/configure.ac
@@ -806,7 +806,7 @@ FIXESPROTO=fixesproto = 5.0
 DAMAGEPROTO=damageproto = 1.1
 XCMISCPROTO=xcmiscproto = 1.2.0
 BIGREQSPROTO=bigreqsproto = 1.1.0
-XTRANS=xtrans = 1.2.2
+XTRANS=xtrans = 1.3
 PRESENTPROTO=presentproto = 1.0
 
 dnl List of libraries that require a specific version
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [Xcb] [PATCH 5/7] Add event queue splitting

2013-11-06 Thread Eric Anholt
Uli Schlachter psyc...@znc.in writes:

 Hi,

 On 06.11.2013 20:34, Peter Harris wrote:
 On 2013-11-05 19:41, Keith Packard wrote:
 [...]
 diff --git a/src/xcb.h b/src/xcb.h
 index f7dc6af..f99e677 100644
 --- a/src/xcb.h
 +++ b/src/xcb.h
 @@ -138,23 +138,6 @@ typedef struct {
  } xcb_generic_event_t;
  
  /**
 - * @brief GE event
 - *
 - * An event as sent by the XGE extension. The length field specifies the
 - * number of 4-byte blocks trailing the struct.
 - */
 -typedef struct {
 -uint8_t  response_type;  /** Type of the response */
 -uint8_t  pad0;   /** Padding */
 -uint16_t sequence;   /** Sequence number */
 -uint32_t length;
 -uint16_t event_type;
 -uint16_t pad1;
 -uint32_t pad[5]; /** Padding */
 -uint32_t full_sequence;  /** full sequence */
 -} xcb_ge_event_t;
 -
 -/**
 
 This hunk doesn't appear to be related to event queue splitting. Should
 it be in a separate commit?

 Thanks for CC'ing the xcb mailing list. I can see why this ended up on
 xorg-devel (xcb being the only sub-project with its own list), but it would
 still be nice to have patches for libxcb or xcb-proto on the xcb mailing list.

 With google I found the patches in question and looked at them quickly. My 
 first
 impression is that the xcb_*_special_event() functions might need way better
 documentation.

 Also, this adds public API that allows to hide XGE events from the normal
 APIs for getting events. Since this seems to be written just with present in
 mind, I can see why it is done like this, but if we really want to go down 
 that
 road, I don't see why this should be XGE-specific.

 Since this is public API, we should IMHO think thrice before settling on 
 something.

 For all the other patches, I am too lazy to get them out of the online 
 archive.
 I would count that as a NAK as long as it is understood that I don't have any
 veto powers. ;-)

libGL needs events from the server that are hidden from the user,
because we events to make direct rendering work, and the user's event
handling will not be ready to see one of those events, and they're
certainly unable to pass us the events because they don't even know they
exist.

We tried to do this with event queue filtering the same way we do with
xlib, and it got NAKed.  Then we came up with new events and a new
mechanism so that we could do this, and it's getting NAKed again.

Right now we're depending on xlib for event handling in GLX so we can
build a working direct-rendered GL, and EGL is broken because it's pure
XCB.  If we can get an API for this, we can move to pure XCB for GLX,
and if not, then I need to go put an xlib dependency into EGL
platform_x11.c so that I can make event handling work.  We'd really
rather be using XCB if we could.


pgp6mq_IDQgpl.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [Xcb] [PATCH 5/7] Add event queue splitting

2013-11-06 Thread Eric Anholt
Peter Harris phar...@opentext.com writes:

 On 2013-11-05 19:41, Keith Packard wrote:
 This allows apps to peel off certain XGE events into separate queues
 for custom handling. Designed to support the Present extension
 
 Signed-off-by: Keith Packard kei...@keithp.com

 Re: xcb_register_for_special_event, xcb_unregister_for_special_event,
 xcb_check_for_special_event, and xcb_wait_for_special_event.

 There was some push-back the last time something similar to this came
 up, on the theory that it should be in a separate library from xcb[1].
 That said, we may have reached the point where it's just too useful to
 not have in libxcb.

The magic extra library is a non-solution.  The user implementing event
handling doesn't know what GLX/EGL is doing, so you can't rely on them
using the magic extra library.

This implementation is basically the fix events somehow option in that
cited email: the new events have the multiplexing token (the eid field),
and this is the code for getting those events to the code that
registered for the event.


pgpAtFUdPsCrR.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] Xext: Enable MIT-SHM FD-passing request definitions only when defined

2013-11-04 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 Check to see if the new protocol headers are available and
 advertise appropriate version of the SHM extension

I'd rather see the updated protocol headers just be required by
configure.ac.


pgpvnEZ5fpzFh.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] glx: Remove DRI1 AIGLX

2013-10-22 Thread Eric Anholt
Adam Jackson a...@redhat.com writes:

 Mesa doesn't ship DRI1 drivers as of 8.0, which is about 18 months and
 three releases ago.  The main reason to have wanted DRI1 AIGLX was to
 get a GLX compositor working, but DRI1's (lack of) memory management API
 meant that the cost of a GLX compositor was breaking direct GLX apps,
 which isn't a great tradeoff.

 Of the DRI1 drivers Mesa has dropped, I believe only mga stands to lose
 some functionality here, since it and only it has support for
 NV_texture_rectangle.  Since that's required for every extant GLX
 compositor I know of, I conclude that anybody with a savage, say, would
 probably not notice AIGLX going away, since they wouldn't be running a
 GLX compositor in the first place.

 In the future we'd like to use GL in the server in a more natural way,
 as just another EGL client, including in the GLX implementation itself.
 Since there's no EGL implemented for DRI1 drivers, this would already
 doom AIGLX on DRI1 (short of entirely forking the GLX implementation,
 which I'm not enthusiastic about).

I think you also want to drop the DRI1 checks for AIGLX and
AIGLX_DRI_LOADER in configure.ac.  If you do:

Reviewed-by: Eric Anholt e...@anholt.net


pgpf4oeYaVwvG.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] glx: Add support for the new DRI loader entrypoint.

2013-10-22 Thread Eric Anholt
This is going to be exposed (and not the old entrypoint) for some DRI
drivers once the megadrivers series lands, and the plan is to
eventually transition all drivers to that.  Hopefully this is
unobtrusive enough to merge to stable X servers so that they can be
compatible with new Mesa versions.

v2: typo fix in the comment

Signed-off-by: Eric Anholt e...@anholt.net
Reviewed-by: Adam Jackson a...@redhat.com
---
 glx/glxdricommon.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index b027f24..0ab3e30 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -211,6 +211,14 @@ glxConvertConfigs(const __DRIcoreExtension * core,
 
 static const char dri_driver_path[] = DRI_DRIVER_PATH;
 
+/* Temporary define to allow building without a dri_interface.h from
+ * updated Mesa.  Some day when we don't care about Mesa that old any
+ * more this can be removed.
+ */
+#ifndef __DRI_DRIVER_GET_EXTENSIONS
+#define __DRI_DRIVER_GET_EXTENSIONS __driDriverGetExtensions
+#endif
+
 void *
 glxProbeDriver(const char *driverName,
void **coreExt, const char *coreName, int coreVersion,
@@ -219,7 +227,8 @@ glxProbeDriver(const char *driverName,
 int i;
 void *driver;
 char filename[PATH_MAX];
-const __DRIextension **extensions;
+char *get_extensions_name;
+const __DRIextension **extensions = NULL;
 
 snprintf(filename, sizeof filename, %s/%s_dri.so,
  dri_driver_path, driverName);
@@ -231,7 +240,18 @@ glxProbeDriver(const char *driverName,
 goto cleanup_failure;
 }
 
-extensions = dlsym(driver, __DRI_DRIVER_EXTENSIONS);
+if (asprintf(get_extensions_name, %s_%s,
+ __DRI_DRIVER_GET_EXTENSIONS, driverName) != -1) {
+const __DRIextension **(*get_extensions)(void);
+
+get_extensions = dlsym(driver, get_extensions_name);
+if (get_extensions)
+extensions = get_extensions();
+free(get_extensions_name);
+}
+
+if (!extensions)
+extensions = dlsym(driver, __DRI_DRIVER_EXTENSIONS);
 if (extensions == NULL) {
 LogMessage(X_ERROR, AIGLX error: %s exports no extensions (%s)\n,
driverName, dlerror());
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH 2/2] ephyr: Ensure stride of private framebuffer is multiple of 4

2013-10-22 Thread Eric Anholt
Søren Sandmann sandm...@cs.au.dk writes:

 From: Søren Sandmann Pedersen s...@redhat.com

 The fb layer of X can't deal with strides that are not a multiple of
 4, so when Xephyr allocates its own framebuffer it should make sure to
 align it.

 This fixes crashes and rendering corruption when Xephyr runs in a
 depth that is different from the host X server and its screen size is
 not a multiple of 4 / depth. (This is particularly easy to trigger if
 you use the -resizeable option).
 ---
  hw/kdrive/ephyr/hostx.c |   15 ---
  1 files changed, 8 insertions(+), 7 deletions(-)

 diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
 index 86f3679..b547525 100644
 --- a/hw/kdrive/ephyr/hostx.c
 +++ b/hw/kdrive/ephyr/hostx.c
 @@ -719,12 +719,14 @@ hostx_screen_init(KdScreenInfo *screen,
  return scrpriv-ximg-data;
  }
  else {
 -*bytes_per_line = width * (scrpriv-server_depth  3);
 +int Bpp = scrpriv-server_depth  3;

It took me a moment to figure out that 'B' was probaby capitalized to
mean bytes as opposed to bits.  I prefer the bytes_per_pixel naming in
the other hunk if you feel the units need clarification here.

 +int stride = (width * Bpp + 0x3)  ~0x3;
 +

trailing whitespace

 +*bytes_per_line = stride;
  *bits_per_pixel = scrpriv-server_depth;

Other than the whitespace, these two patches are:

Reviewed-by: Eric Anholt e...@anholt.net


pgpGPTqqNhHbn.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] glx: Add support for the new DRI loader entrypoint.

2013-10-11 Thread Eric Anholt
This is going to be exposed (and not the old entrypoint) for some DRI
drivers once the megadrivers series lands, and the plan is to
eventually transition all drivers to that.  Hopefully this is
unobtrusive enough to merge to stable X servers so that they can be
compatible with new Mesa versions.
---

The corresponding mesa series isn't landed yet, thus the #ifndef.
Plus it should make the patch trivially backportable, which is kind of
the only way that this patch matters since I expect it patch to have
been deleted from master by the time 1.15 rolls around.

Note that unlike the libGL side of things, I didn't extend things to
use createNewScreen2().  I'm relying on the __driDriverGetExtensions
called here setting a global symbol in the dri_util.c code so that the
common createNewScreen() can pull it out and use that as the reference
to the driver -- it's sleazy, but it means the patch is backportable
without needing a bunch of structs in dri_interface.h updated.

 glx/glxdricommon.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index b027f24..6bb7d1d 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -211,6 +211,14 @@ glxConvertConfigs(const __DRIcoreExtension * core,
 
 static const char dri_driver_path[] = DRI_DRIVER_PATH;
 
+/* Temporary define to allow building without a dri_interface.h from
+ * updated Mesa.  Some day when we don't core about Mesa that old any
+ * more this can be removed.
+ */
+#ifndef __DRI_DRIVER_GET_EXTENSIONS
+#define __DRI_DRIVER_GET_EXTENSIONS __driDriverGetExtensions
+#endif
+
 void *
 glxProbeDriver(const char *driverName,
void **coreExt, const char *coreName, int coreVersion,
@@ -219,7 +227,8 @@ glxProbeDriver(const char *driverName,
 int i;
 void *driver;
 char filename[PATH_MAX];
-const __DRIextension **extensions;
+char *get_extensions_name;
+const __DRIextension **extensions = NULL;
 
 snprintf(filename, sizeof filename, %s/%s_dri.so,
  dri_driver_path, driverName);
@@ -231,7 +240,18 @@ glxProbeDriver(const char *driverName,
 goto cleanup_failure;
 }
 
-extensions = dlsym(driver, __DRI_DRIVER_EXTENSIONS);
+if (asprintf(get_extensions_name, %s_%s,
+ __DRI_DRIVER_GET_EXTENSIONS, driverName) != -1) {
+const __DRIextension **(*get_extensions)(void);
+
+get_extensions = dlsym(driver, get_extensions_name);
+if (get_extensions)
+extensions = get_extensions();
+free(get_extensions_name);
+}
+
+if (!extensions)
+extensions = dlsym(driver, __DRI_DRIVER_EXTENSIONS);
 if (extensions == NULL) {
 LogMessage(X_ERROR, AIGLX error: %s exports no extensions (%s)\n,
driverName, dlerror());
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH] loader: Use RTLD_DEEPBIND if available to prefer local symbols

2013-10-04 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 Egbert Eich e...@freedesktop.org writes:

 If there are namespace clashes among different drivers it would be
 preferrable if each driver used its local symbols. Use the
 RTLD_DEEPBIND if available to achive this.

 Eric and Adam are doing a lot of work in Mesa to fix the exported symbol
 lists; do we expect this hack to still be required in the future? Or is
 it purely a temporary kludge?

Note that Mesa is not involved in the use case that Egbert mentioned.

I think fixing the driver builds to be -Bsymbolic would be superior to
this patch (and a performance win!) while solving the original problem.
RTLD_DEEPBIND has the unfortunate downside that it prevents you from
using LD_PRELOAD for things like cheesy non-valgrind malloc debuggers or
most GL interposers, which is the only real argument I see against it.


pgpE8EUxvneWr.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 2/3] glx: Fix memory leak in context garbage collection

2013-09-30 Thread Eric Anholt
Adam Jackson a...@redhat.com writes:

 I broke this, back in:

 commit a48dadc98a28c969741979b70b7a639f24f4cbbd
 Author: Adam Jackson a...@redhat.com
 Date:   Mon Mar 21 11:59:29 2011 -0400

   glx: Reimplement context tags

 In that, I changed the glx client state to not explicitly track the list
 of current contexts for the client (since that was what we were deriving
 tags from).  The bug was that I removed the code for same from
 glxClientCallback without noticing that it had the side effect of
 effectively de-currenting those contexts, so that ContextGone could free
 them.  So, if you had a client exit with a context still current, the
 context's memory would leak.  Not a huge deal for direct clients, but
 viciously bad for indirect, since the swrast context state at the bottom
 of Mesa is like 15M.

 Fix this by promoting Bool isCurrent to ClientPtr currentClient, so that
 we have a back-pointer to chase when walking the list of contexts when
 ClientStateGone happens.

Patch 1/3 is: Reviewed-by: Eric Anholt e...@anholt.net

But I'm lost on this one.  loseCurrent is just -core-unbindContext,
which is mesa's dri_util.c dereferencing the drawables and calling the
driver UnbindContext, which is just _mesa_make_current(NULL, NULL, NULL)
regardless of the current context.  That doesn't seem to add up to a
savings of a leaked context per client gone (since whatever current
context that was otherwise unreferenced would get reaped at the next
makecurrent).  So I'm pretty sure I'm missing something.

Also, you've got some fresh tab indentation in the last hunk.


pgpzgDQ8Fpa5g.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH RESEND xserver 3/6] Xorg binary: use install-exec-hook rather than install-exec-local

2013-09-28 Thread Eric Anholt
Gaetan Nadon mems...@videotron.ca writes:

 The former was explicitly designed to execute additional code after the binary
 has been installed. The latter can be executed in any order, hence it's
 current dependency on install-binPROGRAMS as a workaround.

 The CYGWIN libXorg.exe.a target is an installation target rather than
 a post-installation one, so it should not be done as a hook. It does not 
 depend
 on the Xorg executable being installed.

 Automake:
 These hooks are run after all other install rules of the appropriate type,
 exec or data, have completed. So, for instance, it is possible to perform
 post-installation modifications using an install hook.

 With the -local targets, there is no particular guarantee of execution order;
 typically, they are run early, but with parallel make, there is no way
 to be sure of that.

Reviewed-by: Eric Anholt e...@anholt.net


pgpZGpBHeAkJe.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 05/17] ephyr: Move event processing into ephyr.c.

2013-09-03 Thread Eric Anholt
Julien Cristau jcris...@debian.org writes:

 On Mon, Aug 26, 2013 at 13:26:11 -0700, Eric Anholt wrote:
 -struct EphyrHostXEvent {
 -EphyrHostXEventType type;
  
 -union {
 -struct mouse_motion {
 -int x;
 -int y;
 -int screen;
 -int window;
 -} mouse_motion;
 +struct EphyrHostScreen {
 +Window win;
 +Window win_pre_existing;/* Set via -parent option like xnest */
 +Window peer_win;/* Used for GL; should be at most one */
 +xcb_image_t*ximg;
 +int win_width, win_height;
 +int server_depth;
 +unsigned char *fb_data; /* only used when host bpp != server bpp */
 +xcb_shm_segment_info_t shminfo;
  
 The previous patch killed EphyrHostScreen, I assume it wasn't supposed
 to come back here?

Fixed, thanks!


pgpt80iEWAgGN.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 09/17] Remove the host/server split for XV attributes.

2013-09-03 Thread Eric Anholt
Julien Cristau jcris...@debian.org writes:

 On Mon, Aug 26, 2013 at 13:26:15 -0700, Eric Anholt wrote:

 ---
  hw/kdrive/ephyr/ephyrhostvideo.c | 107 ---
  hw/kdrive/ephyr/ephyrhostvideo.h |  19 --
  hw/kdrive/ephyr/ephyrvideo.c | 133 
 ---
  3 files changed, 82 insertions(+), 177 deletions(-)
 
 [...]
 diff --git a/hw/kdrive/ephyr/ephyrvideo.c b/hw/kdrive/ephyr/ephyrvideo.c
 index be59886..62f697c 100644
 --- a/hw/kdrive/ephyr/ephyrvideo.c
 +++ b/hw/kdrive/ephyr/ephyrvideo.c
 [...]
 @@ -650,18 +656,23 @@ ephyrXVPrivGetImageBufSize(int a_port_id,
 unsigned short a_width,
 unsigned short a_height, int *a_size)
  {
 +xcb_connection_t *conn = hostx_get_xcbconn();
 +xcb_xv_query_image_attributes_cookie_t cookie;
 +xcb_xv_query_image_attributes_reply_t *reply;
  Bool is_ok = FALSE;
 -unsigned short width = a_width, height = a_height;
  
  EPHYR_RETURN_VAL_IF_FAIL(a_size, FALSE);
  
  EPHYR_LOG(enter\n);
  
 -if (!ephyrHostXVQueryImageAttributes(a_port_id, a_image_id,
 - width, height, a_size, NULL, 
 NULL)) {
 -EPHYR_LOG_ERROR(failed to get image attributes\n);
 +cookie = xcb_xv_query_image_attributes(conn,
 +   a_port_id, a_image_id,
 +   a_width, a_height);
 +reply = xcb_xv_query_image_attributes_reply(conn, cookie, NULL);
 +if (!reply)
  goto out;
 -}
 +
 +*a_size = reply-data_size;
  is_ok = TRUE;
  
   out:

 This seems to leak 'reply'.

 [...]
 @@ -772,8 +781,12 @@ static int
  ephyrGetPortAttribute(KdScreenInfo * a_screen_info,
Atom a_attr_name, int *a_attr_value, pointer 
 a_port_priv)
  {
 +xcb_connection_t *conn = hostx_get_xcbconn();
  int res = Success, host_atom = 0;
  EphyrPortPriv *port_priv = a_port_priv;
 +xcb_generic_error_t *e;
 +xcb_xv_get_port_attribute_cookie_t cookie;
 +xcb_xv_get_port_attribute_reply_t *reply;
  
  EPHYR_RETURN_VAL_IF_FAIL(port_priv, BadMatch);
  EPHYR_RETURN_VAL_IF_FAIL(ValidAtom(a_attr_name), BadMatch);
 @@ -788,12 +801,15 @@ ephyrGetPortAttribute(KdScreenInfo * a_screen_info,
  goto out;
  }
  
 -if (!ephyrHostXVGetPortAttribute(port_priv-port_number,
 - host_atom, a_attr_value)) {
 -EPHYR_LOG_ERROR(failed to get port attribute\n);
 +cookie = xcb_xv_get_port_attribute(conn, port_priv-port_number, 
 host_atom);
 +reply = xcb_xv_get_port_attribute_reply(conn, cookie, e);
 +if (e) {
 +EPHYR_LOG_ERROR (XvGetPortAttribute() failed: %d \n, 
 e-error_code);
 +free(e);
  res = BadMatch;
  goto out;
  }
 +*a_attr_value = reply-value;
  
  res = Success;
   out:

 Missing free(reply) here too.

Fixed, thanks!


pgpIYKrK5dpxK.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 02/17] ephyr: Expose a single function for detecting extensions.

2013-09-03 Thread Eric Anholt
Julien Cristau jcris...@debian.org writes:

 On Mon, Aug 26, 2013 at 13:26:08 -0700, Eric Anholt wrote:

 Signed-off-by: Eric Anholt e...@anholt.net
 ---
  hw/kdrive/ephyr/ephyr.c   | 15 ++-
  hw/kdrive/ephyr/ephyrdriext.c |  7 +--
  hw/kdrive/ephyr/ephyrglxext.c |  3 ++-
  hw/kdrive/ephyr/hostx.c   | 29 -
  hw/kdrive/ephyr/hostx.h   |  3 ++-
  5 files changed, 23 insertions(+), 34 deletions(-)
 
 diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
 index b34b5cc..cd2cae1 100644
 --- a/hw/kdrive/ephyr/ephyr.c
 +++ b/hw/kdrive/ephyr/ephyr.c
 @@ -26,6 +26,9 @@
  #ifdef HAVE_CONFIG_H
  #include kdrive-config.h
  #endif
 +
 +#include xcb/xf86dri.h
 +

 Maybe #ifdef XF86DRI around this one?

I moved it down into the #ifdef block below.


pgp71U4YmHJYZ.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 2/7] damage: Simplify DamageUnregister

2013-09-03 Thread Eric Anholt
Adam Jackson a...@redhat.com writes:

 You can only register one drawable on a given damage, so there's no
 reason to require the caller to specify the drawable, the damage is
 enough.  The implementation would do something fairly horrible if you
 _did_ pass mismatched drawable and damage, so let's avoid the problem
 entirely.

 Signed-off-by: Adam Jackson a...@redhat.com


 diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
 index a393747..0b86f01 100644
 --- a/hw/xfree86/modes/xf86Rotate.c
 +++ b/hw/xfree86/modes/xf86Rotate.c
 @@ -272,9 +272,7 @@ xf86RotateDestroy(xf86CrtcPtr crtc)
  screenDrawable = pScreen-root-drawable;
  /* Free damage structure */
  if (xf86_config-rotation_damage_registered) {
 -if (screenDrawable)
 -DamageUnregister(screenDrawable,
 -xf86_config-rotation_damage);
 +DamageUnregister(xf86_config-rotation_damage);
  xf86_config-rotation_damage_registered = FALSE;
  DisableLimitedSchedulingLatency();
  }

This one looked weird.  I think thanks to patch 1, you want to just drop
this unregister, and drop the conditional on the DamageDestroy that
follows.


pgpEGuNZl6xG_.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 7/7] damageext: Xineramify

2013-09-03 Thread Eric Anholt
Adam Jackson a...@redhat.com writes:

 Probable issues:

 Pixmaps will get N times as many reports as they should; they're
 replicated to all screens, so.

 Windows will have funny-looking seams in the damage report.

Isn't this missing translation for the regions between the client's
damage record and the damage record for windows on the root pixmap?
Looking at, say, PanoramiXPolyFillRectangle, there's:

isRoot = IS_ROOT_DRAWABLE(draw);
...
if (isRoot) {
int x_off = screenInfo.screens[j]-x;
int y_off = screenInfo.screens[j]-y;
...
}

Also, the global for redirecting the per-screen creates to the client's
drawable looked goofy, but I suspect once you solve the translation
thing, that will have gone away.

Patch 5 looked wrong, as noted by Chris.  So, assuming the little
cleanup I noted on #2, patches 1, 2, 3, 4, and 6 are:

Reviewed-by: Eric Anholt e...@anholt.net


pgptHnR7JyAqT.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PULL] xephyr xcb conversion, code deletion, and bugfixes

2013-09-03 Thread Eric Anholt
The following changes since commit 94d4e29aedc69431fa9b299ca1b67947173d7a24:

  Xi: allow for XIAllowEvent requests larger than XI  2.2 size (#68554) 
(2013-08-30 14:26:55 +1000)

are available in the git repository at:

  git://people.freedesktop.org/~anholt/xserver ephyr-fixes

for you to fetch changes up to abc2bfca16adcd1e5657d4ce54f4e1335d5ed53f:

  kdrive: initialize GLX for xephyr (2013-09-03 14:35:39 -0700)


Eric Anholt (20):
  ephyr: Drop dead ephyrHostAtomToLocal code.
  ephyr: Expose a single function for detecting extensions.
  ephyr: Rename and use the proper type for what was host_screen-info.
  ephyr: Move the host screen info into the kdrive screen private.
  ephyr: Move event processing into ephyr.c.
  ephyr: Remove some pointless indirection in the XV code.
  ephyr: Refactor XV adaptor feature detection.
  ephyr: Remove the host/server split for XV adaptors.
  ephyr: Remove the host/server split for XV attributes.
  ephyr: Remove the host/server split for XV formats.
  ephyr: Remove the host/server split for video encodings.
  ephyr: Remove another host/server split for XV image formats.
  ephyr: Remove the host/server split of the actual XV video operations.
  ephyr: Remove the remaining bits of host/server XV split.
  ephyr: Remove the helper libs for each of the optional components.
  ephyr: Garbage collect some dead XV clipping code.
  ephyr: Garbage collect some DOA host window clipping code.
  ephyr: Use host (HW) cursors by default.
  ephyr: Flush the X connection when updating the window title.
  ephyr: Do grab/ungrab for ctrl+shift, not just shift+ctrl.

Julien Cristau (19):
  Xephyr: stop loading the host's keymap
  Xephyr: start converting hostx.c over to xcb
  Xephyr: use xcb-shape instead of XShape*
  Xephyr: no need for XDisplayKeycodes
  Xephyr: xcb-ify pointer/keyboard grab
  Xephyr: xcb-ify visual list construction
  Xephyr: delete unused proxy code
  Xephyr: delete unused hostx_get_extension_info function
  Xephyr: replace XKeycodeToKeysym with xcb-keysyms
  Xephyr: move HostX.visual to xcb
  Xephyr: some more hostx.c xcb-ification
  Xephyr: use xcb for event handling
  Xephyr: use xcb-xv instead of libXv
  Xephyr: move ephyrdri over to xcb
  Xephyr: remove unused DRI1 code
  Xephyr: move glx code to xcb
  Xephyr: drop remaining Xlib dependency
  Xephyr: handle errors in event loop
  Xephyr: we're not using Xlib anymore, no need to undef _XSERVER64

Sebastien Bacher (1):
  kdrive: initialize GLX for xephyr

 configure.ac |6 +-
 hw/kdrive/ephyr/Makefile.am  |   91 ++-
 hw/kdrive/ephyr/XF86dri.c|  654 
 hw/kdrive/ephyr/ephyr.c  |  439 ++
 hw/kdrive/ephyr/ephyr.h  |   20 +-
 hw/kdrive/ephyr/ephyrdri.c   |  201 +--
 hw/kdrive/ephyr/ephyrdriext.c|7 +-
 hw/kdrive/ephyr/ephyrglxext.c|   14 +-
 hw/kdrive/ephyr/ephyrhostglx.c   |  677 +++--
 hw/kdrive/ephyr/ephyrhostglx.h   |   11 +-
 hw/kdrive/ephyr/ephyrhostproxy.c |   91 ---
 hw/kdrive/ephyr/ephyrhostproxy.h |   51 --
 hw/kdrive/ephyr/ephyrhostvideo.c |  975 --
 hw/kdrive/ephyr/ephyrhostvideo.h |  231 ---
 hw/kdrive/ephyr/ephyrinit.c  |   33 +-
 hw/kdrive/ephyr/ephyrproxyext.c  |  115 
 hw/kdrive/ephyr/ephyrproxyext.h  |   33 -
 hw/kdrive/ephyr/ephyrvideo.c |  746 ---
 hw/kdrive/ephyr/hostx.c  | 1228 +++---
 hw/kdrive/ephyr/hostx.h  |  104 +---
 hw/kdrive/ephyr/xf86dri.h|  124 
 21 files changed, 1689 insertions(+), 4162 deletions(-)
 delete mode 100644 hw/kdrive/ephyr/XF86dri.c
 delete mode 100644 hw/kdrive/ephyr/ephyrhostproxy.c
 delete mode 100644 hw/kdrive/ephyr/ephyrhostproxy.h
 delete mode 100644 hw/kdrive/ephyr/ephyrhostvideo.c
 delete mode 100644 hw/kdrive/ephyr/ephyrhostvideo.h
 delete mode 100644 hw/kdrive/ephyr/ephyrproxyext.c
 delete mode 100644 hw/kdrive/ephyr/ephyrproxyext.h
 delete mode 100644 hw/kdrive/ephyr/xf86dri.h


pgpMgEg8z1IXC.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 03/19] Xephyr: use xcb-shape instead of XShape*

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net
Reviewed-by: Eric Anholt e...@anholt.net
Signed-off-by: Julien Cristau jcris...@debian.org
---
 hw/kdrive/ephyr/hostx.c | 40 +++-
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 2ecda14..f4948b9 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -54,7 +54,6 @@
 #include X11/Xlib.h
 #include X11/Xutil.h
 #include X11/keysym.h
-#include X11/extensions/shape.h
 #include xcb/xcb.h
 #include xcb/xproto.h
 #include X11/Xlib-xcb.h
@@ -1300,15 +1299,16 @@ hostx_set_window_bounding_rectangles(int a_window,
  EphyrRect * a_rects, int a_num_rects)
 {
 Bool is_ok = FALSE;
-Display *dpy = hostx_get_display();
 int i = 0;
-XRectangle *rects = NULL;
+xcb_rectangle_t *rects = NULL;
 
-EPHYR_RETURN_VAL_IF_FAIL(dpy  a_rects, FALSE);
+EPHYR_RETURN_VAL_IF_FAIL(a_rects, FALSE);
 
 EPHYR_LOG(enter. num rects:%d\n, a_num_rects);
 
-rects = calloc(a_num_rects, sizeof(XRectangle));
+rects = calloc(a_num_rects, sizeof (xcb_rectangle_t));
+if (!rects)
+goto out;
 for (i = 0; i  a_num_rects; i++) {
 rects[i].x = a_rects[i].x1;
 rects[i].y = a_rects[i].y1;
@@ -1317,11 +1317,17 @@ hostx_set_window_bounding_rectangles(int a_window,
 EPHYR_LOG(borders clipped to rect[x:%d,y:%d,w:%d,h:%d]\n,
   rects[i].x, rects[i].y, rects[i].width, rects[i].height);
 }
-/*this aways returns 1 */
-XShapeCombineRectangles(dpy, a_window, ShapeBounding, 0, 0,
-rects, a_num_rects, ShapeSet, YXBanded);
+xcb_shape_rectangles(HostX.conn,
+ XCB_SHAPE_SO_SET,
+ XCB_SHAPE_SK_BOUNDING,
+ XCB_CLIP_ORDERING_YX_BANDED,
+ a_window,
+ 0, 0,
+ a_num_rects,
+ rects);
 is_ok = TRUE;
 
+out:
 free(rects);
 rects = NULL;
 EPHYR_LOG(leave\n);
@@ -1335,13 +1341,15 @@ hostx_set_window_clipping_rectangles(int a_window,
 Bool is_ok = FALSE;
 Display *dpy = hostx_get_display();
 int i = 0;
-XRectangle *rects = NULL;
+xcb_rectangle_t *rects = NULL;
 
 EPHYR_RETURN_VAL_IF_FAIL(dpy  a_rects, FALSE);
 
 EPHYR_LOG(enter. num rects:%d\n, a_num_rects);
 
-rects = calloc(a_num_rects, sizeof(XRectangle));
+rects = calloc(a_num_rects, sizeof (xcb_rectangle_t));
+if (!rects)
+goto out;
 for (i = 0; i  a_num_rects; i++) {
 rects[i].x = a_rects[i].x1;
 rects[i].y = a_rects[i].y1;
@@ -1350,11 +1358,17 @@ hostx_set_window_clipping_rectangles(int a_window,
 EPHYR_LOG(clipped to rect[x:%d,y:%d,w:%d,h:%d]\n,
   rects[i].x, rects[i].y, rects[i].width, rects[i].height);
 }
-/*this aways returns 1 */
-XShapeCombineRectangles(dpy, a_window, ShapeClip, 0, 0,
-rects, a_num_rects, ShapeSet, YXBanded);
+xcb_shape_rectangles(HostX.conn,
+ XCB_SHAPE_SO_SET,
+ XCB_SHAPE_SK_CLIP,
+ XCB_CLIP_ORDERING_YX_BANDED,
+ a_window,
+ 0, 0,
+ a_num_rects,
+ rects);
 is_ok = TRUE;
 
+out:
 free(rects);
 rects = NULL;
 EPHYR_LOG(leave\n);
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 01/19] Xephyr: stop loading the host's keymap

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

This isn't used anywhere.

v2: Rebase to the top of the patch series (anholt)

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1)
Signed-off-by: Julien Cristau jcris...@debian.org
Signed-off-by: Eric Anholt e...@anholt.net
---
 hw/kdrive/ephyr/ephyr.c |  2 +-
 hw/kdrive/ephyr/hostx.c | 33 +
 hw/kdrive/ephyr/hostx.h |  3 ---
 3 files changed, 2 insertions(+), 36 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 02d4970..b34b5cc 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -1091,7 +1091,7 @@ EphyrKeyboardInit(KdKeyboardInfo * ki)
 ki-driverPrivate = (EphyrKbdPrivate *)
 calloc(sizeof(EphyrKbdPrivate), 1);
 hostx_load_keymap();
-if (!ephyrKeySyms.map) {
+if (!ephyrKeySyms.minKeyCode) {
 ErrorF(Couldn't load keymap from host\n);
 return BadAlloc;
 }
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 5071289..f46770f 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -840,45 +840,14 @@ hostx_paint_debug_rect(struct EphyrHostScreen 
*host_screen,
 void
 hostx_load_keymap(void)
 {
-XID *keymap;
-int host_width, min_keycode, max_keycode, width;
-int i, j;
+int min_keycode, max_keycode;
 
 XDisplayKeycodes(HostX.dpy, min_keycode, max_keycode);
 
 EPHYR_DBG(min: %d, max: %d, min_keycode, max_keycode);
 
-keymap = XGetKeyboardMapping(HostX.dpy,
- min_keycode,
- max_keycode - min_keycode + 1, host_width);
-
-/* Try and copy the hosts keymap into our keymap to avoid loads
- * of messing around.
- *
- * kdrive cannot can have more than 4 keysyms per keycode
- * so we only copy at most the first 4 ( xorg has 6 per keycode, XVNC 2 )
- */
-width = (host_width  4) ? 4 : host_width;
-
-ephyrKeySyms.map = (CARD32 *) calloc(sizeof(CARD32),
- (max_keycode - min_keycode + 1) *
- width);
-if (!ephyrKeySyms.map)
-goto out;
-
-for (i = 0; i  (max_keycode - min_keycode + 1); i++)
-for (j = 0; j  width; j++)
-ephyrKeySyms.map[(i * width) + j] =
-(CARD32) keymap[(i * host_width) + j];
-
-EPHYR_DBG(keymap width, host:%d kdrive:%d, host_width, width);
-
 ephyrKeySyms.minKeyCode = min_keycode;
 ephyrKeySyms.maxKeyCode = max_keycode;
-ephyrKeySyms.mapWidth = width;
-
- out:
-XFree(keymap);
 }
 
 static struct EphyrHostScreen *
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index f47297c..f165606 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -51,12 +51,9 @@ typedef enum EphyrHostXEventType {
 EPHYR_EV_CONFIGURE,
 } EphyrHostXEventType;
 
-/* I can't believe it's not a KeySymsRec. */
 typedef struct {
 int minKeyCode;
 int maxKeyCode;
-int mapWidth;
-CARD32 *map;
 } EphyrKeySyms;
 
 struct EphyrHostXEvent {
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 04/19] Xephyr: no need for XDisplayKeycodes

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net
Reviewed-by: Eric Anholt e...@anholt.net
Signed-off-by: Julien Cristau jcris...@debian.org
---
 hw/kdrive/ephyr/hostx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index f4948b9..699805b 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -910,7 +910,8 @@ hostx_load_keymap(void)
 {
 int min_keycode, max_keycode;
 
-XDisplayKeycodes(HostX.dpy, min_keycode, max_keycode);
+min_keycode = xcb_get_setup(HostX.conn)-min_keycode;
+max_keycode = xcb_get_setup(HostX.conn)-max_keycode;
 
 EPHYR_DBG(min: %d, max: %d, min_keycode, max_keycode);
 
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 05/19] Xephyr: xcb-ify pointer/keyboard grab

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net
Reviewed-by: Eric Anholt e...@anholt.net
Signed-off-by: Julien Cristau jcris...@debian.org
---
 hw/kdrive/ephyr/hostx.c | 45 -
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 699805b..2ebf978 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -1016,30 +1016,49 @@ hostx_get_event(EphyrHostXEvent * ev)
 host_screen_from_window(xev.xexpose.window);
 
 if (grabbed_screen != -1) {
-XUngrabKeyboard(HostX.dpy, CurrentTime);
-XUngrabPointer(HostX.dpy, CurrentTime);
+xcb_ungrab_keyboard(HostX.conn, XCB_TIME_CURRENT_TIME);
+xcb_ungrab_pointer(HostX.conn, XCB_TIME_CURRENT_TIME);
 grabbed_screen = -1;
 hostx_set_win_title(host_screen-info,
 (ctrl+shift grabs mouse and 
keyboard));
 }
 else {
 /* Attempt grab */
-if (XGrabKeyboard(HostX.dpy, host_screen-win, True,
-  GrabModeAsync,
-  GrabModeAsync, CurrentTime) == 0) {
-if (XGrabPointer(HostX.dpy, host_screen-win, True,
- NoEventMask,
- GrabModeAsync,
- GrabModeAsync,
- host_screen-win, None,
- CurrentTime) == 0) {
+xcb_grab_keyboard_cookie_t kbgrabc =
+xcb_grab_keyboard(HostX.conn,
+  True,
+  host_screen-win,
+  XCB_TIME_CURRENT_TIME,
+  XCB_GRAB_MODE_ASYNC,
+  XCB_GRAB_MODE_ASYNC);
+xcb_grab_keyboard_reply_t *kbgrabr;
+xcb_grab_pointer_cookie_t pgrabc =
+xcb_grab_pointer(HostX.conn,
+ True,
+ host_screen-win,
+ 0,
+ XCB_GRAB_MODE_ASYNC,
+ XCB_GRAB_MODE_ASYNC,
+ host_screen-win,
+ XCB_NONE,
+ XCB_TIME_CURRENT_TIME);
+xcb_grab_pointer_reply_t *pgrabr;
+kbgrabr = xcb_grab_keyboard_reply(HostX.conn, kbgrabc, 
NULL);
+if (!kbgrabr || kbgrabr-status != 
XCB_GRAB_STATUS_SUCCESS) {
+xcb_discard_reply(HostX.conn, pgrabc.sequence);
+xcb_ungrab_pointer(HostX.conn, XCB_TIME_CURRENT_TIME);
+} else {
+pgrabr = xcb_grab_pointer_reply(HostX.conn, pgrabc, 
NULL);
+if (!pgrabr || pgrabr-status != 
XCB_GRAB_STATUS_SUCCESS)
+{
+xcb_ungrab_keyboard(HostX.conn,
+XCB_TIME_CURRENT_TIME);
+} else {
 grabbed_screen = host_screen-mynum;
 hostx_set_win_title
 (host_screen-info,
  (ctrl+shift releases mouse and keyboard));
 }
-else/* Failed pointer grabm  ungrab keyboard */
-XUngrabKeyboard(HostX.dpy, CurrentTime);
 }
 }
 }
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 02/19] Xephyr: start converting hostx.c over to xcb

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

v2: Dropped the hostx_load_keymap changes, now that that function is
gutted (anholt).

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1)
Signed-off-by: Julien Cristau jcris...@debian.org
Signed-off-by: Eric Anholt e...@anholt.net
---
 configure.ac|   4 +-
 hw/kdrive/ephyr/hostx.c | 614 +++-
 hw/kdrive/ephyr/hostx.h |   7 +
 3 files changed, 357 insertions(+), 268 deletions(-)

diff --git a/configure.ac b/configure.ac
index d27ca23..2c9585d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2116,12 +2116,12 @@ if test $KDRIVE = yes; then
AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver])
 fi
 
-XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp
+XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape 
xcb-aux xcb-image xcb-icccm xcb-shm
 if test x$XV = xyes; then
 XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS xv
 fi
 if test x$DRI = xyes  test x$GLX = xyes; then
-XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS $LIBGL libdrm
+XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx 
xcb-xf86dri
 fi
 
 if test x$XEPHYR = xauto; then
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index f46770f..2ecda14 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -53,20 +53,22 @@
 
 #include X11/Xlib.h
 #include X11/Xutil.h
-#include X11/Xatom.h
 #include X11/keysym.h
-#include X11/extensions/XShm.h
 #include X11/extensions/shape.h
+#include xcb/xcb.h
+#include xcb/xproto.h
+#include X11/Xlib-xcb.h
+#include xcb/xcb_icccm.h
+#include xcb/xcb_aux.h
+#include xcb/shm.h
+#include xcb/xcb_image.h
+#include xcb/shape.h
 #ifdef XF86DRI
-#include GL/glx.h
-#endif  /* XF86DRI */
+#include xcb/xf86dri.h
+#include xcb/glx.h
+#endif /* XF86DRI */
 #include ephyrlog.h
 
-#ifdef XF86DRI
-extern Bool XF86DRIQueryExtension(Display * dpy,
-  int *event_basep, int *error_basep);
-#endif
-
 /*  
  * All xlib calls go here, which gets built as its own .a .
  * Mixing kdrive and xlib headers causes all sorts of types
@@ -77,11 +79,11 @@ struct EphyrHostScreen {
 Window win;
 Window win_pre_existing;/* Set via -parent option like xnest */
 Window peer_win;/* Used for GL; should be at most one */
-XImage *ximg;
+xcb_image_t*ximg;
 int win_width, win_height;
 int server_depth;
 unsigned char *fb_data; /* only used when host bpp != server bpp */
-XShmSegmentInfo shminfo;
+xcb_shm_segment_info_t shminfo;
 
 void *info; /* Pointer to the screen this is associated 
with */
 int mynum;  /* Screen number */
@@ -90,10 +92,11 @@ struct EphyrHostScreen {
 struct EphyrHostXVars {
 char *server_dpy_name;
 Display *dpy;
+xcb_connection_t *conn;
 int screen;
 Visual *visual;
 Window winroot;
-GC gc;
+xcb_gcontext_t  gc;
 int depth;
 Bool use_host_cursor;
 Bool use_fullscreen;
@@ -126,11 +129,6 @@ char *ephyrTitle = NULL;
 static void
  hostx_set_fullscreen_hint(void);
 
-/* X Error traps */
-
-static int trapped_error_code = 0;
-static int (*old_error_handler) (Display * d, XErrorEvent * e);
-
 #define host_depth_matches_server(_vars) (HostX.depth == (_vars)-server_depth)
 
 static struct EphyrHostScreen *
@@ -146,27 +144,6 @@ host_screen_from_screen_info(EphyrScreenInfo * screen)
 return NULL;
 }
 
-static int
-error_handler(Display * display, XErrorEvent * error)
-{
-trapped_error_code = error-error_code;
-return 0;
-}
-
-static void
-hostx_errors_trap(void)
-{
-trapped_error_code = 0;
-old_error_handler = XSetErrorHandler(error_handler);
-}
-
-static int
-hostx_errors_untrap(void)
-{
-XSetErrorHandler(old_error_handler);
-return trapped_error_code;
-}
-
 int
 hostx_want_screen_size(EphyrScreenInfo screen, int *width, int *height)
 {
@@ -223,9 +200,13 @@ hostx_set_win_title(EphyrScreenInfo screen, const char 
*extra_text)
 return;
 
 if (ephyrTitle) {
-XStoreName(HostX.dpy, host_screen-win, ephyrTitle);
-}
-else {
+xcb_icccm_set_wm_name(HostX.conn,
+  host_screen-win,
+  XCB_ATOM_STRING,
+  8,
+  strlen(ephyrTitle),
+  ephyrTitle);
+} else {
 #define BUF_LEN 256
 char buf[BUF_LEN + 1];
 
@@ -234,7 +215,12 @@ hostx_set_win_title(EphyrScreenInfo screen, const char 
*extra_text)
  HostX.server_dpy_name,
  host_screen-mynum, (extra_text != NULL) ? extra_text : );
 
-XStoreName(HostX.dpy, host_screen-win, buf);
+xcb_icccm_set_wm_name(HostX.conn,
+  host_screen-win,
+  XCB_ATOM_STRING,
+  8

[PATCH 07/19] Xephyr: delete unused proxy code

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net
Reviewed-by: Eric Anholt e...@anholt.net
Signed-off-by: Julien Cristau jcris...@debian.org
---
 hw/kdrive/ephyr/ephyrhostproxy.c |  91 ---
 hw/kdrive/ephyr/ephyrhostproxy.h |  51 -
 hw/kdrive/ephyr/ephyrproxyext.c  | 115 ---
 hw/kdrive/ephyr/ephyrproxyext.h  |  33 ---
 4 files changed, 290 deletions(-)
 delete mode 100644 hw/kdrive/ephyr/ephyrhostproxy.c
 delete mode 100644 hw/kdrive/ephyr/ephyrhostproxy.h
 delete mode 100644 hw/kdrive/ephyr/ephyrproxyext.c
 delete mode 100644 hw/kdrive/ephyr/ephyrproxyext.h

diff --git a/hw/kdrive/ephyr/ephyrhostproxy.c b/hw/kdrive/ephyr/ephyrhostproxy.c
deleted file mode 100644
index a4f25c1..000
--- a/hw/kdrive/ephyr/ephyrhostproxy.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- *  Authored by Matthew Allum mal...@openedhand.com
- * 
- * Copyright © 2007 OpenedHand Ltd 
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided as is without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:
- *Dodji Seketeli do...@openedhand.com
- */
-
-#ifdef HAVE_CONFIG_H
-#include kdrive-config.h
-#endif
-
-#include X11/Xlibint.h
-#define _HAVE_XALLOC_DECLS
-#include ephyrlog.h
-#include ephyrhostproxy.h
-#include hostx.h
-
-/* byte swap a short */
-#define swaps(x, n) { \
-n = ((char *) (x))[0];\
-((char *) (x))[0] = ((char *) (x))[1];\
-((char *) (x))[1] = n; }
-
-#define GetXReq(req) \
-WORD64ALIGN ;\
-if ((dpy-bufptr + SIZEOF(xReq))  dpy-bufmax)\
-_XFlush(dpy);\
-req = (xReq *)(dpy-last_req = dpy-bufptr);\
-dpy-bufptr += SIZEOF(xReq);\
-dpy-request++
-
-Bool
-ephyrHostProxyDoForward(pointer a_request_buffer,
-struct XReply *a_reply, Bool a_do_swap)
-{
-Bool is_ok = FALSE;
-int n = 0;
-Display *dpy = hostx_get_display();
-xReq *in_req = (xReq *) a_request_buffer;
-xReq *forward_req = NULL;
-struct XReply reply;
-
-EPHYR_RETURN_VAL_IF_FAIL(in_req  dpy, FALSE);
-
-EPHYR_LOG(enter\n);
-
-if (a_do_swap) {
-swaps(in_req-length);
-}
-EPHYR_LOG(Req {type:%d, data:%d, length:%d}\n,
-  in_req-reqType, in_req-data, in_req-length);
-GetXReq(forward_req);
-memmove(forward_req, in_req, 4);
-
-if (!_XReply(dpy, (xReply *) reply, 0, FALSE)) {
-EPHYR_LOG_ERROR(failed to get reply\n);
-goto out;
-}
-EPHYR_LOG(XReply{type:%d, foo:%d, seqnum:%d, length:%d}\n,
-  reply.type, reply.foo, reply.sequence_number, reply.length);
-
-if (a_reply) {
-memmove(a_reply, reply, sizeof(reply));
-}
-is_ok = TRUE;
-
- out:
-EPHYR_LOG(leave\n);
-return is_ok;
-}
diff --git a/hw/kdrive/ephyr/ephyrhostproxy.h b/hw/kdrive/ephyr/ephyrhostproxy.h
deleted file mode 100644
index 1372160..000
--- a/hw/kdrive/ephyr/ephyrhostproxy.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- *  Authored by Matthew Allum mal...@openedhand.com
- * 
- * Copyright © 2007 OpenedHand Ltd 
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided as is without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE

[PATCH 09/19] Xephyr: replace XKeycodeToKeysym with xcb-keysyms

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net
Reviewed-by: Eric Anholt e...@anholt.net
Signed-off-by: Julien Cristau jcris...@debian.org
---
 configure.ac|  2 +-
 hw/kdrive/ephyr/hostx.c | 13 -
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2c9585d..db7ef7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2116,7 +2116,7 @@ if test $KDRIVE = yes; then
AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver])
 fi
 
-XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape 
xcb-aux xcb-image xcb-icccm xcb-shm
+XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape 
xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms
 if test x$XV = xyes; then
 XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS xv
 fi
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 1261487..4bcc902 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -62,6 +62,7 @@
 #include xcb/shm.h
 #include xcb/xcb_image.h
 #include xcb/shape.h
+#include xcb/xcb_keysyms.h
 #ifdef XF86DRI
 #include xcb/xf86dri.h
 #include xcb/glx.h
@@ -943,6 +944,10 @@ hostx_get_event(EphyrHostXEvent * ev)
 {
 XEvent xev;
 static int grabbed_screen = -1;
+static xcb_key_symbols_t *keysyms;
+
+if (!keysyms)
+keysyms = xcb_key_symbols_alloc(HostX.conn);
 
 if (XPending(HostX.dpy)) {
 XNextEvent(HostX.dpy, xev);
@@ -1007,11 +1012,9 @@ hostx_get_event(EphyrHostXEvent * ev)
 return 1;
 }
 case KeyRelease:
-
-if ((XKeycodeToKeysym(HostX.dpy, xev.xkey.keycode, 0) == XK_Shift_L
- || XKeycodeToKeysym(HostX.dpy, xev.xkey.keycode,
- 0) == XK_Shift_R)
- (xev.xkey.state  ControlMask)) {
+if ((xcb_key_symbols_get_keysym(keysyms,xev.xkey.keycode, 0) == 
XK_Shift_L
+ || xcb_key_symbols_get_keysym(keysyms,xev.xkey.keycode, 0) == 
XK_Shift_R)
+ (xev.xkey.state  XCB_MOD_MASK_CONTROL)) {
 struct EphyrHostScreen *host_screen =
 host_screen_from_window(xev.xexpose.window);
 
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 06/19] Xephyr: xcb-ify visual list construction

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net
Reviewed-by: Eric Anholt e...@anholt.net
Signed-off-by: Julien Cristau jcris...@debian.org
---
 hw/kdrive/ephyr/hostx.c | 59 +++--
 1 file changed, 33 insertions(+), 26 deletions(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 2ebf978..2b69b0e 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -1175,43 +1175,50 @@ hostx_get_extension_info(const char *a_ext_name,
 int
 hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries)
 {
-Display *dpy = hostx_get_display();
 Bool is_ok = False;
-XVisualInfo templ, *visuals = NULL;
 EphyrHostVisualInfo *host_visuals = NULL;
-int nb_items = 0, i = 0;
+int nb_items = 0, i = 0, screen_num;
+xcb_screen_iterator_t screens;
+xcb_depth_iterator_t depths;
 
-EPHYR_RETURN_VAL_IF_FAIL(a_visuals  a_num_entries  dpy, False);
+EPHYR_RETURN_VAL_IF_FAIL(a_visuals  a_num_entries, False);
 EPHYR_LOG(enter\n);
-memset(templ, 0, sizeof(templ));
-visuals = XGetVisualInfo(dpy, VisualNoMask, templ, nb_items);
-if (!visuals) {
-EPHYR_LOG_ERROR(host does not advertise any visual\n);
-goto out;
+
+screens = xcb_setup_roots_iterator(xcb_get_setup(HostX.conn));
+for (screen_num = 0; screens.rem; screen_num++, xcb_screen_next(screens)) 
{
+depths = xcb_screen_allowed_depths_iterator(screens.data);
+for (; depths.rem; xcb_depth_next(depths)) {
+xcb_visualtype_t *visuals = xcb_depth_visuals(depths.data);
+EphyrHostVisualInfo *tmp_visuals =
+realloc(host_visuals,
+(nb_items + depths.data-visuals_len)
+* sizeof(EphyrHostVisualInfo));
+if (!tmp_visuals) {
+goto out;
+}
+host_visuals = tmp_visuals;
+for (i = 0; i  depths.data-visuals_len; i++) {
+host_visuals[nb_items + i].visualid = visuals[i].visual_id;
+host_visuals[nb_items + i].screen = screen_num;
+host_visuals[nb_items + i].depth = depths.data-depth;
+host_visuals[nb_items + i].class = visuals[i]._class;
+host_visuals[nb_items + i].red_mask = visuals[i].red_mask;
+host_visuals[nb_items + i].green_mask = visuals[i].green_mask;
+host_visuals[nb_items + i].blue_mask = visuals[i].blue_mask;
+host_visuals[nb_items + i].colormap_size = 
visuals[i].colormap_entries;
+host_visuals[nb_items + i].bits_per_rgb = 
visuals[i].bits_per_rgb_value;
+}
+nb_items += depths.data-visuals_len;
+}
 }
+
 EPHYR_LOG(host advertises %d visuals\n, nb_items);
-host_visuals = calloc(nb_items, sizeof(EphyrHostVisualInfo));
-for (i = 0; i  nb_items; i++) {
-host_visuals[i].visualid = visuals[i].visualid;
-host_visuals[i].screen = visuals[i].screen;
-host_visuals[i].depth = visuals[i].depth;
-host_visuals[i].class = visuals[i].class;
-host_visuals[i].red_mask = visuals[i].red_mask;
-host_visuals[i].green_mask = visuals[i].green_mask;
-host_visuals[i].blue_mask = visuals[i].blue_mask;
-host_visuals[i].colormap_size = visuals[i].colormap_size;
-host_visuals[i].bits_per_rgb = visuals[i].bits_per_rgb;
-}
 *a_visuals = host_visuals;
 *a_num_entries = nb_items;
 host_visuals = NULL;
 
 is_ok = TRUE;
- out:
-if (visuals) {
-XFree(visuals);
-visuals = NULL;
-}
+out:
 free(host_visuals);
 host_visuals = NULL;
 EPHYR_LOG(leave\n);
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 11/19] Xephyr: some more hostx.c xcb-ification

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net
Reviewed-by: Eric Anholt e...@anholt.net
Signed-off-by: Julien Cristau jcris...@debian.org
---
 hw/kdrive/ephyr/hostx.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index d984db9..3d3519b 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -368,9 +368,9 @@ hostx_init(void)
 HostX.conn = XGetXCBConnection(HostX.dpy);
 HostX.screen = DefaultScreen(HostX.dpy);
 screen = xcb_aux_get_screen(HostX.conn, HostX.screen);
-HostX.winroot = RootWindow(HostX.dpy, HostX.screen);
+HostX.winroot = screen-root;
 HostX.gc = xcb_generate_id(HostX.conn);
-HostX.depth = DefaultDepth(HostX.dpy, HostX.screen);
+HostX.depth = screen-root_depth;
 HostX.visual  = xcb_aux_find_visual_by_id(screen, screen-root_visual);
 
 xcb_create_gc(HostX.conn, HostX.gc, HostX.winroot, 0, NULL);
@@ -439,8 +439,8 @@ hostx_init(void)
  (ctrl+shift grabs mouse and keyboard));
 
 if (HostX.use_fullscreen) {
-host_screen-win_width  = DisplayWidth(HostX.dpy, 
HostX.screen);
-host_screen-win_height = DisplayHeight(HostX.dpy, 
HostX.screen);
+host_screen-win_width  = screen-width_in_pixels;
+host_screen-win_height = screen-height_in_pixels;
 
 hostx_set_fullscreen_hint();
 }
@@ -1123,7 +1123,7 @@ hostx_get_xcbconn(void)
 int
 hostx_get_screen(void)
 {
-return DefaultScreen(HostX.dpy);
+return HostX.screen;
 }
 
 int
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 12/19] Xephyr: use xcb for event handling

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

v2: Rebase on indentation changes, squash in a simpler variant of the
later event compression patch, fix server hang or segfault on
window close by reimplementing the x_io_error_handler in the new
XCB event loop (anholt).

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1)
Signed-off-by: Julien Cristau jcris...@debian.org
Signed-off-by: Eric Anholt e...@anholt.net
---
 hw/kdrive/ephyr/hostx.c | 284 ++--
 1 file changed, 155 insertions(+), 129 deletions(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 3d3519b..07a2772 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -942,169 +942,195 @@ host_screen_from_window(Window w)
 int
 hostx_get_event(EphyrHostXEvent * ev)
 {
-XEvent xev;
+xcb_generic_event_t *xev;
 static int grabbed_screen = -1;
 static xcb_key_symbols_t *keysyms;
 
 if (!keysyms)
 keysyms = xcb_key_symbols_alloc(HostX.conn);
 
-if (XPending(HostX.dpy)) {
-XNextEvent(HostX.dpy, xev);
-
-switch (xev.type) {
-case Expose:
-/* Not so great event compression, but works ok */
-while (XCheckTypedWindowEvent(HostX.dpy, xev.xexpose.window,
-  Expose, xev));
-{
-struct EphyrHostScreen *host_screen =
-host_screen_from_window(xev.xexpose.window);
-if (host_screen) {
-hostx_paint_rect(host_screen-info, 0, 0, 0, 0,
- host_screen-win_width,
- host_screen-win_height);
-}
-else {
-EPHYR_LOG_ERROR(failed to get host screen\n);
-ev-type = EPHYR_EV_EXPOSE;
-ev-data.expose.window = xev.xexpose.window;
-return 1;
-}
-}
-return 0;
-
-case MotionNotify:
-{
-struct EphyrHostScreen *host_screen =
-host_screen_from_window(xev.xmotion.window);
-
-ev-type = EPHYR_EV_MOUSE_MOTION;
-ev-data.mouse_motion.x = xev.xmotion.x;
-ev-data.mouse_motion.y = xev.xmotion.y;
-ev-data.mouse_motion.window = xev.xmotion.window;
-ev-data.mouse_motion.screen =
-(host_screen ? host_screen-mynum : -1);
+xev = xcb_poll_for_event(HostX.conn);
+if (!xev) {
+/* If our XCB connection has died (for example, our window was
+ * closed), exit now.
+ */
+if (xcb_connection_has_error(HostX.conn)) {
+CloseWellKnownConnections();
+OsCleanup(1);
+exit(1);
 }
-return 1;
 
-case ButtonPress:
-ev-type = EPHYR_EV_MOUSE_PRESS;
-ev-key_state = xev.xkey.state;
-/* 
- * This is a bit hacky. will break for button 5 ( defined as 0x10 )
- * Check KD_BUTTON defines in kdrive.h 
- */
-ev-data.mouse_down.button_num = 1  (xev.xbutton.button - 1);
-return 1;
+return 0;
+}
 
-case ButtonRelease:
-ev-type = EPHYR_EV_MOUSE_RELEASE;
-ev-key_state = xev.xkey.state;
-ev-data.mouse_up.button_num = 1  (xev.xbutton.button - 1);
-return 1;
+switch (xev-response_type  0x7f) {
+case XCB_EXPOSE: {
+xcb_expose_event_t *expose = (xcb_expose_event_t *)xev;
+struct EphyrHostScreen *host_screen =
+host_screen_from_window(expose-window);
 
-case KeyPress:
-{
-ev-type = EPHYR_EV_KEY_PRESS;
-ev-key_state = xev.xkey.state;
-ev-data.key_down.scancode = xev.xkey.keycode;
+/* Wait for the last expose event in a series of cliprects
+ * to actually paint our screen.
+ */
+if (expose-count != 0)
+break;
+
+if (host_screen) {
+hostx_paint_rect(host_screen-info, 0, 0, 0, 0,
+ host_screen-win_width,
+ host_screen-win_height);
+}
+else {
+EPHYR_LOG_ERROR(failed to get host screen\n);
+ev-type = EPHYR_EV_EXPOSE;
+ev-data.expose.window = expose-window;
+free(xev);
 return 1;
 }
-case KeyRelease:
-if ((xcb_key_symbols_get_keysym(keysyms,xev.xkey.keycode, 0) == 
XK_Shift_L
- || xcb_key_symbols_get_keysym(keysyms,xev.xkey.keycode, 0) == 
XK_Shift_R)
- (xev.xkey.state  XCB_MOD_MASK_CONTROL)) {
-struct EphyrHostScreen *host_screen =
-host_screen_from_window(xev.xexpose.window);
-
-if (grabbed_screen != -1) {
-xcb_ungrab_keyboard(HostX.conn

[PATCH 10/19] Xephyr: move HostX.visual to xcb

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net
Reviewed-by: Eric Anholt e...@anholt.net
Signed-off-by: Julien Cristau jcris...@debian.org
---
 hw/kdrive/ephyr/hostx.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 4bcc902..d984db9 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -94,7 +94,7 @@ struct EphyrHostXVars {
 Display *dpy;
 xcb_connection_t *conn;
 int screen;
-Visual *visual;
+xcb_visualtype_t *visual;
 Window winroot;
 xcb_gcontext_t  gc;
 int depth;
@@ -371,7 +371,7 @@ hostx_init(void)
 HostX.winroot = RootWindow(HostX.dpy, HostX.screen);
 HostX.gc = xcb_generate_id(HostX.conn);
 HostX.depth = DefaultDepth(HostX.dpy, HostX.screen);
-HostX.visual = DefaultVisual(HostX.dpy, HostX.screen);
+HostX.visual  = xcb_aux_find_visual_by_id(screen, screen-root_visual);
 
 xcb_create_gc(HostX.conn, HostX.gc, HostX.winroot, 0, NULL);
 cookie_WINDOW_STATE = xcb_intern_atom(HostX.conn, False,
@@ -593,10 +593,10 @@ hostx_get_bpp(EphyrScreenInfo screen)
 if (!host_screen)
 return 0;
 
-if (host_depth_matches_server(host_screen))
-return HostX.visual-bits_per_rgb;
+if (host_depth_matches_server (host_screen))
+return HostX.visual-bits_per_rgb_value;
 else
-return host_screen-server_depth;   /*XXX correct ? */
+return host_screen-server_depth; /*XXX correct ?*/
 }
 
 void
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 18/19] Xephyr: handle errors in event loop

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Signed-off-by: Julien Cristau jcris...@debian.org
Reviewed-by: Eric Anholt e...@anholt.net
Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net
---
 hw/kdrive/ephyr/hostx.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 68bb48a..1eef64e 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -947,6 +947,21 @@ hostx_get_event(EphyrHostXEvent * ev)
 }
 
 switch (xev-response_type  0x7f) {
+case 0: { /* error */
+xcb_generic_error_t *e = (xcb_generic_error_t *)xev;
+fprintf(stderr, X11 error\n
+Error code: %hhu\n
+Sequence number: %hu\n
+Major code: %hhu\tMinor code: %hu\n
+Error value: %u\n,
+e-error_code,
+e-sequence,
+e-major_code, e-minor_code,
+e-resource_id);
+free(xev);
+exit(1);
+}
+
 case XCB_EXPOSE: {
 xcb_expose_event_t *expose = (xcb_expose_event_t *)xev;
 struct EphyrHostScreen *host_screen =
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 17/19] Xephyr: drop remaining Xlib dependency

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net
Reviewed-by: Eric Anholt e...@anholt.net
Signed-off-by: Julien Cristau jcris...@debian.org
---
 configure.ac|  4 ++--
 hw/kdrive/ephyr/hostx.c | 64 -
 hw/kdrive/ephyr/hostx.h |  2 --
 3 files changed, 22 insertions(+), 48 deletions(-)

diff --git a/configure.ac b/configure.ac
index a6c466e..8c72cc0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2116,12 +2116,12 @@ if test $KDRIVE = yes; then
AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver])
 fi
 
-XEPHYR_REQUIRED_LIBS=x11 = 1.6 $LIBXEXT xau xdmcp xcb x11-xcb xcb-shape 
xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms
+XEPHYR_REQUIRED_LIBS=xau xdmcp xcb xcb-shape xcb-aux xcb-image xcb-icccm 
xcb-shm xcb-keysyms
 if test x$XV = xyes; then
 XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS xcb-xv
 fi
 if test x$DRI = xyes  test x$GLX = xyes; then
-XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS $LIBGL libdrm xcb-glx 
xcb-xf86dri  1.6
+XEPHYR_REQUIRED_LIBS=$XEPHYR_REQUIRED_LIBS libdrm xcb-glx xcb-xf86dri 
 1.6
 fi
 
 if test x$XEPHYR = xauto; then
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 07a2772..68bb48a 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -51,12 +51,9 @@
 #include sys/shm.h
 #include sys/time.h
 
-#include X11/Xlib.h
-#include X11/Xutil.h
 #include X11/keysym.h
 #include xcb/xcb.h
 #include xcb/xproto.h
-#include X11/Xlib-xcb.h
 #include xcb/xcb_icccm.h
 #include xcb/xcb_aux.h
 #include xcb/shm.h
@@ -91,7 +88,6 @@ struct EphyrHostScreen {
 
 struct EphyrHostXVars {
 char *server_dpy_name;
-Display *dpy;
 xcb_connection_t *conn;
 int screen;
 xcb_visualtype_t *visual;
@@ -151,7 +147,7 @@ hostx_want_screen_size(EphyrScreenInfo screen, int *width, 
int *height)
 
 if (host_screen 
 (host_screen-win_pre_existing != None ||
- HostX.use_fullscreen == True)) {
+ HostX.use_fullscreen == TRUE)) {
 *width = host_screen-win_width;
 *height = host_screen-win_height;
 return 1;
@@ -233,7 +229,7 @@ hostx_want_host_cursor(void)
 void
 hostx_use_host_cursor(void)
 {
-HostX.use_host_cursor = True;
+HostX.use_host_cursor = TRUE;
 }
 
 int
@@ -252,7 +248,7 @@ hostx_want_preexisting_window(EphyrScreenInfo screen)
 void
 hostx_use_fullscreen(void)
 {
-HostX.use_fullscreen = True;
+HostX.use_fullscreen = TRUE;
 }
 
 int
@@ -323,15 +319,6 @@ hostx_set_title(char *title)
 #pragma does_not_return(exit)
 #endif
 
-static int _X_NORETURN
-x_io_error_handler(Display * dpy)
-{
-ErrorF(Lost connection to X server: %s\n, strerror(errno));
-CloseWellKnownConnections();
-OsCleanup(1);
-exit(1);
-}
-
 int
 hostx_init(void)
 {
@@ -358,15 +345,11 @@ hostx_init(void)
 
 EPHYR_DBG(mark);
 
-if ((HostX.dpy = XOpenDisplay(getenv(DISPLAY))) == NULL) {
+if ((HostX.conn = xcb_connect(NULL, HostX.screen)) == NULL) {
 fprintf(stderr, \nXephyr cannot open host display. Is DISPLAY 
set?\n);
 exit(1);
 }
 
-XSetIOErrorHandler(x_io_error_handler);
-
-HostX.conn = XGetXCBConnection(HostX.dpy);
-HostX.screen = DefaultScreen(HostX.dpy);
 screen = xcb_aux_get_screen(HostX.conn, HostX.screen);
 HostX.winroot = screen-root;
 HostX.gc = xcb_generate_id(HostX.conn);
@@ -374,11 +357,11 @@ hostx_init(void)
 HostX.visual  = xcb_aux_find_visual_by_id(screen, screen-root_visual);
 
 xcb_create_gc(HostX.conn, HostX.gc, HostX.winroot, 0, NULL);
-cookie_WINDOW_STATE = xcb_intern_atom(HostX.conn, False,
+cookie_WINDOW_STATE = xcb_intern_atom(HostX.conn, FALSE,
   strlen(_NET_WM_STATE),
   _NET_WM_STATE);
 cookie_WINDOW_STATE_FULLSCREEN =
-xcb_intern_atom(HostX.conn, False,
+xcb_intern_atom(HostX.conn, FALSE,
 strlen(_NET_WM_STATE_FULLSCREEN),
 _NET_WM_STATE_FULLSCREEN);
 
@@ -519,7 +502,7 @@ hostx_init(void)
 shm_rep = xcb_get_extension_data(HostX.conn, xcb_shm_id);
 if (!shm_rep || !shm_rep-present || getenv(XEPHYR_NO_SHM)) {
 fprintf(stderr, \nXephyr unable to use SHM XImages\n);
-HostX.have_shm = False;
+HostX.have_shm = FALSE;
 }
 else {
 /* Really really check we have shm - better way ?*/
@@ -528,19 +511,19 @@ hostx_init(void)
 xcb_void_cookie_t cookie;
 xcb_shm_seg_t shmseg;
 
-HostX.have_shm = True;
+HostX.have_shm = TRUE;
 
 shminfo.shmid = shmget(IPC_PRIVATE, 1, IPC_CREAT|0777);
 shminfo.shmaddr = shmat(shminfo.shmid,0,0);
 
 shmseg = xcb_generate_id(HostX.conn);
 cookie = xcb_shm_attach_checked(HostX.conn, shmseg, shminfo.shmid,
-True

[PATCH 19/19] Xephyr: we're not using Xlib anymore, no need to undef _XSERVER64

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

Drop obsolete comments about interaction between Xlib code and that
macro, and stop undefining it.

Signed-off-by: Julien Cristau jcris...@debian.org
Reviewed-by: Eric Anholt e...@anholt.net
---
 hw/kdrive/ephyr/ephyrhostglx.c   | 11 ---
 hw/kdrive/ephyr/ephyrhostvideo.c | 10 --
 hw/kdrive/ephyr/hostx.c  | 17 -
 3 files changed, 38 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyrhostglx.c b/hw/kdrive/ephyr/ephyrhostglx.c
index 1c1ac45..9967f9d 100644
--- a/hw/kdrive/ephyr/ephyrhostglx.c
+++ b/hw/kdrive/ephyr/ephyrhostglx.c
@@ -31,17 +31,6 @@
 #include kdrive-config.h
 #endif
 
-/*
- * including some server headers (like kdrive-config.h)
- * might define the macro _XSERVER64
- * on 64 bits machines. That macro must _NOT_ be defined for Xlib
- * client code, otherwise bad things happen.
- * So let's undef that macro if necessary.
- */
-#ifdef _XSERVER64
-#undef _XSERVER64
-#endif
-
 #include X11/Xdefs.h
 #include X11/Xmd.h
 #include GL/glxproto.h
diff --git a/hw/kdrive/ephyr/ephyrhostvideo.c b/hw/kdrive/ephyr/ephyrhostvideo.c
index 8b71687..ea5fc9b 100644
--- a/hw/kdrive/ephyr/ephyrhostvideo.c
+++ b/hw/kdrive/ephyr/ephyrhostvideo.c
@@ -28,16 +28,6 @@
 #ifdef HAVE_CONFIG_H
 #include kdrive-config.h
 #endif
-/*
- * including some server headers (like kdrive-config.h)
- * might define the macro _XSERVER64
- * on 64 bits machines. That macro must _NOT_ be defined for Xlib
- * client code, otherwise bad things happen.
- * So let's undef that macro if necessary.
- */
-#ifdef _XSERVER64
-#undef _XSERVER64
-#endif
 #include xcb/xv.h
 #include xcb/xcb_aux.h
 #define _HAVE_XALLOC_DECLS
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 1eef64e..97b2dc0 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -27,17 +27,6 @@
 #include kdrive-config.h
 #endif
 
-/*
- * including some server headers (like kdrive-config.h)
- * might define the macro _XSERVER64
- * on 64 bits machines. That macro must _NOT_ be defined for Xlib
- * client code, otherwise bad things happen.
- * So let's undef that macro if necessary.
- */
-#ifdef _XSERVER64
-#undef _XSERVER64
-#endif
-
 #include hostx.h
 
 #include stdlib.h
@@ -66,12 +55,6 @@
 #endif /* XF86DRI */
 #include ephyrlog.h
 
-/*  
- * All xlib calls go here, which gets built as its own .a .
- * Mixing kdrive and xlib headers causes all sorts of types
- * to get clobbered. 
- */
-
 struct EphyrHostScreen {
 Window win;
 Window win_pre_existing;/* Set via -parent option like xnest */
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 08/19] Xephyr: delete unused hostx_get_extension_info function

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

v2: Also remove the prototype (anholt)

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1)
Signed-off-by: Julien Cristau jcris...@debian.org
Signed-off-by: Eric Anholt e...@anholt.net
---
 hw/kdrive/ephyr/hostx.c | 15 ---
 hw/kdrive/ephyr/hostx.h |  5 -
 2 files changed, 20 deletions(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 2b69b0e..1261487 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -1158,21 +1158,6 @@ hostx_get_window_attributes(int a_window, 
EphyrHostWindowAttributes * a_attrs)
 }
 
 int
-hostx_get_extension_info(const char *a_ext_name,
- int *a_major_opcode,
- int *a_first_event, int *a_first_error)
-{
-if (!a_ext_name || !a_major_opcode || !a_first_event || !a_first_error)
-return 0;
-if (!XQueryExtension(HostX.dpy,
- a_ext_name,
- a_major_opcode, a_first_event, a_first_error)) {
-return 0;
-}
-return 1;
-}
-
-int
 hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries)
 {
 Bool is_ok = False;
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index c065f2d..1c01f8b 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -220,11 +220,6 @@ int
  hostx_get_window_attributes(int a_window, EphyrHostWindowAttributes * a_attr);
 
 int
-
-hostx_get_extension_info(const char *a_ext_name,
- int *a_major_opcode,
- int *a_first_even, int *a_first_error);
-int
  hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries);
 
 int hostx_create_window(int a_screen_number,
-- 
1.8.4.rc3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 16/19] Xephyr: move glx code to xcb

2013-08-26 Thread Eric Anholt
From: Julien Cristau jcris...@debian.org

v2: Rebase on master, notably adding XCB for
X_GLXvop_MakeCurrentReadSGI (anholt).

Reviewed-by: Mikhail Gusarov dotted...@dottedmag.net (v1)
Signed-off-by: Julien Cristau jcris...@debian.org
Signed-off-by: Eric Anholt e...@anholt.net
---
 hw/kdrive/ephyr/ephyrglxext.c  |  11 +-
 hw/kdrive/ephyr/ephyrhostglx.c | 665 +
 hw/kdrive/ephyr/ephyrhostglx.h |  11 +-
 3 files changed, 211 insertions(+), 476 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c
index 22d5108..1231b0d 100644
--- a/hw/kdrive/ephyr/ephyrglxext.c
+++ b/hw/kdrive/ephyr/ephyrglxext.c
@@ -380,10 +380,9 @@ ephyrGLXQueryServerString(__GLXclientState * a_cl, GLbyte 
* a_pc)
 int length = 0;
 
 EPHYR_LOG(enter\n);
-if (!ephyrHostGLXGetStringFromServer(req-screen,
- req-name,
- EPHYR_HOST_GLX_QueryServerString,
- server_string)) {
+if (!ephyrHostGLXQueryServerString(req-screen,
+   req-name,
+   server_string)) {
 EPHYR_LOG_ERROR(failed to query string from host\n);
 goto out;
 }
@@ -724,9 +723,7 @@ ephyrGLXGetStringReal(__GLXclientState * a_cl, GLbyte * 
a_pc, Bool a_do_swap)
 a_pc += __GLX_SINGLE_HDR_SIZE;
 name = *(GLenum *) (a_pc + 0);
 EPHYR_LOG(context_tag:%d, name:%d\n, context_tag, name);
-if (!ephyrHostGLXGetStringFromServer(context_tag,
- name,
- EPHYR_HOST_GLX_GetString, string)) {
+if (!ephyrHostGLXGetString(context_tag, name, string)) {
 EPHYR_LOG_ERROR(failed to get string from server\n);
 goto out;
 }
diff --git a/hw/kdrive/ephyr/ephyrhostglx.c b/hw/kdrive/ephyr/ephyrhostglx.c
index 5ecb02d..1c1ac45 100644
--- a/hw/kdrive/ephyr/ephyrhostglx.c
+++ b/hw/kdrive/ephyr/ephyrhostglx.c
@@ -42,11 +42,10 @@
 #undef _XSERVER64
 #endif
 
-#include X11/Xlibint.h
-#include GL/glx.h
-#include GL/internal/glcore.h
+#include X11/Xdefs.h
+#include X11/Xmd.h
 #include GL/glxproto.h
-#include GL/glxint.h
+#include xcb/glx.h
 #include ephyrhostglx.h
 #define _HAVE_XALLOC_DECLS
 #include ephyrlog.h
@@ -62,41 +61,20 @@ enum VisualConfRequestType {
 
 static Bool ephyrHostGLXGetVisualConfigsInternal
 (enum VisualConfRequestType a_type,
+ xcb_glx_get_visual_configs_reply_t *reply,
  int32_t a_screen,
- int32_t * a_num_visuals,
- int32_t * a_num_props, int32_t * a_props_buf_size, int32_t ** 
a_props_buf);
-Bool
-ephyrHostGLXGetMajorOpcode(int *a_opcode)
-{
-Bool is_ok = FALSE;
-Display *dpy = hostx_get_display();
-static int opcode;
-int first_event_return = 0, first_error_return = 0;
-
-EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
-EPHYR_LOG(enter\n);
-if (!opcode) {
-if (!XQueryExtension(dpy, GLX_EXTENSION_NAME, opcode,
- first_event_return, first_error_return)) {
-EPHYR_LOG_ERROR(XQueryExtension() failed\n);
-goto out;
-}
-}
-*a_opcode = opcode;
-is_ok = TRUE;
- out:
-EPHYR_LOG(release\n);
-return is_ok;
-}
+ int32_t *a_num_visuals,
+ int32_t *a_num_props,
+ int32_t *a_props_buf_size,
+ int32_t **a_props_buf);
 
 Bool
 ephyrHostGLXQueryVersion(int *a_major, int *a_minor)
 {
 Bool is_ok = FALSE;
-Display *dpy = hostx_get_display();
-int major_opcode = 0;
-xGLXQueryVersionReq *req = NULL;
-xGLXQueryVersionReply reply;
+xcb_connection_t *conn = hostx_get_xcbconn();
+xcb_glx_query_version_cookie_t cookie;
+xcb_glx_query_version_reply_t *reply;
 
 EPHYR_RETURN_VAL_IF_FAIL(a_major  a_minor, FALSE);
 EPHYR_LOG(enter\n);
@@ -107,26 +85,14 @@ ephyrHostGLXQueryVersion(int *a_major, int *a_minor)
 return TRUE;
 }
 
-if (!ephyrHostGLXGetMajorOpcode(major_opcode)) {
-EPHYR_LOG_ERROR(failed to get major opcode\n);
-goto out;
-}
-EPHYR_LOG(major opcode: %d\n, major_opcode);
-
 /* Send the glXQueryVersion request */
-memset(reply, 0, sizeof(reply));
-LockDisplay(dpy);
-GetReq(GLXQueryVersion, req);
-req-reqType = major_opcode;
-req-glxCode = X_GLXQueryVersion;
-req-majorVersion = 2;
-req-minorVersion = 1;
-_XReply(dpy, (xReply *) reply, 0, False);
-UnlockDisplay(dpy);
-SyncHandle();
-
-*a_major = glx_major = reply.majorVersion;
-*a_minor = glx_minor = reply.minorVersion;
+cookie = xcb_glx_query_version(conn, 2, 1);
+reply = xcb_glx_query_version_reply(conn, cookie, NULL);
+if (!reply)
+goto out;
+*a_major = reply-major_version;
+*a_minor = reply-minor_version;
+free(reply);
 
 EPHYR_LOG(major:%d, minor:%d\n, *a_major, *a_minor);
 
@@ -136,129 +102,63 @@ ephyrHostGLXQueryVersion(int *a_major, int

<    5   6   7   8   9   10   11   >