gallium: interface changes necessary to implement transform feedback (v5)
[mesa.git] / src / gallium / include / pipe / p_context.h
index 0e53aef6d2e277f318f1e81907920f557b5d737b..de79a9bfff136cdf7f71dd26a2fc7caf4cb784de 100644 (file)
@@ -29,6 +29,8 @@
 #define PIPE_CONTEXT_H
 
 #include "p_compiler.h"
+#include "p_format.h"
+#include "p_video_enums.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -47,18 +49,21 @@ struct pipe_index_buffer;
 struct pipe_query;
 struct pipe_poly_stipple;
 struct pipe_rasterizer_state;
+struct pipe_resolve_info;
 struct pipe_resource;
 struct pipe_sampler_state;
 struct pipe_sampler_view;
 struct pipe_scissor_state;
 struct pipe_shader_state;
 struct pipe_stencil_ref;
-struct pipe_stream_output_state;
-struct pipe_subresource;
+struct pipe_stream_output_target;
 struct pipe_surface;
 struct pipe_vertex_buffer;
 struct pipe_vertex_element;
+struct pipe_video_buffer;
+struct pipe_video_decoder;
 struct pipe_viewport_state;
+union pipe_color_union;
 
 /**
  * Gallium rendering context.  Basically:
@@ -81,11 +86,6 @@ struct pipe_context {
    /*@{*/
    void (*draw_vbo)( struct pipe_context *pipe,
                      const struct pipe_draw_info *info );
-
-   /**
-    * Draw the stream output buffer at index 0
-    */
-   void (*draw_stream_output)( struct pipe_context *pipe, unsigned mode );
    /*@}*/
 
    /**
@@ -174,11 +174,6 @@ struct pipe_context {
    void   (*bind_vertex_elements_state)(struct pipe_context *, void *);
    void   (*delete_vertex_elements_state)(struct pipe_context *, void *);
 
-   void * (*create_stream_output_state)(struct pipe_context *,
-                                        const struct pipe_stream_output_state *);
-   void   (*bind_stream_output_state)(struct pipe_context *, void *);
-   void   (*delete_stream_output_state)(struct pipe_context*, void*);
-
    /*@}*/
 
    /**
@@ -232,12 +227,26 @@ struct pipe_context {
    void (*set_index_buffer)( struct pipe_context *pipe,
                              const struct pipe_index_buffer * );
 
-   void (*set_stream_output_buffers)(struct pipe_context *,
-                                     struct pipe_resource **buffers,
-                                     int *offsets, /*array of offsets
-                                                     from the start of each
-                                                     of the buffers */
-                                     int num_buffers);
+   /*@}*/
+
+   /**
+    * Stream output functions.
+    */
+   /*@{*/
+
+   struct pipe_stream_output_target *(*create_stream_output_target)(
+                        struct pipe_context *,
+                        struct pipe_resource *,
+                        unsigned buffer_offset,
+                        unsigned buffer_size);
+
+   void (*stream_output_target_destroy)(struct pipe_context *,
+                                        struct pipe_stream_output_target *);
+
+   void (*set_stream_output_targets)(struct pipe_context *,
+                              unsigned num_targets,
+                              struct pipe_stream_output_target **targets,
+                              unsigned append_bitmask);
 
    /*@}*/
 
@@ -256,22 +265,18 @@ struct pipe_context {
     */
    void (*resource_copy_region)(struct pipe_context *pipe,
                                 struct pipe_resource *dst,
-                                struct pipe_subresource subdst,
+                                unsigned dst_level,
                                 unsigned dstx, unsigned dsty, unsigned dstz,
                                 struct pipe_resource *src,
-                                struct pipe_subresource subsrc,
-                                unsigned srcx, unsigned srcy, unsigned srcz,
-                                unsigned width, unsigned height);
+                                unsigned src_level,
+                                const struct pipe_box *src_box);
 
    /**
     * Resolve a multisampled resource into a non-multisampled one.
-    * Source and destination must have the same size and same format.
+    * Source and destination must be of the same format.
     */
    void (*resource_resolve)(struct pipe_context *pipe,
-                            struct pipe_resource *dst,
-                            struct pipe_subresource subdst,
-                            struct pipe_resource *src,
-                            struct pipe_subresource subsrc);
+                            const struct pipe_resolve_info *info);
 
    /*@}*/
 
@@ -280,23 +285,23 @@ struct pipe_context {
     * The entire buffers are cleared (no scissor, no colormask, etc).
     *
     * \param buffers  bitfield of PIPE_CLEAR_* values.
-    * \param rgba  pointer to an array of one float for each of r, g, b, a.
+    * \param color  pointer to a union of fiu array for each of r, g, b, a.
     * \param depth  depth clear value in [0,1].
     * \param stencil  stencil clear value
     */
    void (*clear)(struct pipe_context *pipe,
                  unsigned buffers,
-                 const float *rgba,
+                 const union pipe_color_union *color,
                  double depth,
                  unsigned stencil);
 
    /**
     * Clear a color rendertarget surface.
-    * \param rgba  pointer to an array of one float for each of r, g, b, a.
+    * \param color  pointer to an union of fiu array for each of r, g, b, a.
     */
    void (*clear_render_target)(struct pipe_context *pipe,
                                struct pipe_surface *dst,
-                               const float *rgba,
+                               const union pipe_color_union *color,
                                unsigned dstx, unsigned dsty,
                                unsigned width, unsigned height);
 
@@ -314,28 +319,11 @@ struct pipe_context {
                                unsigned dstx, unsigned dsty,
                                unsigned width, unsigned height);
 
-   /** Flush rendering
-    * \param flags  bitmask of PIPE_FLUSH_x tokens)
+   /** Flush draw commands
     */
    void (*flush)( struct pipe_context *pipe,
-                  unsigned flags,
                   struct pipe_fence_handle **fence );
 
-   /**
-    * Check whether a texture is referenced by an unflushed hw command.
-    * The state-tracker uses this function to avoid unnecessary flushes.
-    * It is safe (but wasteful) to always return
-    * PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE.
-    * \param pipe  context whose unflushed hw commands will be checked.
-    * \param texture  texture to check.
-    * \param face  cubemap face. Use 0 for non-cubemap texture.
-    * \param level  mipmap level.
-    * \return mask of PIPE_REFERENCED_FOR_READ/WRITE or PIPE_UNREFERENCED
-    */
-   unsigned int (*is_resource_referenced)(struct pipe_context *pipe,
-                                         struct pipe_resource *texture,
-                                         unsigned face, unsigned level);
-
    /**
     * Create a view on a texture to be used by a shader stage.
     */
@@ -347,6 +335,18 @@ struct pipe_context {
                                 struct pipe_sampler_view *view);
 
 
+   /**
+    * Get a surface which is a "view" into a resource, used by
+    * render target / depth stencil stages.
+    * \param usage  bitmaks of PIPE_BIND_* flags
+    */
+   struct pipe_surface *(*create_surface)(struct pipe_context *ctx,
+                                          struct pipe_resource *resource,
+                                          const struct pipe_surface *templat);
+
+   void (*surface_destroy)(struct pipe_context *ctx,
+                           struct pipe_surface *);
+
    /**
     * Get a transfer object for transferring data to/from a texture.
     *
@@ -354,14 +354,14 @@ struct pipe_context {
     * interleaved with
     */
    struct pipe_transfer *(*get_transfer)(struct pipe_context *,
-                                        struct pipe_resource *resource,
-                                        struct pipe_subresource,
-                                        unsigned usage,  /* a combination of PIPE_TRANSFER_x */
-                                        const struct pipe_box *);
+                                         struct pipe_resource *resource,
+                                         unsigned level,
+                                         unsigned usage,  /* a combination of PIPE_TRANSFER_x */
+                                         const struct pipe_box *);
 
    void (*transfer_destroy)(struct pipe_context *,
-                                struct pipe_transfer *);
-   
+                            struct pipe_transfer *);
+
    void *(*transfer_map)( struct pipe_context *,
                           struct pipe_transfer *transfer );
 
@@ -381,14 +381,44 @@ struct pipe_context {
     * pointer.  XXX: strides??
     */
    void (*transfer_inline_write)( struct pipe_context *,
-                                 struct pipe_resource *,
-                                 struct pipe_subresource,
-                                 unsigned usage, /* a combination of PIPE_TRANSFER_x */
-                                 const struct pipe_box *,
-                                 const void *data,
-                                 unsigned stride,
-                                 unsigned slice_stride);
+                                  struct pipe_resource *,
+                                  unsigned level,
+                                  unsigned usage, /* a combination of PIPE_TRANSFER_x */
+                                  const struct pipe_box *,
+                                  const void *data,
+                                  unsigned stride,
+                                  unsigned layer_stride);
+
+
+   /* Notify a driver that a content of a user buffer has been changed.
+    * The changed range is [offset, offset+size-1].
+    * The new width0 of the buffer is offset+size. */
+   void (*redefine_user_buffer)(struct pipe_context *,
+                                struct pipe_resource *,
+                                unsigned offset,
+                                unsigned size);
+
+   /**
+    * Flush any pending framebuffer writes and invalidate texture caches.
+    */
+   void (*texture_barrier)(struct pipe_context *);
+   
+   /**
+    * Creates a video decoder for a specific video codec/profile
+    */
+   struct pipe_video_decoder *(*create_video_decoder)( struct pipe_context *context,
+                                                       enum pipe_video_profile profile,
+                                                       enum pipe_video_entrypoint entrypoint,
+                                                       enum pipe_video_chroma_format chroma_format,
+                                                       unsigned width, unsigned height, unsigned max_references );
 
+   /**
+    * Creates a video buffer as decoding target
+    */
+   struct pipe_video_buffer *(*create_video_buffer)( struct pipe_context *context,
+                                                     enum pipe_format buffer_format,
+                                                     enum pipe_video_chroma_format chroma_format,
+                                                     unsigned width, unsigned height );
 };