Skip to content

glsl: don't tree graft globals

Timothy Arceri requested to merge tarceri/mesa:fix_tree_graft into main

glsl: don't tree graft globals

As per this optimisations description:

"Takes assignments to variables that are dereferenced only once and pastes the RHS expression into where the variables dereferenced."

However the optimisation is run at compile time before multiple shaders from the same stage could have been pasted together. So this optimisation can incorrectly assume a global is only referenced once since it cannot see the other pieces of the shader stage until link time.

Here we skip the optimisation if the variable is a global. We could change it to only run at link time however this optimisation is only run at link time if we are being forced to use GLSL IR to inline a function that glsl to nir cannot handle and this will also be removed in a future patchset.

Closes: #10482 (closed) Fixes: d75a36a9 ("glsl: remove do_copy_propagation_elements() optimisation pass")

Merge request reports