shader: Stay in varying limits when emitting clip-plane code

Gert Wollny requested to merge gerddie/virglrenderer:fix-clipplane-emit into master

Writing to gl_ClipDistance can be triggered in two ways: Either the shader emits the code explicitely, or the GL state enables a clip plane and no extra shader code is emitted in the original GLSL code.

In this latter case we emulate the clip planes defined in the compatibility profile by using gl_ClipDistance and emit these extra values that occupy two extra varying slots. With that we may exceed the number of 32 supported varyings, which leads to undefined behaviour in the host driver.

To avoid this emit gl_ClipDistance only in this case if we don't exceed that limit.

Merge request reports