i965/fs: Implement basic SPIR-V subgroup intrinsics
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 22 Aug 2017 05:17:37 +0000 (22:17 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 7 Mar 2018 20:13:47 +0000 (12:13 -0800)
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/intel/compiler/brw_fs_nir.cpp
src/intel/compiler/brw_nir_lower_cs_intrinsics.c

index 554d61d71af54087026323764fc31abee31011ed..651997bb6ff50a8f48697df2926de005abde1f4a 100644 (file)
@@ -4501,6 +4501,14 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
       break;
    }
 
+   case nir_intrinsic_first_invocation: {
+      fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_UD);
+      bld.exec_all().emit(SHADER_OPCODE_FIND_LIVE_CHANNEL, tmp);
+      bld.MOV(retype(dest, BRW_REGISTER_TYPE_UD),
+              fs_reg(component(tmp, 0)));
+      break;
+   }
+
    default:
       unreachable("unknown intrinsic");
    }
index 66eef6be0a609d0544f5c31a8b59c6a240cd178b..bfbdea0e8fa322fa6bca7decdd7f4f6dfb76ed24 100644 (file)
@@ -103,6 +103,24 @@ lower_cs_intrinsics_convert_block(struct lower_intrinsics_state *state,
          break;
       }
 
+      case nir_intrinsic_load_subgroup_id:
+         if (state->local_workgroup_size > 8)
+            continue;
+
+         /* For small workgroup sizes, we know subgroup_id will be zero */
+         sysval = nir_imm_int(b, 0);
+         break;
+
+      case nir_intrinsic_load_num_subgroups: {
+         unsigned local_workgroup_size =
+            nir->info.cs.local_size[0] * nir->info.cs.local_size[1] *
+            nir->info.cs.local_size[2];
+         unsigned num_subgroups =
+            DIV_ROUND_UP(local_workgroup_size, state->dispatch_width);
+         sysval = nir_imm_int(b, num_subgroups);
+         break;
+      }
+
       default:
          continue;
       }