[PATCH v3] Also dump passive grabs on XF86LogGrabInfo

2015-11-06 Thread Michael Stapelberg
Signed-off-by: Michael Stapelberg 
---
 dix/window.c| 126 
 hw/xfree86/dixmods/xkbPrivate.c |   2 +
 include/window.h|   1 +
 3 files changed, 129 insertions(+)

diff --git a/dix/window.c b/dix/window.c
index 69b5a7c..25d29ec 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -127,6 +127,7 @@ Equipment Corporation.
 #include "compint.h"
 #endif
 #include "selection.h"
+#include "inpututils.h"
 
 #include "privates.h"
 #include "xace.h"
@@ -272,6 +273,131 @@ log_window_info(WindowPtr pWin, int depth)
 ErrorF("\n");
 }
 
+static const char*
+grab_grabtype_to_text(GrabPtr pGrab)
+{
+switch (pGrab->grabtype) {
+case XI2:
+return "xi2";
+case CORE:
+return "core";
+default:
+return "xi1";
+}
+}
+
+static const char*
+grab_type_to_text(GrabPtr pGrab)
+{
+switch (pGrab->type) {
+case ButtonPress:
+return "ButtonPress";
+case KeyPress:
+return "KeyPress";
+case XI_Enter:
+return "XI_Enter";
+case XI_FocusIn:
+return "XI_FocusIn";
+default:
+return "unknown?!";
+}
+}
+
+static void
+log_grab_info(void *value, XID id, void *cdata)
+{
+int i, j;
+GrabPtr pGrab = (GrabPtr)value;
+
+ErrorF("  grab 0x%lx (%s), type '%s' on window 0x%lx\n",
+   (unsigned long) pGrab->resource,
+   grab_grabtype_to_text(pGrab),
+   grab_type_to_text(pGrab),
+   (unsigned long) pGrab->window->drawable.id);
+ErrorF("detail %d (mask %lu), modifiersDetail %d (mask %lu)\n",
+   pGrab->detail.exact,
+   pGrab->detail.pMask ? (unsigned long) *(pGrab->detail.pMask) : 0,
+   pGrab->modifiersDetail.exact,
+   pGrab->modifiersDetail.pMask ?
+   (unsigned long) *(pGrab->modifiersDetail.pMask) :
+   (unsigned long) 0);
+ErrorF("device '%s' (%d), modifierDevice '%s' (%d)\n",
+   pGrab->device->name, pGrab->device->id,
+   pGrab->modifierDevice->name, pGrab->modifierDevice->id);
+if (pGrab->grabtype == CORE) {
+ErrorF("core event mask 0x%lx\n",
+   (unsigned long) pGrab->eventMask);
+}
+else if (pGrab->grabtype == XI) {
+ErrorF("xi1 event mask 0x%lx\n",
+   (unsigned long) pGrab->eventMask);
+}
+else if (pGrab->grabtype == XI2) {
+for (i = 0; i < xi2mask_num_masks(pGrab->xi2mask); i++) {
+const unsigned char *mask;
+int print;
+
+print = 0;
+for (j = 0; j < XI2MASKSIZE; j++) {
+mask = xi2mask_get_one_mask(pGrab->xi2mask, i);
+if (mask[j]) {
+print = 1;
+break;
+}
+}
+if (!print)
+continue;
+ErrorF("  xi2 event mask 0x");
+for (j = 0; j < xi2mask_mask_size(pGrab->xi2mask); j++)
+ErrorF("%x ", mask[j]);
+ErrorF("\n");
+}
+}
+ErrorF("owner-events %s, kb %d ptr %d, confine 0x%lx, cursor 0x%lx\n",
+   pGrab->ownerEvents ? "true" : "false",
+   pGrab->keyboardMode, pGrab->pointerMode,
+   pGrab->confineTo ? (unsigned long) pGrab->confineTo->drawable.id : 
0,
+   pGrab->cursor ? (unsigned long) pGrab->cursor->id : 0);
+}
+
+void
+PrintPassiveGrabs(void)
+{
+int i;
+LocalClientCredRec *lcc;
+pid_t clientpid;
+const char *cmdname;
+const char *cmdargs;
+
+ErrorF("Printing all currently registered grabs\n");
+
+for (i = 1; i < currentMaxClients; i++) {
+if (!clients[i] || clients[i]->clientState != ClientStateRunning)
+continue;
+
+clientpid = GetClientPid(clients[i]);
+cmdname = GetClientCmdName(clients[i]);
+cmdargs = GetClientCmdArgs(clients[i]);
+if ((clientpid > 0) && (cmdname != NULL)) {
+ErrorF("  Printing all registered grabs of client pid %ld %s %s\n",
+   (long) clientpid, cmdname, cmdargs ? cmdargs : "");
+} else {
+if (GetLocalClientCreds(clients[i], ) == -1) {
+ErrorF("  GetLocalClientCreds() failed\n");
+continue;
+}
+ErrorF("  Printing all registered grabs of client pid %ld uid %ld 
gid %ld\n",
+   (lcc->fieldsSet & LCC_PID_SET) ? (long) lcc->pid : 0,
+   (lcc->fieldsSet & LCC_UID_SET) ? (long) lcc->euid : 0,
+   (lcc->fieldsSet & LCC_GID_SET) ? (long) lcc->egid : 0);
+FreeLocalClientCreds(lcc);
+}
+
+FindClientResourcesByType(clients[i], RT_PASSIVEGRAB, log_grab_info, 
NULL);
+}
+ErrorF("End list of registered passive grabs\n");
+}
+
 void
 PrintWindowTree(void)
 {
diff --git a/hw/xfree86/dixmods/xkbPrivate.c 

[PATCH:xf86-video-modesetting] Fix build when XSERVER_PLATFORM_BUS is not defined.

2015-11-06 Thread Thomas Klausner
From: Jared McNeill 

---
 src/driver.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/driver.c b/src/driver.c
index d99b027..21326d9 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -93,6 +93,10 @@ static const struct pci_id_match ms_device_match[] = {
 };
 #endif
 
+#ifndef XSERVER_PLATFORM_BUS
+struct xf86_platform_device;
+#endif
+
 #ifdef XSERVER_PLATFORM_BUS
 static Bool ms_platform_probe(DriverPtr driver,
   int entity_num, int flags, struct 
xf86_platform_device *device,
-- 
2.6.2

___
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 xkbcomp] symbols: increase the warning level for shortening a key type

2015-11-06 Thread Benno Schulenberg

On Fri, Nov 6, 2015, at 08:25, Peter Hutterer wrote:
> On Thu, Nov 05, 2015 at 04:21:14PM +0100, Benno Schulenberg wrote:
> > A patch that actually fixes the bug that causes this warning to printed
> > was proposed and reviewed a year ago:
> >   
> > http://lists.x.org/archives/xorg-devel/attachments/20140911/e675c15a/attachment.patch
> > 
> > It was first posted here;
> >   http://lists.x.org/archives/xorg-devel/2014-September/043751.html
> > 
> > Any chance of applying it still?
> 
> looks like there was some disagreement on the details between Ran and you,
> ending with Ran's comment of "if you send a patch I will review it :)".

That comment was about another change that I was thinking of making.
The change that you are now proposing to make, in fact.  :)

> I don't think there was an updated version sent, was there?

The updated version, with Ran's review tag in it, is the one I linked to.

See Ran's comment ("Looks good") about the revised version in:
  http://lists.x.org/archives/xorg-devel/2014-September/043838.html

Benno

-- 
http://www.fastmail.com - Does exactly what it says on the tin

___
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 xf86-video-nested 09/10] Introduce a new XCB client backend, and make it the default one.

2015-11-06 Thread Uli Schlachter
Hi,

Am 06.11.2015 um 14:10 schrieb Laércio de Sousa:
[...]
>>> +static void
>>> +_NestedClientSetWMClass(NestedClientPrivatePtr pPriv,
>>> +const char* wm_class)
>>> +{
>>> +size_t class_len = strlen(wm_class) + 1;
>>> +char *class_hint = malloc(class_len);
>>> +
>>> +if (class_hint)
>>> +{
>>> +strcpy(class_hint, wm_class);
>>> +xcb_change_property(pPriv->conn,
>>> +XCB_PROP_MODE_REPLACE,
>>> +pPriv->window,
>>> +XCB_ATOM_WM_CLASS,
>>> +XCB_ATOM_STRING,
>>> +8,
>>> +class_len,
>>> +class_hint);
>>> +free(class_hint);
>>> +}
>>
>> Why is this strcpy needed?
>>
> I've copied over this piece of code from Xephyr. In that context,
> class_hint stores a concatenation bewteen two strings, so that strcpy is
> needed, but here the WM_CLASS string is much more simple, so that strcpy is
> not needed. I'll remove it. Thanks!

Uhm, right. This wants to set WM_CLASS and WM_CLASS should contain "two" strings
(the class and the instance), separated by a null byte.

Sorry for not noticing this earlier, but isn't this code wrong then?

https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.5

[...]
>>> +if (!ev)
>>> +{
>>> +if (_NestedClientConnectionHasError(pPriv->scrnIndex,
>>> +pPriv->conn))
>>> +{
>>> +/* XXX: Is there a better way to do this? */
>>> +xf86DrvMsg(pPriv->scrnIndex,
>>> +   X_ERROR,
>>> +   "Connection with host X server lost.\n");
>>> +free(ev);
>>> +NestedClientCloseScreen(pPriv);
>>> +exit(1);
>>> +}
>>> +
>>> +break;
>>> +}
>>> +
>>> +switch (ev->response_type & ~0x80)
>>> +{
>>> +case XCB_EXPOSE:
>>> +_NestedClientProcessExpose(pPriv, ev);
>>> +break;
>>> +case XCB_CLIENT_MESSAGE:
>>> +_NestedClientProcessClientMessage(pPriv, ev);
>>> +break;
>>> +case XCB_MOTION_NOTIFY:
>>> +_NestedClientProcessMotionNotify(pPriv, ev);
>>> +break;
>>> +case XCB_KEY_PRESS:
>>> +_NestedClientProcessKeyPress(pPriv, ev);
>>> +break;
>>> +case XCB_KEY_RELEASE:
>>> +_NestedClientProcessKeyRelease(pPriv, ev);
>>> +break;
>>> +case XCB_BUTTON_PRESS:
>>> +_NestedClientProcessButtonPress(pPriv, ev);
>>> +break;
>>> +case XCB_BUTTON_RELEASE:
>>> +_NestedClientProcessButtonRelease(pPriv, ev);
>>> +break;
>>> +}
>>> +
>>> +free(ev);
>>> +xcb_flush(pPriv->conn);
>>
>> Why is this flushing inside of the event loop? Wouldn't a flush after the
>> loop
>> be enough?
>>
> Well... Comparing it with other XCB snippets I've found in the web, it
> seems this xcb_flush() call is not needed at all. Calling it right atfer
> window creation or redrawing (XCB_EXPOSE event only) should be enough,
> right?
[...]

Well, it depends. Something should flush in the end in case there are any
requests still in XCB's output buffer (and nothing implicitly flushes them by
waiting for a reply). So I think that having a call to xcb_flush() before
returning to this function should be added. If it does something, it just
prevented a bug and if it doesn't do anything, it's not expensive. ;-)

Everything else seems fine, thanks.

Uli
-- 
"For saving the Earth.. and eating cheesecake!"
___
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 v2 xf86-video-nested 09/10] Introduce a new XCB client backend, and make it the default one.

2015-11-06 Thread Laércio de Sousa
This patch brings up a new XCB backend client, translated from original
xlibclient.c, and based on latest Xephyr code. This XCB backend
brings some improvements already present in Xephyr, like
fullscreen and output support.

This patch will also change configure.ac to make the new XCB
backend the default one for building the driver. For switching back
to Xlib backend, pass configure option --with-backend=xlib.

Signed-off-by: Laércio de Sousa 
---
 configure.ac|5 +-
 src/Makefile.am |9 +-
 src/xcbclient.c | 1092 ++-
 3 files changed, 1091 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0664e91..51710f0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,7 @@ AC_ARG_WITH([backend],
 AS_HELP_STRING([--with-backend=NAME],
[Backend to be used when building the driver. 
Available options: xlib, xcb (default: xlib)]),
 [BACKEND="$withval"],
-[BACKEND=xlib])
+[BACKEND=xcb])
 AC_SUBST([BACKEND])
 
 # Store the list of server defined optional extensions in REQUIRED_MODULES
@@ -71,6 +71,9 @@ case "$BACKEND" in
 xlib)
 PKG_CHECK_MODULES(XEXT, xext)
 ;;
+xcb)
+PKG_CHECK_MODULES(XCB, xcb xcb-aux xcb-icccm xcb-image xcb-shm 
xcb-randr xcb-xkb)
+;;
 esac
 
 DRIVER_NAME=nested
diff --git a/src/Makefile.am b/src/Makefile.am
index 44dc656..33d223a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,14 +18,15 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 # DEALINGS IN THE SOFTWARE.
 #
-# Author: Paulo Zanoni 
+# Authors: Paulo Zanoni 
+#  Laércio de Sousa 
 #
 
-AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS)
+AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS) $(X11_CFLAGS) $(XEXT_CFLAGS) 
$(XCB_CFLAGS)
 
 nested_drv_la_LTLIBRARIES = nested_drv.la
 nested_drv_la_LDFLAGS = -module -avoid-version
-nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS)
+nested_drv_la_LIBADD = $(XORG_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XCB_LIBS)
 nested_drv_ladir = @moduledir@/drivers
 
-nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h xlibclient.c 
client.h compat-api.h
+nested_drv_la_SOURCES = driver.c nested_input.c nested_input.h 
@BACKEND@client.c client.h compat-api.h
diff --git a/src/xcbclient.c b/src/xcbclient.c
index d10887b..5a59780 100644
--- a/src/xcbclient.c
+++ b/src/xcbclient.c
@@ -20,16 +20,1088 @@
  *
  * Authors:
  *
- * Paulo Zanoni 
- * Tuan Bui 
- * Colin Cornaby 
- * Timothy Fleck 
- * Colin Hill 
- * Weseung Hwang 
- * Nathaniel Way 
+ * Laércio de Sousa 
  */
 
-#include 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
-/* The idea for this driver is that we can change the "client" backend, so we
- * can use xlib, xcb or even something else if we're not on top of X */
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "client.h"
+
+#include "nested_input.h"
+
+#define BUF_LEN 256
+
+#define MAX(a, b) (((a) <= (b)) ? (b) : (a))
+
+extern Bool enableNestedInput;
+extern char *display;
+
+static xcb_atom_t atom_WM_DELETE_WINDOW;
+
+typedef struct _Output {
+const char *name;
+int x;
+int y;
+unsigned int width;
+unsigned int height;
+} Output;
+
+struct NestedClientPrivate {
+/* Host X server data */
+int screenNumber;
+xcb_connection_t *conn;
+xcb_visualtype_t *visual;
+xcb_window_t rootWindow;
+xcb_gcontext_t gc;
+xcb_cursor_t emptyCursor;
+Bool usingShm;
+
+/* Nested X server window data */
+xcb_window_t window;
+int scrnIndex;
+int x;
+int y;
+unsigned int width;
+unsigned int height;
+Bool usingFullscreen;
+xcb_image_t *img;
+xcb_shm_segment_info_t shminfo;
+DeviceIntPtr dev; /* The pointer to the input device.  Passed back to the
+   * input driver when posting input events. */
+
+/* Common data */
+uint32_t attrs[2];
+uint32_t attr_mask;
+};
+
+static Bool
+_nested_client_connection_has_error(int scrnIndex,
+xcb_connection_t *conn) {
+const char *displayName = getenv("DISPLAY");
+
+switch (xcb_connection_has_error(conn)) {
+case XCB_CONN_ERROR:
+xf86DrvMsg(scrnIndex,
+   X_ERROR,
+   "Failed to connect to host X server at display %s.\n", 
displayName);
+return TRUE;
+case XCB_CONN_CLOSED_EXT_NOTSUPPORTED:
+xf86DrvMsg(scrnIndex,
+   X_ERROR,
+  

Re: [Nouveau] NOUVEAU(0): DRI3 on EXA enabled

2015-11-06 Thread poma
On 05.11.2015 23:47, poma wrote:
> On 04.11.2015 12:27, poma wrote:
>> On 04.11.2015 11:57, Martin Peres wrote:
>>> On 02/11/15 08:28, poma wrote:
 An interesting results.

 DRI2:

 $ vblank_mode=0 glxgears
 ATTENTION: default value of option vblank_mode overridden by environment.
 6321 frames in 5.0 seconds = 1264.103 FPS
 6380 frames in 5.0 seconds = 1275.943 FPS
 6369 frames in 5.0 seconds = 1273.629 FPS
 6377 frames in 5.0 seconds = 1275.322 FPS
 6387 frames in 5.0 seconds = 1277.330 FPS
 6407 frames in 5.0 seconds = 1281.337 FPS
 6381 frames in 5.0 seconds = 1276.053 FPS
 6410 frames in 5.0 seconds = 1281.855 FPS
 6405 frames in 5.0 seconds = 1280.905 FPS
 6378 frames in 5.0 seconds = 1275.599 FPS
 ^C

 ~

 DRI3:

 $ cat /etc/X11/xorg.conf.d/nouveau-dri3.conf
 Section "Device"
Identifier  "Videocard0"
Driver  "nouveau"
Option  "DRI" "3"
 EndSection

 $ grep DRI3 /var/log/Xorg.0.log
 [ 4367.417] (II) NOUVEAU(0): DRI3 on EXA enabled
>>>
>>> For the record, the only acceptable way of checking for DRI3 is to run 
>>> the program with LIBGL_DEBUG=verbose. Any other solution is wrong.
>>>
>>
>>
>> - DRI2:
>>
>> [  3210.736] (II) Loading sub module "dri2"
>> [  3210.736] (II) LoadModule: "dri2"
>> [  3210.736] (II) Module "dri2" already built-in
>> [  3210.736] (==) NOUVEAU(0): Allowed maximum DRI level 2.
>> [  3210.877] (II) NOUVEAU(0): [DRI2] Setup complete
>> [  3210.894] (II) GLX: Initialized DRI2 GL provider for screen 0
>>
>>
>> $ LIBGL_DEBUG=verbose vblank_mode=0 glxgears
>> libGL: OpenDriver: trying /usr/lib64/dri/tls/nouveau_dri.so
>> libGL: OpenDriver: trying /usr/lib64/dri/nouveau_dri.so
>> ATTENTION: default value of option vblank_mode overridden by environment.
>> libGL: Using DRI2 for screen 0
>> 6231 frames in 5.0 seconds = 1246.081 FPS
>> 6387 frames in 5.0 seconds = 1277.312 FPS
>> 6421 frames in 5.0 seconds = 1284.023 FPS
>> 6375 frames in 5.0 seconds = 1274.905 FPS
>> 6399 frames in 5.0 seconds = 1279.609 FPS
>> 6440 frames in 5.0 seconds = 1287.837 FPS
>> 6371 frames in 5.0 seconds = 1274.142 FPS
>> 6397 frames in 5.0 seconds = 1279.245 FPS
>> 6429 frames in 5.0 seconds = 1285.668 FPS
>> 6371 frames in 5.0 seconds = 1274.177 FPS
>> ^C
>>
>> ~
>>
>> - DRI3:
>>
>> [  3750.992] (II) Loading sub module "dri2"
>> [  3750.992] (II) LoadModule: "dri2"
>> [  3750.992] (II) Module "dri2" already built-in
>> [  3750.992] (**) NOUVEAU(0): Option "DRI" "3"
>> [  3750.992] (**) NOUVEAU(0): Allowed maximum DRI level 3.
>> [  3751.128] (II) NOUVEAU(0): [DRI2] Setup complete
>> [  3751.128] (II) NOUVEAU(0): DRI3 on EXA enabled
>> [  3751.145] (II) GLX: Initialized DRI2 GL provider for screen 0
>>
>>
>> $ LIBGL_DEBUG=verbose vblank_mode=0 glxgears
>> libGL: pci id for fd 4: 10de:06e4, driver nouveau
>> libGL: OpenDriver: trying /usr/lib64/dri/tls/nouveau_dri.so
>> libGL: OpenDriver: trying /usr/lib64/dri/nouveau_dri.so
>> ATTENTION: default value of option vblank_mode overridden by environment.
>> libGL: Using DRI3 for screen 0
>> 7261 frames in 5.0 seconds = 1452.136 FPS
>> 7353 frames in 5.0 seconds = 1470.404 FPS
>> 7354 frames in 5.0 seconds = 1470.652 FPS
>> 7385 frames in 5.0 seconds = 1476.916 FPS
>> 7337 frames in 5.0 seconds = 1467.380 FPS
>> 7344 frames in 5.0 seconds = 1468.661 FPS
>> 7360 frames in 5.0 seconds = 1471.951 FPS
>> 7327 frames in 5.0 seconds = 1465.211 FPS
>> 7345 frames in 5.0 seconds = 1468.992 FPS
>> 7371 frames in 5.0 seconds = 1474.112 FPS
>> ^C
>>
>> ~
>>
>> $ xfwm4 --version
>> This is xfwm4 version 4.12.3git.20150825 (revision 20150825) for Xfce 4.12
>> Released under the terms of the GNU General Public License.
>> Compiled against GTK+-2.24.28, using GTK+-2.24.28.
>>
>> Build configuration and supported features:
>> - Startup notification support: Yes
>> - XSync support:Yes
>> - Render support:   Yes
>> - Xrandr support:   Yes
>> - Xpresent support: Yes
>> - Embedded compositor:  Yes
>> - Epoxy support:No
>>
>>
>> $ xfconf-query --channel xfwm4 --property /general/use_compositing
>> true
>>
>>
>> SW:
>> xorg-x11-drv-nouveau-1.0.12-0.3.fc22.x86_64
>> xorg-x11-server-Xorg-1.17.3-1.fc22.x86_64
>> mesa-dri-drivers-10.6.9-1.20151008.fc22.x86_64
>> libdrm-2.4.61-3.fc22.x86_64
>> libXpresent-1.0.0-1.fc22.x86_64
>> xfwm4-4.12.3-15.1.xpresent.nv34.git20150825.fc22.x86_64
>>
>>
> 
> NV34 / i686
> 
> - DRI2:
> 
> /var/log/Xorg.0.log
> [   438.397] (II) Loading sub module "dri2"
> [   438.397] (II) LoadModule: "dri2"
> [   438.397] (II) Module "dri2" already built-in
> [   438.397] (==) NOUVEAU(0): Allowed maximum DRI level 2.
> [   

glamor: Handle GL_OUT_OF_MEMORY from glTexImage

2015-11-06 Thread Eric Anholt
One of the troubles vc4 has with doing X with glamor is that we've
only really got 256MB to play with.  It's pretty easy to run out of
that, particularly with glamor's FBO cache camping on so much
memory. When we do run out, we get a GL_OUT_OF_MEMORY error from
either a TexImage call or a glBufferData call.  This series covers the
TexImage case, avoiding crashes in that path

I've tested it with piglit's xts-render on an i965 driver that throws
GL_OOM on every third glTexImage call.  One new test (rendercheck's
large_blend_src) fails compared to a working i965 on server master,
but the series doesn't make it worse.

The code can be found on the glamor-gloom branch of my 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 xserver 5/5] glamor: Fix segfault in fallback picture uploading.

2015-11-06 Thread Eric Anholt
If the source/mask pixmap is a pixmap that doesn't have an FBO
attached, and it doesn't match the Render operation's size, then we'll
composite it to a CPU temporary (not sure why).  We would take the
PictFormatShort from the source Picture, make a pixmap of that depth,
and try to look up the PictFormat description from the depth and the
PictFormatShort.  However, the screen's PictFormats are only attached
to the screen's visuals' depths.  So, with an x2r10g10b10 short format
(depth 30), we wouldn't find the screen's PictFormat for it
(associated with depth 32).

Instead of trying to look up from the screen, just use the pFormat
that came from our source picture.  The only time we need to look up a
PictFormat when we're doing non-shader gradients, which we put in
a8r8g8b8.

Signed-off-by: Eric Anholt 
---
 glamor/glamor_render.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index c3a8f17..d8574ec 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1279,12 +1279,17 @@ glamor_convert_gradient_picture(ScreenPtr screen,
 PixmapPtr pixmap;
 PicturePtr dst = NULL;
 int error;
+PictFormatPtr pFormat;
 PictFormatShort format;
 
-if (!source->pDrawable)
+if (source->pDrawable) {
+pFormat = source->pFormat;
+format = pFormat->format;
+} else {
 format = PICT_a8r8g8b8;
-else
-format = source->format;
+pFormat = PictureMatchFormat(screen, 32, format);
+}
+
 #ifdef GLAMOR_GRADIENT_SHADER
 if (!source->pDrawable) {
 if (source->pSourcePict->type == SourcePictTypeLinear) {
@@ -1320,10 +1325,7 @@ glamor_convert_gradient_picture(ScreenPtr screen,
 return NULL;
 
 dst = CreatePicture(0,
->drawable,
-PictureMatchFormat(screen,
-   PIXMAN_FORMAT_DEPTH(format),
-   format), 0, 0, serverClient, 
);
+>drawable, pFormat, 0, 0, serverClient, 
);
 glamor_destroy_pixmap(pixmap);
 if (!dst)
 return NULL;
-- 
2.6.2

___
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 xserver 3/5] glamor: Fix rendering when core font texture allocation fails.

2015-11-06 Thread Eric Anholt
Signed-off-by: Eric Anholt 
---
 glamor/glamor_font.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/glamor/glamor_font.c b/glamor/glamor_font.c
index 6b3a16a..6753d50 100644
--- a/glamor/glamor_font.c
+++ b/glamor/glamor_font.c
@@ -127,8 +127,13 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
 }
 
 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+glamor_priv->suppress_gl_out_of_memory_logging = true;
 glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, overall_width, overall_height,
  0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, bits);
+glamor_priv->suppress_gl_out_of_memory_logging = false;
+if (glGetError() == GL_OUT_OF_MEMORY)
+return NULL;
 
 free(bits);
 
-- 
2.6.2

___
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 xserver 4/5] glamor: Fix assert failures when fallback picture upload alloc fails.

2015-11-06 Thread Eric Anholt
If the glTexImage (or glTexSubImage) out-of-memories, error out
cleanly so that we can fall back to software.

Signed-off-by: Eric Anholt 
---
 glamor/glamor_picture.c | 37 ++---
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 9b09454..d6f37cf 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -534,7 +534,7 @@ glamor_color_convert_to_bits(void *src_bits, void 
*dst_bits, int w, int h,
  * Upload pixmap to a specified texture.
  * This texture may not be the one attached to it.
  **/
-static void
+static Bool
 __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
   GLenum format,
   GLenum type,
@@ -567,13 +567,24 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, 
unsigned int *tex,
 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
 glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
 }
+glamor_priv->suppress_gl_out_of_memory_logging = true;
 if (non_sub)
 glTexImage2D(GL_TEXTURE_2D, 0, iformat, w, h, 0, format, type, bits);
 else
 glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, format, type, bits);
+glamor_priv->suppress_gl_out_of_memory_logging = false;
+if (glGetError() == GL_OUT_OF_MEMORY) {
+if (non_sub) {
+glDeleteTextures(1, tex);
+*tex = 0;
+}
+return FALSE;
+}
 
 if (bits == NULL)
 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+
+return TRUE;
 }
 
 static Bool
@@ -645,10 +656,15 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
 assert(x + fbo_x_off >= 0 && y + fbo_y_off >= 0);
 assert(x + fbo_x_off + w <= pixmap_priv->fbo->width);
 assert(y + fbo_y_off + h <= pixmap_priv->fbo->height);
-__glamor_upload_pixmap_to_texture(pixmap, _priv->fbo->tex,
-  format, type,
-  x + fbo_x_off, y + fbo_y_off, w, h,
-  bits, pbo);
+if (!__glamor_upload_pixmap_to_texture(pixmap, _priv->fbo->tex,
+   format, type,
+   x + fbo_x_off, y + fbo_y_off,
+   w, h,
+   bits, pbo)) {
+if (need_free_bits)
+free(bits);
+return FALSE;
+}
 } else {
 ptexcoords = texcoords_inv;
 
@@ -660,6 +676,15 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
  vertices);
 /* Slow path, we need to flip y or wire alpha to 1. */
 glamor_make_current(glamor_priv);
+
+if (!__glamor_upload_pixmap_to_texture(pixmap, ,
+   format, type, 0, 0, w, h, bits,
+   pbo)) {
+if (need_free_bits)
+free(bits);
+return FALSE;
+}
+
 glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
   GL_FALSE, 2 * sizeof(float), vertices);
 glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
@@ -669,8 +694,6 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
 
 glamor_set_destination_pixmap_priv_nc(glamor_priv, pixmap, 
pixmap_priv);
 glamor_set_alu(screen, GXcopy);
-__glamor_upload_pixmap_to_texture(pixmap, ,
-  format, type, 0, 0, w, h, bits, pbo);
 glActiveTexture(GL_TEXTURE0);
 glBindTexture(GL_TEXTURE_2D, tex);
 
-- 
2.6.2

___
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 xserver 1/5] glamor: Handle GL_OUT_OF_MEMORY when allocating texture images.

2015-11-06 Thread Eric Anholt
The spec allows general undefined behavior when GL_OOM is thrown.  But
if the driver happens to throw the error at this point, it probably
means the pixmap was just too big, so we should delete that texture
and have this pixmap fall back to software.

Signed-off-by: Eric Anholt 
---
 glamor/glamor.c  |  7 +++
 glamor/glamor_fbo.c  | 18 ++
 glamor/glamor_priv.h |  3 +++
 3 files changed, 28 insertions(+)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index d4a0236..e69f83d 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -379,6 +379,13 @@ glamor_debug_output_callback(GLenum source,
  const void *userParam)
 {
 ScreenPtr screen = (void *)userParam;
+glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+if (glamor_priv->suppress_gl_out_of_memory_logging &&
+source == GL_DEBUG_SOURCE_API && type == GL_DEBUG_TYPE_ERROR) {
+return;
+}
+
 LogMessageVerb(X_ERROR, 0, "glamor%d: GL error: %*s\n",
screen->myNum, length, message);
 }
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 262033f..545f89f 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -347,9 +347,25 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
 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);
+
+glamor_priv->suppress_gl_out_of_memory_logging = true;
 glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
  format, GL_UNSIGNED_BYTE, NULL);
+glamor_priv->suppress_gl_out_of_memory_logging = false;
 }
+
+if (glGetError() == GL_OUT_OF_MEMORY) {
+if (!glamor_priv->logged_any_fbo_allocation_failure) {
+LogMessageVerb(X_WARNING, 0, "glamor: Failed to allocate %dx%d "
+   "FBO due to GL_OUT_OF_MEMORY.\n", w, h);
+LogMessageVerb(X_WARNING, 0,
+   "glamor: Expect reduced performance.\n");
+glamor_priv->logged_any_fbo_allocation_failure = true;
+}
+glDeleteTextures(1, );
+return 0;
+}
+
 return tex;
 }
 
@@ -368,6 +384,8 @@ glamor_create_fbo(glamor_screen_private *glamor_priv,
 return fbo;
  new_fbo:
 tex = _glamor_create_tex(glamor_priv, w, h, format, flag == 
CREATE_PIXMAP_USAGE_SHARED);
+if (!tex)
+return NULL;
 fbo = glamor_create_fbo_from_tex(glamor_priv, w, h, format, tex, flag);
 
 return fbo;
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index f3950f1..058edae 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -292,6 +292,9 @@ typedef struct glamor_screen_private {
 ScreenPtr screen;
 int dri3_enabled;
 
+Bool suppress_gl_out_of_memory_logging;
+Bool logged_any_fbo_allocation_failure;
+
 /* xv */
 GLint xv_prog;
 
-- 
2.6.2

___
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 xserver 2/5] glamor: Fix crashes when the glyph atlas allocation fails.

2015-11-06 Thread Eric Anholt
We already have a fallback path, so we just need to jump to it when we
hit the failure.

Signed-off-by: Eric Anholt 
---
 glamor/glamor_composite_glyphs.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c
index 389c8f4..8692904 100644
--- a/glamor/glamor_composite_glyphs.c
+++ b/glamor/glamor_composite_glyphs.c
@@ -127,6 +127,10 @@ glamor_glyph_atlas_init(ScreenPtr screen, struct 
glamor_glyph_atlas *atlas)
 atlas->atlas = glamor_create_pixmap(screen, glamor_priv->glyph_atlas_dim,
 glamor_priv->glyph_atlas_dim, 
format->depth,
 GLAMOR_CREATE_FBO_NO_FBO);
+if (!glamor_pixmap_has_fbo(atlas->atlas)) {
+glamor_destroy_pixmap(atlas->atlas);
+atlas->atlas = NULL;
+}
 atlas->x = 0;
 atlas->y = 0;
 atlas->row_height = 0;
@@ -420,8 +424,11 @@ glamor_composite_glyphs(CARD8 op,
 glyph_atlas->atlas = NULL;
 }
 }
-if (!glyph_atlas->atlas)
+if (!glyph_atlas->atlas) {
 glamor_glyph_atlas_init(screen, glyph_atlas);
+if (!glyph_atlas->atlas)
+goto bail_one;
+}
 glamor_glyph_add(glyph_atlas, glyph_draw);
 }
 
-- 
2.6.2

___
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 xserver] glamor: Remove the FBO cache.

2015-11-06 Thread Eric Anholt
It is a modest performance improvemnt (2.7% on Intel), with the
significant downside that it keeps extra pixmap contents laying around
for 1000 BlockHandlers without the ability for the system to purge
them when under memory pressure, and tiled renderers don't know that
we could avoid reading their current contents when beginning to render
again.  We could use the FB invalidate functions, but they aren't
always available, aren't hooked up well in Mesa, and would eat into
the performance gains of having the cache.
---
 glamor/glamor.c  |   5 --
 glamor/glamor_fbo.c  | 234 ++-
 glamor/glamor_priv.h |  27 --
 3 files changed, 7 insertions(+), 259 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index d4a0236..47686af 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -110,7 +110,6 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int 
tex)
 ErrorF("XXX fail to create fbo.\n");
 return;
 }
-fbo->external = TRUE;
 
 glamor_pixmap_attach_fbo(pixmap, fbo);
 }
@@ -226,9 +225,7 @@ glamor_block_handler(ScreenPtr screen)
 glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
 
 glamor_make_current(glamor_priv);
-glamor_priv->tick++;
 glFlush();
-glamor_fbo_expire(glamor_priv);
 }
 
 static void
@@ -651,7 +648,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 ps->Glyphs = glamor_composite_glyphs;
 
 glamor_init_vbo(screen);
-glamor_init_pixmap_fbo(screen);
 glamor_init_finish_access_shaders(screen);
 
 #ifdef GLAMOR_GRADIENT_SHADER
@@ -677,7 +673,6 @@ glamor_release_screen_priv(ScreenPtr screen)
 
 glamor_priv = glamor_get_screen_private(screen);
 glamor_fini_vbo(screen);
-glamor_fini_pixmap_fbo(screen);
 glamor_pixmap_fini(screen);
 free(glamor_priv);
 
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 262033f..0524c16 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -30,105 +30,9 @@
 
 #include "glamor_priv.h"
 
-#define GLAMOR_CACHE_EXPIRE_MAX 100
-
-#define GLAMOR_CACHE_DEFAULT0
-#define GLAMOR_CACHE_EXACT_SIZE 1
-
-//#define NO_FBO_CACHE 1
-#define FBO_CACHE_THRESHOLD  (256*1024*1024)
-
-/* Loop from the tail to the head. */
-#define xorg_list_for_each_entry_reverse(pos, head, member) \
-for (pos = __container_of((head)->prev, pos, member);   \
- >member != (head);\
- pos = __container_of(pos->member.prev, pos, member))
-
-#define xorg_list_for_each_entry_safe_reverse(pos, tmp, head, member)   \
-for (pos = __container_of((head)->prev, pos, member),   \
- tmp = __container_of(pos->member.prev, pos, member);   \
- >member != (head);\
- pos = tmp, tmp = __container_of(pos->member.prev, tmp, member))
-
-inline static int
-cache_wbucket(int size)
-{
-int order = __fls(size / 32);
-
-if (order >= CACHE_BUCKET_WCOUNT)
-order = CACHE_BUCKET_WCOUNT - 1;
-return order;
-}
-
-inline static int
-cache_hbucket(int size)
-{
-int order = __fls(size / 32);
-
-if (order >= CACHE_BUCKET_HCOUNT)
-order = CACHE_BUCKET_HCOUNT - 1;
-return order;
-}
-
-static int
-cache_format(GLenum format)
-{
-switch (format) {
-case GL_ALPHA:
-return 2;
-case GL_RGB:
-return 1;
-case GL_RGBA:
-return 0;
-default:
-return -1;
-}
-}
-
-static glamor_pixmap_fbo *
-glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
-int w, int h, GLenum format)
-{
-struct xorg_list *cache;
-glamor_pixmap_fbo *fbo_entry, *ret_fbo = NULL;
-int n_format;
-
-#ifdef NO_FBO_CACHE
-return NULL;
-#else
-n_format = cache_format(format);
-if (n_format == -1)
-return NULL;
-cache = _priv->fbo_cache[n_format]
-[cache_wbucket(w)]
-[cache_hbucket(h)];
-
-xorg_list_for_each_entry(fbo_entry, cache, list) {
-if (fbo_entry->width == w && fbo_entry->height == h) {
-
-DEBUGF("Request w %d h %d format %x \n", w, h, format);
-DEBUGF("got cache entry %p w %d h %d fbo %d tex %d format %x\n",
-   fbo_entry, fbo_entry->width, fbo_entry->height,
-   fbo_entry->fb, fbo_entry->tex, fbo_entry->format);
-assert(format == fbo_entry->format);
-xorg_list_del(_entry->list);
-ret_fbo = fbo_entry;
-break;
-}
-}
-
-if (ret_fbo)
-glamor_priv->fbo_cache_watermark -= ret_fbo->width * ret_fbo->height;
-
-assert(glamor_priv->fbo_cache_watermark >= 0);
-
-return ret_fbo;
-#endif
-}
-
-static void
-glamor_purge_fbo(glamor_screen_private *glamor_priv,
- glamor_pixmap_fbo *fbo)
+void
+glamor_destroy_fbo(glamor_screen_private *glamor_priv,
+   glamor_pixmap_fbo *fbo)
 {
 

Re: [PATCH xf86-video-nested 09/10] Introduce a new XCB client backend, and make it the default one.

2015-11-06 Thread Laércio de Sousa
> [...]
> > +else if (reply->major_version < major || reply->minor_version <
> minor)
> > +{
> > +xf86DrvMsg(scrnIndex,
> > +   X_ERROR,
> > +   "Host X server doesn't support RandR %d.%d, needed
> for Option \"Output\" usage.\n",
> > +   major, minor);
>
> Why is 4.0 not better than 1.1? Shouldn't this check be replaced with the
> following?
>
>   if (reply->major_version < major ||
>  (reply->major_version == major && reply->minor_version < minor))
>
You're absolutely right! Fixed here. Thank you!


> > +static void
> > +_NestedClientSetWMClass(NestedClientPrivatePtr pPriv,
> > +const char* wm_class)
> > +{
> > +size_t class_len = strlen(wm_class) + 1;
> > +char *class_hint = malloc(class_len);
> > +
> > +if (class_hint)
> > +{
> > +strcpy(class_hint, wm_class);
> > +xcb_change_property(pPriv->conn,
> > +XCB_PROP_MODE_REPLACE,
> > +pPriv->window,
> > +XCB_ATOM_WM_CLASS,
> > +XCB_ATOM_STRING,
> > +8,
> > +class_len,
> > +class_hint);
> > +free(class_hint);
> > +}
>
> Why is this strcpy needed?
>
I've copied over this piece of code from Xephyr. In that context,
class_hint stores a concatenation bewteen two strings, so that strcpy is
needed, but here the WM_CLASS string is much more simple, so that strcpy is
not needed. I'll remove it. Thanks!


> > +}
> > +
> [...]
> > +static void
> > +_NestedClientCreateWindow(NestedClientPrivatePtr pPriv)
> > +{
> > +xcb_size_hints_t sizeHints;
> > +
> > +sizeHints.flags = XCB_ICCCM_SIZE_HINT_P_POSITION
> > +  | XCB_ICCCM_SIZE_HINT_P_SIZE
> > +  | XCB_ICCCM_SIZE_HINT_P_MIN_SIZE
> > +  | XCB_ICCCM_SIZE_HINT_P_MAX_SIZE;
> > +sizeHints.min_width = pPriv->width;
> > +sizeHints.max_width = pPriv->width;
> > +sizeHints.min_height = pPriv->height;
> > +sizeHints.max_height = pPriv->height;
> > +
> > +pPriv->window = xcb_generate_id(pPriv->conn);
> > +pPriv->img = NULL;
> > +
> > +xcb_create_window(pPriv->conn,
> > +  XCB_COPY_FROM_PARENT,
> > +  pPriv->window,
> > +  pPriv->rootWindow,
> > +  0, 0, 100, 100, /* will resize */
>
> Why not creating it at the correct size and position and skip at least the
> first
> of the following two xcb_configure_window()?

(Although I don't understand the
> second one either)
>
TBH, for the window size case, I don't know either. It's just the way it's
done in Xephyr, whose code I've copied here. I'll drop the first
xcb_configure_window() and wait for any complaints. Than you!

For the position case, however, there's a reason: setting it after
xcb_map_window() call is the only way I've found to prevent modern WMs from
"ignoring" my explicit positioning and putting nested Xorg window where it
wants. I'll comment that code for clarity.

> +void
> > +NestedClientUpdateScreen(NestedClientPrivatePtr pPriv,
> > + int16_t x1, int16_t y1,
> > + int16_t x2, int16_t y2)
> > +{
> > +if (pPriv->usingShm)
> > +xcb_image_shm_put(pPriv->conn, pPriv->window,
> > +  pPriv->gc, pPriv->img,
> > +  pPriv->shminfo,
> > +  x1, y1, x1, y1, x2 - x1, y2 - y1, FALSE);
> > +else
> > +xcb_image_put(pPriv->conn, pPriv->window, pPriv->gc,
> > +  pPriv->img, x1, y1, 0);
> > +
> > +xcb_aux_sync(pPriv->conn);
> > +}
>
> Does this really need a sync? Wouldn't a flush be enough? Or is the sync
> only
> needed in the usingShm case so that the data isn't modified too early?
>
I'll replace it with xcb_flush() and see if anyone complains. I've also put
a xcb_flush() right after window creation, just in case. Thank you!

>
> > +static inline void
> > +_NestedClientProcessExpose(NestedClientPrivatePtr pPriv,
> > +   xcb_generic_event_t *ev)
> > +{
> > +xcb_expose_event_t *xev = (xcb_expose_event_t *)ev;
> > +NestedClientUpdateScreen(pPriv,
> > + xev->x,
> > + xev->y,
> > + xev->x + xev->width,
> > + xev->y + xev->height);
> > +}
> > +
> > +static inline void
> > +_NestedClientProcessClientMessage(NestedClientPrivatePtr pPriv,
> > +  xcb_generic_event_t *ev)
> > +{
> > +xcb_client_message_event_t *cmev = (xcb_client_message_event_t *)ev;
> > +
> > +if (cmev->data.data32[0] == atom_WM_DELETE_WINDOW)
> > +{
> > +/* XXX: Is there a better way to do this? */
> > +xf86DrvMsg(pPriv->scrnIndex,
> > +   X_INFO,

[PATCH xserver 08/11] glamor: Simplify DRI3 pixmap-from-fd, using GBM.

2015-11-06 Thread Eric Anholt
This GBM import path was introduced in 10.2, which we already require.

Signed-off-by: Eric Anholt 
---
 glamor/glamor_egl.c | 37 +++--
 1 file changed, 7 insertions(+), 30 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index f3650b7..fde7688 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -506,18 +506,8 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap,
 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 struct glamor_egl_screen_private *glamor_egl;
 struct gbm_bo *bo;
-EGLImageKHR image;
 Bool ret = FALSE;
-
-EGLint attribs[] = {
-EGL_WIDTH, 0,
-EGL_HEIGHT, 0,
-EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB,
-EGL_DMA_BUF_PLANE0_FD_EXT, 0,
-EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
-EGL_DMA_BUF_PLANE0_PITCH_EXT, 0,
-EGL_NONE
-};
+struct gbm_import_fd_data import_data = { 0 };
 
 glamor_egl = glamor_egl_get_screen_private(scrn);
 
@@ -527,23 +517,12 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap,
 if (bpp != 32 || !(depth == 24 || depth == 32) || width == 0 || height == 
0)
 return FALSE;
 
-attribs[1] = width;
-attribs[3] = height;
-attribs[7] = fd;
-attribs[11] = stride;
-image = eglCreateImageKHR(glamor_egl->display,
-  EGL_NO_CONTEXT,
-  EGL_LINUX_DMA_BUF_EXT,
-  NULL, attribs);
-
-if (image == EGL_NO_IMAGE_KHR)
-return FALSE;
-
-/* EGL_EXT_image_dma_buf_import can impose restrictions on the
- * usage of the image. Use gbm_bo to bypass the limitations. */
-bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_EGL_IMAGE, image, 0);
-eglDestroyImageKHR(glamor_egl->display, image);
-
+import_data.fd = fd;
+import_data.width = width;
+import_data.height = height;
+import_data.stride = stride;
+import_data.format = GBM_FORMAT_ARGB;
+bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_FD, _data, 0);
 if (!bo)
 return FALSE;
 
@@ -871,8 +850,6 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 #ifdef GLAMOR_HAS_GBM
 if (epoxy_has_egl_extension(glamor_egl->display,
 "EGL_KHR_gl_texture_2D_image") &&
-epoxy_has_egl_extension(glamor_egl->display,
-"EGL_EXT_image_dma_buf_import") &&
 epoxy_has_gl_extension("GL_OES_EGL_image"))
 glamor_egl->dri3_capable = TRUE;
 #endif
-- 
2.6.2

___
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 xserver 07/11] glamor: Use real types for glamor_egl's public gbm functions.

2015-11-06 Thread Eric Anholt
I think void * was just used to avoid needing to #include gbm.h, but
we can just forward-declare the structs and be fine.

Signed-off-by: Eric Anholt 
---
 glamor/glamor.h | 11 +++
 glamor/glamor_egl.c |  7 ---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/glamor/glamor.h b/glamor/glamor.h
index 4459fa4..12dff8e 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -40,6 +40,8 @@
 #endif
 
 struct glamor_context;
+struct gbm_bo;
+struct gbm_device;
 
 /*
  * glamor_pixmap_type : glamor pixmap's type.
@@ -147,7 +149,7 @@ extern _X_EXPORT int 
glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
   unsigned int, Bool,
   CARD16 *, CARD32 *);
 
-extern _X_EXPORT void *glamor_egl_get_gbm_device(ScreenPtr screen);
+extern _X_EXPORT struct gbm_device *glamor_egl_get_gbm_device(ScreenPtr 
screen);
 
 /* @glamor_supports_pixmap_import_export: Returns whether
  * glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and
@@ -207,8 +209,8 @@ extern _X_EXPORT int glamor_name_from_pixmap(PixmapPtr 
pixmap,
  *
  * Returns the gbm_bo on success, NULL on error.
  * */
-extern _X_EXPORT void *glamor_gbm_bo_from_pixmap(ScreenPtr screen,
- PixmapPtr pixmap);
+extern _X_EXPORT struct gbm_bo *glamor_gbm_bo_from_pixmap(ScreenPtr screen,
+  PixmapPtr pixmap);
 
 /* @glamor_pixmap_from_fd: Creates a pixmap to wrap a dma-buf fd.
  *
@@ -315,7 +317,8 @@ extern _X_EXPORT Bool 
glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
  * This function is similar to glamor_egl_create_textured_pixmap.
  */
 extern _X_EXPORT Bool
- glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo);
+ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
+   struct gbm_bo *bo);
 
 #endif
 
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 6580141..f3650b7 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -175,7 +175,7 @@ glamor_create_texture_from_image(ScreenPtr screen,
 return TRUE;
 }
 
-void *
+struct gbm_device *
 glamor_egl_get_gbm_device(ScreenPtr screen)
 {
 #ifdef GLAMOR_HAS_GBM
@@ -335,7 +335,8 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int 
handle, int stride)
 }
 
 Bool
-glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
+glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
+  struct gbm_bo *bo)
 {
 ScreenPtr screen = pixmap->drawable.pScreen;
 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
@@ -428,7 +429,7 @@ _get_gbm_bo_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, 
unsigned int tex)
 }
 #endif
 
-void *
+struct gbm_bo *
 glamor_gbm_bo_from_pixmap(ScreenPtr screen, PixmapPtr pixmap)
 {
 #ifdef GLAMOR_HAS_GBM
-- 
2.6.2

___
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 xserver 10/11] glamor: Delay making pixmaps shareable until we need to.

2015-11-06 Thread Eric Anholt
If a pixmap isn't getting exported as a dmabuf, then we don't need to
go the GBM route for it.  This should reduce normal pixmap allocation
overhead, and also lets the driver choose non-scanout formats which
may be much higher performance.

On Raspberry Pi, where scanout isn't usable as a texture source, this
improves x11perf -copypixwin100 from about 4300/sec to 5780/sec under
xcompmgr -a, because we no longer need to upload our x11perf window to
a tiled temporary in order to render it to the screen.

Signed-off-by: Eric Anholt 
---
 glamor/glamor.c   |   2 +
 glamor/glamor.h   |   5 -
 glamor/glamor_egl.c   | 211 ++
 glamor/glamor_egl_stubs.c |   6 --
 glamor/glamor_fbo.c   |  35 +++
 glamor/glamor_priv.h  |   2 +
 hw/xwayland/xwayland-glamor.c |   6 --
 7 files changed, 109 insertions(+), 158 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index ec5f81b..663399c 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -168,6 +168,8 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int 
depth,
 
 pixmap_priv = glamor_get_pixmap_private(pixmap);
 
+pixmap_priv->usage_shared = (usage == CREATE_PIXMAP_USAGE_SHARED);
+
 format = gl_iformat_for_pixmap(pixmap);
 
 pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 12dff8e..a4e0655 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -140,11 +140,6 @@ extern _X_EXPORT void 
glamor_pixmap_exchange_fbos(PixmapPtr front,
 
 /* The DDX is not supposed to call these three functions */
 extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
-extern _X_EXPORT unsigned int 
glamor_egl_create_argb_based_texture(ScreenPtr
-   screen,
-   int w,
-   int h,
-   Bool 
linear);
 extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
   unsigned int, Bool,
   CARD16 *, CARD32 *);
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index e68af18..8638063 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -187,49 +187,6 @@ glamor_egl_get_gbm_device(ScreenPtr screen)
 #endif
 }
 
-unsigned int
-glamor_egl_create_argb_based_texture(ScreenPtr screen, int w, int h, Bool 
linear)
-{
-ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-struct glamor_egl_screen_private *glamor_egl;
-EGLImageKHR image;
-GLuint texture;
-
-#ifdef GLAMOR_HAS_GBM
-struct gbm_bo *bo;
-EGLNativePixmapType native_pixmap;
-
-glamor_egl = glamor_egl_get_screen_private(scrn);
-bo = gbm_bo_create(glamor_egl->gbm, w, h, GBM_FORMAT_ARGB,
-#ifdef GLAMOR_HAS_GBM_LINEAR
-   (linear ? GBM_BO_USE_LINEAR : 0) |
-#endif
-   GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
-if (!bo)
-return 0;
-
-/* If the following assignment raises an error or a warning
- * then that means EGLNativePixmapType is not struct gbm_bo *
- * on your platform: This code won't work and you should not
- * compile with dri3 support enabled */
-native_pixmap = bo;
-
-image = eglCreateImageKHR(glamor_egl->display,
-  EGL_NO_CONTEXT,
-  EGL_NATIVE_PIXMAP_KHR,
-  native_pixmap, NULL);
-gbm_bo_destroy(bo);
-if (image == EGL_NO_IMAGE_KHR)
-return 0;
-glamor_create_texture_from_image(screen, image, );
-eglDestroyImageKHR(glamor_egl->display, image);
-
-return texture;
-#else
-return 0;   /* this path should never happen */
-#endif
-}
-
 Bool
 glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
 {
@@ -334,6 +291,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int 
handle, int stride)
 return ret;
 }
 
+#ifdef GLAMOR_HAS_GBM
 Bool
 glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
   struct gbm_bo *bo)
@@ -342,6 +300,8 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap,
 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 struct glamor_screen_private *glamor_priv =
 glamor_get_screen_private(screen);
+struct glamor_pixmap_private *pixmap_priv =
+glamor_get_pixmap_private(pixmap);
 struct glamor_egl_screen_private *glamor_egl;
 EGLImageKHR image;
 GLuint texture;
@@ -362,13 +322,15 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap,
 glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
 glamor_set_pixmap_texture(pixmap, texture);
 

[PATCH xserver 03/11] glamor: Remove glamor_egl_destroy_textured_pixmap().

2015-11-06 Thread Eric Anholt
The DestroyPixmap chain and CloseScreen chain all do pixmap teardown
already, and calling it manually would be redundant.

Signed-off-by: Eric Anholt 
---
 glamor/glamor.h | 1 -
 glamor/glamor_egl.c | 6 --
 2 files changed, 7 deletions(-)

diff --git a/glamor/glamor.h b/glamor/glamor.h
index 4be8800..54fec1d 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -324,7 +324,6 @@ extern _X_EXPORT Bool
 
 extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen,
  struct glamor_context 
*glamor_ctx);
-extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
 
 extern _X_EXPORT int glamor_create_gc(GCPtr gc);
 
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index cc16b0a..24d5586 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -633,12 +633,6 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr 
back)
 glamor_set_pixmap_type(back, GLAMOR_TEXTURE_DRM);
 }
 
-void
-glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
-{
-glamor_destroy_textured_pixmap(pixmap);
-}
-
 static Bool
 glamor_egl_close_screen(ScreenPtr screen)
 {
-- 
2.6.2

___
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 xserver 06/11] glamor: Use the GBM function for getting an FD from a GBM BO.

2015-11-06 Thread Eric Anholt
We were rolling ioctl calls ourselves, when there's a nice interface
for it.

Signed-off-by: Eric Anholt 
---
 glamor/glamor_egl.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 761874f..6580141 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -368,22 +368,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap, void *bo)
 }
 
 #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
-glamor_get_fd_from_bo(int gbm_fd, struct gbm_bo *bo, int *fd)
-{
-union gbm_bo_handle handle;
-struct drm_prime_handle args;
-
-handle = gbm_bo_get_handle(bo);
-args.handle = handle.u32;
-args.flags = DRM_CLOEXEC;
-if (ioctl(gbm_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, ))
-return FALSE;
-*fd = args.fd;
-return TRUE;
-}
 
 void
 glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name)
@@ -495,8 +480,7 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
 glamor_get_name_from_bo(glamor_egl->fd, bo, );
 }
 else {
-if (glamor_get_fd_from_bo(glamor_egl->fd, bo, )) {
-}
+fd = gbm_bo_get_fd(bo);
 }
 *stride = pixmap->devKind;
 *size = pixmap->devKind * gbm_bo_get_height(bo);
-- 
2.6.2

___
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 xserver 11/11] glamor: Stop holding on to the EGLImage for textures.

2015-11-06 Thread Eric Anholt
We used to cache the EGLImage to be able to return an fd again faster,
but now we keep the gbm bo on hand to do so.

One concern might be if the early destruction of the EGLImage meant
orphaning. However, the EGL_KHR_image_base spec text says:

Once destroyed,  may not be used to create any additional
EGLImage target resources within any client API contexts, although
existing EGLImage siblings may continue to be used.

and, even more clearly in the issues section:

Note that the EGLImage source and any EGLImage target resources
will still be EGLImage siblings, even if the EGLImage object is
destroyed by a call to DestroyImageKHR.

Signed-off-by: Eric Anholt 
---
 glamor/glamor_egl.c  | 37 ++---
 glamor/glamor_priv.h |  5 -
 2 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 8638063..6eeb7f2 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -225,24 +225,6 @@ glamor_egl_check_has_gem(int fd)
 return FALSE;
 }
 
-static void
-glamor_egl_set_pixmap_image(PixmapPtr pixmap, EGLImageKHR image)
-{
-struct glamor_pixmap_private *pixmap_priv =
-glamor_get_pixmap_private(pixmap);
-EGLImageKHR old;
-
-old = pixmap_priv->image;
-if (old) {
-ScreenPtr   screen = 
pixmap->drawable.pScreen;
-ScrnInfoPtr scrn = 
xf86ScreenToScrn(screen);
-struct glamor_egl_screen_private*glamor_egl = 
glamor_egl_get_screen_private(scrn);
-
-eglDestroyImageKHR(glamor_egl->display, old);
-}
-pixmap_priv->image = image;
-}
-
 Bool
 glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
 {
@@ -284,7 +266,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int 
handle, int stride)
 glamor_create_texture_from_image(screen, image, );
 glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
 glamor_set_pixmap_texture(pixmap, texture);
-glamor_egl_set_pixmap_image(pixmap, image);
+eglDestroyImageKHR(glamor_egl->display, image);
 ret = TRUE;
 
  done:
@@ -321,7 +303,6 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap,
 glamor_create_texture_from_image(screen, image, );
 glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
 glamor_set_pixmap_texture(pixmap, texture);
-glamor_egl_set_pixmap_image(pixmap, image);
 if (pixmap_priv->gbm)
 gbm_bo_destroy(pixmap_priv->gbm);
 pixmap_priv->gbm = bo;
@@ -532,13 +513,10 @@ glamor_egl_destroy_pixmap(PixmapPtr pixmap)
 Bool ret;
 
 if (pixmap->refcnt == 1) {
+#ifdef GLAMOR_HAS_GBM
 struct glamor_pixmap_private *pixmap_priv =
 glamor_get_pixmap_private(pixmap);
 
-if (pixmap_priv->image)
-eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
-
-#ifdef GLAMOR_HAS_GBM
 if (pixmap_priv->gbm) {
 gbm_bo_destroy(pixmap_priv->gbm);
 pixmap_priv->gbm = NULL;
@@ -557,7 +535,6 @@ glamor_egl_destroy_pixmap(PixmapPtr pixmap)
 _X_EXPORT void
 glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
 {
-EGLImageKHR temp_image;
 struct gbm_bo *temp_bo;
 struct glamor_pixmap_private *front_priv =
 glamor_get_pixmap_private(front);
@@ -566,10 +543,6 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr 
back)
 
 glamor_pixmap_exchange_fbos(front, back);
 
-temp_image = back_priv->image;
-back_priv->image = front_priv->image;
-front_priv->image = temp_image;
-
 temp_bo = back_priv->gbm;
 back_priv->gbm = front_priv->gbm;
 front_priv->gbm = temp_bo;
@@ -591,8 +564,10 @@ glamor_egl_close_screen(ScreenPtr screen)
 screen_pixmap = screen->GetScreenPixmap(screen);
 pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
 
-eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
-pixmap_priv->image = NULL;
+if (pixmap_priv->gbm) {
+gbm_bo_destroy(pixmap_priv->gbm);
+pixmap_priv->gbm = NULL;
+}
 
 screen->CloseScreen = glamor_egl->saved_close_screen;
 
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index df6a02a..dd01aeb 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -38,10 +38,6 @@
 #endif
 
 #include 
-#if GLAMOR_HAS_GBM
-#define MESA_EGL_NO_X11_HEADERS
-#include 
-#endif
 
 #define GLAMOR_DEFAULT_PRECISION  \
 "#ifdef GL_ES\n"  \
@@ -355,7 +351,6 @@ typedef struct glamor_pixmap_private {
 Bool prepared;
 Bool usage_shared;
 #if GLAMOR_HAS_GBM
-EGLImageKHR image;
 struct gbm_bo *gbm;
 #endif
 /** block width of this large pixmap. */
-- 
2.6.2

___
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 xserver 01/11] glamor: No need to glFlush before destroying a pixmap.

2015-11-06 Thread Eric Anholt
I assume this was a workaround for an old, broken, closed driver.  The
driver doesn't get to throw away rendering just because the rendering
context's shared-across-processes render target is getting freed from
the local address space.  If the rendering isn't to a shared render
target, then we *do* want to throw away the rendering to it.

Signed-off-by: Eric Anholt 
---
 glamor/glamor_egl.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 2e6c7bd..cc16b0a 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -609,10 +609,6 @@ glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
 struct glamor_egl_screen_private *glamor_egl =
 glamor_egl_get_screen_private(scrn);
 
-/* Before destroy an image which was attached to
- * a texture. we must call glFlush to make sure the
- * operation on that texture has been done.*/
-glamor_block_handler(pixmap->drawable.pScreen);
 eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
 pixmap_priv->image = NULL;
 }
-- 
2.6.2

___
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: Delay making pixmaps shared until needed.

2015-11-06 Thread Eric Anholt
This is a branch I've been working on for a while for glamor,
targeting 1.19.  The observation is that X allocates many pixmaps,
only a few of which will be shared between clients, and sharing a new
pixmap between clients is infrequent.  Given this, we can allocate
higher-performance non-shared pixmaps, and just use a quick CopyArea
to a shared pixmap when we need to produce an fd for one (aka when
texture_from_pixmap is used on a new window).

This is particularly important for VC4 (Raspberry Pi), since the 3D
engine can't read from the raster format, but you really want raster
format for anything you might pageflip to (the scanout engine is slow
at tiled texture formats).  Window dragging in LXDE or XFCE4 goes from
rendering at a few fps to mostly smooth.

This is available in the glamor-delay-shareable branch of my 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 xserver 02/11] modesetting: No need to free the EGLImage just before freeing the pixmap.

2015-11-06 Thread Eric Anholt
DestroyPixmap handles that just fine.  This also lets us drop our use
of the manual image destruction function (Note that the ATI driver
still uses it in a similar fashion, though).

Signed-off-by: Eric Anholt 
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c 
b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 4421578..0d34ca1 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -780,7 +780,6 @@ drmmode_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr 
rotate_pixmap, void *data)
 drmmode_ptr drmmode = drmmode_crtc->drmmode;
 
 if (rotate_pixmap) {
-drmmode_set_pixmap_bo(drmmode, rotate_pixmap, NULL);
 rotate_pixmap->drawable.pScreen->DestroyPixmap(rotate_pixmap);
 }
 
@@ -1588,11 +1587,6 @@ drmmode_set_pixmap_bo(drmmode_ptr drmmode, PixmapPtr 
pixmap, drmmode_bo *bo)
 if (!drmmode->glamor)
 return TRUE;
 
-if (bo == NULL) {
-glamor_egl_destroy_textured_pixmap(pixmap);
-return TRUE;
-}
-
 #ifdef GLAMOR_HAS_GBM
 if (!glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, bo->gbm)) {
 xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed");
-- 
2.6.2

___
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 xserver 09/11] glamor: Make glamor_get_name_from_bo static.

2015-11-06 Thread Eric Anholt
Signed-off-by: Eric Anholt 
---
 glamor/glamor_egl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index fde7688..e68af18 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -369,9 +369,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap,
 }
 
 #ifdef GLAMOR_HAS_GBM
-void glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name);
-
-void
+static void
 glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name)
 {
 union gbm_bo_handle handle;
-- 
2.6.2

___
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 xserver 04/11] glamor: Unexport glamor_destroy_textured_pixmap().

2015-11-06 Thread Eric Anholt
This is just a bit of the DestroyPixmap chain.

Signed-off-by: Eric Anholt 
---
 glamor/glamor.c | 9 ++---
 glamor/glamor.h | 1 -
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index d4a0236..dbaee46 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -202,8 +202,8 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int 
depth,
 return pixmap;
 }
 
-void
-glamor_destroy_textured_pixmap(PixmapPtr pixmap)
+Bool
+glamor_destroy_pixmap(PixmapPtr pixmap)
 {
 if (pixmap->refcnt == 1) {
 #if GLAMOR_HAS_GBM
@@ -211,12 +211,7 @@ glamor_destroy_textured_pixmap(PixmapPtr pixmap)
 #endif
 glamor_pixmap_destroy_fbo(pixmap);
 }
-}
 
-Bool
-glamor_destroy_pixmap(PixmapPtr pixmap)
-{
-glamor_destroy_textured_pixmap(pixmap);
 return fbDestroyPixmap(pixmap);
 }
 
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 54fec1d..6d135df 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -110,7 +110,6 @@ extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr 
pixmap,
 
 extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
  glamor_pixmap_type_t type);
-extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
 extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
 
 extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
-- 
2.6.2

___
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 xserver 05/11] glamor: Hook up EGL DestroyPixmap through the normal wrap chain.

2015-11-06 Thread Eric Anholt
One less layering violation (EGL should call glamor, if anything, not
the other way around).

Signed-off-by: Eric Anholt 
---
 glamor/glamor.c   |  3 ---
 glamor/glamor.h   |  2 --
 glamor/glamor_egl.c   | 33 +++--
 glamor/glamor_egl_stubs.c |  5 -
 hw/xwayland/xwayland-glamor.c |  5 -
 5 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index dbaee46..ec5f81b 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -206,9 +206,6 @@ Bool
 glamor_destroy_pixmap(PixmapPtr pixmap)
 {
 if (pixmap->refcnt == 1) {
-#if GLAMOR_HAS_GBM
-glamor_egl_destroy_pixmap_image(pixmap);
-#endif
 glamor_pixmap_destroy_fbo(pixmap);
 }
 
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 6d135df..4459fa4 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -147,8 +147,6 @@ extern _X_EXPORT int 
glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
   unsigned int, Bool,
   CARD16 *, CARD32 *);
 
-extern void glamor_egl_destroy_pixmap_image(PixmapPtr pixmap);
-
 extern _X_EXPORT void *glamor_egl_get_gbm_device(ScreenPtr screen);
 
 /* @glamor_supports_pixmap_import_export: Returns whether
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 24d5586..761874f 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -78,6 +78,7 @@ struct glamor_egl_screen_private {
 int dri3_capable;
 
 CloseScreenProcPtr saved_close_screen;
+DestroyPixmapProcPtr saved_destroy_pixmap;
 xf86FreeScreenProc *saved_free_screen;
 };
 
@@ -598,20 +599,29 @@ glamor_pixmap_from_fd(ScreenPtr screen,
 #endif
 }
 
-void
-glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
+static Bool
+glamor_egl_destroy_pixmap(PixmapPtr pixmap)
 {
-struct glamor_pixmap_private *pixmap_priv =
-glamor_get_pixmap_private(pixmap);
+ScreenPtr screen = pixmap->drawable.pScreen;
+ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+struct glamor_egl_screen_private *glamor_egl =
+glamor_egl_get_screen_private(scrn);
+Bool ret;
 
-if (pixmap_priv->image) {
-ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
-struct glamor_egl_screen_private *glamor_egl =
-glamor_egl_get_screen_private(scrn);
+if (pixmap->refcnt == 1) {
+struct glamor_pixmap_private *pixmap_priv =
+glamor_get_pixmap_private(pixmap);
 
-eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
-pixmap_priv->image = NULL;
+if (pixmap_priv->image)
+eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
 }
+
+screen->DestroyPixmap = glamor_egl->saved_destroy_pixmap;
+ret = screen->DestroyPixmap(pixmap);
+glamor_egl->saved_destroy_pixmap = screen->DestroyPixmap;
+screen->DestroyPixmap = glamor_egl_destroy_pixmap;
+
+return ret;
 }
 
 _X_EXPORT void
@@ -723,6 +733,9 @@ glamor_egl_screen_init(ScreenPtr screen, struct 
glamor_context *glamor_ctx)
 glamor_egl->saved_close_screen = screen->CloseScreen;
 screen->CloseScreen = glamor_egl_close_screen;
 
+glamor_egl->saved_destroy_pixmap = screen->DestroyPixmap;
+screen->DestroyPixmap = glamor_egl_destroy_pixmap;
+
 glamor_ctx->ctx = glamor_egl->context;
 glamor_ctx->display = glamor_egl->display;
 
diff --git a/glamor/glamor_egl_stubs.c b/glamor/glamor_egl_stubs.c
index c11e6d5..35944c8 100644
--- a/glamor/glamor_egl_stubs.c
+++ b/glamor/glamor_egl_stubs.c
@@ -35,11 +35,6 @@ glamor_egl_screen_init(ScreenPtr screen, struct 
glamor_context *glamor_ctx)
 {
 }
 
-void
-glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
-{
-}
-
 int
 glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
  PixmapPtr pixmap,
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index ece7dbe..dedefdc 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -400,11 +400,6 @@ xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
 return TRUE;
 }
 
-void
-glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
-{
-}
-
 int
 glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
  PixmapPtr pixmap,
-- 
2.6.2

___
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