nir/spirv: Add support for device groups
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 21 Sep 2017 22:51:55 +0000 (15:51 -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>
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_system_values.c
src/compiler/shader_enums.c
src/compiler/shader_enums.h
src/compiler/shader_info.h
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_variables.c

index c676331000fc59df953ab2ab323eee41c427bd8a..804a6561bfff8c0cf506a2a1b66e2a9ce0050523 100644 (file)
@@ -1888,6 +1888,8 @@ typedef struct nir_shader_compiler_options {
 
    bool lower_cs_local_index_from_id;
 
+   bool lower_device_index_to_zero;
+
    /**
     * Should nir_lower_io() create load_interpolated_input intrinsics?
     *
index 3594f4ae5ceb7792b35c17868761676113f12178..fb560ee21bb3c420f8786b01c2ba6ea80cacd28f 100644 (file)
@@ -133,6 +133,11 @@ convert_block(nir_block *block, nir_builder *b)
          break;
       }
 
+      case SYSTEM_VALUE_DEVICE_INDEX:
+         if (b->shader->options->lower_device_index_to_zero)
+            sysval = nir_imm_int(b, 0);
+         break;
+
       default:
          break;
       }
index 2179c475abd413d9fa06ee6b7319732b99ce749b..62c1ac1f0730afcea7e64febf790074a44de0a31 100644 (file)
@@ -232,6 +232,7 @@ gl_system_value_name(gl_system_value sysval)
      ENUM(SYSTEM_VALUE_GLOBAL_INVOCATION_ID),
      ENUM(SYSTEM_VALUE_WORK_GROUP_ID),
      ENUM(SYSTEM_VALUE_NUM_WORK_GROUPS),
+     ENUM(SYSTEM_VALUE_DEVICE_INDEX),
      ENUM(SYSTEM_VALUE_VIEW_INDEX),
      ENUM(SYSTEM_VALUE_VERTEX_CNT),
    };
index ac83c65b30c7ea4788ec7f6913e80c8d00129af7..64fb68828ed808c8a78bed9d759db51883ae038c 100644 (file)
@@ -558,6 +558,9 @@ typedef enum
    SYSTEM_VALUE_LOCAL_GROUP_SIZE,
    /*@}*/
 
+   /** Required for VK_KHR_device_group */
+   SYSTEM_VALUE_DEVICE_INDEX,
+
    /** Required for VK_KHX_multiview */
    SYSTEM_VALUE_VIEW_INDEX,
 
index 2fcbde74bee7ef876628b5c7a59d9cef013697f6..00aee77c00297bda63e0f05626c40d9daa254dfe 100644 (file)
@@ -36,6 +36,7 @@ struct spirv_supported_capabilities {
    bool float64;
    bool image_ms_array;
    bool tessellation;
+   bool device_group;
    bool draw_parameters;
    bool image_read_without_format;
    bool image_write_without_format;
index 1c52f7ff615acfb5e8de2879621bc6bbb8eb3b26..f0122a43424163892f1ce8462b02d50111fb008b 100644 (file)
@@ -3283,6 +3283,10 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
          spv_check_supported(image_write_without_format, cap);
          break;
 
+      case SpvCapabilityDeviceGroup:
+         spv_check_supported(device_group, cap);
+         break;
+
       case SpvCapabilityMultiView:
          spv_check_supported(multiview, cap);
          break;
index 11d2aabac8c530486e54caab1967c82767e76800..da511a44b08c26b12aa6d8941bfe9a4d700b0599 100644 (file)
@@ -1293,6 +1293,10 @@ vtn_get_builtin_location(struct vtn_builder *b,
       *location = SYSTEM_VALUE_DRAW_ID;
       set_mode_system_value(b, mode);
       break;
+   case SpvBuiltInDeviceIndex:
+      *location = SYSTEM_VALUE_DEVICE_INDEX;
+      set_mode_system_value(b, mode);
+      break;
    case SpvBuiltInViewIndex:
       *location = SYSTEM_VALUE_VIEW_INDEX;
       set_mode_system_value(b, mode);