diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2011-06-21 00:13:32 +0200 |
---|---|---|
committer | Thomas Hellstrom <thellstrom@vmware.com> | 2011-06-22 22:37:00 +0200 |
commit | 3650be74d5da602653b2b1d3cf3a6bb5a9cb3539 (patch) | |
tree | 0b810ae23c7a2c9f84c4f84563d3b3c18fffb404 | |
parent | 63d7ddb35fe8b6743de182b73e6967f97f6a7eba (diff) |
vmwgfx: Try to match created hardware formats with the dri state tracker.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | vmwgfx/vmwgfx_dri2.c | 64 | ||||
-rw-r--r-- | vmwgfx/vmwgfx_saa.c | 53 | ||||
-rw-r--r-- | vmwgfx/vmwgfx_saa.h | 1 | ||||
-rw-r--r-- | vmwgfx/vmwgfx_tex_video.c | 2 |
5 files changed, 98 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac index 1f060ae..da140bf 100644 --- a/configure.ac +++ b/configure.ac @@ -115,7 +115,7 @@ AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes) AC_SUBST([moduledir]) if test x$BUILD_VMWGFX = xyes; then - PKG_CHECK_MODULES([XATRACKER], [xatracker >= 0.1.0],[],[BUILD_VMWGFX=no]) + PKG_CHECK_MODULES([XATRACKER], [xatracker >= 0.2.0],[],[BUILD_VMWGFX=no]) fi DRIVER_NAME=vmware diff --git a/vmwgfx/vmwgfx_dri2.c b/vmwgfx/vmwgfx_dri2.c index 1529cdb..07d538f 100644 --- a/vmwgfx/vmwgfx_dri2.c +++ b/vmwgfx/vmwgfx_dri2.c @@ -50,6 +50,32 @@ typedef struct { struct xa_surface *srf; } *BufferPrivatePtr; + +/* + * Attempt to guess what the dri state tracker is up to. + * Currently it sends only bpp as format. + */ + +static unsigned int +vmwgfx_color_format_to_depth(unsigned int format) +{ + return format; +} + +static unsigned int +vmwgfx_zs_format_to_depth(unsigned int format) +{ + if (format == 24) + return 32; + return format; +} + +static unsigned int +vmwgfx_z_format_to_depth(unsigned int format) +{ + return format; +} + static Bool dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int format) { @@ -60,7 +86,8 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for PixmapPtr pPixmap; struct vmwgfx_saa_pixmap *vpix; struct xa_surface *srf = NULL; - unsigned int cpp = 4; + unsigned int depth; + if (pDraw->type == DRAWABLE_PIXMAP) pPixmap = (PixmapPtr) pDraw; @@ -72,13 +99,16 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for switch (buffer->attachment) { default: + depth = (format) ? vmwgfx_color_format_to_depth(format) : + pDraw->depth; + if (buffer->attachment != DRI2BufferFakeFrontLeft || &pPixmap->drawable != pDraw) { pPixmap = (*pScreen->CreatePixmap)(pScreen, pDraw->width, pDraw->height, - pDraw->depth, + depth, 0); if (pPixmap == NullPixmap) return FALSE; @@ -92,10 +122,10 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for break; buffer->name = 0; buffer->pitch = 0; - buffer->cpp = cpp; + buffer->cpp = pDraw->bitsPerPixel / 8; buffer->driverPrivate = private; buffer->flags = 0; /* not tiled */ - buffer->format = 0; + buffer->format = pDraw->bitsPerPixel; if (!private->pPixmap) { private->pPixmap = pPixmap; pPixmap->refcnt++; @@ -103,20 +133,25 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for return TRUE; case DRI2BufferStencil: case DRI2BufferDepthStencil: + + depth = (format) ? vmwgfx_zs_format_to_depth(format) : 32; + + /* + * The SVGA device uses the zs ordering. + */ + srf = xa_surface_create(ms->xat, pDraw->width, pDraw->height, - 32, xa_type_zs, xa_format_unknown, + depth, xa_type_zs, xa_format_unknown, XA_FLAG_SHARED ); if (!srf) - srf = xa_surface_create(ms->xat, pDraw->width, pDraw->height, - 32, xa_type_sz, xa_format_unknown, - XA_FLAG_SHARED ); - if (!srf) return FALSE; - break; + break; case DRI2BufferDepth: + depth = (format) ? vmwgfx_z_format_to_depth(format) : + pDraw->bitsPerPixel; srf = xa_surface_create(ms->xat, pDraw->width, pDraw->height, - (format) ? format: pDraw->depth, + depth, xa_type_z, xa_format_unknown, XA_FLAG_SHARED); if (!srf) @@ -130,7 +165,9 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for } if (!srf) { - if (!vmwgfx_pixmap_validate_hw(pPixmap, NULL, + depth = (format) ? vmwgfx_color_format_to_depth(format) : + pDraw->depth; + if (!vmwgfx_pixmap_validate_hw(pPixmap, NULL, depth, XA_FLAG_SHARED | XA_FLAG_RENDER_TARGET, 0)) return FALSE; @@ -149,7 +186,7 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for if (xa_surface_handle(srf, &buffer->name, &buffer->pitch) != 0) return FALSE; - buffer->cpp = cpp; + buffer->cpp = xa_format_depth(xa_surface_format(srf)) / 8; buffer->driverPrivate = private; buffer->flags = 0; /* not tiled */ buffer->format = format; @@ -273,6 +310,7 @@ dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion, pDestBuffer->attachment == DRI2BufferFakeFrontLeft) { LogMessage(X_INFO, "dri2 Validate hw.\n"); vmwgfx_pixmap_validate_hw(src_priv->pPixmap, NULL, + 0, XA_FLAG_SHARED | XA_FLAG_RENDER_TARGET, 0); return; diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c index ad7f8b1..297e1f3 100644 --- a/vmwgfx/vmwgfx_saa.c +++ b/vmwgfx/vmwgfx_saa.c @@ -63,6 +63,30 @@ to_vmwgfx_saa(struct saa_driver *driver) { return (struct vmwgfx_saa *) driver; } +static enum xa_formats +vmwgfx_choose_xa_format(unsigned int depth) +{ + /* + * For a given depth, choose the same format as the + * dri state tracker. + */ + + switch(depth) { + case 32: + case 24: /* The dri state tracker never uses 24. */ + return xa_format_a8r8g8b8; + case 16: + return xa_format_r5g6b5; + case 15: /* No dri. */ + return xa_format_x1r5g5b5; + default: + break; + } + + return xa_format_unknown; +} + + static Bool vmwgfx_pixmap_add_damage(PixmapPtr pixmap) { @@ -515,7 +539,8 @@ vmwgfx_destroy_pixmap(struct saa_driver *driver, PixmapPtr pixmap) static Bool vmwgfx_pixmap_create_hw(struct vmwgfx_saa *vsaa, - PixmapPtr pixmap, unsigned int flags) + PixmapPtr pixmap, unsigned int depth, + unsigned int flags) { struct vmwgfx_saa_pixmap *vpix = vmwgfx_saa_pixmap(pixmap); struct xa_surface *hw; @@ -526,11 +551,15 @@ vmwgfx_pixmap_create_hw(struct vmwgfx_saa *vsaa, if (vpix->hw) return TRUE; + if (!depth) + depth = pixmap->drawable.depth; + hw = xa_surface_create(vsaa->xat, pixmap->drawable.width, pixmap->drawable.height, - pixmap->drawable.depth, - xa_type_argb, xa_format_unknown, + depth, + xa_type_argb, + vmwgfx_choose_xa_format(depth), XA_FLAG_RENDER_TARGET | flags); if (hw == NULL) return FALSE; @@ -562,6 +591,7 @@ out_no_damage: Bool vmwgfx_pixmap_validate_hw(PixmapPtr pixmap, RegionPtr region, + unsigned int depth, unsigned int add_flags, unsigned int remove_flags) { @@ -575,15 +605,19 @@ vmwgfx_pixmap_validate_hw(PixmapPtr pixmap, RegionPtr region, return FALSE; if (vpix->hw) { + if (!depth) + depth = pixmap->drawable.depth; + if (xa_surface_redefine(vpix->hw, pixmap->drawable.width, pixmap->drawable.height, - pixmap->drawable.depth, - xa_type_argb, xa_format_unknown, + depth, + xa_type_argb, + vmwgfx_choose_xa_format(depth), XA_FLAG_RENDER_TARGET | add_flags, remove_flags, 1) != 0) return FALSE; - } else if (!vmwgfx_pixmap_create_hw(vsaa, pixmap, add_flags)) + } else if (!vmwgfx_pixmap_create_hw(vsaa, pixmap, depth, add_flags)) return FALSE; @@ -864,7 +898,7 @@ vmwgfx_copy_prepare(struct saa_driver *driver, return FALSE; if (vmwgfx_present_prepare(vsaa, src_vpix, dst_vpix)) { - if (!vmwgfx_pixmap_validate_hw(src_pixmap, src_reg, 0, 0)) + if (!vmwgfx_pixmap_validate_hw(src_pixmap, src_reg, 0, 0, 0)) return FALSE; vsaa->present_copy = TRUE; return TRUE; @@ -883,9 +917,10 @@ vmwgfx_copy_prepare(struct saa_driver *driver, if (!has_dirty_hw && !(has_valid_hw && (dst_vpix->hw != NULL))) return FALSE; - if (!vmwgfx_pixmap_validate_hw(src_pixmap, src_reg, 0, 0)) + if (!vmwgfx_pixmap_validate_hw(src_pixmap, src_reg, 0, 0, 0)) return FALSE; - if (!vmwgfx_pixmap_create_hw(vsaa, dst_pixmap, XA_FLAG_RENDER_TARGET)) + if (!vmwgfx_pixmap_create_hw(vsaa, dst_pixmap, 0, + XA_FLAG_RENDER_TARGET)) return FALSE; if (xa_copy_prepare(vsaa->xa_ctx, dst_vpix->hw, src_vpix->hw) == 0) diff --git a/vmwgfx/vmwgfx_saa.h b/vmwgfx/vmwgfx_saa.h index 90fa728..29863c5 100644 --- a/vmwgfx/vmwgfx_saa.h +++ b/vmwgfx/vmwgfx_saa.h @@ -69,6 +69,7 @@ to_vmwgfx_saa_pixmap(struct saa_pixmap *spix) extern Bool vmwgfx_pixmap_validate_hw(PixmapPtr pixmap, RegionPtr region, + unsigned int depth, unsigned int add_flags, unsigned int remove_flags); diff --git a/vmwgfx/vmwgfx_tex_video.c b/vmwgfx/vmwgfx_tex_video.c index fb8f41e..c357f06 100644 --- a/vmwgfx/vmwgfx_tex_video.c +++ b/vmwgfx/vmwgfx_tex_video.c @@ -455,7 +455,7 @@ display_video(ScreenPtr pScreen, struct xorg_xv_port_priv *pPriv, int id, REGION_NULL(pScreen, ®); - if (!vmwgfx_pixmap_validate_hw(pPixmap, ®, XA_FLAG_RENDER_TARGET, 0)) + if (!vmwgfx_pixmap_validate_hw(pPixmap, ®, 0, XA_FLAG_RENDER_TARGET, 0)) goto out_no_dst; hdtv = ((src_w >= RES_720P_X) && (src_h >= RES_720P_Y)); |