lima: introduce ppir_op_load_coords_reg to differentiate between loading texture...
authorArno Messiaen <arnomessiaen@gmail.com>
Sat, 12 Oct 2019 22:05:57 +0000 (00:05 +0200)
committerVasily Khoruzhick <anarsoul@gmail.com>
Thu, 31 Oct 2019 06:29:31 +0000 (06:29 +0000)
Signed-off-by: Arno Messiaen <arnomessiaen@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Reviewed-by: Erico Nunes <nunes.erico@gmail.com>
src/gallium/drivers/lima/ir/pp/codegen.c
src/gallium/drivers/lima/ir/pp/lower.c
src/gallium/drivers/lima/ir/pp/nir.c
src/gallium/drivers/lima/ir/pp/node.c
src/gallium/drivers/lima/ir/pp/node_to_instr.c
src/gallium/drivers/lima/ir/pp/ppir.h

index b6ce500750f7acea04d6e271e2201730052836ed..b2947f300f25a30274742e3457d4b2fc20d3731c 100644 (file)
@@ -53,7 +53,7 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code)
    int index = ppir_target_get_dest_reg_index(dest);
    int num_components = load->num_components;
 
-   if (num_components) {
+   if (node->op != ppir_op_load_coords_reg) {
       assert(node->op == ppir_op_load_varying ||
              node->op == ppir_op_load_coords ||
              node->op == ppir_op_load_fragcoord ||
@@ -94,9 +94,7 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code)
             break;
       }
    }
-   else {
-      assert(node->op == ppir_op_load_coords);
-
+   else {  /* node->op == ppir_op_load_coords_reg */
       f->reg.dest = index >> 2;
       f->reg.mask = dest->write_mask << (index & 0x3);
 
index c0070480a68d6563477555ce460da34fdd54940d..397adf82eab4589ab931496d6ffd5a19e698c082 100644 (file)
@@ -163,13 +163,17 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
       load = ppir_node_to_load(src_coords);
    else {
       /* Create load_coords node */
-      load = ppir_node_create(block, ppir_op_load_coords, -1, 0);
+      load = ppir_node_create(block, ppir_op_load_coords_reg, -1, 0);
       if (!load)
          return false;
       list_addtail(&load->node.list, &node->list);
 
       load->src = load_tex->src_coords;
       load->num_src = 1;
+      if (load_tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE)
+         load->num_components = 3;
+      else
+         load->num_components = 2;
 
       ppir_debug("%s create load_coords node %d for %d\n",
                  __FUNCTION__, load->node.index, node->index);
index 260db1e35af379f73847ef5b7a3d97ca6587331e..6baf4ec93bf4b00a2acc4d864f6fc261a0b5cefd 100644 (file)
@@ -121,6 +121,7 @@ static void ppir_node_add_src(ppir_compiler *comp, ppir_node *node,
          /* Fallthrough */
       case ppir_op_load_uniform:
       case ppir_op_load_coords:
+      case ppir_op_load_coords_reg:
          /* Clone uniform and texture coord loads for each block.
           * Also ensure that each load has a single successor.
           * Let's do a fetch each time and hope for a cache hit instead
index 92f09c8929a8b467f0f304bb6788e2f1f04da457..d06748904a524c540311d95543312e5715d60086 100644 (file)
@@ -260,6 +260,13 @@ const ppir_op_info ppir_op_infos[] = {
          PPIR_INSTR_SLOT_VARYING, PPIR_INSTR_SLOT_END
       },
    },
+   [ppir_op_load_coords_reg] = {
+      .name = "ld_coords_reg",
+      .type = ppir_node_type_load,
+      .slots = (int []) {
+         PPIR_INSTR_SLOT_VARYING, PPIR_INSTR_SLOT_END
+      },
+   },
    [ppir_op_load_fragcoord] = {
       .name = "ld_fragcoord",
       .type = ppir_node_type_load,
@@ -670,6 +677,7 @@ ppir_node *ppir_node_clone(ppir_block *block, ppir_node *node)
    case ppir_op_load_varying:
    case ppir_op_load_temp:
    case ppir_op_load_coords:
+   case ppir_op_load_coords_reg:
       return ppir_node_clone_load(block, node);
    default:
       return NULL;
index d901c2e70869ddbf66efc64bb86a1cf8e395ce31..eb472b5f0f87670fe889cedefed5b456d794f5d6 100644 (file)
@@ -106,6 +106,7 @@ static bool ppir_do_one_node_to_instr(ppir_block *block, ppir_node *node, ppir_n
       switch (node->op) {
       case ppir_op_load_varying:
       case ppir_op_load_coords:
+      case ppir_op_load_coords_reg:
       case ppir_op_load_fragcoord:
       case ppir_op_load_pointcoord:
       case ppir_op_load_frontface:
index 4dc48350fa412c88c1f96759afdbe4e9738353a4..ce4b990c933b331ce010092e617faa9d5bfc1bea 100644 (file)
@@ -99,6 +99,7 @@ typedef enum {
    ppir_op_load_uniform,
    ppir_op_load_varying,
    ppir_op_load_coords,
+   ppir_op_load_coords_reg,
    ppir_op_load_fragcoord,
    ppir_op_load_pointcoord,
    ppir_op_load_frontface,