panfrost: Create transform feedback shaders

Valhall has no architectural support for transform feedback. So if a vertex
shader uses transform feedback, we need to split the shader into two: a pure
vertex stage and a compute-like transform feedback stage. This splitting
resembles the splitting we do for IDVS.

When compiling a vertex shader that uses transform feedback on Bifrost, also
compile the transform feedback variant. That variant (marked by internal=true)
will get its stores lowered by the NIR pass introduced earlier in this series.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15720>
This commit is contained in:
Alyssa Rosenzweig 2022-06-02 10:51:16 -04:00 committed by Marge Bot
parent ed5a5a9d6d
commit a510a94b02
3 changed files with 23 additions and 0 deletions

View file

@ -47,6 +47,19 @@ panfrost_shader_compile(struct pipe_screen *pscreen,
nir_shader *s = nir_shader_clone(NULL, ir);
if (dev->arch >= 6 && s->xfb_info && !s->info.internal) {
/* Create compute shader doing transform feedback */
nir_shader *xfb = nir_shader_clone(NULL, s);
xfb->info.name = ralloc_asprintf(xfb, "%s@xfb", xfb->info.name);
xfb->info.internal = true;
state->xfb = calloc(1, sizeof(struct panfrost_shader_state));
panfrost_shader_compile(pscreen, shader_pool, desc_pool, xfb, state->xfb);
/* Main shader no longer uses XFB */
s->info.has_transform_feedback_varyings = false;
}
/* Lower this early so the backends don't have to worry about it */
if (s->info.stage == MESA_SHADER_FRAGMENT) {
NIR_PASS_V(s, nir_lower_fragcolor, state->key.fs.nr_cbufs);

View file

@ -342,6 +342,13 @@ panfrost_delete_shader_state(
panfrost_bo_unreference(shader_state->bin.bo);
panfrost_bo_unreference(shader_state->state.bo);
panfrost_bo_unreference(shader_state->linkage.bo);
if (shader_state->xfb) {
panfrost_bo_unreference(shader_state->xfb->bin.bo);
panfrost_bo_unreference(shader_state->xfb->state.bo);
panfrost_bo_unreference(shader_state->xfb->linkage.bo);
free(shader_state->xfb);
}
}
simple_mtx_destroy(&cso->lock);

View file

@ -290,6 +290,9 @@ struct panfrost_shader_state {
struct pan_shader_info info;
/* Attached transform feedback program, if one exists */
struct panfrost_shader_state *xfb;
/* Linked varyings, for non-separable programs */
struct pan_linkage linkage;