[Mesa-dev] [PATCH 2/9] util/blitter: add clamping during SINT <-> UINT blits

Nicolai Hähnle nhaehnle at gmail.com
Wed Nov 9 15:01:50 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Even though glBlitFramebuffer cannot be used for SINT <-> UINT blits, we
still need to handle this type of blit here because it can happen as part
of texture uploads / downloads, e.g. uploading a GL_RGBA8I texture from
GL_UNSIGNED_INT data.

Fixes parts of GL45-CTS.gtf32.GL3Tests.packed_pixels.packed_pixels.
---
 src/gallium/auxiliary/util/u_blit.c           |  4 +-
 src/gallium/auxiliary/util/u_blitter.c        | 73 +++++++++++++++++-------
 src/gallium/auxiliary/util/u_simple_shaders.c | 80 +++++++++++++++++++++------
 src/gallium/auxiliary/util/u_simple_shaders.h |  9 ++-
 src/gallium/auxiliary/util/u_tests.c          |  1 +
 src/gallium/tests/trivial/quad-tex.c          |  1 +
 6 files changed, 125 insertions(+), 43 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index fbc9c77..6d8178e 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -173,25 +173,27 @@ set_fragment_shader(struct blit_state *ctx, uint writemask,
       stype = TGSI_RETURN_TYPE_SINT;
       idx = 1;
    } else {
       stype = TGSI_RETURN_TYPE_FLOAT;
       idx = 2;
    }
 
    if (!ctx->fs[pipe_tex][writemask][idx]) {
       unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex, 0);
 
+      /* OpenGL does not allow blits from signed to unsigned integer
+       * or vice versa. */
       ctx->fs[pipe_tex][writemask][idx] =
          util_make_fragment_tex_shader_writemask(ctx->pipe, tgsi_tex,
                                                  TGSI_INTERPOLATE_LINEAR,
                                                  writemask,
-                                                 stype);
+                                                 stype, stype);
    }
 
    cso_set_fragment_shader_handle(ctx->cso, ctx->fs[pipe_tex][writemask][idx]);
 }
 
 
 /**
  * Helper function to set the vertex shader.
  */
 static inline void
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index eb3a97d..98b5421 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -71,32 +71,33 @@ struct blitter_context_priv
    /* Vertex shaders. */
    void *vs; /**< Vertex shader which passes {pos, generic} to the output.*/
    void *vs_pos_only[4]; /**< Vertex shader which passes pos to the output.*/
    void *vs_layered; /**< Vertex shader which sets LAYER = INSTANCEID. */
 
    /* Fragment shaders. */
    void *fs_empty;
    void *fs_write_one_cbuf;
    void *fs_write_all_cbufs;
 
-   /* FS which outputs a color from a texture,
-      where the index is PIPE_TEXTURE_* to be sampled. */
-   void *fs_texfetch_col[3][PIPE_MAX_TEXTURE_TYPES];
+   /* FS which outputs a color from a texture.
+    * The first index indicates the texture type / destination type,
+    * the second index is the PIPE_TEXTURE_* to be sampled. */
+   void *fs_texfetch_col[5][PIPE_MAX_TEXTURE_TYPES];
 
    /* FS which outputs a depth from a texture,
       where the index is PIPE_TEXTURE_* to be sampled. */
    void *fs_texfetch_depth[PIPE_MAX_TEXTURE_TYPES];
    void *fs_texfetch_depthstencil[PIPE_MAX_TEXTURE_TYPES];
    void *fs_texfetch_stencil[PIPE_MAX_TEXTURE_TYPES];
 
    /* FS which outputs one sample from a multisample texture. */
-   void *fs_texfetch_col_msaa[3][PIPE_MAX_TEXTURE_TYPES];
+   void *fs_texfetch_col_msaa[5][PIPE_MAX_TEXTURE_TYPES];
    void *fs_texfetch_depth_msaa[PIPE_MAX_TEXTURE_TYPES];
    void *fs_texfetch_depthstencil_msaa[PIPE_MAX_TEXTURE_TYPES];
    void *fs_texfetch_stencil_msaa[PIPE_MAX_TEXTURE_TYPES];
 
    /* FS which outputs an average of all samples. */
    void *fs_resolve[PIPE_MAX_TEXTURE_TYPES][NUM_RESOLVE_FRAG_SHADERS][2];
 
    /* Blend state. */
    void *blend[PIPE_MASK_RGBA+1][2]; /**< blend state with writemask */
    void *blend_clear[GET_CLEAR_BLEND_STATE_IDX(PIPE_CLEAR_COLOR)+1];
@@ -856,42 +857,60 @@ static void blitter_set_texcoords(struct blitter_context_priv *ctx,
 }
 
 static void blitter_set_dst_dimensions(struct blitter_context_priv *ctx,
                                        unsigned width, unsigned height)
 {
    ctx->dst_width = width;
    ctx->dst_height = height;
 }
 
 static void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx,
-                                         enum pipe_format format,
+                                         enum pipe_format src_format,
+                                         enum pipe_format dst_format,
                                          enum pipe_texture_target target,
                                          unsigned src_nr_samples,
                                          unsigned dst_nr_samples,
                                          unsigned filter)
 {
    struct pipe_context *pipe = ctx->base.pipe;
    unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, src_nr_samples);
    enum tgsi_return_type stype;
+   enum tgsi_return_type dtype;
    unsigned type;
 
    assert(target < PIPE_MAX_TEXTURE_TYPES);
 
-   if (util_format_is_pure_uint(format)) {
+   if (util_format_is_pure_uint(src_format)) {
       stype = TGSI_RETURN_TYPE_UINT;
-      type = 0;
-   } else if (util_format_is_pure_sint(format)) {
+      if (util_format_is_pure_uint(dst_format)) {
+         dtype = TGSI_RETURN_TYPE_UINT;
+         type = 0;
+      } else {
+         assert(util_format_is_pure_sint(dst_format));
+         dtype = TGSI_RETURN_TYPE_SINT;
+         type = 1;
+      }
+   } else if (util_format_is_pure_sint(src_format)) {
       stype = TGSI_RETURN_TYPE_SINT;
-      type = 1;
+      if (util_format_is_pure_sint(dst_format)) {
+         dtype = TGSI_RETURN_TYPE_SINT;
+         type = 2;
+      } else {
+         assert(util_format_is_pure_uint(dst_format));
+         dtype = TGSI_RETURN_TYPE_UINT;
+         type = 3;
+      }
    } else {
-      stype = TGSI_RETURN_TYPE_FLOAT;
-      type = 2;
+      assert(!util_format_is_pure_uint(dst_format) &&
+             !util_format_is_pure_sint(dst_format));
+      dtype = stype = TGSI_RETURN_TYPE_FLOAT;
+      type = 4;
    }
 
    if (src_nr_samples > 1) {
       void **shader;
 
       /* OpenGL requires that integer textures just copy 1 sample instead
        * of averaging.
        */
       if (dst_nr_samples <= 1 &&
           stype != TGSI_RETURN_TYPE_UINT &&
@@ -919,34 +938,34 @@ static void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx,
       }
       else {
          /* The destination has multiple samples, we'll do
           * an MSAA->MSAA copy.
           */
          shader = &ctx->fs_texfetch_col_msaa[type][target];
 
          /* Create the fragment shader on-demand. */
          if (!*shader) {
             assert(!ctx->cached_all_shaders);
-            *shader = util_make_fs_blit_msaa_color(pipe, tgsi_tex, stype);
+            *shader = util_make_fs_blit_msaa_color(pipe, tgsi_tex, stype, dtype);
          }
       }
 
       return *shader;
    } else {
       void **shader = &ctx->fs_texfetch_col[type][target];
 
       /* Create the fragment shader on-demand. */
       if (!*shader) {
          assert(!ctx->cached_all_shaders);
          *shader = util_make_fragment_tex_shader(pipe, tgsi_tex,
                                                  TGSI_INTERPOLATE_LINEAR,
-                                                 stype);
+                                                 stype, dtype);
       }
 
       return *shader;
    }
 }
 
 static inline
 void *blitter_get_fs_texfetch_depth(struct blitter_context_priv *ctx,
                                     enum pipe_texture_target target,
                                     unsigned nr_samples)
@@ -1094,49 +1113,61 @@ void util_blitter_cache_all_shaders(struct blitter_context *blitter)
             continue;
 
 	 if (samples > 1 &&
 	     (target != PIPE_TEXTURE_2D &&
 	      target != PIPE_TEXTURE_2D_ARRAY))
 	    continue;
 
          /* If samples == 1, the shaders read one texel. If samples >= 1,
           * they read one sample.
           */
-         blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_FLOAT, target,
+         blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_FLOAT,
+                                     PIPE_FORMAT_R32_FLOAT, target,
+                                     samples, samples, 0);
+         blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_UINT,
+                                     PIPE_FORMAT_R32_UINT, target,
+                                     samples, samples, 0);
+         blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_UINT,
+                                     PIPE_FORMAT_R32_SINT, target,
                                      samples, samples, 0);
-         blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_UINT, target,
+         blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_SINT,
+                                     PIPE_FORMAT_R32_SINT, target,
                                      samples, samples, 0);
-         blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_SINT, target,
+         blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_SINT,
+                                     PIPE_FORMAT_R32_UINT, target,
                                      samples, samples, 0);
          blitter_get_fs_texfetch_depth(ctx, target, samples);
          if (ctx->has_stencil_export) {
             blitter_get_fs_texfetch_depthstencil(ctx, target, samples);
             blitter_get_fs_texfetch_stencil(ctx, target, samples);
          }
 
          if (samples == 1)
             continue;
 
          /* MSAA resolve shaders. */
          for (j = 2; j < 32; j++) {
             if (!screen->is_format_supported(screen, PIPE_FORMAT_R32_FLOAT,
                                              target, j,
                                              PIPE_BIND_SAMPLER_VIEW)) {
                continue;
             }
 
             for (f = 0; f < 2; f++) {
-               blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_FLOAT, target,
+               blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_FLOAT,
+                                           PIPE_FORMAT_R32_FLOAT, target,
                                            j, 1, f);
-               blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_UINT, target,
+               blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_UINT,
+                                           PIPE_FORMAT_R32_UINT, target,
                                            j, 1, f);
-               blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_SINT, target,
+               blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_SINT,
+                                           PIPE_FORMAT_R32_SINT, target,
                                            j, 1, f);
             }
          }
       }
    }
 
    ctx->fs_empty = util_make_empty_fragment_shader(pipe);
 
    ctx->fs_write_one_cbuf =
       util_make_fragment_passthrough_shader(pipe, TGSI_SEMANTIC_GENERIC,
@@ -1716,21 +1747,21 @@ void util_blitter_blit_generic(struct blitter_context *blitter,
                blitter_get_fs_texfetch_stencil(ctx, src_target,
                                                src_samples));
       }
 
    } else {
       unsigned colormask = mask & PIPE_MASK_RGBA;
 
       pipe->bind_blend_state(pipe, ctx->blend[colormask][alpha_blend]);
       pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
       ctx->bind_fs_state(pipe,
-            blitter_get_fs_texfetch_col(ctx, src->format, src_target,
+            blitter_get_fs_texfetch_col(ctx, src->format, dst->format, src_target,
                                         src_samples, dst_samples, filter));
    }
 
    /* Set the linear filter only for scaled color non-MSAA blits. */
    if (filter == PIPE_TEX_FILTER_LINEAR) {
       if (src_target == PIPE_TEXTURE_RECT) {
          sampler_state = ctx->sampler_state_rect_linear;
       } else {
          sampler_state = ctx->sampler_state_linear;
       }
@@ -1869,21 +1900,21 @@ void util_blitter_generate_mipmap(struct blitter_context *blitter,
    if (is_depth) {
       pipe->bind_blend_state(pipe, ctx->blend[0][0]);
       pipe->bind_depth_stencil_alpha_state(pipe,
                                            ctx->dsa_write_depth_keep_stencil);
       ctx->bind_fs_state(pipe,
                          blitter_get_fs_texfetch_depth(ctx, tex->target, 1));
    } else {
       pipe->bind_blend_state(pipe, ctx->blend[PIPE_MASK_RGBA][0]);
       pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
       ctx->bind_fs_state(pipe,
-            blitter_get_fs_texfetch_col(ctx, tex->format, tex->target,
+            blitter_get_fs_texfetch_col(ctx, tex->format, tex->format, tex->target,
                                         1, 1, PIPE_TEX_FILTER_LINEAR));
    }
 
    if (tex->target == PIPE_TEXTURE_RECT) {
       sampler_state = ctx->sampler_state_rect_linear;
    } else {
       sampler_state = ctx->sampler_state_linear;
    }
    pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
                              0, 1, &sampler_state);
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index 1220e18..b46ec58 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -200,95 +200,118 @@ void *util_make_layered_clear_geometry_shader(struct pipe_context *pipe)
       assert(0);
       return NULL;
    }
    pipe_shader_state_from_tgsi(&state, tokens);
    return pipe->create_gs_state(pipe, &state);
 }
 
 /**
  * Make simple fragment texture shader:
  *  IMM {0,0,0,1}                         // (if writemask != 0xf)
- *  MOV OUT[0], IMM[0]                    // (if writemask != 0xf)
- *  TEX OUT[0].writemask, IN[0], SAMP[0], 2D;
+ *  MOV TEMP[0], IMM[0]                   // (if writemask != 0xf)
+ *  TEX TEMP[0].writemask, IN[0], SAMP[0], 2D;
+ *   .. optional SINT <-> UINT clamping ..
+ *  MOV OUT[0], TEMP[0]
  *  END;
  *
  * \param tex_target  one of PIPE_TEXTURE_x
  * \parma interp_mode  either TGSI_INTERPOLATE_LINEAR or PERSPECTIVE
  * \param writemask  mask of TGSI_WRITEMASK_x
  */
 void *
 util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
                                         unsigned tex_target,
                                         unsigned interp_mode,
                                         unsigned writemask,
-                                        enum tgsi_return_type stype)
+                                        enum tgsi_return_type stype,
+                                        enum tgsi_return_type dtype)
 {
    struct ureg_program *ureg;
    struct ureg_src sampler;
    struct ureg_src tex;
+   struct ureg_dst temp;
    struct ureg_dst out;
 
+   assert((stype == TGSI_RETURN_TYPE_FLOAT) == (dtype == TGSI_RETURN_TYPE_FLOAT));
    assert(interp_mode == TGSI_INTERPOLATE_LINEAR ||
           interp_mode == TGSI_INTERPOLATE_PERSPECTIVE);
 
    ureg = ureg_create( PIPE_SHADER_FRAGMENT );
    if (!ureg)
       return NULL;
    
    sampler = ureg_DECL_sampler( ureg, 0 );
 
    ureg_DECL_sampler_view(ureg, 0, tex_target, stype, stype, stype, stype);
 
    tex = ureg_DECL_fs_input( ureg, 
                              TGSI_SEMANTIC_GENERIC, 0, 
                              interp_mode );
 
    out = ureg_DECL_output( ureg, 
                            TGSI_SEMANTIC_COLOR,
                            0 );
 
+   temp = ureg_DECL_temporary(ureg);
+
    if (writemask != TGSI_WRITEMASK_XYZW) {
       struct ureg_src imm = ureg_imm4f( ureg, 0, 0, 0, 1 );
 
       ureg_MOV( ureg, out, imm );
    }
 
    if (tex_target == TGSI_TEXTURE_BUFFER)
       ureg_TXF(ureg,
-               ureg_writemask(out, writemask),
+               ureg_writemask(temp, writemask),
                tex_target, tex, sampler);
    else
       ureg_TEX(ureg,
-               ureg_writemask(out, writemask),
+               ureg_writemask(temp, writemask),
                tex_target, tex, sampler);
 
+   if (stype != dtype) {
+      if (stype == TGSI_RETURN_TYPE_SINT) {
+         assert(dtype == TGSI_RETURN_TYPE_UINT);
+
+         ureg_IMAX(ureg, temp, ureg_src(temp), ureg_imm1i(ureg, 0));
+      } else {
+         assert(stype == TGSI_RETURN_TYPE_UINT);
+         assert(dtype == TGSI_RETURN_TYPE_SINT);
+
+         ureg_UMIN(ureg, temp, ureg_src(temp), ureg_imm1u(ureg, (1u << 31) - 1));
+      }
+   }
+
+   ureg_MOV(ureg, out, ureg_src(temp));
+
    ureg_END( ureg );
 
    return ureg_create_shader_and_destroy( ureg, pipe );
 }
 
 
 /**
  * Make a simple fragment shader that sets the output color to a color
  * taken from a texture.
  * \param tex_target  one of PIPE_TEXTURE_x
  */
 void *
 util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target,
                               unsigned interp_mode,
-                              enum tgsi_return_type stype)
+                              enum tgsi_return_type stype,
+                              enum tgsi_return_type dtype)
 {
    return util_make_fragment_tex_shader_writemask( pipe,
                                                    tex_target,
                                                    interp_mode,
                                                    TGSI_WRITEMASK_XYZW,
-                                                   stype );
+                                                   stype, dtype );
 }
 
 
 /**
  * Make a simple fragment texture shader which reads an X component from
  * a texture and writes it as depth.
  */
 void *
 util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
                                          unsigned tex_target,
@@ -538,44 +561,49 @@ util_make_fragment_cloneinput_shader(struct pipe_context *pipe, int num_cbufs,
 
    return ureg_create_shader_and_destroy( ureg, pipe );
 }
 
 
 static void *
 util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
                            unsigned tgsi_tex,
                            const char *samp_type,
                            const char *output_semantic,
-                           const char *output_mask)
+                           const char *output_mask,
+                           const char *conversion_decl,
+                           const char *conversion)
 {
    static const char shader_templ[] =
          "FRAG\n"
          "DCL IN[0], GENERIC[0], LINEAR\n"
          "DCL SAMP[0]\n"
          "DCL SVIEW[0], %s, %s\n"
          "DCL OUT[0], %s\n"
          "DCL TEMP[0]\n"
+         "%s"
 
          "F2U TEMP[0], IN[0]\n"
-         "TXF OUT[0]%s, TEMP[0], SAMP[0], %s\n"
+         "TXF TEMP[0], TEMP[0], SAMP[0], %s\n"
+         "%s"
+         "MOV OUT[0]%s, TEMP[0]\n"
          "END\n";
 
    const char *type = tgsi_texture_names[tgsi_tex];
    char text[sizeof(shader_templ)+100];
    struct tgsi_token tokens[1000];
    struct pipe_shader_state state;
 
    assert(tgsi_tex == TGSI_TEXTURE_2D_MSAA ||
           tgsi_tex == TGSI_TEXTURE_2D_ARRAY_MSAA);
 
-   sprintf(text, shader_templ, type, samp_type,
-           output_semantic, output_mask, type);
+   snprintf(text, sizeof(text), shader_templ, type, samp_type,
+            output_semantic, conversion_decl, type, conversion, output_mask);
 
    if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
       puts(text);
       assert(0);
       return NULL;
    }
    pipe_shader_state_from_tgsi(&state, tokens);
 #if 0
    tgsi_dump(state.tokens, 0);
 #endif
@@ -585,61 +613,77 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
 
 
 /**
  * Make a fragment shader that sets the output color to a color
  * fetched from a multisample texture.
  * \param tex_target  one of PIPE_TEXTURE_x
  */
 void *
 util_make_fs_blit_msaa_color(struct pipe_context *pipe,
                              unsigned tgsi_tex,
-                             enum tgsi_return_type stype)
+                             enum tgsi_return_type stype,
+                             enum tgsi_return_type dtype)
 {
    const char *samp_type;
+   const char *conversion_decl = "";
+   const char *conversion = "";
 
-   if (stype == TGSI_RETURN_TYPE_UINT)
+   if (stype == TGSI_RETURN_TYPE_UINT) {
       samp_type = "UINT";
-   else if (stype == TGSI_RETURN_TYPE_SINT)
+
+      if (dtype == TGSI_RETURN_TYPE_SINT) {
+         conversion_decl = "IMM[0] UINT32 {2147483647, 0, 0, 0}\n";
+         conversion = "UMIN TEMP[0], TEMP[0], IMM[0].x\n";
+      }
+   } else if (stype == TGSI_RETURN_TYPE_SINT) {
       samp_type = "SINT";
-   else
+
+      if (dtype == TGSI_RETURN_TYPE_UINT) {
+         conversion_decl = "IMM[0] INT32 {0, 0, 0, 0}\n";
+         conversion = "IMAX TEMP[0], TEMP[0], IMM[0].x\n";
+      }
+   } else {
+      assert(dtype == TGSI_RETURN_TYPE_FLOAT);
       samp_type = "FLOAT";
+   }
 
    return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, samp_type,
-                                     "COLOR[0]", "");
+                                     "COLOR[0]", "", conversion_decl,
+                                     conversion);
 }
 
 
 /**
  * Make a fragment shader that sets the output depth to a depth value
  * fetched from a multisample texture.
  * \param tex_target  one of PIPE_TEXTURE_x
  */
 void *
 util_make_fs_blit_msaa_depth(struct pipe_context *pipe,
                              unsigned tgsi_tex)
 {
    return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, "FLOAT",
-                                     "POSITION", ".z");
+                                     "POSITION", ".z", "", "");
 }
 
 
 /**
  * Make a fragment shader that sets the output stencil to a stencil value
  * fetched from a multisample texture.
  * \param tex_target  one of PIPE_TEXTURE_x
  */
 void *
 util_make_fs_blit_msaa_stencil(struct pipe_context *pipe,
                                unsigned tgsi_tex)
 {
    return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, "UINT",
-                                     "STENCIL", ".y");
+                                     "STENCIL", ".y", "", "");
 }
 
 
 /**
  * Make a fragment shader that sets the output depth and stencil to depth
  * and stencil values fetched from two multisample textures / samplers.
  * The sizes of both textures should match (it should be one depth-stencil
  * texture).
  * \param tex_target  one of PIPE_TEXTURE_x
  */
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.h b/src/gallium/auxiliary/util/u_simple_shaders.h
index fe1917f..0481098 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.h
+++ b/src/gallium/auxiliary/util/u_simple_shaders.h
@@ -66,26 +66,28 @@ extern void *
 util_make_layered_clear_helper_vertex_shader(struct pipe_context *pipe);
 
 extern void *
 util_make_layered_clear_geometry_shader(struct pipe_context *pipe);
 
 extern void *
 util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
                                         unsigned tex_target,
                                         unsigned interp_mode,
                                         unsigned writemask,
-                                        enum tgsi_return_type stype);
+                                        enum tgsi_return_type stype,
+                                        enum tgsi_return_type dtype);
 
 extern void *
 util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target,
                               unsigned interp_mode,
-                              enum tgsi_return_type stype);
+                              enum tgsi_return_type stype,
+                              enum tgsi_return_type dtype);
 
 extern void *
 util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
                                          unsigned tex_target,
                                          unsigned interp_mode);
 
 
 extern void *
 util_make_fragment_tex_shader_writedepthstencil(struct pipe_context *pipe,
                                                 unsigned tex_target,
@@ -111,21 +113,22 @@ util_make_empty_fragment_shader(struct pipe_context *pipe);
 
 extern void *
 util_make_fragment_cloneinput_shader(struct pipe_context *pipe, int num_cbufs,
                                      int input_semantic,
                                      int input_interpolate);
 
 
 extern void *
 util_make_fs_blit_msaa_color(struct pipe_context *pipe,
                              unsigned tgsi_tex,
-                             enum tgsi_return_type stype);
+                             enum tgsi_return_type stype,
+                             enum tgsi_return_type dtype);
 
 
 extern void *
 util_make_fs_blit_msaa_depth(struct pipe_context *pipe,
                              unsigned tgsi_tex);
 
 
 extern void *
 util_make_fs_blit_msaa_depthstencil(struct pipe_context *pipe,
                                     unsigned tgsi_tex);
diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c
index f22ffce..c33c1f6 100644
--- a/src/gallium/auxiliary/util/u_tests.c
+++ b/src/gallium/auxiliary/util/u_tests.c
@@ -367,20 +367,21 @@ null_sampler_view(struct pipe_context *ctx, unsigned tgsi_tex_target)
    cso = cso_create_context(ctx);
    cb = util_create_texture2d(ctx->screen, 256, 256,
                               PIPE_FORMAT_R8G8B8A8_UNORM);
    util_set_common_states_and_clear(cso, ctx, cb);
 
    ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, NULL);
 
    /* Fragment shader. */
    fs = util_make_fragment_tex_shader(ctx, tgsi_tex_target,
                                       TGSI_INTERPOLATE_LINEAR,
+                                      TGSI_RETURN_TYPE_FLOAT,
                                       TGSI_RETURN_TYPE_FLOAT);
    cso_set_fragment_shader_handle(cso, fs);
 
    /* Vertex shader. */
    vs = util_set_passthrough_vertex_shader(cso, ctx, false);
    util_draw_fullscreen_quad(cso);
 
    /* Probe pixels. */
    pass = pass && util_probe_rect_rgba_multi(ctx, cb, 0, 0,
                                   cb->width0, cb->height0, expected,
diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c
index ddee294..c72c5fe 100644
--- a/src/gallium/tests/trivial/quad-tex.c
+++ b/src/gallium/tests/trivial/quad-tex.c
@@ -265,20 +265,21 @@ static void init_prog(struct program *p)
 	{
 		const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
 		                                TGSI_SEMANTIC_GENERIC };
 		const uint semantic_indexes[] = { 0, 0 };
 		p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes, FALSE);
 	}
 
 	/* fragment shader */
 	p->fs = util_make_fragment_tex_shader(p->pipe, TGSI_TEXTURE_2D,
 	                                      TGSI_INTERPOLATE_LINEAR,
+	                                      TGSI_RETURN_TYPE_FLOAT,
 	                                      TGSI_RETURN_TYPE_FLOAT);
 }
 
 static void close_prog(struct program *p)
 {
 	cso_destroy_context(p->cso);
 
 	p->pipe->delete_vs_state(p->pipe, p->vs);
 	p->pipe->delete_fs_state(p->pipe, p->fs);
 
-- 
2.7.4



More information about the mesa-dev mailing list