lima/ppir: Add gl_FrontFace handling
authorAndreas Baierl <ichgeh@imkreisrum.de>
Thu, 1 Aug 2019 09:35:28 +0000 (11:35 +0200)
committerQiang Yu <yuq825@gmail.com>
Sat, 3 Aug 2019 08:04:12 +0000 (08:04 +0000)
Signed-off-by: Andreas Baierl <ichgeh@imkreisrum.de>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
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 7259eb6ec02e290b098bd6ed9c1597095a88f8c1..96f1ffce000033484060679c4b8c82d81166a5ce 100644 (file)
@@ -57,7 +57,8 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code)
       assert(node->op == ppir_op_load_varying ||
              node->op == ppir_op_load_coords ||
              node->op == ppir_op_load_fragcoord ||
-             node->op == ppir_op_load_pointcoord);
+             node->op == ppir_op_load_pointcoord ||
+             node->op == ppir_op_load_frontface);
 
       f->imm.dest = index >> 2;
       f->imm.mask = dest->write_mask << (index & 0x3);
@@ -79,6 +80,10 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code)
          case ppir_op_load_pointcoord:
             f->imm.source_type = 3;
             break;
+         case ppir_op_load_frontface:
+            f->imm.source_type = 3;
+            f->imm.perspective = 1;
+            break;
          default:
             break;
       }
index 552dbdbe0578b228064f9af535440d0aa516d9e5..b0714c8363f5f1d3d8cf009caebe93749db70ea4 100644 (file)
@@ -271,21 +271,28 @@ static ppir_node *ppir_emit_intrinsic(ppir_block *block, nir_instr *ni)
       return &lnode->node;
 
    case nir_intrinsic_load_frag_coord:
-      if (!instr->dest.is_ssa)
-         mask = u_bit_consecutive(0, instr->num_components);
-
-      lnode = ppir_node_create_dest(block, ppir_op_load_fragcoord, &instr->dest, mask);
-      if (!lnode)
-         return NULL;
-
-      lnode->num_components = instr->num_components;
-      return &lnode->node;
-
    case nir_intrinsic_load_point_coord:
+   case nir_intrinsic_load_front_face:
       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);
+      ppir_op op;
+      switch (instr->intrinsic) {
+      case nir_intrinsic_load_frag_coord:
+         op = ppir_op_load_fragcoord;
+         break;
+      case nir_intrinsic_load_point_coord:
+         op = ppir_op_load_pointcoord;
+         break;
+      case nir_intrinsic_load_front_face:
+         op = ppir_op_load_frontface;
+         break;
+      default:
+         assert(0);
+         break;
+      }
+
+      lnode = ppir_node_create_dest(block, op, &instr->dest, mask);
       if (!lnode)
          return NULL;
 
index 5e1264d6cd9a5a5a1b7aed6b96ee0931f12591c4..c62e4cc2e5700787a2cc906ec2564c1a5155b45c 100644 (file)
@@ -252,6 +252,13 @@ const ppir_op_info ppir_op_infos[] = {
          PPIR_INSTR_SLOT_VARYING, PPIR_INSTR_SLOT_END
       },
    },
+   [ppir_op_load_frontface] = {
+      .name = "ld_frontface",
+      .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 478c4f66f2d2bf91087799ef815bb236d2d3a584..baf5b0d815ac7211826e5f4765635248d20a666e 100644 (file)
@@ -233,7 +233,8 @@ static bool ppir_do_node_to_instr(ppir_block *block, ppir_node *node)
       }
       else if (node->op == ppir_op_load_varying ||
                node->op == ppir_op_load_fragcoord ||
-               node->op == ppir_op_load_pointcoord) {
+               node->op == ppir_op_load_pointcoord ||
+               node->op == ppir_op_load_frontface) {
          /* delay the load varying dup to scheduler */
          if (!create_new_instr(block, node))
             return false;
index f5119b0cb115b88025207d4288460b30ca30a9ad..63494bab2af5e8605c882011afd858bcaf1cc434 100644 (file)
@@ -100,6 +100,7 @@ typedef enum {
    ppir_op_load_coords,
    ppir_op_load_fragcoord,
    ppir_op_load_pointcoord,
+   ppir_op_load_frontface,
    ppir_op_load_texture,
    ppir_op_load_temp,
 
index 3ae70b87ef10e281bca02d10c20a75db219d3d7d..26a7051e67eeabe300e5991674e405d76101faad 100644 (file)
@@ -118,6 +118,7 @@ lima_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
 
    case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
    case PIPE_CAP_TGSI_FS_POINT_IS_SYSVAL:
+   case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
       return 1;
 
    case PIPE_CAP_MAX_TEXTURE_2D_SIZE: