On 24 October 2011 13:41, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net">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;">
This is based on my interpretation of the spec, and matches up with a<br>
Khronos spec clarification.<br>
---<br>
.../basic-types/int-literal-size-ok-01.frag | 23 +++++++++++++++++++<br>
.../basic-types/int-literal-size-ok-02.frag | 23 +++++++++++++++++++<br>
.../basic-types/int-literal-size-ok-03.frag | 23 +++++++++++++++++++<br>
.../basic-types/int-literal-size-ok-04.frag | 24 ++++++++++++++++++++<br>
.../basic-types/int-literal-too-large-03.frag | 21 +++++++++++++++++<br>
5 files changed, 114 insertions(+), 0 deletions(-)<br>
create mode 100644 tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-01.frag<br>
create mode 100644 tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-02.frag<br>
create mode 100644 tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-03.frag<br>
create mode 100644 tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-04.frag<br>
create mode 100644 tests/spec/glsl-1.30/compiler/basic-types/int-literal-too-large-03.frag<br>
<br>
diff --git a/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-01.frag b/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-01.frag<br>
new file mode 100644<br>
index 0000000..0703c70<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-01.frag<br>
@@ -0,0 +1,23 @@<br>
+// [config]<br>
+// expect_result: pass<br>
+// glsl_version: 1.30<br>
+// [end config]<br>
+//<br>
+// Integer literals that are too large should raise an error.<br>
+//<br>
+// From page 22 (28 of PDF) of GLSL 1.30 spec:<br>
+// It is an error to provide a literal integer whose magnitude is too<br>
+// large to store in a variable of matching signed or unsigned type.<br>
+//<br>
+// Unsigned integers have exactly 32 bits of precision. Signed integers<br>
+// use 32 bits, including a sign bit, in two's complement form.<br>
+//<br>
+// However, a 32-bit integer literal (whether it has a 'u' suffix or not)<br>
+// is valid.<br>
+<br>
+#version 130<br>
+<br>
+int f() {<br>
+ // Requires 32 bits.<br>
+ return int(0xffffffff);<br>
+}<br>
diff --git a/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-02.frag b/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-02.frag<br>
new file mode 100644<br>
index 0000000..5ebe37b<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-02.frag<br>
@@ -0,0 +1,23 @@<br>
+// [config]<br>
+// expect_result: pass<br>
+// glsl_version: 1.30<br>
+// [end config]<br>
+//<br>
+// Integer literals that are too large should raise an error.<br>
+//<br>
+// From page 22 (28 of PDF) of GLSL 1.30 spec:<br>
+// It is an error to provide a literal integer whose magnitude is too<br>
+// large to store in a variable of matching signed or unsigned type.<br>
+//<br>
+// Unsigned integers have exactly 32 bits of precision. Signed integers<br>
+// use 32 bits, including a sign bit, in two's complement form.<br>
+//<br>
+// However, a 32-bit integer literal (whether it has a 'u' suffix or not)<br>
+// is valid.<br>
+<br>
+#version 130<br>
+<br>
+uint f() {<br>
+ // Requires 32 bits.<br>
+ return uint(0xffffffff);<br>
+}<br>
diff --git a/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-03.frag b/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-03.frag<br>
new file mode 100644<br>
index 0000000..c5ab82f<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-03.frag<br>
@@ -0,0 +1,23 @@<br>
+// [config]<br>
+// expect_result: pass<br>
+// glsl_version: 1.30<br>
+// [end config]<br>
+//<br>
+// Integer literals that are too large should raise an error.<br>
+//<br>
+// From page 22 (28 of PDF) of GLSL 1.30 spec:<br>
+// It is an error to provide a literal integer whose magnitude is too<br>
+// large to store in a variable of matching signed or unsigned type.<br>
+//<br>
+// Unsigned integers have exactly 32 bits of precision. Signed integers<br>
+// use 32 bits, including a sign bit, in two's complement form.<br>
+//<br>
+// However, a 32-bit integer literal (whether it has a 'u' suffix or not)<br>
+// is valid.<br>
+<br>
+#version 130<br>
+<br>
+int f() {<br>
+ // Requires 32 bits.<br>
+ return 3000000000;<br>
+}<br>
diff --git a/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-04.frag b/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-04.frag<br>
new file mode 100644<br>
index 0000000..a1208db<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.30/compiler/basic-types/int-literal-size-ok-04.frag<br>
@@ -0,0 +1,24 @@<br>
+// [config]<br>
+// expect_result: pass<br>
+// glsl_version: 1.30<br>
+// [end config]<br>
+//<br>
+// Integer literals that are too large should raise an error.<br>
+//<br>
+// From page 22 (28 of PDF) of GLSL 1.30 spec:<br>
+// It is an error to provide a literal integer whose magnitude is too<br>
+// large to store in a variable of matching signed or unsigned type.<br>
+//<br>
+// Unsigned integers have exactly 32 bits of precision. Signed integers<br>
+// use 32 bits, including a sign bit, in two's complement form.<br>
+//<br>
+// However, a 32-bit integer literal (whether it has a 'u' suffix or not)<br>
+// is valid. Warnings generation for large signed decimals has to be careful,<br>
+// because -2147483648 is parsed as -(2147483648).<br>
+<br>
+#version 130<br>
+<br>
+int f() {<br>
+ // Requires 32 bits.<br>
+ return -2147483648;<br>
+}<br>
diff --git a/tests/spec/glsl-1.30/compiler/basic-types/int-literal-too-large-03.frag b/tests/spec/glsl-1.30/compiler/basic-types/int-literal-too-large-03.frag<br>
new file mode 100644<br>
index 0000000..5381205<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.30/compiler/basic-types/int-literal-too-large-03.frag<br>
@@ -0,0 +1,21 @@<br>
+// [config]<br>
+// expect_result: fail<br>
+// glsl_version: 1.30<br>
+// [end config]<br>
+//<br>
+// Integer literals that are too large should raise an error.<br>
+//<br>
+// From page 22 (28 of PDF) of GLSL 1.30 spec:<br>
+// It is an error to provide a literal integer whose magnitude is too<br>
+// large to store in a variable of matching signed or unsigned type.<br>
+//<br>
+// Unsigned integers have exactly 32 bits of precision. Signed integers<br>
+// use 32 bits, including a sign bit, in two's complement form.<br>
+<br>
+<br>
+#version 130<br>
+<br>
+int f() {<br>
+ // Requires 33 bits.<br>
+ return 5000000000;<br>
+}<br>
<font color="#888888">--<br>
1.7.7<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></blockquote></div><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>