summaryrefslogtreecommitdiff
path: root/vmwgfx
diff options
context:
space:
mode:
authorSinclair Yeh <syeh@vmware.com>2017-07-13 20:15:52 +0200
committerSinclair Yeh <syeh@vmware.com>2017-07-13 20:27:29 +0200
commit1388a1592cdab7cc8217546fb1e97da293e70393 (patch)
tree88afd3f0a1d1e0c57546f4d33d0c2fa663d3968b /vmwgfx
parentd0d5cf3e35fd47b44f32065c5cb64ba62661f03a (diff)
Revert "vmwgfx: Support DRI3 v2"
This reverts commit d0d5cf3e35fd47b44f32065c5cb64ba62661f03a. Temporarily revert this for internal testing.
Diffstat (limited to 'vmwgfx')
-rw-r--r--vmwgfx/Makefile.am1
-rw-r--r--vmwgfx/vmwgfx_dri3.c310
-rw-r--r--vmwgfx/vmwgfx_driver.c34
-rw-r--r--vmwgfx/vmwgfx_driver.h13
-rw-r--r--vmwgfx/vmwgfx_saa.c35
-rw-r--r--vmwgfx/vmwgfx_saa_priv.h6
-rw-r--r--vmwgfx/vmwgfx_xa_surface.c4
7 files changed, 21 insertions, 382 deletions
diff --git a/vmwgfx/Makefile.am b/vmwgfx/Makefile.am
index a47a5fe..e486514 100644
--- a/vmwgfx/Makefile.am
+++ b/vmwgfx/Makefile.am
@@ -32,6 +32,5 @@ libvmwgfx_la_SOURCES = \
vmwgfx_xwayland.c \
vmwgfx_layout.c \
vmwgfx_rr_inlines.h \
- vmwgfx_dri3.c \
wsbm_util.h
endif
diff --git a/vmwgfx/vmwgfx_dri3.c b/vmwgfx/vmwgfx_dri3.c
deleted file mode 100644
index 0d4be5c..0000000
--- a/vmwgfx/vmwgfx_dri3.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright 2017 VMWare, Inc.
- * 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, sub license, 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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: Thomas Hellstrom <thellstrom@vmware.com>
- *
- */
-#ifdef _HAVE_CONFIG_H_
-#include "config.h"
-#endif
-
-#include <xorg-server.h>
-
-#ifdef DRI3
-#include "vmwgfx_driver.h"
-#if (XA_TRACKER_VERSION_MAJOR == VMW_XA_VERSION_MAJOR_DRI3 && \
- XA_TRACKER_VERSION_MINOR >= VMW_XA_VERSION_MINOR_DRI3)
-
-#include "vmwgfx_driver.h"
-#include "vmwgfx_saa_priv.h"
-#include <dri3.h>
-#include <misyncshm.h>
-#include <xf86drm.h>
-#include <unistd.h>
-
-
-/**
- * \brief DRI3 fd_from_pixmap callback.
- *
- */
-static int
-vmwgfx_dri3_fd_from_pixmap(ScreenPtr screen, PixmapPtr pixmap,
- CARD16 *stride, CARD32 *size)
-{
- struct vmwgfx_saa_pixmap *vpix = vmwgfx_saa_pixmap(pixmap);
- uint32_t handle;
- unsigned int byte_stride;
- ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
-
- if (!vmwgfx_hw_dri2_validate(pixmap, 0)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "DRI3 pixmap export failed to create HW surface.\n");
- return -1;
- }
-
- if (xa_surface_handle(vpix->hw, xa_handle_type_fd, &handle,
- &byte_stride)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "DRI3 pixmap export failed to create handle.\n");
- return -1;
- }
-
- *stride = byte_stride;
- *size = byte_stride * pixmap->drawable.height;
-
- /*
- * hw_is_dri2_fronts will make sure any software rendering to
- * this pixmap is immediately flushed to the underlying surface.
- * Strictly, we could wait for glxWaitX to do that, but alas,
- * even the dri3 glxWaitX appears as broken as the dri2 version.
- * If we, however, wanted to do that, we'd hook up a shm fence
- * trigger callback. (Like glamor does).
- */
- vpix->hw_is_dri2_fronts = 1;
-
- return handle;
-}
-
-/**
- * \brief DRI3 pixmap_from_fd callback.
- *
- */
-static PixmapPtr
-vmwgfx_dri3_pixmap_from_fd(ScreenPtr screen, int fd,
- CARD16 width, CARD16 height, CARD16 stride,
- CARD8 depth, CARD8 bpp)
-{
- struct vmwgfx_saa *vsaa = to_vmwgfx_saa(saa_get_driver(screen));
- struct xa_surface *srf;
- struct vmwgfx_saa_pixmap *vpix;
- ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
- PixmapPtr pixmap;
-
- if (width == 0 || height == 0 ||
- depth < 15 || bpp != BitsPerPixel(depth) || stride < width * bpp / 8)
- return NULL;
-
- pixmap = screen->CreatePixmap(screen, width, height, depth, 0);
- if (!pixmap) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "DRI3 pixmap creation failed.\n");
- return NULL;
- }
-
- vpix = vmwgfx_saa_pixmap(pixmap);
-
- if (!vmwgfx_hw_dri2_stage(pixmap, depth)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "DRI3 pixmap creation bad format.\n");
- goto out_bad_format;
- }
-
- srf = xa_surface_from_handle2(vsaa->xat, width, height, depth,
- xa_type_other,
- vpix->staging_format,
- vpix->staging_add_flags,
- xa_handle_type_fd,
- fd, stride);
- if (!srf) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "DRI3 pixmap creation surface sharing failed.\n");
- goto out_bad_format;
- }
-
- vpix->xa_flags = vpix->staging_add_flags;
- vpix->hw = srf;
- if (!vmwgfx_create_hw(vsaa, pixmap, TRUE)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "DRI3 pixmap creation failed SAA enabling.\n");
- goto out_no_damage;
- }
-
- vpix->hw_is_dri2_fronts = 1;
- return pixmap;
-
- out_no_damage:
- xa_surface_unref(srf);
- out_bad_format:
- screen->DestroyPixmap(pixmap);
-
- return NULL;
-}
-
-/**
- * \brief Open a render node.
- *
- * \param screen[IN] Pointer to the screen
- * \return A valid file descriptor or -1 on failure.
- */
-static int
-vmwgfx_dri3_open_render(ScreenPtr screen)
-{
- ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
- modesettingPtr ms = modesettingPTR(pScrn);
- char bus_id[64];
- int fd;
-
- snprintf(bus_id, sizeof(bus_id), "PCI:%d:%d:%d",
- ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
- ms->PciInfo->dev, ms->PciInfo->func);
-
- /* Render nodes can't be opened by busid yet.. */
- fd = drmOpenWithType("vmwgfx", bus_id, DRM_NODE_RENDER);
- if (fd < 0)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "DRI3 client open busid \"%s\" failed.\n", bus_id);
-
- return fd;
-}
-
-/**
- * \brief DRI3 open_client callback.
- *
- */
-static int
-vmwgfx_dri3_open_client(ClientPtr client, ScreenPtr screen,
- RRProviderPtr provider, int *pfd)
-{
- *pfd = vmwgfx_dri3_open_render(screen);
-
- return (*pfd >= 0) ? Success : BadAlloc;
-}
-
-/**
- * \brief Verify that surface sharing between render client and X server
- * works.
- *
- * \param screen[IN,OUT] A pointer to the current screen.
- * \return TRUE if successful, FALSE otherwise.
- *
- * Opens a render client, creates a surface and tries to share that surface
- * with the X server. There is a vmwgfx kernel driver bug that, combined
- * with a pre-guest-backed-surface svga mesa driver bug,
- * prevents this sharing to happen and thus breaks dri3.
- *
- * Also, we need to make sure that we can share an XRGB surface as an
- * ARGB surface since DRI3 does not appear to be as strict about internal
- * surface formats as DRI2.
- */
-static Bool
-vmwgfx_dri3_verify_sharing(ScreenPtr screen)
-{
- ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
- modesettingPtr ms = modesettingPTR(pScrn);
- int fd = vmwgfx_dri3_open_render(screen);
- struct xa_tracker *xat;
- struct xa_surface *srf1;
- unsigned int stride;
- uint32_t handle;
- Bool ret = FALSE;
-
- if (fd < 0)
- return FALSE;
-
- xat = xa_tracker_create(fd);
- if (!xat)
- goto out_no_xa;
-
- /* Here we're the render client (xat) */
- srf1 = xa_surface_create(xat, 16, 16, 32, xa_type_argb,
- xa_format_unknown,
- XA_FLAG_RENDER_TARGET | XA_FLAG_SHARED);
- if (!srf1)
- goto out_no_surface;
-
- if (xa_surface_handle(srf1, xa_handle_type_fd, &handle, &stride) !=
- XA_ERR_NONE)
- goto out_no_handle;
-
- xa_surface_unref(srf1);
-
- /* Now we're the X server (ms->xat) */
- srf1 = xa_surface_from_handle2(ms->xat, 16, 16, 24, xa_type_argb,
- xa_format_unknown,
- XA_FLAG_RENDER_TARGET | XA_FLAG_SHARED,
- xa_handle_type_fd, handle, stride);
- if (!srf1)
- goto out_no_surface;
-
- ret = TRUE;
- close(handle);
-
- out_no_handle:
- xa_surface_unref(srf1);
- out_no_surface:
- xa_tracker_destroy(xat);
- out_no_xa:
- close(fd);
-
- return ret;
-}
-
-static dri3_screen_info_rec vmwgfx_dri3_info = {
- .version = 1,
- .open = NULL,
- .pixmap_from_fd = vmwgfx_dri3_pixmap_from_fd,
- .fd_from_pixmap = vmwgfx_dri3_fd_from_pixmap,
- .open_client = vmwgfx_dri3_open_client,
-};
-
-
-/**
- * \brief Initialize dri3.
- *
- * \param screen[IN,OUT] A pointer to the current screen.
- * \return TRUE if successful, FALSE otherwise.
- */
-Bool
-vmwgfx_dri3_init(ScreenPtr screen)
-{
- ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
-
- if (!vmwgfx_dri3_verify_sharing(screen)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to verify XA surface sharing for DRI3.\n");
- return FALSE;
- }
-
- if (!miSyncShmScreenInit(screen)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to initialize xshm sync for DRI3.\n");
- return FALSE;
- }
-
- if (!dri3_screen_init(screen, &vmwgfx_dri3_info)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to initialize DRI3.\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-#else /* XA INCLUDES SUFFICIENT */
-Bool
-vmwgfx_dri3_init(ScreenPtr screen)
-{
- return FALSE;
-}
-
-#endif /* !XA INCLUDES SUFFICIENT */
-#endif /* DRI3 */
diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
index e93faaa..b9ee1db 100644
--- a/vmwgfx/vmwgfx_driver.c
+++ b/vmwgfx/vmwgfx_driver.c
@@ -622,11 +622,6 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags)
goto out_modes;
}
- if (!xf86LoadSubModule(pScrn, "dri3")) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to load dri3 module.\n");
- goto out_modes;
- }
-
return TRUE;
out_modes:
@@ -1059,16 +1054,6 @@ drv_screen_init(SCREEN_INIT_ARGS_DECL)
ms->xat = NULL;
ms->from_render = X_PROBED;
}
-#ifdef DRI3
- if (major == VMW_XA_VERSION_MAJOR_DRI3 &&
- minor >= VMW_XA_VERSION_MINOR_DRI3) {
- ms->xa_dri3 = TRUE;
- } else {
- ms->xa_dri3 = FALSE;
- LogMessage(X_WARNING,
- "Gallium3D XA version insufficient for dri3.\n");
- }
-#endif
}
if (ms->xat == NULL && ms->rendercheck) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
@@ -1093,21 +1078,12 @@ drv_screen_init(SCREEN_INIT_ARGS_DECL)
}
ms->dri2_available = FALSE;
- ms->dri3_available = FALSE;
if (ms->enable_dri) {
if (ms->xat) {
ms->dri2_available = xorg_dri2_init(pScreen);
if (!ms->dri2_available)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to initialize direct rendering DRI2.\n");
-#ifdef DRI3
- if (ms->xa_dri3) {
- ms->dri3_available = vmwgfx_dri3_init(pScreen);
- if (!ms->dri3_available)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to initialize direct rendering DRI3.\n");
- }
-#endif /* DRI3 */
+ "Failed to initialize direct rendering.\n");
} else {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Skipped initialization of direct rendering due "
@@ -1123,14 +1099,8 @@ drv_screen_init(SCREEN_INIT_ARGS_DECL)
"Rendercheck mode is %s.\n",
(ms->rendercheck) ? "enabled" : "disabled");
- xf86DrvMsg(pScrn->scrnIndex, ms->from_dri,
- "Direct rendering (DRI2 3D) is %s.\n",
+ xf86DrvMsg(pScrn->scrnIndex, ms->from_dri, "Direct rendering (3D) is %s.\n",
(ms->dri2_available) ? "enabled" : "disabled");
-#ifdef DRI3
- xf86DrvMsg(pScrn->scrnIndex, ms->from_dri,
- "Direct rendering (DRI3 3D) is %s.\n",
- (ms->dri3_available) ? "enabled" : "disabled");
-#endif
if (ms->xat != NULL) {
xf86DrvMsg(pScrn->scrnIndex, ms->from_dp, "Direct presents are %s.\n",
(ms->direct_presents) ? "enabled" : "disabled");
diff --git a/vmwgfx/vmwgfx_driver.h b/vmwgfx/vmwgfx_driver.h
index d5aea75..7c7177f 100644
--- a/vmwgfx/vmwgfx_driver.h
+++ b/vmwgfx/vmwgfx_driver.h
@@ -153,10 +153,6 @@ typedef struct _modesettingRec
struct vmwgfx_layout *layout;
#endif
Bool autoLayout;
-#ifdef DRI3
- Bool xa_dri3;
- Bool dri3_available;
-#endif
} modesettingRec, *modesettingPtr;
#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
@@ -236,13 +232,4 @@ vmw_video_free_adaptor(XF86VideoAdaptorPtr adaptor, Bool free_ports);
void
vmw_ctrl_ext_init(ScrnInfoPtr pScrn);
-/***********************************************************************
- * vmwgfx_dri3.c
- */
-#define VMW_XA_VERSION_MAJOR_DRI3 2
-#define VMW_XA_VERSION_MINOR_DRI3 3
-
-Bool
-vmwgfx_dri3_init(ScreenPtr screen);
-
#endif /* _XORG_TRACKER_H_ */
diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
index 0881e2f..b8ad2a7 100644
--- a/vmwgfx/vmwgfx_saa.c
+++ b/vmwgfx/vmwgfx_saa.c
@@ -371,7 +371,6 @@ vmwgfx_download_from_hw(struct saa_driver *driver, PixmapPtr pixmap,
goto out_err;
REGION_SUBTRACT(vsaa->pScreen, &spix->dirty_hw, &spix->dirty_hw, readback);
REGION_UNINIT(vsaa->pScreen, &intersection);
-
return TRUE;
out_err:
REGION_UNINIT(vsaa->pScreen, &intersection);
@@ -523,6 +522,9 @@ vmwgfx_destroy_pixmap(struct saa_driver *driver, PixmapPtr pixmap)
vmwgfx_pixmap_remove_present(vpix);
WSBMLISTDELINIT(&vpix->pixmap_list);
WSBMLISTDELINIT(&vpix->sync_x_head);
+
+ if (vpix->hw_is_dri2_fronts)
+ LogMessage(X_ERROR, "Incorrect dri2 front count.\n");
}
@@ -797,8 +799,7 @@ vmwgfx_prefer_gmr(struct vmwgfx_saa *vsaa, PixmapPtr pixmap)
Bool
vmwgfx_create_hw(struct vmwgfx_saa *vsaa,
- PixmapPtr pixmap,
- Bool shared)
+ PixmapPtr pixmap)
{
struct vmwgfx_saa_pixmap *vpix = vmwgfx_saa_pixmap(pixmap);
struct xa_surface *hw;
@@ -807,25 +808,19 @@ vmwgfx_create_hw(struct vmwgfx_saa *vsaa,
if (!vsaa->xat)
return FALSE;
- if (!shared) {
- if (vpix->hw)
- return TRUE;
-
- new_flags = (vpix->xa_flags & ~vpix->staging_remove_flags) |
- vpix->staging_add_flags | XA_FLAG_SHARED;
+ if (vpix->hw)
+ return TRUE;
- hw = xa_surface_create(vsaa->xat,
- pixmap->drawable.width,
- pixmap->drawable.height,
- 0,
- xa_type_other,
- vpix->staging_format,
- new_flags);
- } else {
- new_flags = vpix->xa_flags;
- hw = vpix->hw;
- }
+ new_flags = (vpix->xa_flags & ~vpix->staging_remove_flags) |
+ vpix->staging_add_flags | XA_FLAG_SHARED;
+ hw = xa_surface_create(vsaa->xat,
+ pixmap->drawable.width,
+ pixmap->drawable.height,
+ 0,
+ xa_type_other,
+ vpix->staging_format,
+ new_flags);
if (hw == NULL)
return FALSE;
diff --git a/vmwgfx/vmwgfx_saa_priv.h b/vmwgfx/vmwgfx_saa_priv.h
index 6ec32e9..507833a 100644
--- a/vmwgfx/vmwgfx_saa_priv.h
+++ b/vmwgfx/vmwgfx_saa_priv.h
@@ -77,8 +77,7 @@ vmwgfx_hw_kill(struct vmwgfx_saa *vsaa,
struct saa_pixmap *spix);
Bool
vmwgfx_create_hw(struct vmwgfx_saa *vsaa,
- PixmapPtr pixmap,
- Bool shared);
+ PixmapPtr pixmap);
/*
@@ -89,8 +88,7 @@ enum xa_formats
vmwgfx_xa_format(enum _PictFormatShort format);
Bool
vmwgfx_hw_validate(PixmapPtr pixmap, RegionPtr region);
-Bool
-vmwgfx_hw_dri2_stage(PixmapPtr pixmap, unsigned int depth);
+
Bool
vmwgfx_hw_accel_stage(PixmapPtr pixmap, unsigned int depth,
uint32_t add_flags, uint32_t remove_flags);
diff --git a/vmwgfx/vmwgfx_xa_surface.c b/vmwgfx/vmwgfx_xa_surface.c
index 38f7473..a30b41c 100644
--- a/vmwgfx/vmwgfx_xa_surface.c
+++ b/vmwgfx/vmwgfx_xa_surface.c
@@ -114,7 +114,7 @@ vmwgfx_xa_format(enum _PictFormatShort format)
/*
* Choose formats and flags for a dri2 surface.
*/
-Bool
+static Bool
vmwgfx_hw_dri2_stage(PixmapPtr pixmap, unsigned int depth)
{
struct vmwgfx_saa_pixmap *vpix = vmwgfx_saa_pixmap(pixmap);
@@ -379,7 +379,7 @@ vmwgfx_hw_commit(PixmapPtr pixmap)
new_flags, 1) != XA_ERR_NONE)
return FALSE;
vpix->xa_flags = new_flags;
- } else if (!vmwgfx_create_hw(vsaa, pixmap, FALSE))
+ } else if (!vmwgfx_create_hw(vsaa, pixmap))
return FALSE;
return TRUE;