u_blitter: add a msaa parameter to util_blitter_clear
[mesa.git] / src / gallium / drivers / svga / svga_resource_buffer_upload.c
index 93a6dee0724a4204f9731133292d882bc513bc6d..1bb7431abf4e995d838bf1d58e75044cb8c31938 100644 (file)
@@ -183,6 +183,14 @@ svga_buffer_create_host_surface(struct svga_screen *ss,
          sbuf->key.flags = SVGA3D_SURFACE_TRANSFER_FROM_BUFFER;
       }
 
+      if (sbuf->b.b.flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) {
+         /* This surface can be mapped persistently. We use
+          * coherent memory to avoid implementing memory barriers for
+          * persistent non-coherent memory for now.
+          */
+         sbuf->key.coherent = 1;
+      }
+
       sbuf->key.size.width = sbuf->b.b.width0;
       sbuf->key.size.height = 1;
       sbuf->key.size.depth = 1;
@@ -316,6 +324,9 @@ svga_buffer_add_host_surface(struct svga_buffer *sbuf,
    /* add the surface to the surface list */
    LIST_ADD(&bufsurf->list, &sbuf->surfaces);
 
+   /* Set the new bind flags for this buffer resource */
+   sbuf->bind_flags = bind_flags;
+
    return PIPE_OK;
 }
 
@@ -445,6 +456,9 @@ svga_buffer_upload_gb_command(struct svga_context *svga,
    struct pipe_resource *dummy;
    unsigned i;
 
+   if (swc->force_coherent || sbuf->key.coherent)
+      return PIPE_OK;
+
    assert(svga_have_gb_objects(svga));
    assert(numBoxes);
    assert(sbuf->dma.updates == NULL);
@@ -642,7 +656,8 @@ svga_buffer_upload_flush(struct svga_context *svga, struct svga_buffer *sbuf)
    unsigned i;
    struct pipe_resource *dummy;
 
-   if (!sbuf->dma.pending) {
+   if (!sbuf->dma.pending || svga->swc->force_coherent ||
+       sbuf->key.coherent) {
       //debug_printf("no dma pending on buffer\n");
       return;
    }
@@ -656,6 +671,7 @@ svga_buffer_upload_flush(struct svga_context *svga, struct svga_buffer *sbuf)
     */
    if (svga_have_gb_objects(svga)) {
       struct svga_3d_update_gb_image *update = sbuf->dma.updates;
+
       assert(update);
 
       for (i = 0; i < sbuf->map.num_ranges; ++i, ++update) {
@@ -868,6 +884,9 @@ svga_buffer_update_hw(struct svga_context *svga, struct svga_buffer *sbuf,
          memcpy((uint8_t *) map + start, (uint8_t *) sbuf->swbuf + start, len);
       }
 
+      if (svga->swc->force_coherent || sbuf->key.coherent)
+         sbuf->map.num_ranges = 0;
+
       svga_buffer_hw_storage_unmap(svga, sbuf);
 
       /* This user/malloc buffer is now indistinguishable from a gpu buffer */
@@ -1026,6 +1045,8 @@ svga_buffer_handle(struct svga_context *svga, struct pipe_resource *buf,
    }
 
    assert(sbuf->handle);
+   if (svga->swc->force_coherent || sbuf->key.coherent)
+      return sbuf->handle;
 
    if (sbuf->map.num_ranges) {
       if (!sbuf->dma.pending) {