svga: Further cleanup/comment svga buffer code.
[mesa.git] / src / gallium / drivers / svga / svga_screen_buffer.h
index e0e1b22e462495c699a30636d14a08fe230b80f0..044fa0a465b80a4d07bcc87365b7342acdf357db 100644 (file)
@@ -56,35 +56,6 @@ struct svga_buffer_range
 };
 
 
-/**
- * Describe a
- *
- * This holds the information to emit a SVGA3dCmdSurfaceDMA.
- */
-struct svga_buffer_upload
-{
-   /**
-    * Guest memory region.
-    */
-   struct svga_winsys_buffer *buf;
-
-   struct svga_buffer_range ranges[SVGA_BUFFER_MAX_RANGES];
-   unsigned num_ranges;
-
-   SVGA3dSurfaceDMAFlags flags;
-
-   /**
-    * Pointer to the DMA copy box *inside* the command buffer.
-    */
-   SVGA3dCopyBox *boxes;
-
-   /**
-    * Context that has the pending DMA to this buffer.
-    */
-   struct svga_context *svga;
-};
-
-
 /**
  * SVGA pipe buffer.
  */
@@ -110,14 +81,6 @@ struct svga_buffer
     */
    boolean user;
    
-   /**
-    * DMA'ble memory.
-    * 
-    * A piece of GMR memory. It is created when mapping the buffer, and will be
-    * used to upload/download vertex data from the host.
-    */
-   struct svga_buffer_upload hw;
-
    /**
     * Creation key for the host surface handle.
     * 
@@ -134,14 +97,81 @@ struct svga_buffer
     * trying to bind
     */
    struct svga_winsys_surface *handle;
-   
+
+   /**
+    * Information about ongoing and past map operations.
+    */
    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.
+       *
+       * Ranges that were touched by the application and need to be uploaded to
+       * the host.
+       *
+       * This information will be copied into dma.boxes, when emiting the
+       * SVGA3dCmdSurfaceDMA command.
+       */
+      struct svga_buffer_range ranges[SVGA_BUFFER_MAX_RANGES];
+      unsigned num_ranges;
    } map;
-   
-   boolean needs_flush;
+
+   /**
+    * 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.
+    */
+   struct svga_winsys_buffer *hwbuf;
+
+   /**
+    * Information about pending DMA uploads.
+    *
+    */
+   struct {
+      /**
+       * Whether this buffer has an unfinished DMA upload command.
+       *
+       * If not set then the rest of the information is null.
+       */
+      boolean pending;
+
+      SVGA3dSurfaceDMAFlags flags;
+
+      /**
+       * Pointer to the DMA copy box *inside* the command buffer.
+       */
+      SVGA3dCopyBox *boxes;
+
+      /**
+       * Context that has the pending DMA to this buffer.
+       */
+      struct svga_context *svga;
+   } dma;
+
+   /**
+    * Linked list head, used to gather all buffers with pending dma uploads on
+    * a context. It is only valid if the dma.pending is set above.
+    */
    struct list_head head;
 };