Re: [Mesa-dev] [PATCH] nir/search: Support 8 and 16-bit constants

2018-03-01 Thread Chema Casanova
I've been checking the whole nir_search.c and there is another pending
16-bit support in construct_value function. I'm sending a patch so feel
free to squash it to your if it makes sense.

In any case this is.

Reviewed-by: Jose Maria Casanova Crespo 

El 28/02/18 a las 22:18, Jason Ekstrand escribió:
> ---
>  src/compiler/nir/nir_search.c | 20 
>  1 file changed, 20 insertions(+)
> 
> diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
> index dec56fe..c7c52ae 100644
> --- a/src/compiler/nir/nir_search.c
> +++ b/src/compiler/nir/nir_search.c
> @@ -27,6 +27,7 @@
>  
>  #include 
>  #include "nir_search.h"
> +#include "util/half_float.h"
>  
>  struct match_state {
> bool inexact_match;
> @@ -194,6 +195,9 @@ match_value(const nir_search_value *value, nir_alu_instr 
> *instr, unsigned src,
>   for (unsigned i = 0; i < num_components; ++i) {
>  double val;
>  switch (load->def.bit_size) {
> +case 16:
> +   val = _mesa_half_to_float(load->value.u16[new_swizzle[i]]);
> +   break;
>  case 32:
> val = load->value.f32[new_swizzle[i]];
> break;
> @@ -213,6 +217,22 @@ match_value(const nir_search_value *value, nir_alu_instr 
> *instr, unsigned src,
>case nir_type_uint:
>case nir_type_bool32:
>   switch (load->def.bit_size) {
> + case 8:
> +for (unsigned i = 0; i < num_components; ++i) {
> +   if (load->value.u8[new_swizzle[i]] !=
> +   (uint8_t)const_val->data.u)
> +  return false;
> +}
> +return true;
> +
> + case 16:
> +for (unsigned i = 0; i < num_components; ++i) {
> +   if (load->value.u16[new_swizzle[i]] !=
> +   (uint16_t)const_val->data.u)
> +  return false;
> +}
> +return true;
> +
>   case 32:
>  for (unsigned i = 0; i < num_components; ++i) {
> if (load->value.u32[new_swizzle[i]] !=
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] nir/search: Support 8 and 16-bit constants

2018-02-28 Thread Jason Ekstrand
---
 src/compiler/nir/nir_search.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index dec56fe..c7c52ae 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -27,6 +27,7 @@
 
 #include 
 #include "nir_search.h"
+#include "util/half_float.h"
 
 struct match_state {
bool inexact_match;
@@ -194,6 +195,9 @@ match_value(const nir_search_value *value, nir_alu_instr 
*instr, unsigned src,
  for (unsigned i = 0; i < num_components; ++i) {
 double val;
 switch (load->def.bit_size) {
+case 16:
+   val = _mesa_half_to_float(load->value.u16[new_swizzle[i]]);
+   break;
 case 32:
val = load->value.f32[new_swizzle[i]];
break;
@@ -213,6 +217,22 @@ match_value(const nir_search_value *value, nir_alu_instr 
*instr, unsigned src,
   case nir_type_uint:
   case nir_type_bool32:
  switch (load->def.bit_size) {
+ case 8:
+for (unsigned i = 0; i < num_components; ++i) {
+   if (load->value.u8[new_swizzle[i]] !=
+   (uint8_t)const_val->data.u)
+  return false;
+}
+return true;
+
+ case 16:
+for (unsigned i = 0; i < num_components; ++i) {
+   if (load->value.u16[new_swizzle[i]] !=
+   (uint16_t)const_val->data.u)
+  return false;
+}
+return true;
+
  case 32:
 for (unsigned i = 0; i < num_components; ++i) {
if (load->value.u32[new_swizzle[i]] !=
-- 
2.5.0.400.gff86faf

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