nir: Recognize empty shaders in nir_tgsi_scan_shader().
authorJose Fonseca <jfonseca@vmware.com>
Mon, 5 Dec 2022 10:28:15 +0000 (10:28 +0000)
committerMarge Bot <emma+marge@anholt.net>
Tue, 6 Dec 2022 11:44:11 +0000 (11:44 +0000)
commit36a7d6788c92f69e7463fb7e3cd4f1154dea767d
tree7777236fa699b2d8b294d9762c96a952f1eb9252
parentdcf3ae72abf78e8959c5b5a94ef332c0b7396ab2
nir: Recognize empty shaders in nir_tgsi_scan_shader().

When a null PS is bound, the
pipe_query_data_pipeline_statistics::ps_invocations counter should not
be incremented.

However llvmpipe can't cope with a null PS bound, requiring the state
tracker to bind an empty pixel shader instead.  llvmpipe infers empty
TGSI pixel shaders by looking tgsi_shader_info::num_instructions, as an
empty shader should have a single END instruction, but this logic wasn't
working for NIR shaders.

I mulled over the possibility of making llvmpipe handle null pixel
shaders.  Spreading null checks everywhere would be invasive and error
prone, but it would be quite simple if llvmpipe simply created a dummy
PS internally, to be used as a replacement whenever a null PS was bound.
That said, I'm not sure if other gallium drivers can cope with a null PS
neither, and if nought, might as well keep using an empty PS in lavapipe
state tracker.  An any rate, this change makes sense on its own.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20155>
src/gallium/auxiliary/nir/nir_to_tgsi_info.c