st/xorg: flush after loading the cursor
[mesa.git] / src / gallium / state_trackers / xorg / xorg_xv.c
index a221594454e79baabf0358618fa897558d27c3a1..234574b968eb88a55a31ade5c83df3364726c746 100644 (file)
@@ -171,6 +171,7 @@ create_component_texture(struct pipe_context *pipe,
    templ.width0 = width;
    templ.height0 = height;
    templ.depth0 = 1;
+   templ.array_size = 1;
    templ.bind = PIPE_BIND_SAMPLER_VIEW;
 
    tex = screen->resource_create(screen, &templ);
@@ -312,17 +313,17 @@ copy_packed_data(ScrnInfoPtr pScrn,
    int y_array_size = w * h;
 
    ytrans = pipe_get_transfer(pipe, dst[0],
-                                   0, 0, 0,
-                                   PIPE_TRANSFER_WRITE,
-                                   left, top, w, h);
+                              0, 0,
+                              PIPE_TRANSFER_WRITE,
+                              left, top, w, h);
    utrans = pipe_get_transfer(pipe, dst[1],
-                                   0, 0, 0,
-                                   PIPE_TRANSFER_WRITE,
-                                   left, top, w, h);
+                              0, 0,
+                              PIPE_TRANSFER_WRITE,
+                              left, top, w, h);
    vtrans = pipe_get_transfer(pipe, dst[2],
-                                   0, 0, 0,
-                                   PIPE_TRANSFER_WRITE,
-                                   left, top, w, h);
+                              0, 0,
+                              PIPE_TRANSFER_WRITE,
+                              left, top, w, h);
 
    ymap = (char*)pipe->transfer_map(pipe, ytrans);
    umap = (char*)pipe->transfer_map(pipe, utrans);
@@ -413,7 +414,7 @@ setup_fs_video_constants(struct xorg_renderer *r, boolean hdtv)
 
 static void
 draw_yuv(struct xorg_xv_port_priv *port,
-         int src_x, int src_y, int src_w, int src_h,
+         float src_x, float src_y, float src_w, float src_h,
          int dst_x, int dst_y, int dst_w, int dst_h)
 {
    struct pipe_resource **textures = port->yuv[port->current_set];
@@ -460,20 +461,6 @@ bind_shaders(struct xorg_xv_port_priv *port)
    cso_set_fragment_shader_handle(port->r->cso, shader.fs);
 }
 
-static INLINE void
-conditional_flush(struct pipe_context *pipe, struct pipe_resource **tex,
-                  int num)
-{
-   int i;
-   for (i = 0; i < num; ++i) {
-      if (tex[i] && pipe->is_resource_referenced(pipe, tex[i], 0, 0) &
-          PIPE_REFERENCED_FOR_WRITE) {
-         pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
-         return;
-      }
-   }
-}
-
 static void
 bind_samplers(struct xorg_xv_port_priv *port)
 {
@@ -484,8 +471,6 @@ bind_samplers(struct xorg_xv_port_priv *port)
 
    memset(&sampler, 0, sizeof(struct pipe_sampler_state));
 
-   conditional_flush(port->r->pipe, dst, 3);
-
    sampler.wrap_s = PIPE_TEX_WRAP_CLAMP;
    sampler.wrap_t = PIPE_TEX_WRAP_CLAMP;
    sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
@@ -533,11 +518,13 @@ display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
    if (!dst || !dst->tex)
       XORG_FALLBACK("Xv destination %s", !dst ? "!dst" : "!dst->tex");
 
-   dst_surf = xorg_gpu_surface(pPriv->r->pipe->screen, dst);
+   dst_surf = xorg_gpu_surface(pPriv->r->pipe, dst);
    hdtv = ((src_w >= RES_720P_X) && (src_h >= RES_720P_Y));
 
+#ifdef COMPOSITE
    REGION_TRANSLATE(pScrn->pScreen, dstRegion, -pPixmap->screen_x,
                     -pPixmap->screen_y);
+#endif
 
    dxo = dstRegion->extents.x1;
    dyo = dstRegion->extents.y1;
@@ -562,10 +549,15 @@ display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
       int box_y2 = pbox->y2;
       float diff_x = (float)src_w / (float)dst_w;
       float diff_y = (float)src_h / (float)dst_h;
-      int offset_x = box_x1 - dstX + pPixmap->screen_x;
-      int offset_y = box_y1 - dstY + pPixmap->screen_y;
-      int offset_w;
-      int offset_h;
+      float offset_x = box_x1 - dstX;
+      float offset_y = box_y1 - dstY;
+      float offset_w;
+      float offset_h;
+
+#ifdef COMPOSITE
+      offset_x += pPixmap->screen_x;
+      offset_y += pPixmap->screen_y;
+#endif
 
       x = box_x1;
       y = box_y1;
@@ -576,8 +568,8 @@ display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
       offset_h = dst_h - h;
 
       draw_yuv(pPriv,
-               src_x + offset_x*diff_x, src_y + offset_y*diff_y,
-               src_w - offset_w*diff_x, src_h - offset_h*diff_y,
+               (float) src_x + offset_x*diff_x, (float) src_y + offset_y*diff_y,
+               (float) src_w - offset_w*diff_x, (float) src_h - offset_h*diff_y,
                x, y, w, h);
 
       pbox++;