gallivm/nir: add a mesh interface and vert/prim count setting.

This adds a callback to the driver for a mesh interface to implement
the set_vertex_and_primitive_count intrinsic

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23066>
This commit is contained in:
Dave Airlie 2023-05-17 11:42:19 +10:00
parent 24fe5abbae
commit a29ed5ba5d
4 changed files with 39 additions and 0 deletions

View file

@ -2218,6 +2218,11 @@ visit_intrinsic(struct lp_build_nir_context *bld_base,
case nir_intrinsic_task_payload_atomic_swap:
visit_payload_atomic(bld_base, instr, result);
break;
case nir_intrinsic_set_vertex_and_primitive_count:
bld_base->set_vertex_and_primitive_count(bld_base,
get_src(bld_base, instr->src[0]),
get_src(bld_base, instr->src[1]));
break;
default:
fprintf(stderr, "Unsupported intrinsic: ");
nir_print_instr(&instr->instr, stderr);

View file

@ -231,6 +231,9 @@ struct lp_build_nir_context
unsigned const_index,
LLVMValueRef indir_index,
LLVMValueRef offsets[2], LLVMValueRef dst[4]);
void (*set_vertex_and_primitive_count)(struct lp_build_nir_context *bld_base,
LLVMValueRef vert_count,
LLVMValueRef prim_count);
void (*launch_mesh_workgroups)(struct lp_build_nir_context *bld_base,
LLVMValueRef launch_grid);
// LLVMValueRef main_function
@ -270,6 +273,8 @@ struct lp_build_nir_soa_context
const struct lp_build_tcs_iface *tcs_iface;
const struct lp_build_tes_iface *tes_iface;
const struct lp_build_fs_iface *fs_iface;
const struct lp_build_mesh_iface *mesh_iface;
LLVMValueRef emitted_prims_vec_ptr[PIPE_MAX_VERTEX_STREAMS];
LLVMValueRef total_emitted_vertices_vec_ptr[PIPE_MAX_VERTEX_STREAMS];
LLVMValueRef emitted_vertices_vec_ptr[PIPE_MAX_VERTEX_STREAMS];

View file

@ -2517,6 +2517,24 @@ emit_interp_at(struct lp_build_nir_context *bld_base,
}
}
static void
emit_set_vertex_and_primitive_count(struct lp_build_nir_context *bld_base,
LLVMValueRef vert_count,
LLVMValueRef prim_count)
{
struct lp_build_nir_soa_context *bld = (struct lp_build_nir_soa_context *)bld_base;
struct gallivm_state *gallivm = bld_base->base.gallivm;
assert(bld->mesh_iface);
LLVMValueRef idx = first_active_invocation(bld_base);
LLVMValueRef vcount = LLVMBuildExtractElement(gallivm->builder,
vert_count, idx, "");
LLVMValueRef pcount = LLVMBuildExtractElement(gallivm->builder,
prim_count, idx, "");
bld->mesh_iface->emit_vertex_and_primitive_count(bld->mesh_iface, &bld_base->base, vcount, pcount);
}
static void
emit_launch_mesh_workgroups(struct lp_build_nir_context *bld_base,
LLVMValueRef launch_grid)
@ -2765,6 +2783,7 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
bld.bld_base.store_scratch = emit_store_scratch;
bld.bld_base.load_const = emit_load_const;
bld.bld_base.clock = emit_clock;
bld.bld_base.set_vertex_and_primitive_count = emit_set_vertex_and_primitive_count;
bld.bld_base.launch_mesh_workgroups = emit_launch_mesh_workgroups;
bld.mask = params->mask;
@ -2793,6 +2812,7 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
bld.tcs_iface = params->tcs_iface;
bld.tes_iface = params->tes_iface;
bld.fs_iface = params->fs_iface;
bld.mesh_iface = params->mesh_iface;
if (bld.gs_iface) {
struct lp_build_context *uint_bld = &bld.bld_base.uint_bld;

View file

@ -278,6 +278,7 @@ struct lp_build_tgsi_params {
const struct lp_build_gs_iface *gs_iface;
const struct lp_build_tcs_iface *tcs_iface;
const struct lp_build_tes_iface *tes_iface;
const struct lp_build_mesh_iface *mesh_iface;
LLVMValueRef ssbo_ptr;
LLVMValueRef ssbo_sizes_ptr;
const struct lp_build_image_soa *image;
@ -505,6 +506,14 @@ struct lp_build_tes_iface
LLVMValueRef swizzle_index);
};
struct lp_build_mesh_iface
{
void (*emit_vertex_and_primitive_count)(const struct lp_build_mesh_iface *mesh_iface,
struct lp_build_context *bld,
LLVMValueRef vertices_count,
LLVMValueRef primitives_count);
};
struct lp_build_tgsi_soa_context
{
struct lp_build_tgsi_context bld_base;