[Mesa-dev] [PATCH 2/5] i965: Add function to negate immediates.

Jason Ekstrand jason at jlekstrand.net
Fri Jan 30 16:02:29 PST 2015


On Fri, Jan 30, 2015 at 3:54 PM, Matt Turner <mattst88 at gmail.com> wrote:

> ---
>  src/mesa/drivers/dri/i965/brw_shader.cpp | 37
> ++++++++++++++++++++++++++++++++
>  src/mesa/drivers/dri/i965/brw_shader.h   |  1 +
>  2 files changed, 38 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp
> b/src/mesa/drivers/dri/i965/brw_shader.cpp
> index c393bfc..ff2edf3 100644
> --- a/src/mesa/drivers/dri/i965/brw_shader.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
> @@ -620,6 +620,43 @@ brw_saturate_immediate(enum brw_reg_type type, struct
> brw_reg *reg)
>     return false;
>  }
>
> +bool
> +brw_negate_immediate(enum brw_reg_type type, struct brw_reg *reg)
> +{
> +   switch (type) {
> +   case BRW_REGISTER_TYPE_UD:
> +   case BRW_REGISTER_TYPE_D:
> +      reg->dw1.d = -reg->dw1.d;
> +      return true;
> +   case BRW_REGISTER_TYPE_UW:
> +      reg->dw1.d = -(uint16_t)reg->dw1.ud;
>

Do we really want to negate UW and UD sources?  If so, shouldn't we change
the register type to signed or something?  Maybe there's something I don't
know about the arch, but this seems fishy.

Same comment applies on the next patch with abs().

Other than that, everything in this series looks fine.


> +      return true;
> +   case BRW_REGISTER_TYPE_W:
> +      reg->dw1.d = -(int16_t)reg->dw1.ud;
> +      return true;
> +   case BRW_REGISTER_TYPE_F:
> +      reg->dw1.f = -reg->dw1.f;
> +      return true;
> +   case BRW_REGISTER_TYPE_VF:
> +      reg->dw1.ud ^= 0x80808080;
> +      return true;
> +   case BRW_REGISTER_TYPE_UB:
> +   case BRW_REGISTER_TYPE_B:
> +      unreachable("no UB/B immediates");
> +   case BRW_REGISTER_TYPE_UV:
> +   case BRW_REGISTER_TYPE_V:
> +      assert(!"unimplemented: negate UV/V immediate");
> +   case BRW_REGISTER_TYPE_UQ:
> +   case BRW_REGISTER_TYPE_Q:
> +      assert(!"unimplemented: negate UQ/Q immediate");
> +   case BRW_REGISTER_TYPE_DF:
> +   case BRW_REGISTER_TYPE_HF:
> +      assert(!"unimplemented: negate DF/HF immediate");
> +   }
> +
> +   return false;
> +}
> +
>  backend_visitor::backend_visitor(struct brw_context *brw,
>                                   struct gl_shader_program *shader_prog,
>                                   struct gl_program *prog,
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.h
> b/src/mesa/drivers/dri/i965/brw_shader.h
> index 6fc86e1..2b9b72e 100644
> --- a/src/mesa/drivers/dri/i965/brw_shader.h
> +++ b/src/mesa/drivers/dri/i965/brw_shader.h
> @@ -195,6 +195,7 @@ enum brw_conditional_mod
> brw_conditional_for_comparison(unsigned int op);
>  uint32_t brw_math_function(enum opcode op);
>  const char *brw_instruction_name(enum opcode op);
>  bool brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg);
> +bool brw_negate_immediate(enum brw_reg_type type, struct brw_reg *reg);
>
>  #ifdef __cplusplus
>  extern "C" {
> --
> 2.0.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150130/3a71424e/attachment.html>


More information about the mesa-dev mailing list