zink/spirv: implement discard
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
@@ -1021,6 +1021,16 @@ emit_store_output(struct ntv_context *ctx, nir_intrinsic_instr *intr)
|
||||
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)
|
||||
{
|
||||
@@ -1037,6 +1047,10 @@ 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);
|
||||
|
||||
@@ -487,6 +487,13 @@ spirv_builder_set_phi_operand(struct spirv_builder *b, size_t position,
|
||||
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,
|
||||
|
||||
@@ -194,6 +194,8 @@ void
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user