svga: Handle null buffers in svga_buffer_is_user_buffer().
[mesa.git] / src / gallium / drivers / svga / svga_resource_buffer.h
index d3ec11bfd527af0bef7cc6678c8533b414b88ee3..69d6f72a11c0ae6e9f2106e0b83c8cf22104fa2a 100644 (file)
@@ -90,7 +90,9 @@ struct svga_buffer
     * Host surface handle.
     * 
     * This is a platform independent abstraction for host SID. We create when 
-    * trying to bind
+    * trying to bind.
+    *
+    * Only set for non-user buffers.
     */
    struct svga_winsys_surface *handle;
 
@@ -100,23 +102,9 @@ struct svga_buffer
    struct {
       /**
        * Number of concurrent mappings.
-       *
-       * XXX: It is impossible to guarantee concurrent maps work in all
-       * circumstances -- pipe_buffers really need transfer objects too.
        */
       unsigned count;
 
-      /**
-       * Whether this buffer is currently mapped for writing.
-       */
-      boolean writing;
-
-      /**
-       * Whether the application will tell us explicity which ranges it touched
-       * or not.
-       */
-      boolean flush_explicit;
-
       /**
        * Dirty ranges.
        *
@@ -143,12 +131,21 @@ struct svga_buffer
       unsigned offset;
    } uploaded;
 
+   /**
+    * For user buffers, this is the offset to the data about to be
+    * referenced by the next draw command, and hence the data that needs
+    * to be uploaded.
+    */
+   unsigned source_offset;
+
    /**
     * DMA'ble memory.
     *
     * A piece of GMR memory, with the same size of the buffer. It is created
     * when mapping the buffer, and will be used to upload vertex data to the
     * host.
+    *
+    * Only set for non-user buffers.
     */
    struct svga_winsys_buffer *hwbuf;
 
@@ -203,7 +200,11 @@ svga_buffer(struct pipe_resource *buffer)
 static INLINE boolean 
 svga_buffer_is_user_buffer( struct pipe_resource *buffer )
 {
-   return svga_buffer(buffer)->user;
+   if (buffer) {
+      return svga_buffer(buffer)->user;
+   } else {
+      return FALSE;
+   }
 }
 
 
@@ -243,4 +244,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 */