Skip to content

lima: fix vertex shader uniform buffer size

Erico Nunes requested to merge enunes/mesa:lima-uniform-buff-size into master

In some cases when switching shader programs, mesa does not switch the currently set pipe_constant_buffer, which keeps pointing to the one set previously. If the two shader programs have a different number of uniforms, the size of the constant buffer may be different and this needs to be considered while generating the next draw command.

The new constant buffer is set appropriately when switching shaders explicitly in the application, however the situation above is reproducible if mesa switches to an internal shader. For example while performing a clear with scissors, mesa uses an internal "clear" shader (which has no uniforms) to draw a quad in the cleared area.

lima was previously assuming that the number of the uniforms of the current shader in use is the same as the number of values in the currently set pipe_constant_buffer. This does not hold true in the case of clear with quads, which in lima could result in an out of bounds memcpy and random segfault in some applications [#3474 (closed)].

This patch fixes the uniform buffer creation in the lima vertex shader command considering the case described above.

Closes issue #3474 (closed)

Merge request reports