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>
struct tgsi_shader_info *info,
const nir_instr *instr)
{
+ info->num_tokens = 2; /* indicate that the shader is non-empty */
+ info->num_instructions = 2;
+
if (instr->type == nir_instr_type_alu) {
const nir_alu_instr *alu = nir_instr_as_alu(instr);
unsigned i;
info->processor = pipe_shader_type_from_mesa(nir->info.stage);
- info->num_tokens = 2; /* indicate that the shader is non-empty */
- info->num_instructions = 2;
+ info->num_tokens = 1; /* Presume empty */
+ info->num_instructions = 1;
info->properties[TGSI_PROPERTY_NEXT_SHADER] =
pipe_shader_type_from_mesa(nir->info.next_stage);