svga: Proper redefine_user_buffer implementation.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 16 Feb 2011 21:52:49 +0000 (21:52 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 16 Feb 2011 21:53:10 +0000 (21:53 +0000)
Unfortunately still not enough to make GoogleEarth happy.

src/gallium/drivers/svga/svga_pipe_vertex.c
src/gallium/drivers/svga/svga_resource.c
src/gallium/drivers/svga/svga_resource_buffer.h
src/gallium/drivers/svga/svga_resource_buffer_upload.c

index 6bf37fbbbaf2f0f62dc7ac7ad64484a815184800..58469910732ea9970bfef84f1c223300cfce790a 100644 (file)
@@ -132,7 +132,6 @@ void svga_init_vertex_functions( struct svga_context *svga )
    svga->pipe.create_vertex_elements_state = svga_create_vertex_elements_state;
    svga->pipe.bind_vertex_elements_state = svga_bind_vertex_elements_state;
    svga->pipe.delete_vertex_elements_state = svga_delete_vertex_elements_state;
-   svga->pipe.redefine_user_buffer = u_default_redefine_user_buffer;
 }
 
 
index ef2a0c40f03026eb2377377da7c5860dd41c9f0a..bed15ec02e53f8d128bc7916db7d9e1e1598c0f7 100644 (file)
@@ -40,6 +40,7 @@ svga_init_resource_functions(struct svga_context *svga)
    svga->pipe.transfer_unmap = u_transfer_unmap_vtbl;
    svga->pipe.transfer_destroy = u_transfer_destroy_vtbl;
    svga->pipe.transfer_inline_write = u_transfer_inline_write_vtbl;
+   svga->pipe.redefine_user_buffer = svga_redefine_user_buffer;
 }
 
 void
index d3ec11bfd527af0bef7cc6678c8533b414b88ee3..c559f70ec12430f6d8452e58ed9c0d84f955374e 100644 (file)
@@ -243,4 +243,10 @@ svga_winsys_buffer_create(struct svga_context *svga,
                           unsigned usage,
                           unsigned size);
 
+void
+svga_redefine_user_buffer(struct pipe_context *ctx,
+                          struct pipe_resource *resource,
+                          unsigned offset,
+                          unsigned size);
+
 #endif /* SVGA_BUFFER_H */
index fdc0329f6c9daaf2886d4dde7b47a9680120eb8c..76a3803224a268ea38ce554c6cab3d95dae832d5 100644 (file)
@@ -649,3 +649,54 @@ svga_context_flush_buffers(struct svga_context *svga)
       next = curr->next;
    }
 }
+
+
+void
+svga_redefine_user_buffer(struct pipe_context *pipe,
+                          struct pipe_resource *resource,
+                          unsigned offset,
+                          unsigned size)
+{
+   struct svga_screen *ss = svga_screen(pipe->screen);
+   struct svga_context *svga = svga_context(pipe);
+   struct svga_buffer *sbuf = svga_buffer(resource);
+
+   assert(sbuf->user);
+
+   /*
+    * Release any uploaded user buffer.
+    *
+    * TODO: As an optimization, we could try to update the uploaded buffer
+    * instead.
+    */
+
+   pipe_resource_reference(&sbuf->uploaded.buffer, NULL);
+
+   pipe_mutex_lock(ss->swc_mutex);
+
+   if (offset + size > resource->width0) {
+      /*
+       * User buffers shouldn't have DMA directly, unless
+       * SVGA_COMBINE_USERBUFFERS is not set.
+       */
+
+      if (sbuf->dma.pending) {
+         svga_buffer_upload_flush(svga, sbuf);
+      }
+
+      if (sbuf->handle) {
+         svga_buffer_destroy_host_surface(ss, sbuf);
+      }
+
+      if (sbuf->hwbuf) {
+         svga_buffer_destroy_hw_storage(ss, sbuf);
+      }
+
+      sbuf->key.size.width = sbuf->b.b.width0 = offset + size;
+   }
+
+   pipe_mutex_unlock(ss->swc_mutex);
+
+   svga->curr.any_user_vertex_buffers = TRUE;
+   svga->dirty |= SVGA_NEW_VBUFFER | SVGA_NEW_VELEMENT;
+}