From 597bd11b7b328b13dde8051e57388e08a9e9a4b2 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 2 Mar 2022 14:03:42 -0500 Subject: [PATCH] mesa/st: add a gl_program struct flag to skip psiz exports for xfb if this output did not exist in the original shader, then it must not be exported in xfb Reviewed-by: Ilia Mirkin Part-of: --- src/mesa/main/shader_types.h | 3 +++ src/mesa/state_tracker/st_glsl_to_nir.cpp | 2 ++ src/mesa/state_tracker/st_program.c | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/src/mesa/main/shader_types.h b/src/mesa/main/shader_types.h index 0df22fa9c84..c832ca1a095 100644 --- a/src/mesa/main/shader_types.h +++ b/src/mesa/main/shader_types.h @@ -531,6 +531,9 @@ struct gl_program /** Is this program written to on disk shader cache */ bool program_written_to_cache; + /** whether to skip VARYING_SLOT_PSIZ in st_translate_stream_output_info() */ + bool skip_pointsize_xfb; + /** A bitfield indicating which vertex shader inputs consume two slots * * This is used for mapping from single-slot input locations in the GL API diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 9340e094e36..b806cfbf982 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -304,6 +304,8 @@ st_nir_preprocess(struct st_context *st, struct gl_program *prog, st->ctx->SoftFP64 = glsl_float64_funcs_to_nir(st->ctx, options); } + prog->skip_pointsize_xfb = !(nir->info.outputs_written & VARYING_BIT_PSIZ); + /* ES has strict SSO validation rules for shader IO matching so we can't * remove dead IO until the resource list has been built. Here we skip * removing them until later. This will potentially make the IO lowering diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index d3985a44c71..d16a2ff688e 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -472,6 +472,12 @@ st_translate_stream_output_info(struct gl_program *prog) memset(output_mapping, 0, sizeof(output_mapping)); for (unsigned attr = 0; attr < VARYING_SLOT_MAX; attr++) { + /* this output was added by mesa/st and should not be tracked for xfb: + * drivers must check var->data.explicit_location to find the original output + * and only emit that one for xfb + */ + if (prog->skip_pointsize_xfb && attr == VARYING_SLOT_PSIZ) + continue; if (prog->info.outputs_written & BITFIELD64_BIT(attr)) output_mapping[attr] = num_outputs++; }