Re: [Mesa-dev] [PATCH 1/5] st/mesa: stop using TGSI_OPCODE_CLAMP

2017-02-17 Thread Nicolai Hähnle

With Roland's comment on #5 addressed, the series is:

Reviewed-by: Nicolai Hähnle 

On 16.02.2017 23:00, Marek Olšák wrote:

From: Marek Olšák 

---
 src/mesa/state_tracker/st_atifs_to_tgsi.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c 
b/src/mesa/state_tracker/st_atifs_to_tgsi.c
index 9c4218e..64879f1 100644
--- a/src/mesa/state_tracker/st_atifs_to_tgsi.c
+++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c
@@ -612,21 +612,20 @@ st_init_atifs_prog(struct gl_context *ctx, struct 
gl_program *prog)
prog->arb.NumParameters = MAX_NUM_FRAGMENT_CONSTANTS_ATI + 2; /* 2 state 
variables for fog */
 }


 struct tgsi_atifs_transform {
struct tgsi_transform_context base;
struct tgsi_shader_info info;
const struct st_fp_variant_key *key;
bool first_instruction_emitted;
unsigned fog_factor_temp;
-   unsigned fog_clamp_imm;
 };

 static inline struct tgsi_atifs_transform *
 tgsi_atifs_transform(struct tgsi_transform_context *tctx)
 {
return (struct tgsi_atifs_transform *)tctx;
 }

 /* copied from st_cb_drawpixels_shader.c */
 static void
@@ -669,24 +668,20 @@ transform_instr(struct tgsi_transform_context *tctx,

if (ctx->first_instruction_emitted)
   goto transform_inst;

ctx->first_instruction_emitted = true;

if (ctx->key->fog) {
   /* add a new temp for the fog factor */
   ctx->fog_factor_temp = ctx->info.file_max[TGSI_FILE_TEMPORARY] + 1;
   tgsi_transform_temp_decl(tctx, ctx->fog_factor_temp);
-
-  /* add immediates for clamp */
-  ctx->fog_clamp_imm = ctx->info.immediate_count;
-  tgsi_transform_immediate_decl(tctx, 1.0f, 0.0f, 0.0f, 0.0f);
}

 transform_inst:
if (current_inst->Instruction.Opcode == TGSI_OPCODE_TEX) {
   /* fix texture target */
   unsigned newtarget = 
ctx->key->texture_targets[current_inst->Src[1].Register.Index];
   if (newtarget)
  current_inst->Texture.Texture = newtarget;

} else if (ctx->key->fog && current_inst->Instruction.Opcode == TGSI_OPCODE_MOV 
&&
@@ -783,31 +778,30 @@ transform_inst:
  inst.Instruction.Opcode = TGSI_OPCODE_EX2;
  inst.Instruction.NumDstRegs = 1;
  inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
  inst.Dst[0].Register.Index = ctx->fog_factor_temp;
  inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
  inst.Instruction.NumSrcRegs = 1;
  SET_SRC(, 0, TGSI_FILE_TEMPORARY, ctx->fog_factor_temp, X, Y, Z, 
W);
  inst.Src[0].Register.Negate ^= 1;
  tctx->emit_instruction(tctx, );
   }
-  /* f = CLAMP(f, 0.0, 1.0) */
+  /* f = saturate(f) */
   inst = tgsi_default_full_instruction();
-  inst.Instruction.Opcode = TGSI_OPCODE_CLAMP;
+  inst.Instruction.Opcode = TGSI_OPCODE_MOV;
   inst.Instruction.NumDstRegs = 1;
+  inst.Instruction.Saturate = 1;
   inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
   inst.Dst[0].Register.Index = ctx->fog_factor_temp;
   inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
-  inst.Instruction.NumSrcRegs = 3;
+  inst.Instruction.NumSrcRegs = 1;
   SET_SRC(, 0, TGSI_FILE_TEMPORARY, ctx->fog_factor_temp, X, Y, Z, W);
-  SET_SRC(, 1, TGSI_FILE_IMMEDIATE, ctx->fog_clamp_imm, Y, Y, Y, Y); 
// 0.0
-  SET_SRC(, 2, TGSI_FILE_IMMEDIATE, ctx->fog_clamp_imm, X, X, X, X); 
// 1.0
   tctx->emit_instruction(tctx, );

   /* REG0 = LRP(f, REG0, fogcolor) */
   inst = tgsi_default_full_instruction();
   inst.Instruction.Opcode = TGSI_OPCODE_LRP;
   inst.Instruction.NumDstRegs = 1;
   inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
   inst.Dst[0].Register.Index = reg0_index;
   inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
   inst.Instruction.NumSrcRegs = 3;



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/5] st/mesa: stop using TGSI_OPCODE_CLAMP

2017-02-16 Thread Roland Scheidegger
I've just checked, and we don't use it anywhere (even if we did, we
could easily replace it with min/max - we can't really execute it any
different than min/max with sw rasterization in any case).
So no objections...

Am 17.02.2017 um 00:37 schrieb Dave Airlie:
> On 17 February 2017 at 08:00, Marek Olšák  wrote:
>> From: Marek Olšák 
> 
> 1, the new 2, 3, 4 are
> 
> Reviewed-by: Dave Airlie 
> 
> 5 is reviewed-by me, but might want to wait for a vmware person to say
> if it causes unknown fallout (not that I think we should care too
> much).
> 
> Dave.
> 
>>
>> ---
>>  src/mesa/state_tracker/st_atifs_to_tgsi.c | 14 --
>>  1 file changed, 4 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c 
>> b/src/mesa/state_tracker/st_atifs_to_tgsi.c
>> index 9c4218e..64879f1 100644
>> --- a/src/mesa/state_tracker/st_atifs_to_tgsi.c
>> +++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c
>> @@ -612,21 +612,20 @@ st_init_atifs_prog(struct gl_context *ctx, struct 
>> gl_program *prog)
>> prog->arb.NumParameters = MAX_NUM_FRAGMENT_CONSTANTS_ATI + 2; /* 2 state 
>> variables for fog */
>>  }
>>
>>
>>  struct tgsi_atifs_transform {
>> struct tgsi_transform_context base;
>> struct tgsi_shader_info info;
>> const struct st_fp_variant_key *key;
>> bool first_instruction_emitted;
>> unsigned fog_factor_temp;
>> -   unsigned fog_clamp_imm;
>>  };
>>
>>  static inline struct tgsi_atifs_transform *
>>  tgsi_atifs_transform(struct tgsi_transform_context *tctx)
>>  {
>> return (struct tgsi_atifs_transform *)tctx;
>>  }
>>
>>  /* copied from st_cb_drawpixels_shader.c */
>>  static void
>> @@ -669,24 +668,20 @@ transform_instr(struct tgsi_transform_context *tctx,
>>
>> if (ctx->first_instruction_emitted)
>>goto transform_inst;
>>
>> ctx->first_instruction_emitted = true;
>>
>> if (ctx->key->fog) {
>>/* add a new temp for the fog factor */
>>ctx->fog_factor_temp = ctx->info.file_max[TGSI_FILE_TEMPORARY] + 1;
>>tgsi_transform_temp_decl(tctx, ctx->fog_factor_temp);
>> -
>> -  /* add immediates for clamp */
>> -  ctx->fog_clamp_imm = ctx->info.immediate_count;
>> -  tgsi_transform_immediate_decl(tctx, 1.0f, 0.0f, 0.0f, 0.0f);
>> }
>>
>>  transform_inst:
>> if (current_inst->Instruction.Opcode == TGSI_OPCODE_TEX) {
>>/* fix texture target */
>>unsigned newtarget = 
>> ctx->key->texture_targets[current_inst->Src[1].Register.Index];
>>if (newtarget)
>>   current_inst->Texture.Texture = newtarget;
>>
>> } else if (ctx->key->fog && current_inst->Instruction.Opcode == 
>> TGSI_OPCODE_MOV &&
>> @@ -783,31 +778,30 @@ transform_inst:
>>   inst.Instruction.Opcode = TGSI_OPCODE_EX2;
>>   inst.Instruction.NumDstRegs = 1;
>>   inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
>>   inst.Dst[0].Register.Index = ctx->fog_factor_temp;
>>   inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
>>   inst.Instruction.NumSrcRegs = 1;
>>   SET_SRC(, 0, TGSI_FILE_TEMPORARY, ctx->fog_factor_temp, X, Y, 
>> Z, W);
>>   inst.Src[0].Register.Negate ^= 1;
>>   tctx->emit_instruction(tctx, );
>>}
>> -  /* f = CLAMP(f, 0.0, 1.0) */
>> +  /* f = saturate(f) */
>>inst = tgsi_default_full_instruction();
>> -  inst.Instruction.Opcode = TGSI_OPCODE_CLAMP;
>> +  inst.Instruction.Opcode = TGSI_OPCODE_MOV;
>>inst.Instruction.NumDstRegs = 1;
>> +  inst.Instruction.Saturate = 1;
>>inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
>>inst.Dst[0].Register.Index = ctx->fog_factor_temp;
>>inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
>> -  inst.Instruction.NumSrcRegs = 3;
>> +  inst.Instruction.NumSrcRegs = 1;
>>SET_SRC(, 0, TGSI_FILE_TEMPORARY, ctx->fog_factor_temp, X, Y, Z, 
>> W);
>> -  SET_SRC(, 1, TGSI_FILE_IMMEDIATE, ctx->fog_clamp_imm, Y, Y, Y, 
>> Y); // 0.0
>> -  SET_SRC(, 2, TGSI_FILE_IMMEDIATE, ctx->fog_clamp_imm, X, X, X, 
>> X); // 1.0
>>tctx->emit_instruction(tctx, );
>>
>>/* REG0 = LRP(f, REG0, fogcolor) */
>>inst = tgsi_default_full_instruction();
>>inst.Instruction.Opcode = TGSI_OPCODE_LRP;
>>inst.Instruction.NumDstRegs = 1;
>>inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
>>inst.Dst[0].Register.Index = reg0_index;
>>inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
>>inst.Instruction.NumSrcRegs = 3;
>> --
>> 2.7.4
>>
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


Re: [Mesa-dev] [PATCH 1/5] st/mesa: stop using TGSI_OPCODE_CLAMP

2017-02-16 Thread Dave Airlie
On 17 February 2017 at 08:00, Marek Olšák  wrote:
> From: Marek Olšák 

1, the new 2, 3, 4 are

Reviewed-by: Dave Airlie 

5 is reviewed-by me, but might want to wait for a vmware person to say
if it causes unknown fallout (not that I think we should care too
much).

Dave.

>
> ---
>  src/mesa/state_tracker/st_atifs_to_tgsi.c | 14 --
>  1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c 
> b/src/mesa/state_tracker/st_atifs_to_tgsi.c
> index 9c4218e..64879f1 100644
> --- a/src/mesa/state_tracker/st_atifs_to_tgsi.c
> +++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c
> @@ -612,21 +612,20 @@ st_init_atifs_prog(struct gl_context *ctx, struct 
> gl_program *prog)
> prog->arb.NumParameters = MAX_NUM_FRAGMENT_CONSTANTS_ATI + 2; /* 2 state 
> variables for fog */
>  }
>
>
>  struct tgsi_atifs_transform {
> struct tgsi_transform_context base;
> struct tgsi_shader_info info;
> const struct st_fp_variant_key *key;
> bool first_instruction_emitted;
> unsigned fog_factor_temp;
> -   unsigned fog_clamp_imm;
>  };
>
>  static inline struct tgsi_atifs_transform *
>  tgsi_atifs_transform(struct tgsi_transform_context *tctx)
>  {
> return (struct tgsi_atifs_transform *)tctx;
>  }
>
>  /* copied from st_cb_drawpixels_shader.c */
>  static void
> @@ -669,24 +668,20 @@ transform_instr(struct tgsi_transform_context *tctx,
>
> if (ctx->first_instruction_emitted)
>goto transform_inst;
>
> ctx->first_instruction_emitted = true;
>
> if (ctx->key->fog) {
>/* add a new temp for the fog factor */
>ctx->fog_factor_temp = ctx->info.file_max[TGSI_FILE_TEMPORARY] + 1;
>tgsi_transform_temp_decl(tctx, ctx->fog_factor_temp);
> -
> -  /* add immediates for clamp */
> -  ctx->fog_clamp_imm = ctx->info.immediate_count;
> -  tgsi_transform_immediate_decl(tctx, 1.0f, 0.0f, 0.0f, 0.0f);
> }
>
>  transform_inst:
> if (current_inst->Instruction.Opcode == TGSI_OPCODE_TEX) {
>/* fix texture target */
>unsigned newtarget = 
> ctx->key->texture_targets[current_inst->Src[1].Register.Index];
>if (newtarget)
>   current_inst->Texture.Texture = newtarget;
>
> } else if (ctx->key->fog && current_inst->Instruction.Opcode == 
> TGSI_OPCODE_MOV &&
> @@ -783,31 +778,30 @@ transform_inst:
>   inst.Instruction.Opcode = TGSI_OPCODE_EX2;
>   inst.Instruction.NumDstRegs = 1;
>   inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
>   inst.Dst[0].Register.Index = ctx->fog_factor_temp;
>   inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
>   inst.Instruction.NumSrcRegs = 1;
>   SET_SRC(, 0, TGSI_FILE_TEMPORARY, ctx->fog_factor_temp, X, Y, 
> Z, W);
>   inst.Src[0].Register.Negate ^= 1;
>   tctx->emit_instruction(tctx, );
>}
> -  /* f = CLAMP(f, 0.0, 1.0) */
> +  /* f = saturate(f) */
>inst = tgsi_default_full_instruction();
> -  inst.Instruction.Opcode = TGSI_OPCODE_CLAMP;
> +  inst.Instruction.Opcode = TGSI_OPCODE_MOV;
>inst.Instruction.NumDstRegs = 1;
> +  inst.Instruction.Saturate = 1;
>inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
>inst.Dst[0].Register.Index = ctx->fog_factor_temp;
>inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
> -  inst.Instruction.NumSrcRegs = 3;
> +  inst.Instruction.NumSrcRegs = 1;
>SET_SRC(, 0, TGSI_FILE_TEMPORARY, ctx->fog_factor_temp, X, Y, Z, 
> W);
> -  SET_SRC(, 1, TGSI_FILE_IMMEDIATE, ctx->fog_clamp_imm, Y, Y, Y, 
> Y); // 0.0
> -  SET_SRC(, 2, TGSI_FILE_IMMEDIATE, ctx->fog_clamp_imm, X, X, X, 
> X); // 1.0
>tctx->emit_instruction(tctx, );
>
>/* REG0 = LRP(f, REG0, fogcolor) */
>inst = tgsi_default_full_instruction();
>inst.Instruction.Opcode = TGSI_OPCODE_LRP;
>inst.Instruction.NumDstRegs = 1;
>inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
>inst.Dst[0].Register.Index = reg0_index;
>inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
>inst.Instruction.NumSrcRegs = 3;
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/5] st/mesa: stop using TGSI_OPCODE_CLAMP

2017-02-16 Thread Marek Olšák
From: Marek Olšák 

---
 src/mesa/state_tracker/st_atifs_to_tgsi.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c 
b/src/mesa/state_tracker/st_atifs_to_tgsi.c
index 9c4218e..64879f1 100644
--- a/src/mesa/state_tracker/st_atifs_to_tgsi.c
+++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c
@@ -612,21 +612,20 @@ st_init_atifs_prog(struct gl_context *ctx, struct 
gl_program *prog)
prog->arb.NumParameters = MAX_NUM_FRAGMENT_CONSTANTS_ATI + 2; /* 2 state 
variables for fog */
 }
 
 
 struct tgsi_atifs_transform {
struct tgsi_transform_context base;
struct tgsi_shader_info info;
const struct st_fp_variant_key *key;
bool first_instruction_emitted;
unsigned fog_factor_temp;
-   unsigned fog_clamp_imm;
 };
 
 static inline struct tgsi_atifs_transform *
 tgsi_atifs_transform(struct tgsi_transform_context *tctx)
 {
return (struct tgsi_atifs_transform *)tctx;
 }
 
 /* copied from st_cb_drawpixels_shader.c */
 static void
@@ -669,24 +668,20 @@ transform_instr(struct tgsi_transform_context *tctx,
 
if (ctx->first_instruction_emitted)
   goto transform_inst;
 
ctx->first_instruction_emitted = true;
 
if (ctx->key->fog) {
   /* add a new temp for the fog factor */
   ctx->fog_factor_temp = ctx->info.file_max[TGSI_FILE_TEMPORARY] + 1;
   tgsi_transform_temp_decl(tctx, ctx->fog_factor_temp);
-
-  /* add immediates for clamp */
-  ctx->fog_clamp_imm = ctx->info.immediate_count;
-  tgsi_transform_immediate_decl(tctx, 1.0f, 0.0f, 0.0f, 0.0f);
}
 
 transform_inst:
if (current_inst->Instruction.Opcode == TGSI_OPCODE_TEX) {
   /* fix texture target */
   unsigned newtarget = 
ctx->key->texture_targets[current_inst->Src[1].Register.Index];
   if (newtarget)
  current_inst->Texture.Texture = newtarget;
 
} else if (ctx->key->fog && current_inst->Instruction.Opcode == 
TGSI_OPCODE_MOV &&
@@ -783,31 +778,30 @@ transform_inst:
  inst.Instruction.Opcode = TGSI_OPCODE_EX2;
  inst.Instruction.NumDstRegs = 1;
  inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
  inst.Dst[0].Register.Index = ctx->fog_factor_temp;
  inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
  inst.Instruction.NumSrcRegs = 1;
  SET_SRC(, 0, TGSI_FILE_TEMPORARY, ctx->fog_factor_temp, X, Y, Z, 
W);
  inst.Src[0].Register.Negate ^= 1;
  tctx->emit_instruction(tctx, );
   }
-  /* f = CLAMP(f, 0.0, 1.0) */
+  /* f = saturate(f) */
   inst = tgsi_default_full_instruction();
-  inst.Instruction.Opcode = TGSI_OPCODE_CLAMP;
+  inst.Instruction.Opcode = TGSI_OPCODE_MOV;
   inst.Instruction.NumDstRegs = 1;
+  inst.Instruction.Saturate = 1;
   inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
   inst.Dst[0].Register.Index = ctx->fog_factor_temp;
   inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
-  inst.Instruction.NumSrcRegs = 3;
+  inst.Instruction.NumSrcRegs = 1;
   SET_SRC(, 0, TGSI_FILE_TEMPORARY, ctx->fog_factor_temp, X, Y, Z, W);
-  SET_SRC(, 1, TGSI_FILE_IMMEDIATE, ctx->fog_clamp_imm, Y, Y, Y, Y); 
// 0.0
-  SET_SRC(, 2, TGSI_FILE_IMMEDIATE, ctx->fog_clamp_imm, X, X, X, X); 
// 1.0
   tctx->emit_instruction(tctx, );
 
   /* REG0 = LRP(f, REG0, fogcolor) */
   inst = tgsi_default_full_instruction();
   inst.Instruction.Opcode = TGSI_OPCODE_LRP;
   inst.Instruction.NumDstRegs = 1;
   inst.Dst[0].Register.File  = TGSI_FILE_TEMPORARY;
   inst.Dst[0].Register.Index = reg0_index;
   inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
   inst.Instruction.NumSrcRegs = 3;
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev