mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 22:10:10 +01:00
nir: Also gather decomposed primitive count
Simple extension. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Antonino Maniscalco <antonino.maniscalco@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26056>
This commit is contained in:
parent
b65636ca40
commit
cc3f20ca6c
4 changed files with 13 additions and 2 deletions
|
|
@ -3513,7 +3513,7 @@ ac_nir_lower_ngg_gs(nir_shader *shader, const ac_nir_lower_ngg_options *options)
|
||||||
|
|
||||||
if (!options->can_cull) {
|
if (!options->can_cull) {
|
||||||
nir_gs_count_vertices_and_primitives(shader, state.const_out_vtxcnt,
|
nir_gs_count_vertices_and_primitives(shader, state.const_out_vtxcnt,
|
||||||
state.const_out_prmcnt, 4u);
|
state.const_out_prmcnt, NULL, 4u);
|
||||||
state.output_compile_time_known =
|
state.output_compile_time_known =
|
||||||
state.const_out_vtxcnt[0] == shader->info.gs.vertices_out &&
|
state.const_out_vtxcnt[0] == shader->info.gs.vertices_out &&
|
||||||
state.const_out_prmcnt[0] != -1;
|
state.const_out_prmcnt[0] != -1;
|
||||||
|
|
|
||||||
|
|
@ -5023,6 +5023,7 @@ void nir_dump_cfg(nir_shader *shader, FILE *fp);
|
||||||
void nir_gs_count_vertices_and_primitives(const nir_shader *shader,
|
void nir_gs_count_vertices_and_primitives(const nir_shader *shader,
|
||||||
int *out_vtxcnt,
|
int *out_vtxcnt,
|
||||||
int *out_prmcnt,
|
int *out_prmcnt,
|
||||||
|
int *out_decomposed_prmcnt,
|
||||||
unsigned num_streams);
|
unsigned num_streams);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
||||||
|
|
@ -56,12 +56,14 @@ void
|
||||||
nir_gs_count_vertices_and_primitives(const nir_shader *shader,
|
nir_gs_count_vertices_and_primitives(const nir_shader *shader,
|
||||||
int *out_vtxcnt,
|
int *out_vtxcnt,
|
||||||
int *out_prmcnt,
|
int *out_prmcnt,
|
||||||
|
int *out_decomposed_prmcnt,
|
||||||
unsigned num_streams)
|
unsigned num_streams)
|
||||||
{
|
{
|
||||||
assert(num_streams);
|
assert(num_streams);
|
||||||
|
|
||||||
int vtxcnt_arr[4] = { -1, -1, -1, -1 };
|
int vtxcnt_arr[4] = { -1, -1, -1, -1 };
|
||||||
int prmcnt_arr[4] = { -1, -1, -1, -1 };
|
int prmcnt_arr[4] = { -1, -1, -1, -1 };
|
||||||
|
int decomposed_prmcnt_arr[4] = { -1, -1, -1, -1 };
|
||||||
bool cnt_found[4] = { false, false, false, false };
|
bool cnt_found[4] = { false, false, false, false };
|
||||||
|
|
||||||
nir_foreach_function_impl(impl, shader) {
|
nir_foreach_function_impl(impl, shader) {
|
||||||
|
|
@ -82,6 +84,7 @@ nir_gs_count_vertices_and_primitives(const nir_shader *shader,
|
||||||
|
|
||||||
int vtxcnt = -1;
|
int vtxcnt = -1;
|
||||||
int prmcnt = -1;
|
int prmcnt = -1;
|
||||||
|
int decomposed_prmcnt = -1;
|
||||||
|
|
||||||
/* If the number of vertices/primitives is compile-time known, we use that,
|
/* If the number of vertices/primitives is compile-time known, we use that,
|
||||||
* otherwise we leave it at -1 which means that it's unknown.
|
* otherwise we leave it at -1 which means that it's unknown.
|
||||||
|
|
@ -90,6 +93,8 @@ nir_gs_count_vertices_and_primitives(const nir_shader *shader,
|
||||||
vtxcnt = nir_src_as_int(intrin->src[0]);
|
vtxcnt = nir_src_as_int(intrin->src[0]);
|
||||||
if (nir_src_is_const(intrin->src[1]))
|
if (nir_src_is_const(intrin->src[1]))
|
||||||
prmcnt = nir_src_as_int(intrin->src[1]);
|
prmcnt = nir_src_as_int(intrin->src[1]);
|
||||||
|
if (nir_src_is_const(intrin->src[2]))
|
||||||
|
decomposed_prmcnt = nir_src_as_int(intrin->src[2]);
|
||||||
|
|
||||||
/* We've found contradictory set_vertex_and_primitive_count intrinsics.
|
/* We've found contradictory set_vertex_and_primitive_count intrinsics.
|
||||||
* This can happen if there are early-returns in main() and
|
* This can happen if there are early-returns in main() and
|
||||||
|
|
@ -99,9 +104,12 @@ nir_gs_count_vertices_and_primitives(const nir_shader *shader,
|
||||||
vtxcnt = -1;
|
vtxcnt = -1;
|
||||||
if (cnt_found[stream] && prmcnt != prmcnt_arr[stream])
|
if (cnt_found[stream] && prmcnt != prmcnt_arr[stream])
|
||||||
prmcnt = -1;
|
prmcnt = -1;
|
||||||
|
if (cnt_found[stream] && decomposed_prmcnt != decomposed_prmcnt_arr[stream])
|
||||||
|
prmcnt = -1;
|
||||||
|
|
||||||
vtxcnt_arr[stream] = vtxcnt;
|
vtxcnt_arr[stream] = vtxcnt;
|
||||||
prmcnt_arr[stream] = prmcnt;
|
prmcnt_arr[stream] = prmcnt;
|
||||||
|
decomposed_prmcnt_arr[stream] = decomposed_prmcnt;
|
||||||
cnt_found[stream] = true;
|
cnt_found[stream] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -111,4 +119,6 @@ nir_gs_count_vertices_and_primitives(const nir_shader *shader,
|
||||||
memcpy(out_vtxcnt, vtxcnt_arr, num_streams * sizeof(int));
|
memcpy(out_vtxcnt, vtxcnt_arr, num_streams * sizeof(int));
|
||||||
if (out_prmcnt)
|
if (out_prmcnt)
|
||||||
memcpy(out_prmcnt, prmcnt_arr, num_streams * sizeof(int));
|
memcpy(out_prmcnt, prmcnt_arr, num_streams * sizeof(int));
|
||||||
|
if (out_decomposed_prmcnt)
|
||||||
|
memcpy(out_decomposed_prmcnt, decomposed_prmcnt_arr, num_streams * sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -632,7 +632,7 @@ brw_compile_gs(const struct brw_compiler *compiler,
|
||||||
|
|
||||||
if (compiler->devinfo->ver >= 8)
|
if (compiler->devinfo->ver >= 8)
|
||||||
nir_gs_count_vertices_and_primitives(
|
nir_gs_count_vertices_and_primitives(
|
||||||
nir, &prog_data->static_vertex_count, nullptr, 1u);
|
nir, &prog_data->static_vertex_count, nullptr, nullptr, 1u);
|
||||||
|
|
||||||
if (compiler->devinfo->ver >= 7) {
|
if (compiler->devinfo->ver >= 7) {
|
||||||
if (nir->info.gs.output_primitive == MESA_PRIM_POINTS) {
|
if (nir->info.gs.output_primitive == MESA_PRIM_POINTS) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue