gallium/util: add 1d/2d mipmap generation support
[mesa.git] / src / gallium / auxiliary / util / u_blitter.h
index f316587dea02c19f8e1d868bc38af8ef319d143d..41470d92bba344a972f30b53c3e35188543179ef 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef U_BLITTER_H
 #define U_BLITTER_H
 
+#include "util/u_framebuffer.h"
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
 
@@ -54,13 +55,13 @@ struct blitter_context
     * \param y1      A Y coordinate of the top-left corner.
     * \param x2      An X coordinate of the bottom-right corner.
     * \param y2      A Y coordinate of the bottom-right corner.
-    * \param depth  A depth which the rectangle is rendered at.
+    * \param depth   A depth which the rectangle is rendered at.
     *
     * \param type   Semantics of the attributes "attrib".
     *               If type is UTIL_BLITTER_ATTRIB_NONE, ignore them.
     *               If type is UTIL_BLITTER_ATTRIB_COLOR, the attributes
-    *               make up a constant RGBA color, and should go to the COLOR0
-    *               varying slot of a fragment shader.
+    *               make up a constant RGBA color, and should go
+    *               to the GENERIC0 varying slot of a fragment shader.
     *               If type is UTIL_BLITTER_ATTRIB_TEXCOORD, {a1, a2} and
     *               {a3, a4} specify top-left and bottom-right texture
     *               coordinates of the rectangle, respectively, and should go
@@ -78,6 +79,9 @@ struct blitter_context
                           enum blitter_attrib_type type,
                           const float attrib[4]);
 
+   /* Whether the blitter is running. */
+   boolean running;
+
    /* Private members, really. */
    struct pipe_context *pipe; /**< pipe context */
 
@@ -140,6 +144,10 @@ void util_blitter_clear(struct blitter_context *blitter,
                         const float *rgba,
                         double depth, unsigned stencil);
 
+void util_blitter_clear_depth_custom(struct blitter_context *blitter,
+                                     unsigned width, unsigned height,
+                                     double depth, void *custom_dsa);
+
 /**
  * Copy a block of pixels from one surface to another.
  *
@@ -163,12 +171,11 @@ void util_blitter_clear(struct blitter_context *blitter,
  */
 void util_blitter_copy_region(struct blitter_context *blitter,
                               struct pipe_resource *dst,
-                              struct pipe_subresource subdst,
+                              unsigned dstlevel,
                               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 srclevel,
+                              const struct pipe_box *srcbox,
                               boolean ignore_stencil);
 
 /**
@@ -200,8 +207,11 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
                                       unsigned dstx, unsigned dsty,
                                       unsigned width, unsigned height);
 
-void util_blitter_flush_depth_stencil(struct blitter_context *blitter,
-                                      struct pipe_surface *dstsurf);
+void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
+                                      struct pipe_surface *zsurf,
+                                      struct pipe_surface *cbsurf,
+                                      void *dsa_stage, float depth);
+
 /* The functions below should be used to save currently bound constant state
  * objects inside a driver. The objects are automatically restored at the end
  * of the util_blitter_{clear, copy_region, fill_region} functions and then
@@ -258,45 +268,12 @@ void util_blitter_save_vertex_shader(struct blitter_context *blitter,
    blitter->saved_vs = vs;
 }
 
-/* XXX This should probably be moved elsewhere. */
-static INLINE
-void util_assign_framebuffer_state(struct pipe_framebuffer_state *dst,
-                                   const struct pipe_framebuffer_state *src)
-{
-   unsigned i;
-
-   if (src) {
-      /* Reference all surfaces. */
-      for (i = 0; i < src->nr_cbufs; i++) {
-         pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]);
-      }
-      for (; i < dst->nr_cbufs; i++) {
-         pipe_surface_reference(&dst->cbufs[i], NULL);
-      }
-
-      pipe_surface_reference(&dst->zsbuf, src->zsbuf);
-
-      dst->nr_cbufs = src->nr_cbufs;
-      dst->width = src->width;
-      dst->height = src->height;
-   } else {
-      /* Set all surfaces to NULL. */
-      for (i = 0; i < dst->nr_cbufs; i++) {
-         pipe_surface_reference(&dst->cbufs[i], NULL);
-      }
-
-      pipe_surface_reference(&dst->zsbuf, NULL);
-
-      dst->nr_cbufs = 0;
-   }
-}
-
 static INLINE
 void util_blitter_save_framebuffer(struct blitter_context *blitter,
                                    const struct pipe_framebuffer_state *state)
 {
    blitter->saved_fb_state.nr_cbufs = 0; /* It's ~0 now, meaning it's unsaved. */
-   util_assign_framebuffer_state(&blitter->saved_fb_state, state);
+   util_copy_framebuffer_state(&blitter->saved_fb_state, state);
 }
 
 static INLINE
@@ -345,21 +322,13 @@ util_blitter_save_vertex_buffers(struct blitter_context *blitter,
                                          int num_vertex_buffers,
                                          struct pipe_vertex_buffer *vertex_buffers)
 {
-   unsigned i;
    assert(num_vertex_buffers <= Elements(blitter->saved_vertex_buffers));
 
-   blitter->saved_num_vertex_buffers = num_vertex_buffers;
-
-   for (i = 0; i < num_vertex_buffers; i++) {
-      if (vertex_buffers[i].buffer) {
-         pipe_resource_reference(&blitter->saved_vertex_buffers[i].buffer,
-                                 vertex_buffers[i].buffer);
-      }
-   }
-
-   memcpy(blitter->saved_vertex_buffers,
-          vertex_buffers,
-          num_vertex_buffers * sizeof(struct pipe_vertex_buffer));
+   blitter->saved_num_vertex_buffers = 0;
+   util_copy_vertex_buffers(blitter->saved_vertex_buffers,
+                            (unsigned*)&blitter->saved_num_vertex_buffers,
+                            vertex_buffers,
+                            num_vertex_buffers);
 }
 
 #ifdef __cplusplus