-
Paul Berry authored
This patch adds 160 generated tests to verify correct behavior of the GLSL 1.30 interpolation qualifiers under all combinations of the following circumstances: - When the interpolation qualifier is 'flat', 'noperspective', 'smooth', or not specified. - When the variable in question is 'gl_FrontColor', 'gl_BackColor', 'gl_FrontSecondaryColor', 'gl_BackSecondaryColor', or a non-built-in vertex shader output. - When the GL shade model (set with the glShadeModel command) is 'GL_SMOOTH' or 'GL_FLAT'. - When the triangle is clipped using gl_ClipDistance, using gl_ClipVertex, using fixed clip planes, or not clipped at all. Note: in a perfect world, we wouldn't need to test all 160 combinations of these possibilities (e.g. the GL shade model should only have an effect when no interpolation qualifier is specified, and clipping should have no effect whatsoever on interpolation). However, based on what I know about how interpolation currently works in Mesa's i965 driver, it seems prudent to err on the side of caution and test all 160 possible combinations. The tests all operate by painting a triangle on the screen using a frustum projection, where the three vertices are colored red, green, and blue, and each vertex has a different Z coordinate (so that we can test proper perspective interpolation). Then they use "relative probe rgba" on various points in the interior of the triangle to verify that the colors have been interpolated correctly. I've validated the tests using nVidia's proprietary Linux driver, and they all pass except for the tests that attempt to override the default interpolation behavior of one of the built-in gl_Color variables. In those cases, the nVidia driver favors the interpolation mode that is set in GL state. GLSL 1.30 section 4.3.7 ("Interpolation") explicitly states that the interpolation behavior of these variables may be overridden, and that "When an interpolation qualifier is used, it overrides settings established through the OpenGL API." So this seems pretty clearly to be due to a bug in the nVidia driver. As an aid in review, here is an example of one of the tests created by the test generator script. This one is called "interpolation-noperspective-gl_FrontColor-flat-fixed.shader_test": [require] GLSL >= 1.30 [vertex shader] in vec4 vertex; in vec4 input_data; noperspective out vec4 gl_FrontColor; void main() { gl_Position = gl_ModelViewProjectionMatrix * vertex; gl_FrontColor = input_data; } [fragment shader] noperspective in vec4 gl_Color; void main() { gl_FragColor = gl_Color; } [vertex data] vertex/float/3 input_data/float/4 0.0 2.0 -2.0 0.0 1.0 0.0 1.0 -1.0 -1.0 -1.0 1.0 0.0 0.0 1.0 3.0 -3.0 -3.0 0.0 0.0 1.0 1.0 [test] frustum -1.75 1.75 -1.75 1.75 1.75 3.0 clear color 0.0 0.0 0.0 0.0 clear enable GL_VERTEX_PROGRAM_TWO_SIDE shade model flat draw arrays GL_TRIANGLES 0 3 relative probe rgba (0.444444444444, 0.222222222222) (0.0, 0.0, 0.0, 0.0) relative probe rgba (0.636363636364, 0.181818181818) (0.272727272727, 0.181818181818, 0.545454545455, 1.0) relative probe rgba (0.769230769231, 0.153846153846) (0.153846153846, 0.153846153846, 0.692307692308, 1.0) relative probe rgba (0.866666666667, 0.133333333333) (0.0666666666667, 0.133333333333, 0.8, 1.0) relative probe rgba (0.5, 0.4) (0.0, 0.0, 0.0, 0.0) relative probe rgba (0.666666666667, 0.333333333333) (0.166666666667, 0.333333333333, 0.5, 1.0) relative probe rgba (0.785714285714, 0.285714285714) (0.0714285714286, 0.285714285714, 0.642857142857, 1.0) relative probe rgba (0.545454545455, 0.545454545455) (0.181818181818, 0.545454545455, 0.272727272727, 1.0) relative probe rgba (0.692307692308, 0.461538461538) (0.0769230769231, 0.461538461538, 0.461538461538, 1.0) relative probe rgba (0.583333333333, 0.666666666667) (0.0833333333333, 0.666666666667, 0.25, 1.0) Reviewed-by: Eric Anholt <eric@anholt.net>
f36a14a2