svga->hud.num_buffers_mapped++;
if (sws->have_gb_objects) {
- return svga->swc->surface_map(svga->swc, sbuf->handle, flags, retry);
+ struct svga_winsys_context *swc = svga->swc;
+ boolean rebind;
+ void *map;
+
+ map = swc->surface_map(swc, sbuf->handle, flags, retry, &rebind);
+ if (map && rebind) {
+ enum pipe_error ret;
+
+ ret = SVGA3D_BindGBSurface(swc, sbuf->handle);
+ if (ret != PIPE_OK) {
+ svga_context_flush(svga, NULL);
+ ret = SVGA3D_BindGBSurface(swc, sbuf->handle);
+ assert(ret == PIPE_OK);
+ }
+ svga_context_flush(svga, NULL);
+ }
+ return map;
} else {
*retry = FALSE;
return sws->buffer_map(sws, sbuf->hwbuf, flags);
{
SVGA3dSize baseLevelSize;
uint8_t *map;
- boolean retry;
+ boolean retry, rebind;
unsigned offset, mip_width, mip_height;
+ struct svga_winsys_context *swc = svga->swc;
- map = svga->swc->surface_map(svga->swc, surf, usage, &retry);
+ map = swc->surface_map(swc, surf, usage, &retry, &rebind);
if (map == NULL && retry) {
/*
* At this point, the svga_surfaces_flush() should already have
*/
svga->hud.surface_write_flushes++;
svga_context_flush(svga, NULL);
- map = svga->swc->surface_map(svga->swc, surf, usage, &retry);
+ map = swc->surface_map(swc, surf, usage, &retry, &rebind);
+ }
+ if (map && rebind) {
+ enum pipe_error ret;
+
+ ret = SVGA3D_BindGBSurface(swc, surf);
+ if (ret != PIPE_OK) {
+ svga_context_flush(svga, NULL);
+ ret = SVGA3D_BindGBSurface(swc, surf);
+ assert(ret == PIPE_OK);
+ }
+ svga_context_flush(svga, NULL);
}
/*
/**
* Map a guest-backed surface.
+ * \param swc The winsys context
+ * \param surface The surface to map
* \param flags bitmaks of PIPE_TRANSFER_x flags
+ * \param retry Whether to flush and retry the map
+ * \param rebind Whether to issue an immediate rebind and flush.
*
* The surface_map() member is allowed to fail due to a
* shortage of command buffer space, if the
void *
(*surface_map)(struct svga_winsys_context *swc,
struct svga_winsys_surface *surface,
- unsigned flags, boolean *retry);
+ unsigned flags, boolean *retry,
+ boolean *rebind);
/**
* Unmap a guest-backed surface.
void *
vmw_svga_winsys_surface_map(struct svga_winsys_context *swc,
struct svga_winsys_surface *srf,
- unsigned flags, boolean *retry)
+ unsigned flags, boolean *retry,
+ boolean *rebind)
{
struct vmw_svga_winsys_surface *vsrf = vmw_svga_winsys_surface(srf);
void *data = NULL;
struct vmw_winsys_screen *vws = vsrf->screen;
*retry = FALSE;
+ *rebind = FALSE;
assert((flags & (PIPE_TRANSFER_READ | PIPE_TRANSFER_WRITE)) != 0);
mtx_lock(&vsrf->mutex);
if (vsrf->buf)
vmw_svga_winsys_buffer_destroy(&vws->base, vsrf->buf);
vsrf->buf = vbuf;
+
+ /* Rebind persistent maps immediately */
+ if (flags & PIPE_TRANSFER_PERSISTENT) {
+ *rebind = TRUE;
+ vsrf->rebind = FALSE;
+ }
goto out_mapped;
} else
vmw_svga_winsys_buffer_destroy(&vws->base, vbuf);
struct vmw_svga_winsys_surface *src);
void *
vmw_svga_winsys_surface_map(struct svga_winsys_context *swc,
- struct svga_winsys_surface *srf,
- unsigned flags, boolean *retry);
+ struct svga_winsys_surface *srf,
+ unsigned flags, boolean *retry,
+ boolean *rebind);
void
vmw_svga_winsys_surface_unmap(struct svga_winsys_context *swc,
struct svga_winsys_surface *srf,