Merge branch 'gallium-newclear'
[mesa.git] / src / gallium / auxiliary / util / u_blitter.c
index d05a193bf8d7974dc72953a0a6eb2f242b9b8028..183ffe5670ff01dcbd0fab4b6f9e3567f43f0ad2 100644 (file)
@@ -26,7 +26,7 @@
 
 /**
  * @file
- * Blitter utility to facilitate acceleration of the clear, clearRT, clearDS
+ * Blitter utility to facilitate acceleration of the clear, clear_render_target, clear_depth_stencil
  * resource_copy_region functions.
  *
  * @author Marek Olšák
@@ -522,6 +522,26 @@ void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs)
    return ctx->fs_col[num_cbufs];
 }
 
+/** Convert PIPE_TEXTURE_x to TGSI_TEXTURE_x */
+static unsigned
+pipe_tex_to_tgsi_tex(unsigned pipe_tex_target)
+{
+   switch (pipe_tex_target) {
+   case PIPE_TEXTURE_1D:
+      return TGSI_TEXTURE_1D;
+   case PIPE_TEXTURE_2D:
+      return TGSI_TEXTURE_2D;
+   case PIPE_TEXTURE_3D:
+      return TGSI_TEXTURE_3D;
+   case PIPE_TEXTURE_CUBE:
+      return TGSI_TEXTURE_CUBE;
+   default:
+      assert(0 && "unexpected texture target");
+      return TGSI_TEXTURE_UNKNOWN;
+   }
+}
+
+
 static INLINE
 void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx,
                                   unsigned tex_target)
@@ -532,25 +552,10 @@ void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx,
 
    /* Create the fragment shader on-demand. */
    if (!ctx->fs_texfetch_col[tex_target]) {
-      switch (tex_target) {
-         case PIPE_TEXTURE_2D:
-            ctx->fs_texfetch_col[PIPE_TEXTURE_2D] =
-               util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
-            break;
-         case PIPE_TEXTURE_3D:
-            ctx->fs_texfetch_col[PIPE_TEXTURE_3D] =
-               util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_3D);
-            break;
-         case PIPE_TEXTURE_CUBE:
-            ctx->fs_texfetch_col[PIPE_TEXTURE_CUBE] =
-               util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE);
-            break;
-         case PIPE_TEXTURE_1D:
-         default:
-            ctx->fs_texfetch_col[PIPE_TEXTURE_1D] =
-               util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_1D);
-            tex_target = PIPE_TEXTURE_1D; /* for the default case */
-      }
+      unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target);
+
+      ctx->fs_texfetch_col[tex_target] =
+        util_make_fragment_tex_shader(pipe, tgsi_tex, TGSI_INTERPOLATE_LINEAR);
    }
 
    return ctx->fs_texfetch_col[tex_target];
@@ -566,25 +571,11 @@ void *blitter_get_fs_texfetch_depth(struct blitter_context_priv *ctx,
 
    /* Create the fragment shader on-demand. */
    if (!ctx->fs_texfetch_depth[tex_target]) {
-      switch (tex_target) {
-         case PIPE_TEXTURE_2D:
-            ctx->fs_texfetch_depth[PIPE_TEXTURE_2D] =
-               util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_2D);
-            break;
-         case PIPE_TEXTURE_3D:
-            ctx->fs_texfetch_depth[PIPE_TEXTURE_3D] =
-               util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_3D);
-            break;
-         case PIPE_TEXTURE_CUBE:
-            ctx->fs_texfetch_depth[PIPE_TEXTURE_CUBE] =
-               util_make_fragment_tex_shader_writedepth(pipe,TGSI_TEXTURE_CUBE);
-            break;
-         case PIPE_TEXTURE_1D:
-         default:
-            ctx->fs_texfetch_depth[PIPE_TEXTURE_1D] =
-               util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_1D);
-            tex_target = PIPE_TEXTURE_1D; /* for the default case */
-      }
+      unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target);
+
+      ctx->fs_texfetch_depth[tex_target] =
+         util_make_fragment_tex_shader_writedepth(pipe, tgsi_tex,
+                                                  TGSI_INTERPOLATE_LINEAR);
    }
 
    return ctx->fs_texfetch_depth[tex_target];
@@ -781,11 +772,11 @@ void util_blitter_copy_region(struct blitter_context *blitter,
 }
 
 /* Clear a region of a color surface to a constant value. */
-void util_blitter_clearRT(struct blitter_context *blitter,
-                          struct pipe_surface *dstsurf,
-                          const float *rgba,
-                          unsigned dstx, unsigned dsty,
-                          unsigned width, unsigned height)
+void util_blitter_clear_render_target(struct blitter_context *blitter,
+                                      struct pipe_surface *dstsurf,
+                                      const float *rgba,
+                                      unsigned dstx, unsigned dsty,
+                                      unsigned width, unsigned height)
 {
    struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
    struct pipe_context *pipe = ctx->pipe;
@@ -822,13 +813,13 @@ void util_blitter_clearRT(struct blitter_context *blitter,
 }
 
 /* Clear a region of a depth stencil surface. */
-void util_blitter_clearDS(struct blitter_context *blitter,
-                          struct pipe_surface *dstsurf,
-                          unsigned clear_flags,
-                          double depth,
-                          unsigned stencil,
-                          unsigned dstx, unsigned dsty,
-                          unsigned width, unsigned height)
+void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
+                                      struct pipe_surface *dstsurf,
+                                      unsigned clear_flags,
+                                      double depth,
+                                      unsigned stencil,
+                                      unsigned dstx, unsigned dsty,
+                                      unsigned width, unsigned height)
 {
    struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
    struct pipe_context *pipe = ctx->pipe;