[Mesa-dev] [PATCH 3/3] llvmpipe: Support half integer pixel center fs coord.

Roland Scheidegger sroland at vmware.com
Thu Apr 18 06:06:56 PDT 2013


Series looks good to me. I guess you've tested it both with 4 and 8-wide
vectors?
At least now only have 2 different cases to worry about in the
interpolation code :-).

Reviewed-by: Roland Scheidegger <sroland at vmware.com>

Am 18.04.2013 12:40, schrieb jfonseca at vmware.com:
> From: José Fonseca <jfonseca at vmware.com>
> 
> Tested with graw/fs-fragcoord 2/3, and piglit
> glsl-arb-fragment-coord-conventions.
> ---
>  src/gallium/drivers/llvmpipe/lp_bld_interp.c |   25 +++++++++++++++++++++++--
>  src/gallium/drivers/llvmpipe/lp_bld_interp.h |    3 +++
>  src/gallium/drivers/llvmpipe/lp_screen.c     |    2 +-
>  src/gallium/drivers/llvmpipe/lp_state_fs.c   |    1 +
>  4 files changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.c b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
> index 083c6da..490a691 100644
> --- a/src/gallium/drivers/llvmpipe/lp_bld_interp.c
> +++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
> @@ -283,9 +283,15 @@ attribs_update_simple(struct lp_build_interp_soa_context *bld,
>              case LP_INTERP_LINEAR:
>                 if (attrib == 0 && chan == 0) {
>                    dadx = coeff_bld->one;
> +                  if (bld->pos_offset) {
> +                     a = lp_build_const_vec(gallivm, coeff_bld->type, bld->pos_offset);
> +                  }
>                 }
>                 else if (attrib == 0 && chan == 1) {
>                    dady = coeff_bld->one;
> +                  if (bld->pos_offset) {
> +                     a = lp_build_const_vec(gallivm, coeff_bld->type, bld->pos_offset);
> +                  }
>                 }
>                 else {
>                    dadx = lp_build_extract_broadcast(gallivm, setup_bld->type,
> @@ -454,12 +460,20 @@ coeffs_init(struct lp_build_interp_soa_context *bld,
>              LLVMValueRef chan_index = lp_build_const_int32(gallivm, chan);
>  
>              if (attrib == 0 && chan == 0) {
> -               a = lp_build_broadcast_scalar(coeff_bld, bld->x);
> +               a = bld->x;
> +               if (bld->pos_offset) {
> +                  a = LLVMBuildFAdd(builder, a, lp_build_const_float(gallivm, bld->pos_offset), "");
> +               }
> +               a = lp_build_broadcast_scalar(coeff_bld, a);
>                 dadx = coeff_bld->one;
>                 dady = coeff_bld->zero;
>              }
>              else if (attrib == 0 && chan == 1) {
> -               a = lp_build_broadcast_scalar(coeff_bld, bld->y);
> +               a = bld->y;
> +               if (bld->pos_offset) {
> +                  a = LLVMBuildFAdd(builder, a, lp_build_const_float(gallivm, bld->pos_offset), "");
> +               }
> +               a = lp_build_broadcast_scalar(coeff_bld, a);
>                 dady = coeff_bld->one;
>                 dadx = coeff_bld->zero;
>              }
> @@ -667,6 +681,7 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
>                           struct gallivm_state *gallivm,
>                           unsigned num_inputs,
>                           const struct lp_shader_input *inputs,
> +                         boolean pixel_center_integer,
>                           LLVMBuilderRef builder,
>                           struct lp_type type,
>                           LLVMValueRef a0_ptr,
> @@ -723,6 +738,12 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
>        }
>     }
>  
> +   if (pixel_center_integer) {
> +      bld->pos_offset = 0.0;
> +   } else {
> +      bld->pos_offset = 0.5;
> +   }
> +
>     pos_init(bld, x0, y0);
>  
>     if (coeff_type.length > 4) {
> diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.h b/src/gallium/drivers/llvmpipe/lp_bld_interp.h
> index 23c9a59..9029d2a 100644
> --- a/src/gallium/drivers/llvmpipe/lp_bld_interp.h
> +++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.h
> @@ -86,6 +86,8 @@ struct lp_build_interp_soa_context
>     enum lp_interp interp[1 + PIPE_MAX_SHADER_INPUTS];
>     boolean simple_interp;
>  
> +   double pos_offset;
> +
>     LLVMValueRef x;
>     LLVMValueRef y;
>  
> @@ -113,6 +115,7 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
>                           struct gallivm_state *gallivm,
>                           unsigned num_inputs,
>                           const struct lp_shader_input *inputs,
> +                         boolean pixel_center_integer,
>                           LLVMBuilderRef builder,
>                           struct lp_type type,
>                           LLVMValueRef a0_ptr,
> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
> index ebcf680..7152c3e 100644
> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
> @@ -154,9 +154,9 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>        return 1;
>     case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
>     case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
> +   case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
>        return 1;
>     case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
> -   case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
>        return 0;
>     case PIPE_CAP_PRIMITIVE_RESTART:
>        return 1;
> diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
> index 3ec9e0c..8712885 100644
> --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
> +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
> @@ -1919,6 +1919,7 @@ generate_fragment(struct llvmpipe_context *lp,
>                                 gallivm,
>                                 shader->info.base.num_inputs,
>                                 inputs,
> +                               shader->info.base.pixel_center_integer,
>                                 builder, fs_type,
>                                 a0_ptr, dadx_ptr, dady_ptr,
>                                 x, y);
> 


More information about the mesa-dev mailing list