<p dir="ltr">Subtle..</p>
<p dir="ltr">Reviewed-by: Chris Forbes <<a href="mailto:chrisf@ijw.co.nz">chrisf@ijw.co.nz</a>></p>
<div class="gmail_quote">On Jan 8, 2015 1:07 AM, "Neil Roberts" <<a href="mailto:neil@linux.intel.com">neil@linux.intel.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Adds a test which tries setting a uint attrib value to 0x7f817f81.<br>
If this value were interpreted as a float then it would look like a<br>
signalling NaN. If this is passed through an x87 register then it<br>
would get converted to a quiet NaN on store.<br>
<br>
Currently Mesa does this on 32-bit builds (possibly only with<br>
optimisations turned on) so the test fails. The code is in Mesa main<br>
so it should fail on all drivers.<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=82668" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=82668</a><br>
---<br>
<br>
This patch has been sitting as an attachment in the bug report for a<br>
while but I think it would be a good idea to land it in master.<br>
<br>
tests/all.py | 1 +<br>
tests/shaders/CMakeLists.gl.txt | 1 +<br>
tests/shaders/glsl-vs-int-attrib.c | 115 +++++++++++++++++++++++++++++++++++++<br>
3 files changed, 117 insertions(+)<br>
create mode 100644 tests/shaders/glsl-vs-int-attrib.c<br>
<br>
diff --git a/tests/all.py b/tests/all.py<br>
index 051b157..c62749b 100644<br>
--- a/tests/all.py<br>
+++ b/tests/all.py<br>
@@ -496,6 +496,7 @@ add_concurrent_test(shaders, 'useshaderprogram-bad-type')<br>
add_concurrent_test(shaders, 'useshaderprogram-bad-program')<br>
add_concurrent_test(shaders, 'useshaderprogram-flushverts-1')<br>
add_concurrent_test(shaders, 'point-vertex-id')<br>
+add_concurrent_test(shaders, 'glsl-vs-int-attrib')<br>
for subtest in ('interstage', 'intrastage', 'vs-gs'):<br>
cmdline = 'version-mixing {0}'.format(subtest)<br>
shaders[cmdline] = PiglitGLTest(cmdline, run_concurrent=True)<br>
diff --git a/tests/shaders/CMakeLists.gl.txt b/tests/shaders/CMakeLists.gl.txt<br>
index c827256..3efc6bf 100644<br>
--- a/tests/shaders/CMakeLists.gl.txt<br>
+++ b/tests/shaders/CMakeLists.gl.txt<br>
@@ -168,5 +168,6 @@ piglit_add_executable (useshaderprogram-bad-type useshaderprogram-bad-type.c)<br>
piglit_add_executable (useshaderprogram-bad-program useshaderprogram-bad-program.c)<br>
piglit_add_executable (useshaderprogram-flushverts-1 useshaderprogram-flushverts-1.c)<br>
piglit_add_executable (version-mixing version-mixing.c)<br>
+piglit_add_executable (glsl-vs-int-attrib glsl-vs-int-attrib.c)<br>
<br>
# vim: ft=cmake:<br>
diff --git a/tests/shaders/glsl-vs-int-attrib.c b/tests/shaders/glsl-vs-int-attrib.c<br>
new file mode 100644<br>
index 0000000..9668866<br>
--- /dev/null<br>
+++ b/tests/shaders/glsl-vs-int-attrib.c<br>
@@ -0,0 +1,115 @@<br>
+/*<br>
+ * Copyright (c) 2014 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/** @file glsl-vs-int-attrib.c<br>
+ *<br>
+ * Tests that we can set an integer vertex attribute to a value that<br>
+ * looks like a signalling NaN if it were interpreted as a float. If<br>
+ * an implementation passes this through a floating point variable it<br>
+ * might incorrectly get corrupted to a quiet NaN.<br>
+ */<br>
+<br>
+#include "piglit-util-gl.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+ config.supports_gl_compat_version = 20;<br>
+<br>
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+/* This value looks like a signalling NaN if it were interpreted as a<br>
+ * float */<br>
+#define TEST_VALUE 0x7f817f81<br>
+<br>
+#define STR(x) #x<br>
+#define STRINGIFY(x) STR(x)<br>
+<br>
+static const char<br>
+vertex_source[] =<br>
+ "#version 130\n"<br>
+ "\n"<br>
+ "attribute vec4 piglit_vertex;\n"<br>
+ "attribute uint a_value;\n"<br>
+ "\n"<br>
+ "void\n"<br>
+ "main()\n"<br>
+ "{\n"<br>
+ " if (a_value == " STRINGIFY(TEST_VALUE) "u)\n"<br>
+ " gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);\n"<br>
+ " else\n"<br>
+ " gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);\n"<br>
+ " gl_Position = piglit_vertex;\n"<br>
+ "}\n";<br>
+<br>
+static const float red[] = { 1.0f, 0.0f, 0.0f };<br>
+<br>
+static bool<br>
+run_test(void)<br>
+{<br>
+ GLuint prog;<br>
+ GLint attrib;<br>
+ bool pass;<br>
+<br>
+ prog = piglit_build_simple_program(vertex_source,<br>
+ NULL /* fs_source */);<br>
+ glUseProgram(prog);<br>
+<br>
+ attrib = glGetAttribLocation(prog, "a_value");<br>
+ glVertexAttribI1ui(attrib, TEST_VALUE);<br>
+<br>
+ piglit_draw_rect(-1, -1, 2, 2);<br>
+ pass = piglit_probe_pixel_rgb(0, 0, red);<br>
+<br>
+ glUseProgram(0);<br>
+ glDeleteProgram(prog);<br>
+<br>
+ return pass;<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ bool pass;<br>
+<br>
+ /* We need to be able to call glVertexAttribI1ui */<br>
+ if (piglit_get_gl_version() < 30<br>
+ && !piglit_is_extension_supported("GL_EXT_gpu_shader4")) {<br>
+ printf("OpenGL 3.0 or GL_EXT_gpu_shader4 is required.\n");<br>
+ piglit_report_result(PIGLIT_SKIP);<br>
+ }<br>
+<br>
+ piglit_require_GLSL_version(130);<br>
+<br>
+ pass = run_test();<br>
+<br>
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ /* unused */<br>
+ return PIGLIT_FAIL;<br>
+}<br>
--<br>
1.9.3<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>
</blockquote></div>