Module: Mesa Branch: staging/20.0 Commit: 76dbcb1f5e48e10467b15a0e19232eccc3a57ae3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=76dbcb1f5e48e10467b15a0e19232eccc3a57ae3
Author: Danylo Piliaiev <[email protected]> Date: Thu Apr 16 16:34:25 2020 +0300 st/mesa: Update shader info of ffvp/ARB_vp after translation to NIR We must update stp->Base.info after translation and before st_prepare_vertex_program is called, because inputs_read may become outdated after NIR optimization passes. For ffvp/ARB_vp inputs_read is populated based on declared attributes without taking their usage into consideration. When creating shader variants we expect that their inputs_read would match the base ones for input mapping to work properly. Cc: <[email protected]> Fixes: 8a0dd0af3f1a6c0310a08daf4220132ec6815b31 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2758 Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4598> (cherry picked from commit d684fb37bfbc47d098158cb03c0672119a4469fe) --- .pick_status.json | 2 +- src/mesa/state_tracker/st_program.c | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 8acad3bed5d..aeeb689ca4f 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -814,7 +814,7 @@ "description": "st/mesa: Update shader info of ffvp/ARB_vp after translation to NIR", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "8a0dd0af3f1a6c0310a08daf4220132ec6815b31" }, diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 66dc4d16dd9..698ac07a212 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -490,8 +490,6 @@ st_translate_vertex_program(struct st_context *st, if (stp->Base.arb.IsPositionInvariant) _mesa_insert_mvp_code(st->ctx, &stp->Base); - st_prepare_vertex_program(stp); - /* ARB_vp: */ if (!stp->glsl_to_tgsi) { _mesa_remove_output_reads(&stp->Base, PROGRAM_OUTPUT); @@ -518,14 +516,33 @@ st_translate_vertex_program(struct st_context *st, stp->state.type = PIPE_SHADER_IR_NIR; stp->Base.nir = st_translate_prog_to_nir(st, &stp->Base, MESA_SHADER_VERTEX); + + /* We must update stp->Base.info after translation and before + * st_prepare_vertex_program is called, because inputs_read + * may become outdated after NIR optimization passes. + * + * For ffvp/ARB_vp inputs_read is populated based + * on declared attributes without taking their usage into + * consideration. When creating shader variants we expect + * that their inputs_read would match the base ones for + * input mapping to work properly. + */ + nir_shader_gather_info(stp->Base.nir, + nir_shader_get_entrypoint(stp->Base.nir)); + stp->Base.info = stp->Base.nir->info; + /* For st_draw_feedback, we need to generate TGSI too if draw doesn't * use LLVM. */ - if (draw_has_llvm()) + if (draw_has_llvm()) { + st_prepare_vertex_program(stp); return true; + } } } + st_prepare_vertex_program(stp); + /* Get semantic names and indices. */ for (attr = 0; attr < VARYING_SLOT_MAX; attr++) { if (stp->Base.info.outputs_written & BITFIELD64_BIT(attr)) { _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
