unreachable("output-addressing not yet supported");
}
+static void
+emit_discard(struct ntv_context *ctx, nir_intrinsic_instr *intr)
+{
+ assert(ctx->block_started);
+ spirv_builder_emit_kill(&ctx->builder);
+ /* discard is weird in NIR, so let's just create an unreachable block after
+ it and hope that the vulkan driver will DCE any instructinos in it. */
+ spirv_builder_label(&ctx->builder, spirv_builder_new_id(&ctx->builder));
+}
+
static void
emit_intrinsic(struct ntv_context *ctx, nir_intrinsic_instr *intr)
{
emit_store_output(ctx, intr);
break;
+ case nir_intrinsic_discard:
+ emit_discard(ctx, intr);
+ break;
+
default:
fprintf(stderr, "emit_intrinsic: not implemented (%s)\n",
nir_intrinsic_infos[intr->intrinsic].name);
b->instructions.words[position + index * 2 + 1] = parent;
}
+void
+spirv_builder_emit_kill(struct spirv_builder *b)
+{
+ spirv_buffer_prepare(&b->instructions, 1);
+ spirv_buffer_emit_word(&b->instructions, SpvOpKill | (1 << 16));
+}
+
SpvId
spirv_builder_emit_image_sample_implicit_lod(struct spirv_builder *b,
SpvId result_type,
spirv_builder_set_phi_operand(struct spirv_builder *b, size_t position,
size_t index, SpvId variable, SpvId parent);
+void
+spirv_builder_emit_kill(struct spirv_builder *b);
SpvId
spirv_builder_emit_image_sample_implicit_lod(struct spirv_builder *b,