<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 25, 2015 at 7:27 AM, Ivan Kalvachev <span dir="ltr"><<a href="mailto:ikalvachev@gmail.com" target="_blank">ikalvachev@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 10/25/15, Ivan Kalvachev <<a href="mailto:ikalvachev@gmail.com">ikalvachev@gmail.com</a>> wrote:<br>
> Some constants (like 1.0 and 0.5) could be inlined as immediate inputs<br>
> without using their literal value. The r600_bytecode_special_constants()<br>
> function emulates the negative of these constants by using NEG modifier.<br>
><br>
> However some shaders define -1.0 constant and want to use it as 1.0.<br>
> They do so by using ABS modifier. But r600_bytecode_special_constants()<br>
> set NEG in addition to ABS. Since NEG modifier have priority over ABS one,<br>
> we get -|1.0| as result, instead of |1.0|.<br>
><br>
> The patch simply prevents the additional switching of NEG when ABS is set.<br>
><br>
> Signed-off-by: Ivan Kalvachev <<a href="mailto:ikalvachev@gmail.com">ikalvachev@gmail.com</a>><br>
> ---<br>
>  src/gallium/drivers/r600/r600_asm.c    | 9 +++++----<br>
>  src/gallium/drivers/r600/r600_shader.c | 2 +-<br>
>  2 files changed, 6 insertions(+), 5 deletions(-)<br>
><br>
> diff --git a/src/gallium/drivers/r600/r600_asm.c<br>
> b/src/gallium/drivers/r600/r600_asm.c<br>
> index bc69806..8fc622c 100644<br>
> --- a/src/gallium/drivers/r600/r600_asm.c<br>
> +++ b/src/gallium/drivers/r600/r600_asm.c<br>
> @@ -635,8 +635,9 @@ static int replace_gpr_with_pv_ps(struct r600_bytecode<br>
> *bc,<br>
>         return 0;<br>
>  }<br>
><br>
> -void r600_bytecode_special_constants(uint32_t value, unsigned *sel,<br>
> unsigned *neg)<br>
> +void r600_bytecode_special_constants(uint32_t value, unsigned *sel,<br>
> unsigned *neg, unsigned abs)<br>
>  {<br>
> +<br>
>         switch(value) {<br>
>         case 0:<br>
>                 *sel = V_SQ_ALU_SRC_0;<br>
> @@ -655,11 +656,11 @@ void r600_bytecode_special_constants(uint32_t<br>
> value, unsigned *sel, unsigned *ne<br>
>                 break;<br>
>         case 0xBF800000: /* -1.0f */<br>
>                 *sel = V_SQ_ALU_SRC_1;<br>
> -               *neg ^= 1;<br>
> +               *neg ^= !abs;<br>
>                 break;<br>
>         case 0xBF000000: /* -0.5f */<br>
>                 *sel = V_SQ_ALU_SRC_0_5;<br>
> -               *neg ^= 1;<br>
> +               *neg ^= !abs;<br>
>                 break;<br>
>         default:<br>
>                 *sel = V_SQ_ALU_SRC_LITERAL;<br>
> @@ -1208,7 +1209,7 @@ int r600_bytecode_add_alu_type(struct r600_bytecode<br>
> *bc,<br>
>                 }<br>
>                 if (nalu->src[i].sel == V_SQ_ALU_SRC_LITERAL)<br>
>                         r600_bytecode_special_constants(nalu->src[i].value,<br>
> -                               &nalu->src[i].sel, &nalu->src[i].neg);<br>
> +                               &nalu->src[i].sel, &nalu->src[i].neg,<br>
> nalu->src[i].abs);<br>
>         }<br>
>         if (nalu->dst.sel >= bc->ngpr) {<br>
>                 bc->ngpr = nalu->dst.sel + 1;<br>
> diff --git a/src/gallium/drivers/r600/r600_shader.c<br>
> b/src/gallium/drivers/r600/r600_shader.c<br>
> index 8efe902..50c0329 100644<br>
> --- a/src/gallium/drivers/r600/r600_shader.c<br>
> +++ b/src/gallium/drivers/r600/r600_shader.c<br>
> @@ -1008,7 +1008,7 @@ static void tgsi_src(struct r600_shader_ctx *ctx,<br>
>                         (tgsi_src->Register.SwizzleX ==<br>
> tgsi_src->Register.SwizzleW)) {<br>
><br>
>                         index = tgsi_src->Register.Index * 4 +<br>
> tgsi_src->Register.SwizzleX;<br>
> -<br>
> r600_bytecode_special_constants(ctx->literals[index], &r600_src->sel,<br>
> &r600_src->neg);<br>
> +<br>
> r600_bytecode_special_constants(ctx->literals[index], &r600_src->sel,<br>
> &r600_src->neg, r600_src->abs);<br>
>                         if (r600_src->sel != V_SQ_ALU_SRC_LITERAL)<br>
>                                 return;<br>
>                 }<br>
> --<br>
> 2.5.1<br>
><br>
<br>
It's the same patch, I've just forgotten to add the header file change:<br>
<br>
diff --git a/src/gallium/drivers/r600/r600_asm.h<br>
b/src/gallium/drivers/r600/r600_asm.h<br>
index 7cf3a09..d48ad1e 100644<br>
--- a/src/gallium/drivers/r600/r600_asm.h<br>
+++ b/src/gallium/drivers/r600/r600_asm.h<br>
@@ -255,7 +255,7 @@ int r600_bytecode_add_cfinst(struct r600_bytecode *bc,<br>
 int r600_bytecode_add_alu_type(struct r600_bytecode *bc,<br>
                const struct r600_bytecode_alu *alu, unsigned type);<br>
 void r600_bytecode_special_constants(uint32_t value,<br>
-               unsigned *sel, unsigned *neg);<br>
+               unsigned *sel, unsigned *neg, unsigned abs);<br>
 void r600_bytecode_disasm(struct r600_bytecode *bc);<br>
 void r600_bytecode_alu_read(struct r600_bytecode *bc,<br>
                struct r600_bytecode_alu *alu, uint32_t word0, uint32_t word1);<br>
<br>_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
<br></blockquote></div><br></div><div class="gmail_extra">Tested-By: Nick Sarnie <<a href="mailto:commendsarnex@gmail.com">commendsarnex@gmail.com</a>><br></div></div>