On 18 April 2012 18:29, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
generated_tests/gen_builtin_uniform_tests.py | 71 ++++++++++++++++++++------<br>
1 file changed, 54 insertions(+), 17 deletions(-)<br>
<br>
diff --git a/generated_tests/gen_builtin_uniform_tests.py b/generated_tests/gen_builtin_uniform_tests.py<br>
index d6f4f06..5ff595f 100644<br>
--- a/generated_tests/gen_builtin_uniform_tests.py<br>
+++ b/generated_tests/gen_builtin_uniform_tests.py<br>
@@ -169,8 +169,8 @@ class BoolComparator(Comparator):<br>
value += [0.0] * self.__padding<br>
return value<br>
<br>
- def make_result_test(self, test_num, test_vector):<br>
- test = 'draw rect -1 -1 2 2\n'<br>
+ def make_result_test(self, test_num, test_vector, draw):<br>
+ test = draw<br>
test += 'probe rgba {0} 0 {1}\n'.format(<br>
test_num,<br>
shader_runner_format(self.convert_to_float(test_vector.result)))<br>
@@ -209,8 +209,8 @@ class BoolIfComparator(Comparator):<br>
else:<br>
return [0.0, 0.0, 1.0, 1.0]<br>
<br>
- def make_result_test(self, test_num, test_vector):<br>
- test = 'draw rect -1 -1 2 2\n'<br>
+ def make_result_test(self, test_num, test_vector, draw):<br>
+ test = draw<br>
test += 'probe rgba {0} 0 {1}\n'.format(<br>
test_num,<br>
shader_runner_format(self.convert_to_float(test_vector.result)))<br>
@@ -246,11 +246,11 @@ class IntComparator(Comparator):<br>
red='vec4(1.0, 0.0, 0.0, 1.0)')<br>
return statements<br>
<br>
- def make_result_test(self, test_num, test_vector):<br>
+ def make_result_test(self, test_num, test_vector, draw):<br>
test = 'uniform {0} expected {1}\n'.format(<br>
shader_runner_type(self.__signature.rettype),<br>
shader_runner_format(column_major_values(test_vector.result)))<br>
- test += 'draw rect -1 -1 2 2\n'<br>
+ test += draw<br>
test += 'probe rgba {0} 0 0.0 1.0 0.0 1.0\n'.format(test_num)<br>
return test<br>
<br>
@@ -314,13 +314,13 @@ class FloatComparator(Comparator):<br>
red='vec4(1.0, 0.0, 0.0, 1.0)')<br>
return statements<br>
<br>
- def make_result_test(self, test_num, test_vector):<br>
+ def make_result_test(self, test_num, test_vector, draw):<br>
test = 'uniform {0} expected {1}\n'.format(<br>
shader_runner_type(self.__signature.rettype),<br>
shader_runner_format(column_major_values(test_vector.result)))<br>
test += 'uniform float tolerance {0}\n'.format(<br>
shader_runner_format([test_vector.tolerance]))<br>
- test += 'draw rect -1 -1 2 2\n'<br>
+ test += draw<br>
test += 'probe rgba {0} 0 0.0 1.0 0.0 1.0\n'.format(test_num)<br>
return test<br>
<br>
@@ -362,11 +362,17 @@ class ShaderTest(object):<br>
return self._signature.version_introduced<br>
<br>
def version_directive(self):<br>
- if self.glsl_version() == '1.10':<br>
+ if float(self.glsl_version()) == '1.10':<br></blockquote><div><br>I see why you're changing this--doing string comparisons on values that are intended as floating point is ugly. But what you've changed it to won't do the right thing, since the test now compares a float to a string (which always fails). Did you perhaps mean to compare a float to a float, like this?<br>
<br> if float(self.glsl_version()) == 1.10:<br><br> I would be ok with changing this to a float/float comparison, or leaving it as a string/string comparison.<br><br>In retrospect I wish I had made self.glsl_version() an integer representing 100x the GLSL version (e.g. 140 for GLSL version 1.40), like we do in Mesa internals. Sorry you have to deal with this nonsense.<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
return ''<br>
else:<br>
return '#version {0}\n'.format(self.glsl_version().replace('.', ''))<br>
<br>
+ def draw_command(self):<br>
+ if float(self.glsl_version()) >= 1.40:<br>
+ return 'draw arrays GL_TRIANGLE_FAN 0 4\n'<br>
+ else:<br>
+ return 'draw rect -1 -1 2 2\n'<br>
+<br>
@abc.abstractmethod<br>
def test_prefix(self):<br>
"""Return the prefix that should be used in the test file name<br>
@@ -425,9 +431,24 @@ class ShaderTest(object):<br>
# Note: shader_runner uses a 250x250 window so we must<br>
# ensure that test_num <= 250.<br>
test += self._comparator.make_result_test(<br>
- test_num % 250, test_vector)<br>
+ test_num % 250, test_vector, self.draw_command())<br>
return test<br>
<br>
+ def make_vbo_data(self):<br>
+ # Starting with GLSL 1.40/GL 3.1, we need to use VBOs and<br>
+ # vertex shader input bindings for our vertex data instead of<br>
+ # the piglit drawing utilities and gl_Vertex.<br>
+ if float(self.glsl_version()) < 1.40:<br></blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ return "" <br></blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ vbo = '[vertex data]\n'<br>
+ vbo += 'vertex/float/2\n'<br>
+ vbo += '-1.0 -1.0\n'<br>
+ vbo += ' 1.0 -1.0\n'<br>
+ vbo += ' 1.0 1.0\n'<br>
+ vbo += '-1.0 1.0\n'<br>
+ vbo += '\n'<br>
+ return vbo<br>
+<br>
def filename(self):<br>
argtype_names = '-'.join(<br>
str(argtype) for argtype in self._signature.argtypes)<br>
@@ -449,6 +470,7 @@ class ShaderTest(object):<br>
shader_test += '[fragment shader]\n'<br>
shader_test += self.make_fragment_shader()<br>
shader_test += '\n'<br>
+ shader_test += self.make_vbo_data()<br>
shader_test += '[test]\n'<br>
shader_test += self.make_test()<br>
filename = self.filename()<br>
@@ -468,8 +490,17 @@ class VertexShaderTest(ShaderTest):<br>
return 'vs'<br>
<br>
def make_vertex_shader(self):<br>
- return self.make_test_shader(<br>
- 'varying vec4 color;\n', ' gl_Position = gl_Vertex;\n', 'color')<br>
+ if float(self.glsl_version()) >= 1.40: <br></blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ return self.make_test_shader(<br>
+ 'in vec4 vertex;\n' +<br>
+ 'out vec4 color;\n',<br>
+ ' gl_Position = vertex;\n',<br>
+ 'color')<br>
+ else:<br>
+ return self.make_test_shader(<br>
+ 'varying vec4 color;\n',<br>
+ ' gl_Position = gl_Vertex;\n',<br>
+ 'color')<br>
<br>
def make_fragment_shader(self):<br>
shader = self.version_directive()<br>
@@ -493,11 +524,17 @@ class FragmentShaderTest(ShaderTest):<br>
<br>
def make_vertex_shader(self):<br>
shader = self.version_directive()<br>
- shader += '''void main()<br>
-{<br>
- gl_Position = gl_Vertex;<br>
-}<br>
-'''<br>
+ if float(self.glsl_version()) >= 1.40:<br>
+ shader += "in vec4 vertex;\n"<br>
+<br>
+ shader += "void main()\n"<br>
+ shader += "{\n"<br>
+ if float(self.glsl_version()) >= 1.40:<br>
+ shader += " gl_Position = vertex;\n"<br>
+ else:<br>
+ shader += " gl_Position = gl_Vertex;\n"<br>
+ shader += "}\n"<br>
+<br>
return shader<br>
<br>
def make_fragment_shader(self):<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.10<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br>Assuming the float/string issue gets resolved, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>