zink: add conversion util for nir_scope -> SpvScope
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 5 Apr 2021 13:53:44 +0000 (09:53 -0400)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 29 Apr 2021 00:04:08 +0000 (20:04 -0400)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10510>

src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c

index 54ddd40..6b20f82 100644 (file)
@@ -123,6 +123,21 @@ get_bvec_type(struct ntv_context *ctx, int num_components)
    return bool_type;
 }
 
+static SpvScope
+get_scope(nir_scope scope)
+{
+   SpvScope conv[] = {
+      [NIR_SCOPE_NONE] = 0,
+      [NIR_SCOPE_INVOCATION] = SpvScopeInvocation,
+      [NIR_SCOPE_SUBGROUP] = SpvScopeSubgroup,
+      [NIR_SCOPE_SHADER_CALL] = SpvScopeShaderCallKHR,
+      [NIR_SCOPE_WORKGROUP] = SpvScopeWorkgroup,
+      [NIR_SCOPE_QUEUE_FAMILY] = SpvScopeQueueFamily,
+      [NIR_SCOPE_DEVICE] = SpvScopeDevice,
+   };
+   return conv[scope];
+}
+
 static SpvId
 block_label(struct ntv_context *ctx, nir_block *block)
 {