mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-19 13:38:19 +02:00
To count primitives generated when primitive restart is enabled, we need to dispatch a precomp shader with dimensions that depend on the indirect draw count. For this, we need some kind of precomp dispatch mechanism where the dimensions are determined at execution time. The standard shape for this would be an "indirect precomp" dispatch which reads dimensions from memory, but in this case that would be a little awkward because the draw count is min(*draw_count_buffer, max_draw_count). So to implement that with a typical indirect dispatch mechanism, we would need to read the buffer, compare it with the max draw count, and then write it back to scratch memory, just to read it again. To simplify this, I went for a precomp dispatch mechanism where it just reading the dimensions from the JOB_SIZE registers set by the caller, which can use whatever CS code it wants to calculate them. Signed-off-by: Olivia Lee <olivia.lee@collabora.com> Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38547>
73 lines
1.6 KiB
C
73 lines
1.6 KiB
C
/*
|
|
* Copyright 2024 Collabora Ltd.
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#ifndef LIBPAN_DGC_H
|
|
#define LIBPAN_DGC_H
|
|
#include "libpan.h"
|
|
|
|
enum panlib_barrier {
|
|
PANLIB_BARRIER_NONE = 0,
|
|
PANLIB_BARRIER_JM_BARRIER = (1 << 0),
|
|
PANLIB_BARRIER_JM_SUPPRESS_PREFETCH = (1 << 1),
|
|
/* On panvk, increment the syncobj on the compute subqueue */
|
|
PANLIB_BARRIER_CSF_SYNC = (1 << 2),
|
|
/* On panvk, insert a WAIT on the compute dispatch */
|
|
PANLIB_BARRIER_CSF_WAIT = (1 << 3),
|
|
};
|
|
|
|
struct panlib_precomp_grid {
|
|
uint32_t count[3];
|
|
|
|
union {
|
|
struct {
|
|
uint16_t local_dep;
|
|
uint16_t global_dep;
|
|
} jm;
|
|
|
|
struct {
|
|
/* If set, the dispatch size is determined at execution time, and
|
|
* passed in by the caller in the JOB_SIZE_{X,Y,Z} SRs */
|
|
bool dynamic_count;
|
|
} csf;
|
|
};
|
|
};
|
|
|
|
static struct panlib_precomp_grid
|
|
panlib_3d(uint32_t x, uint32_t y, uint32_t z)
|
|
{
|
|
return (struct panlib_precomp_grid){.count = {x, y, z}};
|
|
}
|
|
|
|
static struct panlib_precomp_grid
|
|
panlib_3d_with_jm_deps(uint32_t x, uint32_t y, uint32_t z, uint16_t local_dep,
|
|
uint16_t global_dep)
|
|
{
|
|
return (struct panlib_precomp_grid){
|
|
.count = {x, y, z},
|
|
.jm = {local_dep, global_dep},
|
|
};
|
|
}
|
|
|
|
static struct panlib_precomp_grid
|
|
panlib_dynamic_csf()
|
|
{
|
|
return (struct panlib_precomp_grid){
|
|
.csf.dynamic_count = true,
|
|
};
|
|
}
|
|
|
|
static struct panlib_precomp_grid
|
|
panlib_1d(uint32_t x)
|
|
{
|
|
return panlib_3d(x, 1, 1);
|
|
}
|
|
|
|
static struct panlib_precomp_grid
|
|
panlib_1d_with_jm_deps(uint32_t x, uint16_t local_dep, uint16_t global_dep)
|
|
{
|
|
return panlib_3d_with_jm_deps(x, 1, 1, local_dep, global_dep);
|
|
}
|
|
|
|
#endif
|