svga: Handle null buffers in svga_buffer_is_user_buffer().
[mesa.git] / src / gallium / drivers / svga / svga_resource_buffer.h
index a689fcb3bb7925518efc948c56284bec9669d545..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;
 
@@ -129,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;
 
@@ -189,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;
+   }
 }