zink: implement load_instance_id
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 30 Jan 2020 19:35:04 +0000 (20:35 +0100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 31 Jan 2020 08:40:24 +0000 (08:40 +0000)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3644>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3644>

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

index 6d2d713b7f9171046c0c55bf037642db0c0ffad7..34bb14379c4b2b963703c04d557a3790f0473e2d 100644 (file)
@@ -57,7 +57,7 @@ struct ntv_context {
    bool block_started;
    SpvId loop_break, loop_cont;
 
-   SpvId front_face_var, vertex_id_var;
+   SpvId front_face_var, instance_id_var, vertex_id_var;
 };
 
 static SpvId
@@ -1313,6 +1313,22 @@ emit_load_front_face(struct ntv_context *ctx, nir_intrinsic_instr *intr)
    store_dest_uint(ctx, &intr->dest, result);
 }
 
+static void
+emit_load_instance_id(struct ntv_context *ctx, nir_intrinsic_instr *intr)
+{
+   SpvId var_type = spirv_builder_type_uint(&ctx->builder, 32);
+   if (!ctx->instance_id_var)
+      ctx->instance_id_var = create_builtin_var(ctx, var_type,
+                                               SpvStorageClassInput,
+                                               "gl_InstanceId",
+                                               SpvBuiltInInstanceIndex);
+
+   SpvId result = spirv_builder_emit_load(&ctx->builder, var_type,
+                                          ctx->instance_id_var);
+   assert(1 == nir_dest_num_components(intr->dest));
+   store_dest_uint(ctx, &intr->dest, result);
+}
+
 static void
 emit_load_vertex_id(struct ntv_context *ctx, nir_intrinsic_instr *intr)
 {
@@ -1353,6 +1369,10 @@ emit_intrinsic(struct ntv_context *ctx, nir_intrinsic_instr *intr)
       emit_load_front_face(ctx, intr);
       break;
 
+   case nir_intrinsic_load_instance_id:
+      emit_load_instance_id(ctx, intr);
+      break;
+
    case nir_intrinsic_load_vertex_id:
       emit_load_vertex_id(ctx, intr);
       break;
index d0a29609881e541545e85ea98a5ba891fea47c7b..9e29a51862ac08c69480cf257794f03903f700c5 100644 (file)
@@ -139,9 +139,8 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
       return 0;
 #endif
 
+   case PIPE_CAP_TGSI_INSTANCEID:
    case PIPE_CAP_MIXED_COLORBUFFER_FORMATS:
-      return 1;
-
    case PIPE_CAP_SEAMLESS_CUBE_MAP:
       return 1;