Re: [Mesa-dev] [PATCH] nir/print: fix printing of 8/16 bit constant variables

2018-05-21 Thread Karol Herbst
On Mon, May 21, 2018 at 7:31 PM, Chema Casanova  wrote:
> As GLSL_TYPE_FLOAT16 type support is not implemented in this patch, we
> would need to change commit summary to ".. 8/16 bit integer constant.."
> or just implement half float support with something like.
>
> +   case GLSL_TYPE_FLOAT16:
> +  for (i = 0; i < cols; i++) {
> + for (j = 0; j < rows; j++) {
> +if (i + j > 0) fprintf(fp, ", ");
> +fprintf(fp, "%f",_mesa_half_to_float(c->values[i].u16[j]));
> + }
> +  }
> +  break;
>
>
> Chema
>

yeah, I guess it makes sense to include it as well, thanks!

>
> El 21/05/18 a las 14:51, Karol Herbst escribió:
>> Signed-off-by: Karol Herbst 
>> ---
>>  src/compiler/nir/nir_print.c | 22 ++
>>  1 file changed, 22 insertions(+)
>>
>> diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
>> index 97b2d6164cd..e331a26d932 100644
>> --- a/src/compiler/nir/nir_print.c
>> +++ b/src/compiler/nir/nir_print.c
>> @@ -299,6 +299,28 @@ print_constant(nir_constant *c, const struct glsl_type 
>> *type, print_state *state
>> unsigned i, j;
>>
>> switch (glsl_get_base_type(type)) {
>> +   case GLSL_TYPE_UINT8:
>> +   case GLSL_TYPE_INT8:
>> +  /* Only float base types can be matrices. */
>> +  assert(cols == 1);
>> +
>> +  for (i = 0; i < rows; i++) {
>> + if (i > 0) fprintf(fp, ", ");
>> + fprintf(fp, "0x%02x", c->values[0].u8[i]);
>> +  }
>> +  break;
>> +
>> +   case GLSL_TYPE_UINT16:
>> +   case GLSL_TYPE_INT16:
>> +  /* Only float base types can be matrices. */
>> +  assert(cols == 1);
>> +
>> +  for (i = 0; i < rows; i++) {
>> + if (i > 0) fprintf(fp, ", ");
>> + fprintf(fp, "0x%04x", c->values[0].u16[i]);
>> +  }
>> +  break;
>> +
>> case GLSL_TYPE_UINT:
>> case GLSL_TYPE_INT:
>> case GLSL_TYPE_BOOL:
>>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] nir/print: fix printing of 8/16 bit constant variables

2018-05-21 Thread Chema Casanova
As GLSL_TYPE_FLOAT16 type support is not implemented in this patch, we
would need to change commit summary to ".. 8/16 bit integer constant.."
or just implement half float support with something like.

+   case GLSL_TYPE_FLOAT16:
+  for (i = 0; i < cols; i++) {
+ for (j = 0; j < rows; j++) {
+if (i + j > 0) fprintf(fp, ", ");
+fprintf(fp, "%f",_mesa_half_to_float(c->values[i].u16[j]));
+ }
+  }
+  break;


Chema

El 21/05/18 a las 14:51, Karol Herbst escribió:
> Signed-off-by: Karol Herbst 
> ---
>  src/compiler/nir/nir_print.c | 22 ++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
> index 97b2d6164cd..e331a26d932 100644
> --- a/src/compiler/nir/nir_print.c
> +++ b/src/compiler/nir/nir_print.c
> @@ -299,6 +299,28 @@ print_constant(nir_constant *c, const struct glsl_type 
> *type, print_state *state
> unsigned i, j;
>  
> switch (glsl_get_base_type(type)) {
> +   case GLSL_TYPE_UINT8:
> +   case GLSL_TYPE_INT8:
> +  /* Only float base types can be matrices. */
> +  assert(cols == 1);
> +
> +  for (i = 0; i < rows; i++) {
> + if (i > 0) fprintf(fp, ", ");
> + fprintf(fp, "0x%02x", c->values[0].u8[i]);
> +  }
> +  break;
> +
> +   case GLSL_TYPE_UINT16:
> +   case GLSL_TYPE_INT16:
> +  /* Only float base types can be matrices. */
> +  assert(cols == 1);
> +
> +  for (i = 0; i < rows; i++) {
> + if (i > 0) fprintf(fp, ", ");
> + fprintf(fp, "0x%04x", c->values[0].u16[i]);
> +  }
> +  break;
> +
> case GLSL_TYPE_UINT:
> case GLSL_TYPE_INT:
> case GLSL_TYPE_BOOL:
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] nir/print: fix printing of 8/16 bit constant variables

2018-05-21 Thread Karol Herbst
Signed-off-by: Karol Herbst 
---
 src/compiler/nir/nir_print.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 97b2d6164cd..e331a26d932 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -299,6 +299,28 @@ print_constant(nir_constant *c, const struct glsl_type 
*type, print_state *state
unsigned i, j;
 
switch (glsl_get_base_type(type)) {
+   case GLSL_TYPE_UINT8:
+   case GLSL_TYPE_INT8:
+  /* Only float base types can be matrices. */
+  assert(cols == 1);
+
+  for (i = 0; i < rows; i++) {
+ if (i > 0) fprintf(fp, ", ");
+ fprintf(fp, "0x%02x", c->values[0].u8[i]);
+  }
+  break;
+
+   case GLSL_TYPE_UINT16:
+   case GLSL_TYPE_INT16:
+  /* Only float base types can be matrices. */
+  assert(cols == 1);
+
+  for (i = 0; i < rows; i++) {
+ if (i > 0) fprintf(fp, ", ");
+ fprintf(fp, "0x%04x", c->values[0].u16[i]);
+  }
+  break;
+
case GLSL_TYPE_UINT:
case GLSL_TYPE_INT:
case GLSL_TYPE_BOOL:
-- 
2.17.0

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