On 16 May 2012 14:23, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</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">
From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
<br>
These tests are similar to the previous tests except the uniforms are<br>
initialized using a variable declared as const. Since any<br>
compile-time constant expression can be used to initialize a uniform,<br>
this should also work.<br>
<br>
Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
---<br>
generated_tests/CMakeLists.txt | 2 +<br>
generated_tests/gen_uniform_initializer_tests.py | 1 +<br>
.../fs-initializer-from-const.template | 42 ++++++++++++++++++++<br>
.../vs-initializer-from-const.template | 42 ++++++++++++++++++++<br>
4 files changed, 87 insertions(+), 0 deletions(-)<br>
create mode 100644 generated_tests/uniform-initializer-templates/fs-initializer-from-const.template<br>
create mode 100644 generated_tests/uniform-initializer-templates/vs-initializer-from-const.template<br>
<br>
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt<br>
index 84d648b..33be413 100644<br>
--- a/generated_tests/CMakeLists.txt<br>
+++ b/generated_tests/CMakeLists.txt<br>
@@ -38,6 +38,8 @@ piglit_make_generated_tests(<br>
gen_uniform_initializer_tests.py<br>
uniform-initializer-templates/fs-initializer.template<br>
uniform-initializer-templates/vs-initializer.template<br>
+ uniform-initializer-templates/fs-initializer-from-const.template<br>
+ uniform-initializer-templates/vs-initializer-from-const.template<br>
)<br>
<br>
# Add a "gen-tests" target that can be used to generate all the<br>
diff --git a/generated_tests/gen_uniform_initializer_tests.py b/generated_tests/gen_uniform_initializer_tests.py<br>
index 87d7068..81f41bd 100644<br>
--- a/generated_tests/gen_uniform_initializer_tests.py<br>
+++ b/generated_tests/gen_uniform_initializer_tests.py<br>
@@ -169,6 +169,7 @@ random_numbers = (0.78685, 0.89828, 0.36590, 0.92504, 0.48998, 0.27989,<br>
0.72414, 0.88036, 0.54498, 0.32668, 0.02967, 0.12643)<br>
<br>
all_templates = ("",<br>
+ "-from-const",<br>
)<br>
<br>
bool_types = [("bool", 1), ("bvec2", 2), ("bvec3", 3), ("bvec4", 4)]<br>
diff --git a/generated_tests/uniform-initializer-templates/fs-initializer-from-const.template b/generated_tests/uniform-initializer-templates/fs-initializer-from-const.template<br>
new file mode 100644<br>
index 0000000..dc2a63e<br>
--- /dev/null<br>
+++ b/generated_tests/uniform-initializer-templates/fs-initializer-from-const.template<br>
@@ -0,0 +1,42 @@<br>
+<%!<br>
+def name(type, base):<br>
+ return "{}{}{}".format(base, type[0], type[-1])<br>
+<br>
+%>[require]<br>
+GLSL >= ${"{}.{}".format(major, minor)}<br>
+<br>
+[vertex shader]<br>
+#version ${"{}{}".format(major, minor)}<br>
+<br>
+void main()<br>
+{<br>
+ gl_Position = gl_Vertex;<br>
+}<br>
+<br>
+[fragment shader]<br>
+#version ${"{}{}".format(major, minor)}<br>
+<br>
+% for (type, name, value) in type_list:<br>
+const ${type} ${"".join(["c", name])} = ${value};<br></blockquote><div><br>It seems a little odd to me to use join just to concatenate two strings. Consider one of these alternatives:<br><br>const ${type} ${"c" + name} = $(value);<br>
<br>or<br><br>const ${type} c${name} = $(value);<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+% endfor<br>
+<br>
+% for (type, name, value) in type_list:<br>
+uniform ${type} ${name} = ${"".join(["c", name])};<br></blockquote><div><br>Same comment as above.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+% endfor<br>
+<br>
+void main()<br>
+{<br>
+ if ((${type_list[0][1]} == ${type_list[0][2]})<br>
+% for (type, name, value) in type_list[1:-1]:<br>
+ && (${name} == ${value})<br>
+% endfor<br>
+ && (${type_list[-1][1]} == ${type_list[-1][2]})) {<br></blockquote><div><br>I commented about this last time.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ gl_FragColor = vec4(0, 1, 0, 1);<br>
+ } else {<br>
+ gl_FragColor = vec4(1, 0, 0, 1);<br>
+ }<br>
+}<br>
+<br>
+[test]<br>
+draw rect -1 -1 2 2<br>
+probe all rgb 0 1 0<br>
diff --git a/generated_tests/uniform-initializer-templates/vs-initializer-from-const.template b/generated_tests/uniform-initializer-templates/vs-initializer-from-const.template<br>
new file mode 100644<br>
index 0000000..4c32edb<br>
--- /dev/null<br>
+++ b/generated_tests/uniform-initializer-templates/vs-initializer-from-const.template<br>
@@ -0,0 +1,42 @@<br>
+[require]<br>
+GLSL >= ${"{}.{}".format(major, minor)}<br>
+<br>
+[vertex shader]<br>
+#version ${"{}{}".format(major, minor)}<br>
+varying vec4 color;<br>
+<br>
+% for (type, name, value) in type_list:<br>
+const ${type} ${"".join(["c", name])} = ${value};<br>
+% endfor<br>
+<br>
+% for (type, name, value) in type_list:<br>
+uniform ${type} ${name} = ${"".join(["c", name])};<br>
+% endfor<br>
+<br>
+void main()<br>
+{<br>
+ if ((${type_list[0][1]} == ${type_list[0][2]})<br>
+% for (type, name, value) in type_list[1:-1]:<br>
+ && (${name} == ${value})<br>
+% endfor<br>
+ && (${type_list[-1][1]} == ${type_list[-1][2]})) {<br>
+ color = vec4(0, 1, 0, 1);<br>
+ } else {<br>
+ color = vec4(1, 0, 0, 1);<br>
+ }<br>
+<br>
+ gl_Position = gl_Vertex;<br>
+}<br>
+<br>
+[fragment shader]<br>
+#version ${"{}{}".format(major, minor)}<br>
+varying vec4 color;<br>
+<br>
+void main()<br>
+{<br>
+ gl_FragColor = color;<br>
+}<br>
+<br>
+[test]<br>
+draw rect -1 -1 2 2<br>
+probe all rgb 0 1 0<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.6.5<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>Again, I'm nit-picking, so whether or not you take my suggestions:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>