Glamor GLES gradient shaders fail on R300
Was testing the OpenGL ES glamor for xorg/xserver!1173 (merged)
One failing shader is gradient_fs_getcolor_no_array from https://gitlab.freedesktop.org/xorg/xserver/-/blob/master/glamor/glamor_gradient.c?ref_type=heads#L86 Currently we end with 71 instructions (we need to fit into 64). It is probably doable to fit, there is a lot of operations with uniforms, like here:
uniform float stop0;
uniform float stop1;
uniform float stop2;
uniform float stop3;
uniform float stop4;
uniform float stop5;
uniform float stop6;
uniform float stop7;
uniform vec4 stop_color0;
uniform vec4 stop_color1;
uniform vec4 stop_color2;
uniform vec4 stop_color3;
uniform vec4 stop_color4;
uniform vec4 stop_color5;
uniform vec4 stop_color6;
uniform vec4 stop_color7;
....
} else if((stop_len < stop1) && (n_stop >= 2)) {
stop_color_before = stop_color0;
stop_color_after = stop_color1;
stop_before = stop0;
stop_delta = stop1 - stop0;
} else if((stop_len < stop2) && (n_stop >= 3)) {
stop_color_before = stop_color1;
stop_color_after = stop_color2;
stop_before = stop1;
stop_delta = stop2 - stop1;
} else if((stop_len < stop3) && (n_stop >= 4)){
stop_color_before = stop_color2;
stop_color_after = stop_color3;
stop_before = stop2;
stop_delta = stop3 - stop2;
....
For example if we merge the stop0 ... stop7
into 2 vec4 we could vectorize some of the the stop_delta
calculations which could be enough to move us into the limit. Or in theory maybe glamor can precompute the 7 stop_delta values and upload them as extra uniforms (preferably 2 vec4).
However, for the another gradient shader gradient_fs_getcolor
https://gitlab.freedesktop.org/xorg/xserver/-/blob/master/glamor/glamor_gradient.c?ref_type=heads#L47 there is a bigger issue.
uniform int n_stop;
uniform float stops[18];
...
for(i = 1; i < n_stop; i++) {
if(stop_len < stops[i])
break;
}
...
We have no indirect uniform access and no loops (except R500), and both really hurts us, so there is no chance to make this work unfortunately (in theory we should lower the indirect access into large of ladder, unroll and than clean most of it up, but it doesn't work currently). Additionally OpenGL ES 2.0 drivers are not even required to implement this as the loop condition does contain non-contant expression.
BTW @rilian-la-te I saw you have been working on the GLES glamor a lot, do you think that it is possible to reimplement this somehow that it actually works with the minimum GLSL ES requirements for loops?