lima/ppir: Add gl_PointCoord handling
authorAndreas Baierl <ichgeh@imkreisrum.de>
Fri, 31 May 2019 07:54:27 +0000 (09:54 +0200)
committerQiang Yu <yuq825@gmail.com>
Thu, 18 Jul 2019 13:20:39 +0000 (13:20 +0000)
Treat gl_PointCoord as a system value and
add the necessary bits for correct codegen.

Signed-off-by: Andreas Baierl <ichgeh@imkreisrum.de>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/drivers/lima/ir/pp/codegen.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
src/gallium/drivers/lima/lima_screen.c

index 09cf5e623bd9cbb546af45c194283ce36133a23c..6a90dc6ede793944ae637754da6e0639625b2864 100644 (file)
@@ -56,7 +56,8 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code)
    if (num_components) {
       assert(node->op == ppir_op_load_varying ||
              node->op == ppir_op_load_coords ||
-             node->op == ppir_op_load_fragcoord);
+             node->op == ppir_op_load_fragcoord ||
+             node->op == ppir_op_load_pointcoord);
 
       f->imm.dest = index >> 2;
       f->imm.mask = dest->write_mask << (index & 0x3);
@@ -70,9 +71,16 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code)
       else
          f->imm.index = load->index >> alignment;
 
-      if (node->op == ppir_op_load_fragcoord) {
-         f->imm.source_type = 2;
-         f->imm.perspective = 3;
+      switch (node->op) {
+         case ppir_op_load_fragcoord:
+            f->imm.source_type = 2;
+            f->imm.perspective = 3;
+            break;
+         case ppir_op_load_pointcoord:
+            f->imm.source_type = 3;
+            break;
+         default:
+            break;
       }
    }
    else {
index 55d961919102b2d6c0fbb924149173001a138c68..c7858640f01afa65d36f234b962a5b58ed97a1a9 100644 (file)
@@ -285,6 +285,17 @@ static ppir_node *ppir_emit_intrinsic(ppir_block *block, nir_instr *ni)
       lnode->num_components = instr->num_components;
       return &lnode->node;
 
+   case nir_intrinsic_load_point_coord:
+      if (!instr->dest.is_ssa)
+         mask = u_bit_consecutive(0, instr->num_components);
+
+      lnode = ppir_node_create_dest(block, ppir_op_load_pointcoord, &instr->dest, mask);
+      if (!lnode)
+         return NULL;
+
+      lnode->num_components = instr->num_components;
+      return &lnode->node;
+
    case nir_intrinsic_load_uniform:
       if (!instr->dest.is_ssa)
          mask = u_bit_consecutive(0, instr->num_components);
index 5522b875269561745992ee09229ee341b59b8302..280e08e9e2d6c5964ca4a0fe0a9803aadec86384 100644 (file)
@@ -254,6 +254,13 @@ const ppir_op_info ppir_op_infos[] = {
          PPIR_INSTR_SLOT_VARYING, PPIR_INSTR_SLOT_END
       },
    },
+   [ppir_op_load_pointcoord] = {
+      .name = "ld_pointcoord",
+      .type = ppir_node_type_load,
+      .slots = (int []) {
+         PPIR_INSTR_SLOT_VARYING, PPIR_INSTR_SLOT_END
+      },
+   },
    [ppir_op_load_uniform] = {
       .name = "ld_uni",
       .type = ppir_node_type_load,
index 22678ae33498daf16b6827ae898fa9bf0159ee29..fc1671985e3d7d1b13709ebb5c2cb8f00c969007 100644 (file)
@@ -240,7 +240,8 @@ static bool ppir_do_node_to_instr(ppir_block *block, ppir_node *node)
          load->dest.pipeline = ppir_pipeline_reg_uniform;
       }
       else if (node->op == ppir_op_load_varying ||
-               node->op == ppir_op_load_fragcoord) {
+               node->op == ppir_op_load_fragcoord ||
+               node->op == ppir_op_load_pointcoord) {
          /* delay the load varying dup to scheduler */
          if (!create_new_instr(block, node))
             return false;
index dafbd9425322ca66c13b5de5c6d9e3dddeb17434..3395a13ee564c438162373c1e2083dbd9d4cab36 100644 (file)
@@ -103,6 +103,7 @@ typedef enum {
    ppir_op_load_varying,
    ppir_op_load_coords,
    ppir_op_load_fragcoord,
+   ppir_op_load_pointcoord,
    ppir_op_load_texture,
    ppir_op_load_temp,
 
index 7cced495696054798d7f9a43abc07c6f48e4d85e..b3f7fff26c4c24746eeaee8809d160b1c0267ce5 100644 (file)
@@ -117,6 +117,7 @@ lima_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
       return 1;
 
    case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
+   case PIPE_CAP_TGSI_FS_POINT_IS_SYSVAL:
       return 1;
 
    case PIPE_CAP_MAX_TEXTURE_2D_SIZE: