gallium: introduce PIPE_CAP_LOAD_CONSTBUF
[mesa.git] / src / gallium / drivers / i915 / i915_winsys.h
index 246e95b00d6fcfb6af9e0b0e78523316b49811d0..509e6cca13bbb0eabc1b02a897894e3aaf2821fd 100644 (file)
@@ -31,7 +31,7 @@
 struct i915_winsys;
 struct i915_winsys_buffer;
 struct i915_winsys_batchbuffer;
-struct pipe_texture;
+struct pipe_resource;
 struct pipe_fence_handle;
 struct winsys_handle;
 
@@ -53,6 +53,7 @@ enum i915_winsys_buffer_type
    I915_NEW_VERTEX
 };
 
+/* These need to be in sync with the definitions of libdrm-intel! */
 enum i915_winsys_buffer_tile
 {
    I915_TILE_NONE,
@@ -60,6 +61,12 @@ enum i915_winsys_buffer_tile
    I915_TILE_Y
 };
 
+enum i915_winsys_flush_flags
+{
+   I915_FLUSH_ASYNC = 0,
+   I915_FLUSH_END_OF_FRAME = 1
+};
+
 struct i915_winsys_batchbuffer {
 
    struct i915_winsys *iws;
@@ -75,12 +82,13 @@ struct i915_winsys_batchbuffer {
    size_t size;
 
    size_t relocs;
-   size_t max_relocs;
    /*@}*/
 };
 
 struct i915_winsys {
 
+   unsigned pci_id; /**< PCI ID for the device */
+
    /**
     * Batchbuffer functions.
     */
@@ -91,6 +99,18 @@ struct i915_winsys {
    struct i915_winsys_batchbuffer *
       (*batchbuffer_create)(struct i915_winsys *iws);
 
+   /**
+    * Validate buffers for usage in this batchbuffer.
+    * Does space-checking and asorted other book-keeping.
+    *
+    * @batch
+    * @buffers array to buffers to validate
+    * @num_of_buffers size of the passed array
+    */
+   boolean (*validate_buffers)(struct i915_winsys_batchbuffer *batch,
+                              struct i915_winsys_buffer **buffers,
+                              int num_of_buffers);
+
    /**
     * Emit a relocation to a buffer.
     * Target position in batchbuffer is the same as ptr.
@@ -100,17 +120,19 @@ struct i915_winsys {
     * @usage how is the hardware going to use the buffer.
     * @offset add this to the reloc buffers address
     * @target buffer where to write the address, null for batchbuffer.
+    * @fenced relocation needs a fence.
     */
    int (*batchbuffer_reloc)(struct i915_winsys_batchbuffer *batch,
                             struct i915_winsys_buffer *reloc,
                             enum i915_winsys_buffer_usage usage,
-                            unsigned offset);
+                            unsigned offset, boolean fenced);
 
    /**
     * Flush a bufferbatch.
     */
    void (*batchbuffer_flush)(struct i915_winsys_batchbuffer *batch,
-                             struct pipe_fence_handle **fence);
+                             struct pipe_fence_handle **fence,
+                             enum i915_winsys_flush_flags flags);
 
    /**
     * Destroy a batchbuffer.
@@ -128,22 +150,38 @@ struct i915_winsys {
     */
    struct i915_winsys_buffer *
       (*buffer_create)(struct i915_winsys *iws,
-                       unsigned size, unsigned alignment,
+                       unsigned size,
                        enum i915_winsys_buffer_type type);
 
+   /**
+    * Create a tiled buffer.
+    *
+    * *stride, height are in bytes. The winsys tries to allocate the buffer with
+    * the tiling mode provide in *tiling. If tiling is no possible, *tiling will
+    * be set to I915_TILE_NONE. The calculated stride (incorporateing hw/kernel
+    * requirements) is always returned in *stride.
+    */
+   struct i915_winsys_buffer *
+      (*buffer_create_tiled)(struct i915_winsys *iws,
+                             unsigned *stride, unsigned height,
+                             enum i915_winsys_buffer_tile *tiling,
+                             enum i915_winsys_buffer_type type);
+
    /**
     * Creates a buffer from a handle.
-    * Used to implement pipe_screen::texture_from_handle.
+    * Used to implement pipe_screen::resource_from_handle.
     * Also provides the stride information needed for the
     * texture via the stride argument.
     */
    struct i915_winsys_buffer *
       (*buffer_from_handle)(struct i915_winsys *iws,
                             struct winsys_handle *whandle,
+                            unsigned height,
+                            enum i915_winsys_buffer_tile *tiling,
                             unsigned *stride);
 
    /**
-    * Used to implement pipe_screen::texture_get_handle.
+    * Used to implement pipe_screen::resource_get_handle.
     * The winsys might need the stride information.
     */
    boolean (*buffer_get_handle)(struct i915_winsys *iws,
@@ -151,15 +189,6 @@ struct i915_winsys {
                                 struct winsys_handle *whandle,
                                 unsigned stride);
 
-   /**
-    * Fence a buffer with a fence reg.
-    * Not to be confused with pipe_fence_handle.
-    */
-   int (*buffer_set_fence_reg)(struct i915_winsys *iws,
-                               struct i915_winsys_buffer *buffer,
-                               unsigned stride,
-                               enum i915_winsys_buffer_tile tile);
-
    /**
     * Map a buffer.
     */
@@ -186,6 +215,12 @@ struct i915_winsys {
 
    void (*buffer_destroy)(struct i915_winsys *iws,
                           struct i915_winsys_buffer *buffer);
+
+   /**
+    * Check if a buffer is busy.
+    */
+   boolean (*buffer_is_busy)(struct i915_winsys *iws,
+                             struct i915_winsys_buffer *buffer);
    /*@}*/
 
 
@@ -213,6 +248,11 @@ struct i915_winsys {
                        struct pipe_fence_handle *fence);
    /*@}*/
 
+   /**
+    * Retrieve the aperture size (in MiB) of the device.
+    */
+   int (*aperture_size)(struct i915_winsys *iws);
+
 
    /**
     * Destroy the winsys.
@@ -220,11 +260,4 @@ struct i915_winsys {
    void (*destroy)(struct i915_winsys *iws);
 };
 
-
-/**
- * Create i915 pipe_screen.
- */
-struct pipe_screen *i915_create_screen(struct i915_winsys *iws, unsigned pci_id);
-
-
 #endif