lima/ppir: don't assume that load coords gets value from register
authorVasily Khoruzhick <anarsoul@gmail.com>
Sun, 1 Sep 2019 17:21:32 +0000 (10:21 -0700)
committerVasily Khoruzhick <anarsoul@gmail.com>
Wed, 4 Sep 2019 00:02:13 +0000 (00:02 +0000)
It can load value from varying directly as well. Also load_regs is the
only op that has a source, so add src_num field to load node and set it
accordingly.

Reviewed-by: Erico Nunes <nunes.erico@gmail.com>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
src/gallium/drivers/lima/ir/pp/codegen.c
src/gallium/drivers/lima/ir/pp/lower.c
src/gallium/drivers/lima/ir/pp/ppir.h

index f08f83a9f4376728ea15060baa0c9000ebcc2e31..8dac09bd471347560710fe69ec29752825176c04 100644 (file)
@@ -94,14 +94,15 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code)
       f->reg.dest = index >> 2;
       f->reg.mask = dest->write_mask << (index & 0x3);
 
-      f->reg.source_type = 1;
-
-      ppir_src *src = &load->src;
-      index = ppir_target_get_src_reg_index(src);
-      f->reg.source = index >> 2;
-      f->reg.negate = src->negate;
-      f->reg.absolute = src->absolute;
-      f->reg.swizzle = encode_swizzle(src->swizzle, index & 0x3, 0);
+      if (load->num_src) {
+         f->reg.source_type = 1;
+         ppir_src *src = &load->src;
+         index = ppir_target_get_src_reg_index(src);
+         f->reg.source = index >> 2;
+         f->reg.negate = src->negate;
+         f->reg.absolute = src->absolute;
+         f->reg.swizzle = encode_swizzle(src->swizzle, index & 0x3, 0);
+      }
    }
 }
 
index e49b20e8c7e40cb7b751c6dcde059e671aa8573d..ee63912a1b7f4085b1790ed0fcd2d9180c925c77 100644 (file)
@@ -147,6 +147,7 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
    load->dest.pipeline = ppir_pipeline_reg_discard;
 
    load->src = load_tex->src_coords;
+   load->num_src = 1;
 
    ppir_node_foreach_pred_safe(node, dep) {
       ppir_node *pred = dep->pred;
index ec649e4afa9a12f363118588ef4a533844386af3..cdacad01c1f0aacdb2a2980dba2f9b4a6d463c0c 100644 (file)
@@ -248,6 +248,7 @@ typedef struct {
    int num_components;
    ppir_dest dest;
    ppir_src src;
+   int num_src;
 } ppir_load_node;
 
 typedef struct {
@@ -457,8 +458,9 @@ static inline int ppir_node_get_src_num(ppir_node *node)
       return ppir_node_to_alu(node)->num_src;
    case ppir_node_type_branch:
       return ppir_node_to_branch(node)->num_src;
-   case ppir_node_type_load_texture:
    case ppir_node_type_load:
+      return ppir_node_to_load(node)->num_src;
+   case ppir_node_type_load_texture:
    case ppir_node_type_store:
       return 1;
    default: