gallivm: add new compute related intrinsics
authorDave Airlie <airlied@redhat.com>
Sun, 21 Jul 2019 22:27:27 +0000 (08:27 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 4 Sep 2019 05:22:20 +0000 (15:22 +1000)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c

index ed3465874bc5e0b1795507fc208d102f655513ef..5bc2f67dbf4a6b54c32725e6dd8c7b3881dcdbd6 100644 (file)
@@ -170,6 +170,9 @@ struct lp_bld_tgsi_system_values {
    LLVMValueRef prim_id;
    LLVMValueRef basevertex;
    LLVMValueRef invocation_id;
+   LLVMValueRef thread_id;
+   LLVMValueRef block_id;
+   LLVMValueRef grid_size;
 };
 
 
index ef27b547b7920cb6060e1d75af8d7ea07b77e54a..e097dcf57096cb155635961c8c72b72c037416f4 100644 (file)
@@ -1690,6 +1690,7 @@ emit_fetch_system_value(
    LLVMBuilderRef builder = gallivm->builder;
    LLVMValueRef res;
    enum tgsi_opcode_type atype; // Actual type of the value
+   unsigned swizzle = swizzle_in & 0xffff;
 
    assert(!reg->Register.Indirect);
 
@@ -1729,6 +1730,21 @@ emit_fetch_system_value(
       atype = TGSI_TYPE_UNSIGNED;
       break;
 
+   case TGSI_SEMANTIC_THREAD_ID:
+      res = LLVMBuildExtractValue(gallivm->builder, bld->system_values.thread_id, swizzle, "");
+      atype = TGSI_TYPE_UNSIGNED;
+      break;
+
+   case TGSI_SEMANTIC_BLOCK_ID:
+      res = lp_build_extract_broadcast(gallivm, lp_type_int_vec(32, 96), bld_base->uint_bld.type, bld->system_values.block_id, lp_build_const_int32(gallivm, swizzle));
+      atype = TGSI_TYPE_UNSIGNED;
+      break;
+
+   case TGSI_SEMANTIC_GRID_SIZE:
+      res = lp_build_extract_broadcast(gallivm, lp_type_int_vec(32, 96), bld_base->uint_bld.type, bld->system_values.grid_size, lp_build_const_int32(gallivm, swizzle));
+      atype = TGSI_TYPE_UNSIGNED;
+      break;
+
    default:
       assert(!"unexpected semantic in emit_fetch_system_value");
       res = bld_base->base.zero;