st/glsl_to_nir: lower indirect derefs of builtins in non-packed uniform case

the builtin lowering can't handle dynamic array indexing, so this requires
that all indirect derefs be lowered any time this pass is invoked in order
to avoid crashing

fixes #4132

Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9741>
This commit is contained in:
Mike Blumenkrantz
2021-03-21 14:07:26 -04:00
committed by Marge Bot
parent 6900498faa
commit f9c83782f7

View File

@@ -513,8 +513,15 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
* storage don't need to lower builtins.
*/
if (!shader_program->data->spirv &&
!st->ctx->Const.PackedDriverUniformStorage)
!st->ctx->Const.PackedDriverUniformStorage) {
/* at this point, array uniforms have been split into separate
* nir_variable structs where possible. this codepath can't handle dynamic
* array indexing, however, so all indirect uniform derefs
* must be eliminated beforehand to avoid trying to lower one of those builtins
*/
NIR_PASS_V(nir, nir_lower_indirect_builtin_uniform_derefs);
NIR_PASS_V(nir, st_nir_lower_builtin);
}
if (!screen->get_param(screen, PIPE_CAP_NIR_ATOMICS_AS_DEREF))
NIR_PASS_V(nir, gl_nir_lower_atomics, shader_program, true);