Skip to content

mesa/st: make sure we remove dead IO variables before handing NIR to backends

Iago Toral requested to merge itoral/mesa:st_remove_dead_io_vars into master

Commit "1c2bf82d glsl: disable lower_fragdata_array() for NIR drivers" disabled the GLSL IR lowering that turned gl_FragData from an array into a collection of scalar outputs under the assumption that this was already being handled properly elsewhere, however there are some corner cases where NIR would fail to do this, leaving gl_FragData[] as an array variable. This can break backends that assume that all their outputs will be scalar and use the variable definitions from the shader to do their output setup, such as the case of V3D.

At least one corner case was found in some Portal shaders from shader-db, where NIR would optimize out the full body of a fragment shader. In this scenario, the empty shader would keep the original array definition of gl_FragData[], causing the backend to assert.

We need to do this late enough for it to be effective, since doing it in st_nir_preprocess does not fix the original problem.

Merge request reports