[Piglit] [PATCH] arb_sample_shading: Add gl_SampleMaskIn subtest with msaa disabled, fix test

2018-02-04 Thread sroland
From: Roland Scheidegger 

The spec says with msaa disabled gl_SampleMaskIn is always 1.
This is not particularly related to arb_sample_shading, but drivers may
do different workarounds depending on the state of sample shading and the
presence of bits in the shader which would force per-sample execution, so it
seems appropriate to test here.
At least r600/eg will fail (the hw will give the coverage mask for the pixel,
not the coverage per sample or 1 if msaa is disabled).
Since the existing partition test could only be passed when giving the wrong
answer for this, I would expect more drivers to fail...

This also fixes the partition test with msaa disabled, as it expected a wrong
gl_SampleMaskIn value in this case (it could easily verify gl_SampleMaskIn is
1 but omit it from there as it's quite likely multiple things are failing in
the test simultaneously and then the failures can't be distinguished - the new
test for this also doesn't require atomics).
---
 .../arb_sample_shading/execution/samplemask.cpp| 109 ++---
 1 file changed, 96 insertions(+), 13 deletions(-)

diff --git a/tests/spec/arb_sample_shading/execution/samplemask.cpp 
b/tests/spec/arb_sample_shading/execution/samplemask.cpp
index 74baddc11..8ed65ff42 100644
--- a/tests/spec/arb_sample_shading/execution/samplemask.cpp
+++ b/tests/spec/arb_sample_shading/execution/samplemask.cpp
@@ -34,7 +34,11 @@
  * 2. The bits of gl_SampleMaskIn over all fragment shader invocations form a
  *partition of the set of samples. This subtest requires
  *ARB_shader_atomic_counters to disambiguate between fragment shader
- *invocations.
+ *invocations. (Also verifies sampleID is 0 when msaa is disabled.)
+ * Additionally, there's a test to just verify gl_SampleMaskIn is 1 when 
+ * msaa is disabled (regardless of per-sample frequency shader or sample
+ * shading). (Omitted from test 2 because it's difficult to track down
+ * what's going wrong if drivers fail too many parts of the test.)
  *
  * The sample rate is controlled in one of two ways: Either glMinSampleShading
  * or a fragment shader variant that uses gl_SampleID is used.
@@ -71,21 +75,24 @@ enum rate_mode {
 static int num_samples;
 static int actual_num_samples;
 static bool partition_check_supported;
+static bool mask_in_one_supported;
 static const char *procname;
 static const char *testname;
 static const char *sample_rate;
 static unsigned prog_fix_sample_mask[2];
 static unsigned prog_fix_check;
+static unsigned prog_mask_in_one[2];
 static unsigned prog_partition_write[2];
 static unsigned prog_partition_check;
 static unsigned prog_partition_check_have_sampleid;
+static unsigned prog_partition_check_msaa_disabled;
 static Fbo ms_fbo;
 static Fbo ms_ifbo;
 
 static void
 print_usage_and_exit(const char *prog_name)
 {
-   printf("Usage: %s   {fix|partition|all}\n"
+   printf("Usage: %s   
{fix|partition|mask_in_one|all}\n"
   "where  is either a floating point MinSampleShading 
value\n"
   " or 'sample', 'noms', or 'all'\n",
   prog_name);
@@ -165,6 +172,16 @@ compile_shaders(void)
"  }\n"
"}\n";
 
+   static const char frag_mask_in_one[] =
+   "#version 130\n"
+   "#extension GL_ARB_gpu_shader5 : enable\n"
+   "#extension GL_ARB_sample_shading : enable\n"
+   "out vec4 out_color;\n"
+   "void main()\n"
+   "{\n"
+   "  out_color = vec4(float(gl_SampleMaskIn[0]) / 10.0, 0.0, %s, 
0.0);\n"
+   "}\n";
+
static const char frag_partition_write[] =
"#version 140\n"
"#extension GL_ARB_gpu_shader5 : enable\n"
@@ -183,16 +200,23 @@ compile_shaders(void)
"uniform isampler2DMS tex;\n"
"uniform int num_samples;\n"
"uniform bool have_sampleid;\n"
+   "uniform bool msaa_disabled;\n"
"out vec4 out_color;\n"
"void main()\n"
"{\n"
"  out_color = vec4(0, 1, 0, 1);\n"
"  for (int i = 0; i < num_samples; ++i) {\n"
"ivec4 di = texelFetch(tex, ivec2(gl_FragCoord.xy), i);\n"
-   "if ((di.x & (1 << i)) == 0)\n"
-   "  out_color = vec4(0.1, float(i) / 255, 0, 0);\n"
-   "if (have_sampleid && di.z != i)\n"
-   "  out_color = vec4(0.2, float(i) / 255, float(di.z) / 255, 
0);\n"
+   "if (msaa_disabled) {\n"
+   "  /* omit di.x == 1 test here, drivers fail multiple parts 
already... */\n"
+   "  if (di.z != 0)\n"
+   "out_color = vec4(0.2, float(i) / 255, float(di.z) / 
255, 0);\n"
+   "} else {\n"
+   "  if ((di.x & (1 << i)) == 0)\n"
+   "out_color = vec4(0.1, float(i) / 255, float(di.x) / 
255, 0);\n"
+   "   

[Piglit] [PATCH 2/2] arb_internalformat_query2: don't try glGetTexLevelParameteriv() for tex buffers

2018-01-26 Thread sroland
From: Roland Scheidegger 

I believe querying that information for GL_TEXTURE_BUFFFER via internal format
query should return the correct values, but it's definitely impossible if just
ARB_texture_buffer_object is supported but not GL 3.1. Hence just pretend it
succeeded in this case. (Also see the corresponding mesa change.)
---
 tests/spec/arb_internalformat_query2/common.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/tests/spec/arb_internalformat_query2/common.c 
b/tests/spec/arb_internalformat_query2/common.c
index 5fc4c833b..f1757d041 100644
--- a/tests/spec/arb_internalformat_query2/common.c
+++ b/tests/spec/arb_internalformat_query2/common.c
@@ -553,6 +553,18 @@ test_data_check_against_get_tex_level_parameter(test_data 
*data,
 GLenum real_target = target;
 GLenum pname_equiv = translate_pname(pname);
 
+/*
+ * Special case for texture buffer - this is not valid as
+ * glGetTexLevelParameteriv target with just ARB_tbo, only with gl 3.1.
+ * However, I believe the query2 should still return the correct
+ * values, despite the spec saying
+ * "For textures this query will return the same information as
+ * querying GetTexLevelParameter{if}v for TEXTURE_*_SIZE would return."
+ */
+if (target == GL_TEXTURE_BUFFER && piglit_get_gl_version() < 31) {
+return GL_TRUE;
+}
+
 result = create_texture(target, internalformat, &tex, &buffer);
 if (!result)
 return test_data_is_unsupported_response(data, pname);
-- 
2.12.3

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 1/2] arb_internalformat_query2: avoid bogus error spam about unsupported pnames

2018-01-26 Thread sroland
From: Roland Scheidegger 

The test fed the equivalent_pname into the get_unsupported_response()
function, which led to nonsense logged errors as this only recognizes
the original pnames.
Refactor pname/equivalent_pname translation so always the original pnames
are fed into that function.
---
 tests/spec/arb_internalformat_query2/common.c  | 34 +-
 .../internalformat-size-checks.c   | 23 ++-
 .../internalformat-type-checks.c   | 21 ++---
 .../arb_transform_feedback_overflow_query/basic.c  | 22 ++
 4 files changed, 59 insertions(+), 41 deletions(-)

diff --git a/tests/spec/arb_internalformat_query2/common.c 
b/tests/spec/arb_internalformat_query2/common.c
index 9fa5fa9d1..5fc4c833b 100644
--- a/tests/spec/arb_internalformat_query2/common.c
+++ b/tests/spec/arb_internalformat_query2/common.c
@@ -496,6 +496,37 @@ create_texture(const GLenum target,
 }
 return result;
 }
+
+
+static GLenum
+translate_pname(const GLenum pname)
+{
+switch (pname) {
+case GL_INTERNALFORMAT_RED_TYPE:
+case GL_INTERNALFORMAT_GREEN_TYPE:
+case GL_INTERNALFORMAT_BLUE_TYPE:
+case GL_INTERNALFORMAT_ALPHA_TYPE:
+   return pname - GL_INTERNALFORMAT_RED_TYPE + GL_TEXTURE_RED_TYPE;
+ case GL_INTERNALFORMAT_DEPTH_TYPE:
+/* case GL_INTERNALFORMAT_STENCIL_TYPE, */
+return GL_TEXTURE_DEPTH_TYPE;
+case GL_INTERNALFORMAT_RED_SIZE:
+case GL_INTERNALFORMAT_GREEN_SIZE:
+case GL_INTERNALFORMAT_BLUE_SIZE:
+case GL_INTERNALFORMAT_ALPHA_SIZE:
+return pname - GL_INTERNALFORMAT_RED_SIZE + 
GL_TEXTURE_RED_SIZE;
+case GL_INTERNALFORMAT_DEPTH_SIZE:
+return GL_TEXTURE_DEPTH_SIZE;
+case GL_INTERNALFORMAT_STENCIL_SIZE:
+return GL_TEXTURE_STENCIL_SIZE;
+case GL_INTERNALFORMAT_SHARED_SIZE:
+return GL_TEXTURE_SHARED_SIZE;
+default:
+assert(!"incorrect pname");
+return 0;
+}
+}
+
 /*
  * Builds a a texture using @target and @internalformat, and compares
  * the result of calling GetTexLevelParameter using @pname with the
@@ -520,6 +551,7 @@ test_data_check_against_get_tex_level_parameter(test_data 
*data,
 GLuint tex;
 GLuint buffer;
 GLenum real_target = target;
+GLenum pname_equiv = translate_pname(pname);
 
 result = create_texture(target, internalformat, &tex, &buffer);
 if (!result)
@@ -530,7 +562,7 @@ test_data_check_against_get_tex_level_parameter(test_data 
*data,
 if (target == GL_TEXTURE_CUBE_MAP) {
 real_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
 }
-glGetTexLevelParameteriv(real_target, 0, pname, ¶m);
+glGetTexLevelParameteriv(real_target, 0, pname_equiv, ¶m);
 if (!piglit_check_gl_error(GL_NO_ERROR)) {
 result = false;
 fprintf(stderr, "\tError calling glGetTexLevelParameter\n");
diff --git a/tests/spec/arb_internalformat_query2/internalformat-size-checks.c 
b/tests/spec/arb_internalformat_query2/internalformat-size-checks.c
index bbccbd6d1..928133133 100644
--- a/tests/spec/arb_internalformat_query2/internalformat-size-checks.c
+++ b/tests/spec/arb_internalformat_query2/internalformat-size-checks.c
@@ -53,24 +53,6 @@ static const GLenum pnames[] = {
 GL_INTERNALFORMAT_SHARED_SIZE,
 };
 
-/* From spec:
- *
- * "For textures this query will return the same information
- *  as querying GetTexLevelParameter{if}v for TEXTURE_*_SIZE
- *  would return."
- *
- * The following are the pnames we would need to use when
- * calling GetTexLevelParameter (so equivalent to pnames)
- */
-static const GLenum equivalent_pnames[] = {
-GL_TEXTURE_RED_SIZE,
-GL_TEXTURE_GREEN_SIZE,
-GL_TEXTURE_BLUE_SIZE,
-GL_TEXTURE_ALPHA_SIZE,
-GL_TEXTURE_DEPTH_SIZE,
-GL_TEXTURE_STENCIL_SIZE,
-GL_TEXTURE_SHARED_SIZE,
-};
 
 enum piglit_result
 piglit_display(void)
@@ -102,7 +84,6 @@ static bool
 try_textures_size(const GLenum *targets, unsigned num_targets,
   const GLenum *internalformats, unsigned num_internalformats,
   const GLenum pname,
-  const GLenum equivalent_pname,
   test_data *data)
 {
 bool pass = true;
@@ -128,7 +109,7 @@ try_textures_size(const GLenum *targets, unsigned 
num_targets,
 value_test = supported ?
 
test_data_check_against_get_tex_level_parameter(data,

 targets[i],
-   
 equivalent_pname,
+   
 pname,
  

[Piglit] [PATCH] teximage-colors: accept -127 instead of -128 for exact snorm up/download

2018-01-07 Thread sroland
From: Roland Scheidegger 

-128 and -127 represent exactly the same value (-1.0) for snorm8 values,
as do -32768/-32767 for snorm16. Therefore it seems quite reasonable that an
implementation would return the other representation (in particular r600 will
do this with a blit, and the snorm->float->snorm conversion implied by this
will never return the -128/-32768 values).
---
 tests/texturing/teximage-colors.c | 39 +++
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/tests/texturing/teximage-colors.c 
b/tests/texturing/teximage-colors.c
index de2024644..61a3c5d15 100644
--- a/tests/texturing/teximage-colors.c
+++ b/tests/texturing/teximage-colors.c
@@ -833,10 +833,41 @@ test_exact()
  observed);
pass &= piglit_check_gl_error(GL_NO_ERROR);
 
-   for (i = 0; i < texture_size; ++i)
-   pass &= memcmp(&data[i * texture_size * Bpp],
-  &observed[i * tex_width * Bpp],
-  texture_size * Bpp) == 0;
+   /*
+* For snorm formats, -127/-128 and -32767/-32768 represent the exact
+* same value (-1.0). Therefore, it is quite reasonable to expect
+* an implementation could return the other representation.
+* (We'll assume it will happen only one way the other way seems rather
+* unlikely.)
+*/
+   if (format->data_type == GL_BYTE) {
+   int j;
+   for (j = 0; j < texture_size; ++j) {
+   for (i = 0; i < tex_width * channels; i++) {
+   if (!(data[i] == observed[i] ||
+ (data[i] == 128 && observed[i] == 129))) {
+   pass = GL_FALSE;
+   }
+   }
+   }
+   } else if (format->data_type == GL_SHORT) {
+   int j;
+   for (j = 0; j < texture_size; ++j) {
+   for (i = 0; i < tex_width * channels; i++) {
+   GLshort datas = ((GLshort *)data)[i];
+   GLshort obss = ((GLshort *)observed)[i];
+   if (!(datas == obss ||
+ (datas == -32768 && obss == -32767))) {
+   pass = GL_FALSE;
+   }
+   }
+   }
+   } else {
+   for (i = 0; i < texture_size; ++i)
+   pass &= memcmp(&data[i * texture_size * Bpp],
+   &observed[i * tex_width * Bpp],
+   texture_size * Bpp) == 0;
+   }
 
free(observed);
free(tmp_float);
-- 
2.12.3

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] arb_texture_buffer_object/indexed: test indexed samplers with tbo

2018-01-03 Thread sroland
From: Roland Scheidegger 

This just verifies that sampler arrays indexed with a uniform work with TBOs.
(Broken on r600 evergreen pending a fix.)

v2: fix compiler warnings, directly assign index uniform in shader
---
 tests/all.py   |   1 +
 .../arb_texture_buffer_object/CMakeLists.gl.txt|   1 +
 tests/spec/arb_texture_buffer_object/indexed.c | 110 +
 3 files changed, 112 insertions(+)
 create mode 100644 tests/spec/arb_texture_buffer_object/indexed.c

diff --git a/tests/all.py b/tests/all.py
index ac1947ca4..0a1a65ef4 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2483,6 +2483,7 @@ with profile.test_list.group_manager(
 g(['arb_texture_buffer_object-subdata-sync'], 'subdata-sync')
 g(['arb_texture_buffer_object-unused-name'], 'unused-name')
 g(['arb_texture_buffer_object-render-no-bo'], 'render-no-bo')
+g(['arb_texture_buffer_object-indexed'], 'indexed')
 
 with profile.test_list.group_manager(
 PiglitGLTest,
diff --git a/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt 
b/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt
index ec0d0b463..959ca0c2f 100644
--- a/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt
+++ b/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt
@@ -24,3 +24,4 @@ piglit_add_executable (arb_texture_buffer_object-render-no-bo 
render-no-bo.c)
 piglit_add_executable (arb_texture_buffer_object-subdata-sync subdata-sync.c)
 piglit_add_executable (arb_texture_buffer_object-unused-name unused-name.c)
 piglit_add_executable (arb_texture_buffer_object-fetch-outside-bounds 
fetch-outside-bounds.c)
+piglit_add_executable (arb_texture_buffer_object-indexed indexed.c)
diff --git a/tests/spec/arb_texture_buffer_object/indexed.c 
b/tests/spec/arb_texture_buffer_object/indexed.c
new file mode 100644
index 0..e62c246f3
--- /dev/null
+++ b/tests/spec/arb_texture_buffer_object/indexed.c
@@ -0,0 +1,110 @@
+/* Copyright © 2015 Ilia Mirkin
+ * Copyright © 2017 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/** @file indexed.c
+ *
+ * Tests that we can sample texture buffers with sampler indexing.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+   config.supports_gl_core_version = 32;
+   config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+   config.khr_no_error_support = PIGLIT_NO_ERRORS;
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+   static const float green[4] = {0, 1, 0, 0};
+   bool pass;
+
+   glViewport(0, 0, piglit_width, piglit_height);
+   glClearColor(0.2, 0.2, 0.2, 0.2);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   piglit_draw_rect(-1, -1, 2, 2);
+
+   pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green);
+
+   piglit_present_results();
+
+   return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+   static const char *vs_source =
+   "#version 150\n"
+   "in vec4 piglit_vertex;\n"
+   "void main()\n"
+   "{\n"
+   "   gl_Position = piglit_vertex;\n"
+   "}\n";
+
+   static const char *fs_source =
+   "#version 150\n"
+   "#extension GL_ARB_gpu_shader5: require\n"
+   "uniform samplerBuffer s[2];\n"
+   "uniform int offset;\n"
+   "uniform int index = 1;\n"
+   "void main()\n"
+   "{\n"
+   "   gl_FragColor = texelFetch(s[index], offset);\n"
+   "}\n";
+
+   GLuint tex[2], tbo[2];
+   GLint indices[2] = { 0, 1 };
+   static const uint8_t datag[4] = {0x00, 0xff, 0x00, 0x00};
+   static const uint8_t datar[4] = {0xff, 0x00, 0x00, 0x00};
+   GLuint prog;
+   GLint size = 4;
+   piglit_require_extension("GL_ARB_gp

[Piglit] [PATCH] arb_texture_buffer_object/indexed: test indexed samplers with tbo

2018-01-02 Thread sroland
From: Roland Scheidegger 

This just verifies that sampler arrays indexed with a uniform work with TBOs.
(Broken on r600 evergreen pending a fix.)
---
 tests/all.py   |   1 +
 .../arb_texture_buffer_object/CMakeLists.gl.txt|   1 +
 tests/spec/arb_texture_buffer_object/indexed.c | 112 +
 3 files changed, 114 insertions(+)
 create mode 100644 tests/spec/arb_texture_buffer_object/indexed.c

diff --git a/tests/all.py b/tests/all.py
index 5d90e8fa3..5dcb68895 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2456,6 +2456,7 @@ with profile.test_list.group_manager(
 g(['arb_texture_buffer_object-subdata-sync'], 'subdata-sync')
 g(['arb_texture_buffer_object-unused-name'], 'unused-name')
 g(['arb_texture_buffer_object-render-no-bo'], 'render-no-bo')
+g(['arb_texture_buffer_object-indexed'], 'indexed')
 
 with profile.test_list.group_manager(
 PiglitGLTest,
diff --git a/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt 
b/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt
index ec0d0b463..959ca0c2f 100644
--- a/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt
+++ b/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt
@@ -24,3 +24,4 @@ piglit_add_executable (arb_texture_buffer_object-render-no-bo 
render-no-bo.c)
 piglit_add_executable (arb_texture_buffer_object-subdata-sync subdata-sync.c)
 piglit_add_executable (arb_texture_buffer_object-unused-name unused-name.c)
 piglit_add_executable (arb_texture_buffer_object-fetch-outside-bounds 
fetch-outside-bounds.c)
+piglit_add_executable (arb_texture_buffer_object-indexed indexed.c)
diff --git a/tests/spec/arb_texture_buffer_object/indexed.c 
b/tests/spec/arb_texture_buffer_object/indexed.c
new file mode 100644
index 0..fbd341317
--- /dev/null
+++ b/tests/spec/arb_texture_buffer_object/indexed.c
@@ -0,0 +1,112 @@
+/* Copyright © 2015 Ilia Mirkin
+ * Copyright © 2017 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/** @file indexed.c
+ *
+ * Tests that we can sample texture buffers with sampler indexing.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+   config.supports_gl_core_version = 32;
+   config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+   config.khr_no_error_support = PIGLIT_NO_ERRORS;
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+   static const float green[4] = {0, 1, 0, 0};
+   bool pass;
+
+   glViewport(0, 0, piglit_width, piglit_height);
+   glClearColor(0.2, 0.2, 0.2, 0.2);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   piglit_draw_rect(-1, -1, 2, 2);
+
+   pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green);
+
+   piglit_present_results();
+
+   return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+   static const char *vs_source =
+   "#version 150\n"
+   "in vec4 piglit_vertex;\n"
+   "void main()\n"
+   "{\n"
+   "   gl_Position = piglit_vertex;\n"
+   "}\n";
+
+   static const char *fs_source =
+   "#version 150\n"
+   "#extension GL_ARB_gpu_shader5: require\n"
+   "uniform samplerBuffer s[2];\n"
+   "uniform int offset;\n"
+   "uniform int index;\n"
+   "void main()\n"
+   "{\n"
+   "   gl_FragColor = texelFetch(s[index], offset);\n"
+   "}\n";
+
+   GLuint tex[2], tbo[2];
+   GLuint indices[2] = { 0, 1 };
+   static const uint8_t datag[4] = {0x00, 0xff, 0x00, 0x00};
+   static const uint8_t datar[4] = {0xff, 0x00, 0x00, 0x00};
+   GLuint prog;
+   GLint size = 4;
+   GLenum err;
+   piglit_require_extension("GL_ARB_gpu_shader5");
+
+   prog = piglit_build_simple_p

[Piglit] [PATCH 2/2] arb_texture_buffer_object/max-size: skip if the buffer can't be allocated

2017-12-31 Thread sroland
From: Roland Scheidegger 

The max size reported by GL_MAX_TEXTURE_BUFFER_SIZE only guarantees that
buffers which contain that many texels can be sampled from. It does not mean
it is guaranteed the corresponding huge buffers can be allocated in the first
place. (r600 for instance will report some huge number, the test cuts this
to 512 million texels, but naturally fails to allocate the 2GB buffer for it,
at least on my card with 1GB vram. The driver actually will report 0.7 times
the max of vram and gart size, but since the gl cap is in texels this doesn't
really help as the test uses rgba8 format.)
Since the test specifically tries to test the max, skip it when this happens
(instead of trying lower sizes).
---
 tests/spec/arb_texture_buffer_object/max-size.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tests/spec/arb_texture_buffer_object/max-size.c 
b/tests/spec/arb_texture_buffer_object/max-size.c
index 19f4ddf04..b94d2d094 100644
--- a/tests/spec/arb_texture_buffer_object/max-size.c
+++ b/tests/spec/arb_texture_buffer_object/max-size.c
@@ -76,6 +76,7 @@ piglit_init(int argc, char **argv)
static const uint8_t data[4] = {0x00, 0xff, 0x00, 0x00};
GLuint prog;
GLint max;
+   GLenum err;
 
prog = piglit_build_simple_program(vs_source, fs_source);
glUseProgram(prog);
@@ -101,6 +102,11 @@ piglit_init(int argc, char **argv)
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, tbo);
glBufferData(GL_TEXTURE_BUFFER,
 max * sizeof(data), NULL, GL_STATIC_READ);
+   err = glGetError();
+   if (err == GL_OUT_OF_MEMORY) {
+   printf("couldn't allocate buffer due to OOM, skipping.\n");
+   piglit_report_result(PIGLIT_SKIP);
+   }
glBufferSubData(GL_TEXTURE_BUFFER,
(max - 1) * sizeof(data), sizeof(data), data);
 
-- 
2.12.3

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 1/2] textureSize: add ability to test tess eval stage

2017-12-31 Thread sroland
From: Roland Scheidegger 

This is a problem of all texturing tests, they cannot exercise the tesselation
stages. (But I'm too lazy to fix the others, and too lazy to hack something up
for tcs stage, I only need it to verify a bug/fix with r600 buffer textures.)
---
 tests/texturing/shaders/common.c  |  3 ++
 tests/texturing/shaders/common.h  |  3 +-
 tests/texturing/shaders/textureSize.c | 76 ---
 3 files changed, 75 insertions(+), 7 deletions(-)

diff --git a/tests/texturing/shaders/common.c b/tests/texturing/shaders/common.c
index b377bbcae..bda149971 100644
--- a/tests/texturing/shaders/common.c
+++ b/tests/texturing/shaders/common.c
@@ -378,6 +378,9 @@ require_GL_features(enum shader_target test_stage)
glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &tex_units);
if (test_stage == VS && tex_units <= 0)
piglit_report_result(PIGLIT_SKIP);
+
+   if (test_stage == TES)
+   piglit_require_extension("GL_ARB_tessellation_shader");
 }
 
 /**
diff --git a/tests/texturing/shaders/common.h b/tests/texturing/shaders/common.h
index 49f38e8b5..3edc68bff 100644
--- a/tests/texturing/shaders/common.h
+++ b/tests/texturing/shaders/common.h
@@ -91,7 +91,8 @@ enum shader_target {
UNKNOWN,
VS,
FS,
-   GS
+   GS,
+   TES,
 };
 
 float max2(float x, float y);
diff --git a/tests/texturing/shaders/textureSize.c 
b/tests/texturing/shaders/textureSize.c
index 2693633fb..3035e0505 100644
--- a/tests/texturing/shaders/textureSize.c
+++ b/tests/texturing/shaders/textureSize.c
@@ -60,7 +60,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
piglit_gl_process_args(&argc, argv, &config);
 
parse_args(argc, argv);
-   if (test_stage == GS) {
+   if (test_stage == GS || test_stage == TES) {
config.supports_gl_compat_version = 32;
config.supports_gl_core_version = 32;
} else {
@@ -154,7 +154,7 @@ piglit_display()
 
glUniform1i(lod_location, l);
glViewport(x, 10, 10, 10);
-   glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+   glDrawArrays(test_stage == TES ? GL_PATCHES : GL_TRIANGLE_FAN, 
0, 4);
 
pass &= piglit_probe_rect_rgba(x, 10, 10, 10, expected_color);
}
@@ -248,12 +248,14 @@ has_lod(void)
 int
 generate_GLSL(enum shader_target test_stage)
 {
-   int vs, gs = 0, fs;
+   int vs, gs = 0, tes = 0, tcs = 0, fs;
int prog;
 
static char *vs_code;
static char *gs_code = NULL;
static char *fs_code;
+   static char *tes_code = NULL;
+   static char *tcs_code = NULL;
char *lod_arg;
static const char *zeroes[3] = { "", "0, ", "0, 0, " };
 
@@ -357,6 +359,55 @@ generate_GLSL(enum shader_target test_stage)
 shader_version, extension, sampler.name, size, lod_arg,
 zeroes[3 - size]);
break;
+   case TES:
+   (void)!asprintf(&vs_code,
+"#version %d\n"
+"in vec4 vertex;\n"
+"void main()\n"
+"{\n"
+"gl_Position = vertex;\n"
+"}\n",
+shader_version);
+   (void)!asprintf(&tes_code,
+"#version %d\n%s"
+"#extension GL_ARB_tessellation_shader: require\n"
+"#define ivec1 int\n"
+"uniform int lod;\n"
+"uniform %s tex;\n"
+"layout(quads) in;\n"
+"flat out ivec%d size;\n"
+"void main()\n"
+"{\n"
+"gl_Position = vec4(gl_TessCoord.x * 2 - 1, 
gl_TessCoord.y * 2 - 1, 0, 1);\n"
+"size = textureSize(tex%s);\n"
+"}\n",
+shader_version, extension, sampler.name, size, 
lod_arg);
+   (void)!asprintf(&tcs_code,
+"#version %d\n"
+"#extension GL_ARB_tessellation_shader: require\n"
+"layout(vertices = 4) out;\n"
+"void main()\n"
+"{\n"
+"gl_TessLevelInner[0] = 1.0;\n"
+"gl_TessLevelInner[1] = 1.0;\n"
+"gl_TessLevelOuter[0] = 1.0;\n"
+"gl_TessLevelOuter[1] = 1.0;\n"
+"gl_TessLevelOuter[2] = 1.0;\n"
+"gl_TessLevelOuter[3] = 1.0;\n"
+"}\n",
+shader_version);
+   (void)!asprintf(&fs_code,
+"#version %d\n"
+"#define ivec1 int\n"
+"#define vec1 float\n"
+"fl

[Piglit] [PATCH] textureGather: add new options for testing mirror address modes

2017-12-09 Thread sroland
From: Roland Scheidegger 

The existing repeat and clamp modes are easy to implement. The
mirror_repeat (GL_MIRRORED_REPEAT) and mirror_clamp
(GL_MIRROR_CLAMP_TO_EDGE) modes however have some very interesting
differences to "gather is just the same as bilinear filtering without
the actual filtering". In particular, a bilinear filter implementation
can cut a lot of corners wrt texel selection as it doesn't need to
maintain texel order (as long as the weights follow the same order) and
can even pick different samples (as long as they have weight 0).
So, test these modes too. I used this for fixing llvmpipe, passes with
nvidia blob too (the test actually always hits exactly the cases where
one texel would have weight 0).
---
 tests/texturing/shaders/textureGather.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/tests/texturing/shaders/textureGather.c 
b/tests/texturing/shaders/textureGather.c
index f364c5c..8ea94b6 100644
--- a/tests/texturing/shaders/textureGather.c
+++ b/tests/texturing/shaders/textureGather.c
@@ -135,6 +135,23 @@ pixel_value(int i, int j, int offset_sel)
if (i > texture_width - 1) i = texture_width - 1;
if (j > texture_height - 1) j = texture_height - 1;
}
+   else if (address_mode == GL_MIRRORED_REPEAT) {
+   bool isOdd;
+   if (i < 0) i = -i - 1;
+   isOdd = (i / texture_width) & 1;
+   i = i % texture_width;
+   if (isOdd) i = texture_width - i - 1;
+   if (j < 0) j = -j - 1;
+   isOdd = (j / texture_height) & 1;
+   j = j % texture_height;
+   if (isOdd) j = texture_height - j - 1;
+   }
+   else if (address_mode == GL_MIRROR_CLAMP_TO_EDGE) {
+   if (i < 0) i = -i - 1;
+   if (j < 0) j = -j - 1;
+   if (i > texture_width - 1) i = texture_width - 1;
+   if (j > texture_height - 1) j = texture_height - 1;
+   }
 
return i + j * texture_width;
 }
@@ -555,7 +572,7 @@ fail_with_usage(void)
   "comptype = unorm|float|uint|int|shadow\n"
   "sampler = 2D|2DArray|Cube|CubeArray|2DRect\n"
   "compselect = 0|1|2|3\n"
-  "addressmode = repeat|clamp\n");
+  "addressmode = 
repeat|clamp|mirror_repeat|mirror_clamp\n");
piglit_report_result(PIGLIT_SKIP);
 }
 
@@ -596,6 +613,8 @@ piglit_init(int argc, char **argv)
else if (!strcmp(opt, "3")) comp_select = 3;
else if (!strcmp(opt, "repeat")) address_mode = GL_REPEAT;
else if (!strcmp(opt, "clamp")) address_mode = GL_CLAMP_TO_EDGE;
+   else if (!strcmp(opt, "mirror_repeat")) address_mode = 
GL_MIRRORED_REPEAT;
+   else if (!strcmp(opt, "mirror_clamp")) address_mode = 
GL_MIRROR_CLAMP_TO_EDGE;
}
 
if (stage == NOSTAGE) fail_with_usage();
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] fbo-blending-snorm: new test for testing snorm blend behavior

2017-11-21 Thread sroland
From: Roland Scheidegger 

The existing fbo-blending-formats test is mostly useless for anything but
unorm formats, since it does not test any values outside [0,1] (neither for
src, dst, intermeidate calculations, blend result).
I tried to enhance it but it got too complex, in particular because I really
want to test snorm, not floats (which aren't really validated much neither),
because if you actually use int math for them it's difficult to handle and
llvmpipe had lots of bugs. And it's not even obvious from the GL spec when
clamping actually happens (in particular, the inverse blend factors will be
in range [0,2]). snorm blending is sort of semi-supported in GL, the
presence of EXT_texture_snorm doesn't guarantee it (and nvidia doesn't support
the extension, presumably because they can't or don't want to deal with the
legacy alpha/luminance/intensity formats), and while GL 3.1 introduces the
snorm formats too it isn't guaranteed for rendering neither (for GLES OTOH
there's a EXT_render_snorm extension), so the format handling of the
fbo-blending-formats test isn't really sufficient and not easily extensible.
So, this test will test actual blend behavior with values which will need
clamping, and where the intermediate and final values will be negative (and,
for the inverse blend factors, be even larger than one).
This passes (now) on llvmpipe, and nvidia blob. softpipe is a complete
failure (if there's clamping it will always clamp to [0,1] for starters),
and as a matter of fact, softpipe doesn't get the clamping right even with
unorm neither, since values outside [0,1] won't get clamped in the tile
cache when there's no clamping, hence they'll enter the blend later when
blend is enabled unclamped - but there's no test for this (note this is
only an issue if the fragment color clamp is disabled).
---
 tests/all.py   |   1 +
 tests/fbo/CMakeLists.gl.txt|   1 +
 tests/fbo/fbo-blending-snorm.c | 358 +
 3 files changed, 360 insertions(+)
 create mode 100644 tests/fbo/fbo-blending-snorm.c

diff --git a/tests/all.py b/tests/all.py
index 70f8efd..472024a 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3180,6 +3180,7 @@ with profile.test_list.group_manager(
 g(['fbo-alphatest-nocolor'])
 g(['fbo-alphatest-nocolor-ff'])
 g(['fbo-blending-formats'])
+g(['fbo-blending-snorm'])
 g(['fbo-bind-renderbuffer'])
 g(['fbo-clearmipmap'])
 g(['fbo-clear-formats'])
diff --git a/tests/fbo/CMakeLists.gl.txt b/tests/fbo/CMakeLists.gl.txt
index 2db8bf7..d594c24 100644
--- a/tests/fbo/CMakeLists.gl.txt
+++ b/tests/fbo/CMakeLists.gl.txt
@@ -29,6 +29,7 @@ piglit_add_executable (fbo-blit fbo-blit.c)
 piglit_add_executable (fbo-blit-d24s8 fbo-blit-d24s8.c)
 piglit_add_executable (fbo-blit-stretch fbo-blit-stretch.cpp)
 piglit_add_executable (fbo-blending-formats fbo-blending-formats.c)
+piglit_add_executable (fbo-blending-snorm fbo-blending-snorm.c)
 piglit_add_executable (fbo-colormask-formats fbo-colormask-formats.c)
 piglit_add_executable (fbo-copypix fbo-copypix.c)
 piglit_add_executable (fbo-readdrawpix fbo-readdrawpix.c)
diff --git a/tests/fbo/fbo-blending-snorm.c b/tests/fbo/fbo-blending-snorm.c
new file mode 100644
index 000..a7c2bba
--- /dev/null
+++ b/tests/fbo/fbo-blending-snorm.c
@@ -0,0 +1,358 @@
+/*
+ * Copyright © 2010 Intel Corporation
+ * Copyright © 2010 Marek Olšák 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Eric Anholt 
+ *Marek Olšák 
+ *Roland Scheidegger 
+ *
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 30;
+
+   /* Drivers that do not support GL_ARB_texture_non_power_of_two require
+* window dimensions that are powers of two for this test.
+*/
+   config.window_width = next_power_of_two(config.window_width);
+   config.window_he

[Piglit] [PATCH] isinf-and-isnan: add clamp / min / max tests

2017-11-09 Thread sroland
From: Roland Scheidegger 

We expect non-nan results for these (according to d3d10 rules, and at least
for min/max, also according to ieee rules). The tests will not actually fail
with other results (since GL's NaN behavior is all undefined), albeit some
apps may rely on this.
(We'll use clamp to 0/1 on purpose, which may get optimized to a saturate
modifier on some hw, and ideally we'd see a non-nan result there too. The
expected result there is really zero (d3d10 would require this), so if
it gets decomposed into min/max combo the order is actually important.)
On r600, right now all 3 give undesired (NaN) results (pending fixes),
albeit all legal.
---
 tests/spec/glsl-1.30/execution/isinf-and-isnan.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/tests/spec/glsl-1.30/execution/isinf-and-isnan.c 
b/tests/spec/glsl-1.30/execution/isinf-and-isnan.c
index 099b5c2..77a7591 100644
--- a/tests/spec/glsl-1.30/execution/isinf-and-isnan.c
+++ b/tests/spec/glsl-1.30/execution/isinf-and-isnan.c
@@ -340,6 +340,7 @@ enum behavior
B_FINITE = 1, /* Expected to evaluate to a finite value */
B_POSINF = 2, /* Expected to evaluate to +Infinity */
B_NEGINF = 3, /* Expected to evaluate to -Infinity */
+   B_FINITE_NANOK = 4, /* Expected finite value, but NaN ok */
 };
 
 struct expression_table_element
@@ -369,6 +370,10 @@ static struct expression_table_element expressions[] = {
{ "log(-1.0+z)", B_NAN },
{ "sqrt(-1.0)", B_NAN },
{ "sqrt(-1.0+z)", B_NAN },
+   { "clamp(u_nan, 0.0, 1.0)", B_FINITE_NANOK },
+   { "min(u_two, u_nan)", B_FINITE_NANOK },
+   { "max(u_two, u_nan)", B_FINITE_NANOK },
+
 };
 
 /**
@@ -446,6 +451,7 @@ test_expr(char *expression, int expected_behavior)
"uniform float u_inf;\n" /* Always == +infinity */
"uniform float u_minus_inf;\n" /* Always == -infinity */
"uniform float u_nan;\n" /* Always == NaN */
+   "uniform float u_two = 2.0;\n" /* To defeat constant folding */
"float compute_value() {\n"
"  return %s;\n"
"}\n",
@@ -523,6 +529,9 @@ test_expr(char *expression, int expected_behavior)
pass = false;
}
break;
+   case B_FINITE_NANOK:
+   expected_behavior_string = "finite";
+   break;
default:
expected_behavior_string = "NaN";
break;
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] arb_texture_query_lod: add tolerance for some comparisons

2017-09-08 Thread sroland
From: Roland Scheidegger 

Tolerance was added for the tests a while ago, but it looks like it was
forgotten for the nearest_biased test (the nearest one has it).
Also, for the linear test, add tolerance too when comparing x and y lodq
results - the values should probably be the same mostly, however it's possible
(due to interpolation inaccuracies) to get values just below 0 or above 3, in
which case they will get clamped. (Could just do a clamp instead of allowing
tolerance I suppose, but some tolerance might be allowed in any case there
too.)

This is required for llvmpipe (with a in-progress change) to pass.
---
 .../execution/fs-textureQueryLOD-linear.shader_test | 2 +-
 .../execution/fs-textureQueryLOD-nearest-biased.shader_test | 6 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test
 
b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test
index 6afef71..bb2d8ba 100644
--- 
a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test
+++ 
b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test
@@ -60,7 +60,7 @@ void main()
 }
 
 vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st);
-if (queried_lod.x != queried_lod.y) {
+if (!equal(queried_lod.x, queried_lod.y)) {
discard;
 }
 if (!equal(queried_lod.x, lod)) {
diff --git 
a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test
 
b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test
index 1e0c557..4487930 100644
--- 
a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test
+++ 
b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test
@@ -51,6 +51,10 @@ GL_ARB_texture_query_lod
 #define MAX_MIPMAP_LEVEL 3
 uniform sampler2D tex;
 uniform float lod;
+
+#define tolerance (1.0/255.0)
+#define equal(x,y) (abs((x) - (y)) <= tolerance)
+
 void main()
 {
 /* The ARB_texture_query_lod spec says that if TEXTURE_MIN_FILTER is set
@@ -69,7 +73,7 @@ void main()
 }
 
 vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st);
-if (queried_lod.x != min(queried_lod.y, MAX_MIPMAP_LEVEL)) {
+if (!equal(queried_lod.x, min(queried_lod.y, MAX_MIPMAP_LEVEL))) {
discard;
 }
 if (queried_lod.x != min(nearest_lod + 1, MAX_MIPMAP_LEVEL)) {
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] msaa: add test to verify alpha-to-coverage together with alpha-to-one

2017-08-04 Thread sroland
From: Roland Scheidegger 

I believe the sole reason alpha-to-one exists at all is that it can be
used together with alpha-to-coverage (otherwise why not just output alpha
1.0 in the fs in the first place...).
Therefore, it seems quite appropriate to test this together with
alpha-to-coverage.

Note: the test is a simple copy of sample-alpha-to-coverage with only
trivial adjustments. I don't think the common code used actually handles
this case correctly for the reference image (as it's the same as when
just using alpha-to-coverage, which can't be right), but I haven't looked
at it long enough to be able to fix it.
It is, however, good enough to pass on my nvidia card, albeit some mesa
drivers trying to emulate this feature are definitely broken (I'm looking
at you radeons...).
---
 tests/all.py   |   5 +
 .../ext_framebuffer_multisample/CMakeLists.gl.txt  |   2 +
 .../sample-alpha-to-coverage-one.cpp   | 162 +
 3 files changed, 169 insertions(+)
 create mode 100644 
tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage-one.cpp

diff --git a/tests/all.py b/tests/all.py
index fc00d99..bc5b9e0 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3028,6 +3028,11 @@ with profile.test_list.group_manager(
sample_count, buffer_type],
   'sample-alpha-to-coverage {} {}'.format(
   sample_count, buffer_type))
+g(['ext_framebuffer_multisample-sample-alpha-to-coverage-one',
+   sample_count, buffer_type],
+  'sample-alpha-to-coverage-one {} {}'.format(
+  sample_count, buffer_type))
+
 
 for test in ['line-smooth', 'point-smooth', 'polygon-smooth',
  'sample-alpha-to-one',
diff --git a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt 
b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt
index 6841267..e93c609 100644
--- a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt
+++ b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt
@@ -62,6 +62,8 @@ piglit_add_executable (ext_framebuffer_multisample-samples 
samples.c)
 piglit_add_executable (ext_framebuffer_multisample-sample-coverage common.cpp 
sample-coverage.cpp)
 piglit_add_executable (ext_framebuffer_multisample-sample-alpha-to-coverage 
common.cpp
   draw-buffers-common.cpp sample-alpha-to-coverage.cpp)
+piglit_add_executable 
(ext_framebuffer_multisample-sample-alpha-to-coverage-one common.cpp
+  draw-buffers-common.cpp sample-alpha-to-coverage-one.cpp)
 piglit_add_executable (ext_framebuffer_multisample-sample-alpha-to-one 
common.cpp
   draw-buffers-common.cpp sample-alpha-to-one.cpp)
 piglit_add_executable (ext_framebuffer_multisample-turn-on-off common.cpp 
turn-on-off.cpp)
diff --git 
a/tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage-one.cpp 
b/tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage-one.cpp
new file mode 100644
index 000..887893a
--- /dev/null
+++ b/tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage-one.cpp
@@ -0,0 +1,162 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "draw-buffers-common.h"
+
+/**
+ * \file sample-alpha-to-coverage.cpp
+ *
+ * Verify sample alpha to coverage plus alpha to one with multisample FBO
+ *
+ * When rendering to multisample FBO, fragment's alpha value should be
+ * used to determine the coverage value, and then the alpha value set to 1.
+ *
+ * This test operates by drawing a pattern in multisample FBO to generate
+ * reference and test image. Reference image is drawn to right half of window
+ * system frame buffer and test image to left half.
+ *
+ * Compute the expected color / depth values.
+ *
+ * Probe color / depth buffer blitted to downsampled FBO (resolve_fbo) and

[Piglit] [PATCH] depth-clamp-range: make sure clamping actually makes a difference

2016-08-14 Thread sroland
From: Roland Scheidegger 

The problem with the chosen depth values was that the depth values
naturally got viewport-transformed to values below 0.5 (for those
quads drawn) or above 0.5 (for those not drawn).
This allowed buggy implementations (in particular llvmpipe) to pass
the test, even though llvmpipe a) couldn't handle swapped near/far and
b) didn't actually do any clamping whatsoever in this particular case.
So change the depth values so that transformed values actually end up
"on the wrong side" of the depth range.
---
 tests/general/depth-clamp-range.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/general/depth-clamp-range.c 
b/tests/general/depth-clamp-range.c
index dd93000..d61d351 100644
--- a/tests/general/depth-clamp-range.c
+++ b/tests/general/depth-clamp-range.c
@@ -89,17 +89,17 @@ piglit_display(void)
/* Now, test that near depth clamping works.*/
glEnable(GL_DEPTH_CLAMP);
glDepthRange(0.25, 1.0);
-   quad(30, 10, 2); /* 0.25 - drawn. */
+   quad(30, 10, 4); /* 0.25 - drawn. */
 
glDepthRange(0.75, 1.0);
-   quad(30, 30, 2); /* 0.75 - not drawn. */
+   quad(30, 30, 4); /* 0.75 - not drawn. */
 
/* Test that far clamping works.*/
glDepthRange(0.0, 0.25);
-   quad(50, 10, -2); /* 0.25 - drawn. */
+   quad(50, 10, -4); /* 0.25 - drawn. */
 
glDepthRange(0.0, 0.75);
-   quad(50, 30, -2); /* 0.75 - not drawn. */
+   quad(50, 30, -4); /* 0.75 - not drawn. */
 
/* Now, flip near and far around and make sure that it's doing the
 * min/max of near and far in the clamping.
@@ -107,17 +107,17 @@ piglit_display(void)
 
/* Test that near (max) clamping works. */
glDepthRange(0.25, 0.0);
-   quad(70, 10, 2); /* 0.25 - drawn. */
+   quad(70, 10, 4); /* 0.25 - drawn. */
 
glDepthRange(0.75, 0.0);
-   quad(70, 30, 2); /* 0.75 - not drawn. */
+   quad(70, 30, 4); /* 0.75 - not drawn. */
 
/* Now, test far (min) clamping works. */
glDepthRange(1.0, 0.0);
-   quad(90, 10, -2); /* 0.0 - drawn */
+   quad(90, 10, -4); /* 0.0 - drawn */
 
glDepthRange(1.0, 0.75);
-   quad(90, 30, -2); /* 0.75 - not drawn*/
+   quad(90, 30, -4); /* 0.75 - not drawn*/
 
pass = piglit_probe_pixel_rgb(15, 15, white) && pass;
pass = piglit_probe_pixel_rgb(15, 35, clear) && pass;
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] tex-miplevel-selection: only require glsl 1.30 for textureOffset 2DArrayShadow

2016-04-18 Thread sroland
From: Roland Scheidegger 

The spec doesn't really say this should work in older versions. It was first
added in glsl 4.30, mentioning it was forgotten (initially part of
EXT_gpu_shader4, hence should have been added with 1.30), but with the wrong
syntax. Finally fixed in glsl 4.40.
It does, however, work with nvidia blob with version 130 directive.
Also works with llvmpipe (with mesa fix).
---
 tests/texturing/tex-miplevel-selection.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/tests/texturing/tex-miplevel-selection.c 
b/tests/texturing/tex-miplevel-selection.c
index 959bab2..59030b5 100644
--- a/tests/texturing/tex-miplevel-selection.c
+++ b/tests/texturing/tex-miplevel-selection.c
@@ -322,12 +322,6 @@ piglit_init(int argc, char **argv)
}
piglit_require_gl_version(NEED_GL3(test) ? 30 : 14);
 
-   if (target == TEX_2D_ARRAY_SHADOW &&
-   test == GL3_TEXTURE_OFFSET) {
-   piglit_require_GLSL_version(430);
-   version = "430";
-   }
-
switch (target) {
case TEX_1D:
gltarget = GL_TEXTURE_1D;
-- 
2.1.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] arb_viewport_array: add GL_ARB_gpu_shader5 requirement for render_viewport_2

2016-01-13 Thread sroland
From: Roland Scheidegger 

The test cannot work without this (and thus always failed if not present).
---
 tests/spec/arb_viewport_array/render_viewport_2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/spec/arb_viewport_array/render_viewport_2.c 
b/tests/spec/arb_viewport_array/render_viewport_2.c
index 963709b..7e8360f 100644
--- a/tests/spec/arb_viewport_array/render_viewport_2.c
+++ b/tests/spec/arb_viewport_array/render_viewport_2.c
@@ -152,6 +152,7 @@ piglit_init(int argc, char **argv)
GLuint program;
GLuint vao;
piglit_require_extension("GL_ARB_viewport_array");
+   piglit_require_extension("GL_ARB_gpu_shader5");
 
program = piglit_build_simple_program_multiple_shaders(
GL_VERTEX_SHADER, vsSource,
-- 
2.1.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] arb_texture_view-mipgen: add test to verify correct format is used for mipgen

2016-01-12 Thread sroland
From: Roland Scheidegger 

At least mesa/st fails this right now (always uses the initial format for mip
gen).

v2: don't use piglit_display (not actually drawing anything), suggested
by Ilia Mirkin.
---
 tests/all.py  |   1 +
 tests/spec/arb_texture_view/CMakeLists.gl.txt |   1 +
 tests/spec/arb_texture_view/mipgen.c  | 104 ++
 3 files changed, 106 insertions(+)
 create mode 100644 tests/spec/arb_texture_view/mipgen.c

diff --git a/tests/all.py b/tests/all.py
index d9f88d6..0a97d26 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2480,6 +2480,7 @@ with profile.group_manager(
 g(['arb_texture_view-cubemap-view'], 'cubemap-view')
 g(['arb_texture_view-texture-immutable-levels'], 'immutable_levels')
 g(['arb_texture_view-max-level'], 'max-level')
+g(['arb_texture_view-mipgen'], 'mipgen')
 g(['arb_texture_view-params'], 'params')
 g(['arb_texture_view-formats'], 'formats')
 g(['arb_texture_view-targets'], 'targets')
diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt 
b/tests/spec/arb_texture_view/CMakeLists.gl.txt
index 772f8b4..47b3320 100644
--- a/tests/spec/arb_texture_view/CMakeLists.gl.txt
+++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt
@@ -17,6 +17,7 @@ piglit_add_executable(arb_texture_view-formats formats.c 
common.c)
 piglit_add_executable(arb_texture_view-getteximage-srgb getteximage-srgb.c)
 piglit_add_executable(arb_texture_view-lifetime-format lifetime_format.c 
common.c)
 piglit_add_executable(arb_texture_view-max-level max-level.c)
+piglit_add_executable(arb_texture_view-mipgen mipgen.c)
 piglit_add_executable(arb_texture_view-params params.c)
 piglit_add_executable(arb_texture_view-queries queries.c)
 piglit_add_executable(arb_texture_view-rendering-formats rendering-formats.c)
diff --git a/tests/spec/arb_texture_view/mipgen.c 
b/tests/spec/arb_texture_view/mipgen.c
new file mode 100644
index 000..f29a95c
--- /dev/null
+++ b/tests/spec/arb_texture_view/mipgen.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright © 2016 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * Verifies that mipmap generation uses the right format (from view,
+ * not what was originally specified).
+ */
+
+#include "piglit-util-gl.h"
+#include "common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 20;
+
+   config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *TestName = "arb_texture_view-mipgen";
+
+/**
+ * Create view with different view format and generate mipmap.
+ */
+static bool
+test_mipgen(void)
+{
+   GLuint tex, new_tex;
+   GLint width = 4, height = 4, levels = 2;
+   bool pass = true;
+
+   glGenTextures(1, &tex);
+   glBindTexture(GL_TEXTURE_2D, tex);
+
+   glTexStorage2D(GL_TEXTURE_2D, levels, GL_R8, width, height);
+
+   /* averaging these as snorm values should give 0 */
+   GLubyte buf[4][4] =
+   {{0xFF, 0x01, 0xFF, 0x01},
+{0xFF, 0x01, 0xFF, 0x01},
+{0xFF, 0x01, 0xFF, 0x01},
+{0xFF, 0x01, 0xFF, 0x01}};
+   GLbyte res[4];
+
+   glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height,
+   GL_RED, GL_UNSIGNED_BYTE, buf);
+
+   glGenTextures(1, &new_tex);
+
+   glTextureView(new_tex, GL_TEXTURE_2D, tex,  GL_R8_SNORM, 0, 2, 0, 1);
+   glBindTexture(GL_TEXTURE_2D, new_tex);
+   glGenerateMipmap(GL_TEXTURE_2D);
+   glPixelStorei(GL_PACK_ALIGNMENT, 1);
+   glGetTexImage(GL_TEXTURE_2D, 1, GL_RED, GL_BYTE, &res);
+   pass = !res[0] && !res[1] && !res[2] && !res[3];
+
+   if (!pass) {
+   printf("expected 0, got %d %d %d %d\n",
+  res[0], res[1], res[2], res[3]);
+   }
+
+   glDeleteTextures(1, &new_tex);
+   glDeleteTextures(1, &tex);
+
+  

[Piglit] [PATCH] arb_texture_view-mipgen: add test to verify correct format is used for mipgen

2016-01-12 Thread sroland
From: Roland Scheidegger 

At least mesa/st fails this right now (always uses the initial format for mip
gen).
---
 tests/all.py  |   1 +
 tests/spec/arb_texture_view/CMakeLists.gl.txt |   1 +
 tests/spec/arb_texture_view/mipgen.c  | 102 ++
 3 files changed, 104 insertions(+)
 create mode 100644 tests/spec/arb_texture_view/mipgen.c

diff --git a/tests/all.py b/tests/all.py
index d9f88d6..0a97d26 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2480,6 +2480,7 @@ with profile.group_manager(
 g(['arb_texture_view-cubemap-view'], 'cubemap-view')
 g(['arb_texture_view-texture-immutable-levels'], 'immutable_levels')
 g(['arb_texture_view-max-level'], 'max-level')
+g(['arb_texture_view-mipgen'], 'mipgen')
 g(['arb_texture_view-params'], 'params')
 g(['arb_texture_view-formats'], 'formats')
 g(['arb_texture_view-targets'], 'targets')
diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt 
b/tests/spec/arb_texture_view/CMakeLists.gl.txt
index 772f8b4..47b3320 100644
--- a/tests/spec/arb_texture_view/CMakeLists.gl.txt
+++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt
@@ -17,6 +17,7 @@ piglit_add_executable(arb_texture_view-formats formats.c 
common.c)
 piglit_add_executable(arb_texture_view-getteximage-srgb getteximage-srgb.c)
 piglit_add_executable(arb_texture_view-lifetime-format lifetime_format.c 
common.c)
 piglit_add_executable(arb_texture_view-max-level max-level.c)
+piglit_add_executable(arb_texture_view-mipgen mipgen.c)
 piglit_add_executable(arb_texture_view-params params.c)
 piglit_add_executable(arb_texture_view-queries queries.c)
 piglit_add_executable(arb_texture_view-rendering-formats rendering-formats.c)
diff --git a/tests/spec/arb_texture_view/mipgen.c 
b/tests/spec/arb_texture_view/mipgen.c
new file mode 100644
index 000..0f96f77
--- /dev/null
+++ b/tests/spec/arb_texture_view/mipgen.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright © 2016 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * Verifies that mipmap generation uses the right format (from view,
+ * not what was originally specified).
+ */
+
+#include "piglit-util-gl.h"
+#include "common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 20;
+
+   config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *TestName = "arb_texture_view-mipgen";
+
+/**
+ * Create view with different view format and generate mipmap.
+ */
+static bool
+test_mipgen(void)
+{
+   GLuint tex, new_tex;
+   GLint width = 4, height = 4, levels = 2;
+   bool pass = true;
+
+   glGenTextures(1, &tex);
+   glBindTexture(GL_TEXTURE_2D, tex);
+
+   glTexStorage2D(GL_TEXTURE_2D, levels, GL_R8, width, height);
+
+   /* averaging these as snorm values should give 0 */
+   GLubyte buf[4][4] =
+   {{0xFF, 0x01, 0xFF, 0x01},
+{0xFF, 0x01, 0xFF, 0x01},
+{0xFF, 0x01, 0xFF, 0x01},
+{0xFF, 0x01, 0xFF, 0x01}};
+   GLbyte res[4];
+
+   glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height,
+   GL_RED, GL_UNSIGNED_BYTE, buf);
+
+   glGenTextures(1, &new_tex);
+
+   glTextureView(new_tex, GL_TEXTURE_2D, tex,  GL_R8_SNORM, 0, 2, 0, 1);
+   glBindTexture(GL_TEXTURE_2D, new_tex);
+   glGenerateMipmap(GL_TEXTURE_2D);
+   glPixelStorei(GL_PACK_ALIGNMENT, 1);
+   glGetTexImage(GL_TEXTURE_2D, 1, GL_RED, GL_BYTE, &res);
+   pass = !res[0] && !res[1] && !res[2] && !res[3];
+
+   if (!pass) {
+   printf("expected 0, got %d %d %d %d\n",
+  res[0], res[1], res[2], res[3]);
+   }
+
+   glDeleteTextures(1, &new_tex);
+   glDeleteTextures(1, &tex);
+
+   return pass;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+   bool pass = t

[Piglit] [PATCH] glsl-1.50-geometry-end-primitive: ensure position data is reasonably aligned

2016-01-08 Thread sroland
From: Roland Scheidegger 

The rect halves comparison is in fact not valid in general. The reason is that
the same geometry does not have the same precision even if it it just shifted
by some fixed amount in one direction.
As an example, some calculated x value near 7 will be near 263 if drawn with
a viewport x value of 256. The value near 7 has 5 bits more precision -
when calculating the fixed-point values for rasterization (with subpixel
accuracy), the lower value thus may be rounded in a different direction
than the higher one, even with correct rounding (not even entirely sure what
"correct" rounding here means, nearest-floor or nearest-even or whatever, the
problem is independent from that). This can then cause different pixels to be
covered by the primitive.
This causes a failure with this test in llvmpipe when the rounding mode is
changed slightly (from "mostly" nearest-away-from-zero to nearest-even). I was
not able to reproduce this with this test on nvidia or amd hardware, but they
are definitely affected in theory by the same issue (proven by some quick and
dirty test).
So, do floor(tmp*2048) / 2048 to ensure everything is reasonably aligned. This
still retains some subpixel bits (but only very few).

This may be a problem with more tests, albeit most tend to use vertex data
which is already sufficiently aligned (e.g. drawing simple aligned rects).

v2: use mul/floor/div sequence suggested by Ian Romanick instead of add/sub -
trying to beat the compiler may not be reliable (as it could reorder
operations).
---
 tests/spec/glsl-1.50/execution/geometry/end-primitive.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/spec/glsl-1.50/execution/geometry/end-primitive.c 
b/tests/spec/glsl-1.50/execution/geometry/end-primitive.c
index 6df3a89..97d8375 100644
--- a/tests/spec/glsl-1.50/execution/geometry/end-primitive.c
+++ b/tests/spec/glsl-1.50/execution/geometry/end-primitive.c
@@ -105,7 +105,9 @@ static const char *spiral_text =
"  if (vertex_id % 2 == 1) r += 1.0;\n"
"  float max_r = b*sqrt(a*float(num_vertices)) + 1.0;\n"
"  r /= max_r;\n"
-   "  return r*vec2(cos(theta), sin(theta));\n"
+   "  vec2 tmp = r*vec2(cos(theta), sin(theta));\n"
+   "  // ensure reasonably aligned vertices\n"
+   "  return floor(tmp * 2048.0f) / 2048.0f;\n"
"}\n";
 
 /**
-- 
2.1.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] glsl-1.50-geometry-end-primitive: ensure position data is reasonably aligned

2016-01-08 Thread sroland
From: Roland Scheidegger 

The rect halves comparison is in fact not valid in general. The reason is that
the same geometry does not have the same precision even if it it just shifted
by some fixed amount in one direction.
As an example, some calculated x value near 7 will be near 263 if drawn with
a viewport x value of 256. The value near 7 has 5 bits more precision -
when calculating the fixed-point values for rasterization (with subpixel
accuracy), the lower value thus may be rounded in a different direction
than the higher one, even with correct rounding (not even entirely sure what
"correct" rounding here means, nearest-floor or nearest-even or whatever, the
problem is independent from that). This can then cause different pixels to be
covered by the primitive.
This causes a failure with this test in llvmpipe when the rounding mode is
changed slightly (from "mostly" nearest-away-from-zero to nearest-even). I was
not able to reproduce this with this test on nvidia or amd hardware, but they
are definitely affected in theory by the same issue (proven by some quick and
dirty test).
So, simply add then subtract some fixed amount to the position values, which
ensures there should be no differences in the position later even after
viewport translate (we use window size + 1 here, so the values in range
-1.0 - +1.0 will all have the same exponent (just above the window size)).
(We must do that with uniforms otherwise mesa will optimize the add/sub away -
this is definitely unsafe math optimization but may well be allowed.)

This may be a problem with more tests, albeit most tend to use vertex data
which is already sufficiently aligned (e.g. drawing simple aligned rects).
---
 tests/general/quad-invariance.c| 55 +-
 .../glsl-1.50/execution/geometry/end-primitive.c   | 15 +-
 2 files changed, 36 insertions(+), 34 deletions(-)

diff --git a/tests/general/quad-invariance.c b/tests/general/quad-invariance.c
index b5741d0..fd51dec 100644
--- a/tests/general/quad-invariance.c
+++ b/tests/general/quad-invariance.c
@@ -38,9 +38,13 @@
 
 #include "piglit-util-gl.h"
 
+#define PATTERN_SIZE 256
+
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
config.supports_gl_compat_version = 10;
+   config.window_width = 2*PATTERN_SIZE;
+   config.window_height = PATTERN_SIZE;
 
config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
 
@@ -49,41 +53,24 @@ PIGLIT_GL_TEST_CONFIG_END
 enum piglit_result
 piglit_display(void)
 {
+   int i;
GLboolean pass = GL_TRUE;
-   float verts[12][2] = {
+   float verts[3][2] = {
/* prim 1: left half of screen. */
-   {-1.0, -1.0},
-   { 0.0, -1.0},
-   { 0.0,  1.0},
-   {-1.0,  1.0},
-   /* prim 2: right half of screen. */
-   { 0.0, -1.0},
-   { 1.0, -1.0},
-   { 1.0,  1.0},
+   {-1.0 + 2.0f / PATTERN_SIZE, -1.0},
+   {-1.0 + 2.0f / PATTERN_SIZE,  1.0},
{ 0.0,  1.0},
-   /* prim 3: somewhere off the screen. */
-   { 2.0, -1.0},
-   { 3.0, -1.0},
-   { 3.0,  1.0},
-   { 2.0,  1.0},
};
-   float colors[12][4] = {
-   {1.0, 0.0, 0.0, 0.0},
-   {0.0, 1.0, 0.0, 0.0},
-   {0.0, 0.0, 1.0, 0.0},
-   {1.0, 1.0, 1.0, 0.0},
-
-   {1.0, 0.0, 0.0, 0.0},
-   {0.0, 1.0, 0.0, 0.0},
-   {0.0, 0.0, 1.0, 0.0},
-   {1.0, 1.0, 1.0, 0.0},
-
-   {1.0, 0.0, 0.0, 0.0},
-   {0.0, 1.0, 0.0, 0.0},
-   {0.0, 0.0, 1.0, 0.0},
-   {1.0, 1.0, 1.0, 0.0},
+   float colors[3][4] = {
+   {1.0, 0.0, 0.0, 1.0},
+   {1.0, 0.0, 0.0, 1.0},
+   {1.0, 0.0, 0.0, 1.0},
+
};
+
static GLboolean once = GL_TRUE;
+   for (i = 0; i < (1 << 24) && pass; i++) {
+   verts[1][0] += 5.96046447754E-08f * 2.0f;
 
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
@@ -94,19 +81,21 @@ piglit_display(void)
glEnableClientState(GL_VERTEX_ARRAY);
 
/* left: 1 prim */
-   glDrawArrays(GL_QUADS, 0, 4);
+   glViewport(0, 0, piglit_width/2, piglit_height);
+   glDrawArrays(GL_TRIANGLES, 0, 3);
 
+   glViewport(piglit_width/2, 0, piglit_width/2, piglit_height);
/* right: 1 prim */
-   glDrawArrays(GL_QUADS, 4, 8);
+   glDrawArrays(GL_TRIANGLES, 0, 3);
 
if (once) {
printf("Left and right half should match.\n");
once = GL_FALSE;
}
 
-   pass = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width,
+   pass &= piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width,
   piglit_height);
-
+   }
piglit_present_results();
 
return pass ? PIGLIT_PASS : PIGLIT_WAR

[Piglit] [PATCH] polygon-mode-facing: verify facing information is preserved with unfilled prims

2015-12-22 Thread sroland
From: Roland Scheidegger 

This test is quite mean to mesa's draw pipe. llvmpipe/softpipe fail even if
front and back fill mode is the same (for points and aa lines as the latter
get rendered as tris finally again). Most everything else fails too, before
the driver dies in a fire...
---
 tests/general/CMakeLists.gl.txt |   1 +
 tests/general/polygon-mode-facing.c | 381 
 2 files changed, 382 insertions(+)
 create mode 100644 tests/general/polygon-mode-facing.c

diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
index 298f59c..8f291db 100644
--- a/tests/general/CMakeLists.gl.txt
+++ b/tests/general/CMakeLists.gl.txt
@@ -86,6 +86,7 @@ piglit_add_executable (pbo-teximage-tiling-2 
pbo-teximage-tiling-2.c)
 piglit_add_executable (point-line-no-cull point-line-no-cull.c)
 piglit_add_executable (point-vertex-id point-vertex-id.c)
 piglit_add_executable (polygon-mode-offset polygon-mode-offset.c)
+piglit_add_executable (polygon-mode-facing polygon-mode-facing.c)
 piglit_add_executable (polygon-mode polygon-mode.c)
 piglit_add_executable (polygon-offset polygon-offset.c)
 piglit_add_executable (primitive-restart primitive-restart.c)
diff --git a/tests/general/polygon-mode-facing.c 
b/tests/general/polygon-mode-facing.c
new file mode 100644
index 000..f107616
--- /dev/null
+++ b/tests/general/polygon-mode-facing.c
@@ -0,0 +1,381 @@
+/*
+ * Copyright (c) 2011 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT.  IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
+ * Tests glPolygonMode wrt facing.
+ * Roland Scheidegger
+ * December 2015
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 20;
+
+   config.window_width = 400;
+   config.window_height = 100;
+   config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *TestName = "polygon-mode-facing";
+
+static const char *vstext =
+"#version 130\n"
+"\n"
+"void main()\n"
+"{\n"
+"  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+"}\n";
+
+static const char *fstext =
+"#version 130\n"
+"\n"
+"void main()\n"
+"{\n"
+"  vec4 color = gl_FrontFacing ? vec4(1.0, 0.0, 0.0, 1.0)\n"
+"  : vec4(0.0, 1.0, 0.0, 1.0);\n"
+"  gl_FragColor = color;\n"
+"}\n";
+
+
+static const GLfloat Colors[2][4] = {
+   /* back color */
+   {0, 1, 0, 1},
+   /* front color */
+   {1, 0, 0, 1},
+};
+
+static const GLfloat Positions[16][2] = {
+   {10, 10},
+   {90, 10},
+   {90, 90},
+   {10, 90},
+
+   {190, 10},
+   {110, 10},
+   {110, 90},
+   {190, 90},
+
+   {290, 10},
+   {210, 10},
+   {210, 90},
+   {290, 90},
+  
+   {310, 10},
+   {390, 10},
+   {390, 90},
+   {310, 90},
+};
+
+static const char *
+get_mode_str(GLenum mode)
+{
+   switch (mode) {
+   case GL_POINT:
+  return "GL_POINT";
+   case GL_LINE:
+  return "GL_LINE";
+   case GL_FILL:
+  return "GL_FILL";
+   default:
+  return NULL;
+   }
+}
+
+
+static GLenum
+get_prim_mode(GLenum mode)
+{
+   switch (mode) {
+   case GL_POINT:
+  return GL_POINTS;
+   case GL_LINE:
+  return GL_LINE_LOOP;
+   case GL_FILL:
+  return GL_QUADS;
+   default:
+  return 0;
+   }
+}
+
+
+/**
+ * Probe a 3x3 pixel region to see if any of the pixels matches the
+ * expected color.
+ */
+static GLboolean
+probe_region(float px, float py, const GLfloat expectedColor[4])
+{
+   GLfloat img[3][3][4];
+   int i, j;
+
+   glReadPixels(px-1, py-1, 3, 3, GL_RGBA, GL_FLOAT, img);
+
+   /* see if any of the pixels matches the expected color */
+   for (i = 0; i < 3; i++) {
+  for (j = 0; j < 3; j++) {
+ if (img[i][j][0] == expectedColor[0] &&
+ img[i][j][1] == expectedColor[1] &&
+ img[i][j][2] == expect

[Piglit] [PATCH] texwrap: fix stencil texturing a bit

2015-12-15 Thread sroland
From: Roland Scheidegger 

Previously, the test was actually using all-zeros in the end for the image,
so unsurprisingly it passed, except when border color was used.
Add the special stencil case handling in a couple more cases.
This will still not test depth/stencil textures in stencil texturing mode, and
furthermore because the spec doesn't seem to say what should happen with all
the channels make it ignore all errors on non-first channel.
---
 tests/texturing/texwrap.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tests/texturing/texwrap.c b/tests/texturing/texwrap.c
index ffe5e83..e10e6ec 100644
--- a/tests/texturing/texwrap.c
+++ b/tests/texturing/texwrap.c
@@ -724,6 +724,10 @@ static void sample_nearest(int x, int y, int z,
image[(coords[2]*size_y*size_x +
   coords[1]*size_x + coords[0])];
result[3] = 1;
+   } else if (format->stencil) {
+   result[0] = result[1] = result[2] = result[3] =
+   image[(coords[2]*size_y*size_x +
+  coords[1]*size_x + coords[0])];
} else {
memcpy(result,
   &image[(coords[2]*size_y*size_x +
@@ -1021,6 +1025,16 @@ static GLboolean probe_pixels(const struct format_desc 
*format, GLboolean npot,
for (j = 0; j < 4; j++) {
deltamax[j] = deltamax_lut[format->intensity];
}
+   } else if (format->stencil && !format->depth) {
+   deltamax[0] = deltamax_lut[format->stencil];
+   /*
+* XXX unless someone can figure out what the hell all
+* those channels should actually return... Right now
+* the test would expect the same value for all 
channels.
+*/
+   for (j = 1; j < 4; j++) {
+   deltamax[j] = 255;
+   }
} else {
if (format->luminance) {
for (j = 0; j < 3; j++) {
@@ -1427,7 +1441,7 @@ static void init_int_texture(const struct format_desc 
*format,
black = colors[5];
 
/* Set the colors to match the base format. */
-   if (format->intensity) {
+   if (format->intensity || format->stencil) {
for (i = 0; i < 7; i++) {
colors[i][3] = colors[i][2] = colors[i][1] = 
colors[i][0];
}
-- 
2.1.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] gl-3.2: add layered rendering test doing clipping

2015-12-03 Thread sroland
From: Roland Scheidegger 

This is more of a clip test involving the system-interpreted values (which
cannot be interpolated). This exposes some problems in gallium for drivers
using draw, where clipping such values was completely broken, thus layered
rendering being generally quite broken in practice (viewport index isn't
tested here but should follow all the same logic).
The test itself is a cut down (we're definitely not interested in different
texture types here, albeit different primitives would be worth testing for)
and modified copy of gl-layer-render, just making sure the rectangle extends
beyond vp bounds. Also testing both provoking vertex conventions, albeit
not mean as it would be possible to only supply the correct layer to one
vertex if the result of GL_LAYER_PROVOKING_VERTEX isn't GL_UNDEFINED_VERTEX.
---
 tests/all.py   |   1 +
 .../gl-3.2/layered-rendering/CMakeLists.gl.txt |   1 +
 .../layered-rendering/gl-layer-render-clipped.c| 216 +
 3 files changed, 218 insertions(+)
 create mode 100644 
tests/spec/gl-3.2/layered-rendering/gl-layer-render-clipped.c

diff --git a/tests/all.py b/tests/all.py
index 9f1b4f3..a69d7c3 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1252,6 +1252,7 @@ with profile.group_manager(
 g(['gl-3.2-layered-rendering-gl-layer-not-layered'],
   'gl-layer-not-layered')
 g(['gl-3.2-layered-rendering-gl-layer-render'], 'gl-layer-render')
+g(['gl-3.2-layered-rendering-gl-layer-render-clipped'], 
'gl-layer-render-clipped')
 g(['gl-3.2-layered-rendering-gl-layer-render-storage'], 
'gl-layer-render-storage')
 
 for texture_type in ['3d', '2d_array', '2d_multisample_array', '1d_array',
diff --git a/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt 
b/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
index a35720d..468dc22 100644
--- a/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
+++ b/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
@@ -25,5 +25,6 @@ piglit_add_executable (gl-3.2-layered-rendering-gl-layer 
gl-layer.c)
 piglit_add_executable (gl-3.2-layered-rendering-gl-layer-cube-map 
gl-layer-cube-map.c)
 piglit_add_executable (gl-3.2-layered-rendering-gl-layer-not-layered 
gl-layer-not-layered.c)
 piglit_add_executable (gl-3.2-layered-rendering-gl-layer-render 
gl-layer-render.c)
+piglit_add_executable (gl-3.2-layered-rendering-gl-layer-render-clipped 
gl-layer-render-clipped.c)
 piglit_add_executable (gl-3.2-layered-rendering-gl-layer-render-storage 
gl-layer-render-storage.c)
 # vim: ft=cmake:
diff --git a/tests/spec/gl-3.2/layered-rendering/gl-layer-render-clipped.c 
b/tests/spec/gl-3.2/layered-rendering/gl-layer-render-clipped.c
new file mode 100644
index 000..015a619
--- /dev/null
+++ b/tests/spec/gl-3.2/layered-rendering/gl-layer-render-clipped.c
@@ -0,0 +1,216 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/** @file gl-layer-render-clipped.c
+ * This tests correct passing of layer to post-clip stages (when clipping
+ * is needed). This parameter must not be interpolated in clip (there's no
+ * corresponding fs input from where the interpolation info could be taken).
+ * And clipping needs to make sure the right value is copied to the right
+ * vertex. We'll test both first and last provoking vertex convention (albeit
+ * we use the same layer for all vertices as we don't use
+ * GL_LAYER_PROVOKING_VERTEX query). (Could also test vp index)
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 32;
+   config.supports_gl_core_version = 32;
+
+   config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+
+const char *vs_source = {
+   "#version 150\n"
+   "in vec4 piglit_vertex;\n"
+   "out vec4 vert;\n"
+   "void main

[Piglit] [PATCH] glsl-1.50/execution: add primitive id tests with tri strip primitives

2014-12-05 Thread sroland
From: Roland Scheidegger 

Just using tri strip instead of tri fan.
Exposing more bugs in llvmpipe/draw...
---
 ...imitive-id-no-gs-strip-first-vertex.shader_test | 62 ++
 .../execution/primitive-id-no-gs-strip.shader_test | 60 +
 2 files changed, 122 insertions(+)
 create mode 100644 
tests/spec/glsl-1.50/execution/primitive-id-no-gs-strip-first-vertex.shader_test
 create mode 100644 
tests/spec/glsl-1.50/execution/primitive-id-no-gs-strip.shader_test

diff --git 
a/tests/spec/glsl-1.50/execution/primitive-id-no-gs-strip-first-vertex.shader_test
 
b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-strip-first-vertex.shader_test
new file mode 100644
index 000..36c16e8
--- /dev/null
+++ 
b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-strip-first-vertex.shader_test
@@ -0,0 +1,62 @@
+# Check proper functioning of the gl_PrimitiveID fragment shader
+# input, in the case where there is no geometry shader.
+
+[require]
+GLSL >= 1.50
+GL_EXT_provoking_vertex
+
+[vertex shader]
+#version 150
+
+in vec4 piglit_vertex;
+flat out int vertex_id;
+
+void main()
+{
+  gl_Position = piglit_vertex;
+  vertex_id = gl_VertexID;
+}
+
+[fragment shader]
+#version 150
+
+flat in int vertex_id;
+
+void main()
+{
+  /* We draw a triangle strip containing 6 vertices, so the relationship 
between
+   * the primitive ID and the input vertex ID's should be:
+   *
+   * Primitive ID  Vertex ID's  Provoking vertex ID
+   *  0 0 1 20
+   *  1 1 3 21
+   *  2 2 3 42
+   *  3 3 5 43
+   *
+   * Since vertex_id uses interpolation qualifier "flat", it should
+   * always receive the value from the provoking vertex.  Therefore,
+   * by the table above, it should always be the same as the
+   * expected value of gl_PrimitiveID.
+   */
+  int expected_primitive_id = vertex_id;
+  if (expected_primitive_id == gl_PrimitiveID)
+gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[vertex data]
+piglit_vertex/float/2
+-1.0 -1.0
+ 1.0 -1.0
+-1.0  0.0
+ 1.0  0.0
+-1.0  1.0
+ 1.0  1.0
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+provoking vertex first
+draw arrays GL_TRIANGLE_STRIP 0 6
+probe all rgba 0.0 1.0 0.0 1.0
diff --git 
a/tests/spec/glsl-1.50/execution/primitive-id-no-gs-strip.shader_test 
b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-strip.shader_test
new file mode 100644
index 000..50ba6b3
--- /dev/null
+++ b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-strip.shader_test
@@ -0,0 +1,60 @@
+# Check proper functioning of the gl_PrimitiveID fragment shader
+# input, in the case where there is no geometry shader.
+
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+#version 150
+
+in vec4 piglit_vertex;
+flat out int vertex_id;
+
+void main()
+{
+  gl_Position = piglit_vertex;
+  vertex_id = gl_VertexID;
+}
+
+[fragment shader]
+#version 150
+
+flat in int vertex_id;
+
+void main()
+{
+  /* We draw a triangle strip containing 6 vertices, so the relationship 
between
+   * the primitive ID and the input vertex ID's should be:
+   *
+   * Primitive ID  Vertex ID's  Provoking vertex ID
+   *  0 0 1 22
+   *  1 2 1 33
+   *  2 2 3 44
+   *  3 4 3 55
+   *
+   * Since vertex_id uses interpolation qualifier "flat", it should
+   * always receive the value from the provoking vertex.  Therefore,
+   * by the table above, it should always be 2 greater than the
+   * expected value of gl_PrimitiveID.
+   */
+  int expected_primitive_id = vertex_id - 2;
+  if (expected_primitive_id == gl_PrimitiveID)
+gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[vertex data]
+piglit_vertex/float/2
+-1.0 -1.0
+ 1.0 -1.0
+-1.0  0.0
+ 1.0  0.0
+-1.0  1.0
+ 1.0  1.0
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw arrays GL_TRIANGLE_STRIP 0 6
+probe all rgba 0.0 1.0 0.0 1.0
-- 
1.9.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] teximage-colors: fix bogus precision assumptions and other issues

2014-10-08 Thread sroland
From: Roland Scheidegger 

Some formats had some "implied" precision which relied on the driver picking a
specific hw format (e.g. RGB5 and RGB5 both relied on driver picking 565).
These tests will now be skipped (for the exact test).
Others didn't have any implied precision but relied on driver picking a format
with at least 8 bits even though the internal format only implied 4.
Also, the exact tests for srgb8 and srgb8_alpha8 were failing too due to using
GL_BYTE instead of GL_UNSIGNED_BYTE.
With these fixes the only tests llvmpipe is failing seem to be the exact
GL_RGB8_SNORM and GL_RGB16_SNORM ones (1, 2 or 4 channels work and the errors
seem to be one bit so maybe triggers some conversion somewhere using different
signed conversion formula).
---
 tests/texturing/teximage-colors.c | 43 ++-
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/tests/texturing/teximage-colors.c 
b/tests/texturing/teximage-colors.c
index 2bee02f..dcbab65 100644
--- a/tests/texturing/teximage-colors.c
+++ b/tests/texturing/teximage-colors.c
@@ -60,12 +60,12 @@ struct texture_format formats[] = {
 
FORMAT(GL_RGB, GL_RGB, GL_NONE),
FORMAT(GL_R3_G3_B2, GL_RGB, GL_UNSIGNED_BYTE_3_3_2),
-   FORMAT(GL_RGB4, GL_RGB, GL_UNSIGNED_SHORT_5_6_5),
-   FORMAT(GL_RGB5, GL_RGB, GL_UNSIGNED_SHORT_5_6_5),
+   FORMAT(GL_RGB4, GL_RGB, GL_NONE),
+   FORMAT(GL_RGB5, GL_RGB, GL_NONE),
FORMAT(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE),
FORMAT(GL_RGB8_SNORM, GL_RGB, GL_BYTE),
-   FORMAT(GL_SRGB8, GL_RGB, GL_BYTE),
-   FORMAT(GL_RGB10, GL_RGB, GL_UNSIGNED_SHORT),
+   FORMAT(GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE),
+   FORMAT(GL_RGB10, GL_RGB, GL_NONE),
FORMAT(GL_R11F_G11F_B10F, GL_RGB, GL_NONE),
FORMAT(GL_RGB12, GL_RGB, GL_NONE),
FORMAT(GL_RGB9_E5, GL_RGB, GL_NONE),
@@ -81,7 +81,7 @@ struct texture_format formats[] = {
FORMAT(GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE),
FORMAT(GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_10_10_10_2),
FORMAT(GL_RGBA8_SNORM, GL_RGBA, GL_BYTE),
-   FORMAT(GL_SRGB8_ALPHA8, GL_RGBA, GL_BYTE),
+   FORMAT(GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE),
FORMAT(GL_RGBA12, GL_RGBA, GL_NONE),
FORMAT(GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT),
FORMAT(GL_RGBA16_SNORM, GL_RGBA, GL_SHORT),
@@ -543,6 +543,39 @@ piglit_init(int argc, char **argv)
tolerance[3] = 0.3;
break;
}
+
+   /* The tolerance lowering above only works for formats which have
+   explicit data types associated with them and even then it's fishy
+   for some.
+   The default sort of assumes at least 7 bits which doesn't make
+  much sense in any case (for the specific formats with more bits).
+  But just fix the cases which cannot pass (unless the driver encodes
+  them with more bits). */
+   switch (format->internal_format) {
+   case GL_RGB4:
+   tolerance[0] = 0.1;
+   tolerance[1] = 0.1;
+   tolerance[2] = 0.1;
+   tolerance[3] = 0.1;
+   break;
+   case GL_RGB5:
+   tolerance[0] = 0.05;
+   tolerance[1] = 0.05;
+   tolerance[2] = 0.05;
+   break;
+   case GL_LUMINANCE4_ALPHA4:
+   tolerance[0] = 0.1;
+   tolerance[1] = 0.1;
+   tolerance[2] = 0.1;
+   tolerance[3] = 0.1;
+   break;
+case GL_LUMINANCE6_ALPHA2: /* broken but everybody uses 8+8 bits */
+case GL_LUMINANCE4: /* broken but presumably noone uses just 4 bits */
+   case GL_ALPHA4: /* broken but presumably noone uses just 4 bits */
+   case GL_RGBA2: /* broken () but everybody uses more bits anyway */
+   default:
+   break;
+   }
 }
 
 void
-- 
1.9.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] fp-indirections: limit to 1024 indirections

2014-09-18 Thread sroland
From: Roland Scheidegger 

The test takes ages (somewhere in the order of an hour) on llvmpipe, because
the driver announces support for one million indirections (some drivers
actually say billions even). It never gets compiled even, that hour is fully
spent on string concatenation when constructing the shader in the test itself,
which seems rather silly.
Thus, follow fp-indirections2, which limits it to 1024 indirections. If you've
got that many indirections the hw is pretty much guaranteed to not have a limit
on that anyway.
---
 tests/shaders/fp-indirections.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/tests/shaders/fp-indirections.c b/tests/shaders/fp-indirections.c
index a25432f..927e3dc 100644
--- a/tests/shaders/fp-indirections.c
+++ b/tests/shaders/fp-indirections.c
@@ -187,12 +187,14 @@ GLboolean test_temporary_dest_indirections(void)
GLboolean pass = GL_TRUE;
GLuint progname;
char *prog;
-   GLint indirections_limit;
+   GLint indirections_limit, use_limit;
GLint count;
 
indirections_limit = get_program_i(GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB);
 
-   count = indirections_limit - 1;
+   use_limit = indirections_limit > 1024 ? 1024 : indirections_limit;
+
+   count = use_limit - 1;
printf("testing program with %d indirections from temporary dests\n",
   count);
prog = gen_temporary_dest_indirections(count, &progname);
@@ -206,11 +208,11 @@ GLboolean test_temporary_dest_indirections(void)
free(prog);
}
 
-   count = indirections_limit + 1;
+   count = use_limit + 1;
printf("testing program with %d indirections from temporary dests\n",
   count);
prog = gen_temporary_dest_indirections(count, &progname);
-   if (prog != NULL) {
+   if (prog != NULL && count > indirections_limit) {
if (get_program_i(GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB)) {
printf("Program with %d indirections unexpectedly "
   "met native limits.\n", count);
@@ -231,12 +233,14 @@ GLboolean test_temporary_source_indirections(void)
GLboolean pass = GL_TRUE;
GLuint progname;
char *prog;
-   GLint indirections_limit;
+   GLint indirections_limit, use_limit;
GLint count;
 
indirections_limit = get_program_i(GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB);
 
-   count = indirections_limit - 1;
+   use_limit = indirections_limit > 1024 ? 1024 : indirections_limit;
+
+   count = use_limit - 1;
printf("testing program with %d indirections from temporary sources\n",
   count);
prog = gen_temporary_source_indirections(count, &progname);
@@ -250,11 +254,11 @@ GLboolean test_temporary_source_indirections(void)
free(prog);
}
 
-   count = indirections_limit + 1;
+   count = use_limit + 1;
printf("testing program with %d indirections from temporary sources\n",
   count);
prog = gen_temporary_source_indirections(count, &progname);
-   if (prog != NULL) {
+   if (prog != NULL && count > indirections_limit) {
if (get_program_i(GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB)) {
printf("Program with %d indirections unexpectedly "
   "met native limits.\n", count);
-- 
1.9.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] tex-miplevel-selection: use GL_CLAMP_TO_EDGE instead of GL_REPEAT

2014-08-06 Thread sroland
From: Roland Scheidegger 

GL_REPEAT is not legal for the rectangle targets, and because the test uses
sampler objects the default GL_REPEAT value will be used even for rectangle
target because unlike texture objects they can't be initialized to the legal
CLAMP_TO_EDGE value. According to the spec the texture actually should be
treated as incomplete in this case which mesa does not do (and I don't know if
anyone bothers enough to fix this) but some drivers (like llvmpipe) might
not treat unnormalized coords correctly in this case.
---
 tests/texturing/tex-miplevel-selection.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/texturing/tex-miplevel-selection.c 
b/tests/texturing/tex-miplevel-selection.c
index 11e4292..ef9a066 100644
--- a/tests/texturing/tex-miplevel-selection.c
+++ b/tests/texturing/tex-miplevel-selection.c
@@ -981,6 +981,10 @@ piglit_init(int argc, char **argv)
 
set_sampler_parameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
set_sampler_parameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   /* need to set this for rect targets, otherwise default GL_REPEAT
+* in sampler obj should trigger incomplete tex behavior */
+   set_sampler_parameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   set_sampler_parameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
if (IS_SHADOW(target)) {
glActiveTexture(GL_TEXTURE1);
-- 
1.9.1
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] lineloop: add test for checking behavior with many immediate mode verts

2014-07-15 Thread sroland
From: Roland Scheidegger 

line loops are difficult to handle because when trying to accumulate vertex
data in a buffer the loop must be closed at the end - this is problematic if
using any kind of fixed size buffer. With immediate mode api (presumably
display lists have similar problems) this exposes a bug in mesa when the
buffer gets full and data is wrapped around (each buffer forms its own
incorrect line loop) (actually it seems to expose two bugs, one in vbo,
one in draw). See https://bugs.freedesktop.org/show_bug.cgi?id=81174.
This only tests line loops, not the primitive-from-hell, GL_POLYGON, which
should have the same problem but only with fill mode line...
---
 tests/all.py|  1 +
 tests/general/CMakeLists.gl.txt |  1 +
 tests/general/lineloop.c| 99 +
 3 files changed, 101 insertions(+)
 create mode 100644 tests/general/lineloop.c

diff --git a/tests/all.py b/tests/all.py
index 17d5d9b..3de9061 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -745,6 +745,7 @@ add_plain_test(gl11, 'hiz')
 add_plain_test(gl11, 'infinite-spot-light')
 add_plain_test(gl11, 'line-aa-width')
 add_concurrent_test(gl11, 'line-flat-clip-color')
+add_plain_test(gl11, 'lineloop')
 add_plain_test(gl11, 'linestipple')
 add_plain_test(gl11, 'longprim')
 add_concurrent_test(gl11, 'masked-clear')
diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
index cd25124..5917df2 100644
--- a/tests/general/CMakeLists.gl.txt
+++ b/tests/general/CMakeLists.gl.txt
@@ -74,6 +74,7 @@ IF (UNIX)
target_link_libraries (line-aa-width m)
 ENDIF (UNIX)
 piglit_add_executable (line-flat-clip-color line-flat-clip-color.c)
+piglit_add_executable (lineloop lineloop.c)
 piglit_add_executable (longprim longprim.c)
 piglit_add_executable (masked-clear masked-clear.c)
 piglit_add_executable (pos-array pos-array.c)
diff --git a/tests/general/lineloop.c b/tests/general/lineloop.c
new file mode 100644
index 000..734743f
--- /dev/null
+++ b/tests/general/lineloop.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2014 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * @file lineloop.c
+ *
+ * Test line loop with many vertices.
+ * No additional lines should appear due to buffer splitting.
+ */
+
+#include "piglit-util-gl-common.h"
+
+#define WSIZE 400
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 10;
+config.window_width = WSIZE;
+config.window_height = WSIZE;
+   config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *TestName = "lineloop";
+static int vert_count = 1;
+
+static void
+draw(GLuint numVerts)
+{
+   GLuint i;
+
+   glColor3f(1,0,1);
+   glBegin(GL_LINE_LOOP);
+   for (i = 0; i < numVerts; i++) {
+  glVertex3f(sin(i*M_PI*2/numVerts), cos(i*M_PI*2/numVerts),0);
+   }
+   glEnd();
+}
+
+static void
+test_prims(void)
+{
+   if (!piglit_automatic)
+  printf("%s: %u vertices\n", TestName, vert_count);
+   glClear(GL_COLOR_BUFFER_BIT);
+   draw(vert_count);
+   piglit_present_results();
+}
+
+
+enum piglit_result
+piglit_display(void)
+{
+   float expected[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+   int pass;
+   int half_quad = (int)((float)(WSIZE/2) / sqrt(2.0f) - 1.0f);
+   test_prims();
+   pass = piglit_probe_rect_rgb(WSIZE / 2 - half_quad,
+WSIZE / 2 - half_quad,
+half_quad, half_quad, expected);
+   return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char**argv)
+{
+   int i;
+   for (i = 1; i < argc; ++i) {
+  if (i + 1 < argc) {
+ if (strcmp(argv[i], "-count") == 0) {
+vert_count = strtoul(argv[++i], NULL, 0);
+ }
+  }
+   }
+ 
+   glViewport(0,0, WSIZE, WSIZE);
+   glOrtho(-1,1,-1,1,-1,1);
+}
-- 
1.9.1
___

[Piglit] [PATCH] triangle-rasterization: increase the precision of the test

2014-06-23 Thread sroland
From: Zack Rusin 

Increase the subpixel precision to 8 bits. This requires
changing some of the code to 64 bits to avoid overflows.

v2 (sroland): Query GL for the number of subpixel bits and use that
instead of a fixed 8 bits. Note that mesa drivers don't set this yet
individually always using default 4 bits (GL requires 4 bits, all d3d10
capable hw should have 8 bits) and gallium drivers even can't set it so
also add an override subpixel_bits arg so any desired precision can be tested.
---
 tests/general/triangle-rasterization.cpp | 96 ++--
 1 file changed, 53 insertions(+), 43 deletions(-)

diff --git a/tests/general/triangle-rasterization.cpp 
b/tests/general/triangle-rasterization.cpp
index d006188..bd20af2 100644
--- a/tests/general/triangle-rasterization.cpp
+++ b/tests/general/triangle-rasterization.cpp
@@ -103,8 +103,8 @@ static enum filling_convention_t {
 } filling_convention;
 
 /* Fixed point format */
-const int FIXED_SHIFT = 4;
-const int FIXED_ONE = 1 << FIXED_SHIFT;
+static int FIXED_SHIFT;
+static int FIXED_ONE;
 
 /* Default test size */
 int fbo_width = 256;
@@ -144,13 +144,13 @@ namespace std {
 }
 
 /* Proper rounding of float to integer */
-int iround(float v)
+int64_t iround(float v)
 {
if (v > 0.0f)
v += 0.5f;
if (v < 0.0f)
v -= 0.5f;
-   return (int)v;
+   return (int64_t)v;
 }
 
 /* Calculate log2 for integers */
@@ -168,57 +168,57 @@ void rast_triangle(uint8_t* buffer, uint32_t stride, 
const Triangle& tri)
 {
float center_offset = -0.5f;
 
-   /* 28.4 fixed point coordinates */
-   int x1 = iround(FIXED_ONE * (tri[0].x + center_offset));
-   int x2 = iround(FIXED_ONE * (tri[1].x + center_offset));
-   int x3 = iround(FIXED_ONE * (tri[2].x + center_offset));
+   /* fixed point coordinates */
+   int64_t x1 = iround(FIXED_ONE * (tri[0].x + center_offset));
+   int64_t x2 = iround(FIXED_ONE * (tri[1].x + center_offset));
+   int64_t x3 = iround(FIXED_ONE * (tri[2].x + center_offset));
 
-   int y1 = iround(FIXED_ONE * (tri[0].y + center_offset));
-   int y2 = iround(FIXED_ONE * (tri[1].y + center_offset));
-   int y3 = iround(FIXED_ONE * (tri[2].y + center_offset));
+   int64_t y1 = iround(FIXED_ONE * (tri[0].y + center_offset));
+   int64_t y2 = iround(FIXED_ONE * (tri[1].y + center_offset));
+   int64_t y3 = iround(FIXED_ONE * (tri[2].y + center_offset));
 
/* Force correct vertex order */
-   const int cross = (x2 - x1) * (y3 - y2) - (y2 - y1) * (x3 - x2);
+   const int64_t cross = (x2 - x1) * (y3 - y2) - (y2 - y1) * (x3 - x2);
if (cross > 0) {
std::swap(x1, x3);
std::swap(y1, y3);
}
 
/* Deltas */
-   const int dx12 = x1 - x2;
-   const int dx23 = x2 - x3;
-   const int dx31 = x3 - x1;
+   const int64_t dx12 = x1 - x2;
+   const int64_t dx23 = x2 - x3;
+   const int64_t dx31 = x3 - x1;
 
-   const int dy12 = y1 - y2;
-   const int dy23 = y2 - y3;
-   const int dy31 = y3 - y1;
+   const int64_t dy12 = y1 - y2;
+   const int64_t dy23 = y2 - y3;
+   const int64_t dy31 = y3 - y1;
 
/* Fixed-point deltas */
-   const int fdx12 = dx12 << FIXED_SHIFT;
-   const int fdx23 = dx23 << FIXED_SHIFT;
-   const int fdx31 = dx31 << FIXED_SHIFT;
+   const int64_t fdx12 = dx12 << FIXED_SHIFT;
+   const int64_t fdx23 = dx23 << FIXED_SHIFT;
+   const int64_t fdx31 = dx31 << FIXED_SHIFT;
 
-   const int fdy12 = dy12 << FIXED_SHIFT;
-   const int fdy23 = dy23 << FIXED_SHIFT;
-   const int fdy31 = dy31 << FIXED_SHIFT;
+   const int64_t fdy12 = dy12 << FIXED_SHIFT;
+   const int64_t fdy23 = dy23 << FIXED_SHIFT;
+   const int64_t fdy31 = dy31 << FIXED_SHIFT;
 
/* Bounding rectangle */
-   int minx = std::min(x1, x2, x3) >> FIXED_SHIFT;
-   int maxx = (std::max(x1, x2, x3)) >> FIXED_SHIFT;
+   int64_t minx = std::min(x1, x2, x3) >> FIXED_SHIFT;
+   int64_t maxx = (std::max(x1, x2, x3)) >> FIXED_SHIFT;
 
-   int miny = (std::min(y1, y2, y3)) >> FIXED_SHIFT;
-   int maxy = std::max(y1, y2, y3) >> FIXED_SHIFT;
+   int64_t miny = (std::min(y1, y2, y3)) >> FIXED_SHIFT;
+   int64_t maxy = std::max(y1, y2, y3) >> FIXED_SHIFT;
 
-   minx = std::max(minx, 0);
-   maxx = std::min(maxx, fbo_width - 1);
+   minx = std::max(minx, (int64_t)0);
+   maxx = std::min(maxx, (int64_t)fbo_width - 1);
 
-   miny = std::max(miny, 0);
-   maxy = std::min(maxy, fbo_height - 1);
+   miny = std::max(miny, (int64_t)0);
+   maxy = std::min(maxy, (int64_t)fbo_height - 1);
 
/* Half-edge constants */
-   int c1 = dy12 * x1 - dx12 * y1;
-   int c2 = dy23 * x2 - dx23 * y2;
-   i

[Piglit] [PATCH] glsl-1.30: add test for default in switch not after all case statements

2013-04-12 Thread sroland
From: Roland Scheidegger 

By the looks of it "default" is not required to appear as last statement
in a switch expression, and c rules should be followed (which is probably
a mess to implement thanks to fallthrough).
Seems to fail with mesa glsl compiler (at least with tgsi translation).
---
 .../switch/fs-default_notlast.shader_test  |   33 
 1 file changed, 33 insertions(+)
 create mode 100644 
tests/spec/glsl-1.30/execution/switch/fs-default_notlast.shader_test

diff --git 
a/tests/spec/glsl-1.30/execution/switch/fs-default_notlast.shader_test 
b/tests/spec/glsl-1.30/execution/switch/fs-default_notlast.shader_test
new file mode 100644
index 000..385fd78
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/switch/fs-default_notlast.shader_test
@@ -0,0 +1,33 @@
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+#version 130
+void main()
+{
+   gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+#version 130
+
+uniform int i;
+
+void main()
+{
+   vec4 tmp = vec4(0.0, 0.0, 0.0, 0.0);
+   switch (i) {
+   default:
+   tmp = vec4(0.5, 0.0, 0.5, 0.0);
+   case 0:
+   gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);
+   break;
+   }
+   gl_FragColor = gl_FragColor + tmp;
+}
+
+[test]
+uniform int i 0
+draw rect -1 -1 2 2
+
+probe all rgba 0 1 0 0
-- 
1.7.9.5

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] arb_shader_texture_lod-texgradcube: Test explicit derivatives for cube maps

2013-04-03 Thread sroland
From: Roland Scheidegger 

Similar to arb_shader_texture_lod-texgrad, but using cube maps instead.
Given the somewhat undefined behavior of explicit gradients with cube
maps, the main purpose of the test is really to test that those work at
all, as there doesn't seem to be any other test covering this.
That said, drivers which simply drop explicit derivatives on the floor
(like softpipe) pass this perfectly as it simply compares implicit vs.
explicit behavior (which, given the fuzzy specification, might not be
really required to be the same here, though given the chosen values, that
is the major axis derivatives being zero, it might seem like a reasonable
assumption).
I guess something which would also test that the implementation is really
using explicit derivatives instead of implicit ones would also be desirable,
but I'll leave that for now, I couldn't really come up with something.
---
 .../execution/CMakeLists.gl.txt|1 +
 .../arb_shader_texture_lod/execution/texgradcube.c |  195 
 2 files changed, 196 insertions(+)
 create mode 100644 tests/spec/arb_shader_texture_lod/execution/texgradcube.c

diff --git a/tests/spec/arb_shader_texture_lod/execution/CMakeLists.gl.txt 
b/tests/spec/arb_shader_texture_lod/execution/CMakeLists.gl.txt
index c403939..2366fa9 100644
--- a/tests/spec/arb_shader_texture_lod/execution/CMakeLists.gl.txt
+++ b/tests/spec/arb_shader_texture_lod/execution/CMakeLists.gl.txt
@@ -10,5 +10,6 @@ link_libraries (
 )
 
 piglit_add_executable (arb_shader_texture_lod-texgrad texgrad.c)
+piglit_add_executable (arb_shader_texture_lod-texgradcube texgradcube.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/arb_shader_texture_lod/execution/texgradcube.c 
b/tests/spec/arb_shader_texture_lod/execution/texgradcube.c
new file mode 100644
index 000..90f7ddc
--- /dev/null
+++ b/tests/spec/arb_shader_texture_lod/execution/texgradcube.c
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2013 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS AND/OR THEIR
+ * SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *Roland Scheidegger 
+ *
+ * Based on arb_shader_texture_lod-texgrad:
+ *Marek Olšák 
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 10;
+
+   config.window_width = 512;
+   config.window_height = 256;
+   config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+#define TEX_WIDTH 256
+#define TEX_HEIGHT 256
+
+static const float colors[][3] = {
+   {1.0, 0.0, 0.0},
+   {0.0, 1.0, 0.0},
+   {0.0, 0.0, 1.0},
+   {1.0, 1.0, 0.0},
+   {0.0, 1.0, 1.0},
+   {1.0, 0.0, 1.0},
+   {0.5, 0.0, 0.5},
+   {1.0, 1.0, 1.0},
+};
+
+static const char *sh_tex =
+   "uniform samplerCube tex;"
+   "void main()"
+   "{"
+   "   gl_FragColor = textureCube(tex, gl_TexCoord[0].xyz);"
+   "}";
+
+static const char *sh_texgrad =
+   "#extension GL_ARB_shader_texture_lod : enable\n"
+   "uniform samplerCube tex;"
+   "void main()"
+   "{"
+   "   gl_FragColor = textureCubeGradARB(tex, gl_TexCoord[0].xyz,"
+   " dFdx(gl_TexCoord[0].xyz),"
+   " dFdy(gl_TexCoord[0].xyz));"
+   "}";
+
+static GLint prog_tex, prog_texgrad;
+
+void piglit_init(int argc, char **argv)
+{
+   GLuint tex, fb;
+   GLenum status;
+   int i, j, dim;
+   static GLuint fs_tex, fs_texgrad;
+
+   piglit_require_GLSL();
+   piglit_require_extension("GL_EXT_framebuffer_object");
+   piglit_require_extension("GL_ARB_shader_texture_lod");
+
+   fs_tex = piglit_compile_shader_text(GL_FRAGMENT_SHADER, sh_tex);
+   fs_texgrad = piglit_compile_shader_text(GL_FRAGMENT_SHADER, sh_texgrad);
+   prog_tex = piglit_link_simple_program(0, fs_tex);
+   prog_texgrad = piglit

[Piglit] [PATCH] glsl-fs-main-return-conditional: Test for using return in main

2013-03-22 Thread sroland
From: Roland Scheidegger 

Similar to glsl-fs-main-return (and glsl-vs-main-return), this is testing
using return in main. Contrary to the these other tests, this hits both
the cases where the return path is and is NOT taken (the gallivm code
got it wrong and always did an early exit which got unnoticed by the
existing tests, see https://bugs.freedesktop.org/show_bug.cgi?id=62357).

v2: use mod() instead of integer arithmetic suggested by Ian Romanick.
This gets rid of the glsl 1.30 requirement. And do minor simplifications.
---
 .../glsl-fs-main-return-conditional.shader_test|   28 
 1 file changed, 28 insertions(+)
 create mode 100644 tests/shaders/glsl-fs-main-return-conditional.shader_test

diff --git a/tests/shaders/glsl-fs-main-return-conditional.shader_test 
b/tests/shaders/glsl-fs-main-return-conditional.shader_test
new file mode 100644
index 000..173ae03
--- /dev/null
+++ b/tests/shaders/glsl-fs-main-return-conditional.shader_test
@@ -0,0 +1,28 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+void main()
+{
+   gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+const vec4 v = vec4(0., 1., 0., 1.);
+
+void main()
+{
+   gl_FragColor = v;
+   if (mod(gl_FragCoord.x, 2.0) >= 1.0)
+   return;  // return for every second pixel
+
+   gl_FragColor = vec4(1.0) - v;
+}
+
+[test]
+draw rect -1 -1 2 2
+probe rgb 0 0 1 0 1
+probe rgb 1 0 0 1 0
+probe rgb 2 0 1 0 1
+probe rgb 3 0 0 1 0
+
-- 
1.7.9.5
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] glsl-fs-main-return-conditional: Test for using return in main

2013-03-22 Thread sroland
From: Roland Scheidegger 

Similar to glsl-fs-main-return (and glsl-vs-main-return), this is testing
using return in main. Contrary to the these other tests, this hits both
the cases where the return path is and is NOT taken (the gallivm code
got it wrong and always did an early exit which got unnoticed by the
existing tests, see https://bugs.freedesktop.org/show_bug.cgi?id=62357).
It also needs glsl 1.30 (even though this is not specific to what's tested
here).
---
 .../glsl-fs-main-return-conditional.shader_test|   34 
 1 file changed, 34 insertions(+)
 create mode 100644 tests/shaders/glsl-fs-main-return-conditional.shader_test

diff --git a/tests/shaders/glsl-fs-main-return-conditional.shader_test 
b/tests/shaders/glsl-fs-main-return-conditional.shader_test
new file mode 100644
index 000..124a4cd
--- /dev/null
+++ b/tests/shaders/glsl-fs-main-return-conditional.shader_test
@@ -0,0 +1,34 @@
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+#version 130
+void main()
+{
+   gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+#version 130
+uniform vec4 v;
+
+void main()
+{
+   uint posintx = uint(gl_FragCoord.x);
+   uint one = uint(1);
+   gl_FragColor = v;
+   if ((posintx & one) == one) {
+   return;  // return for every second pixel
+   }
+   gl_FragColor = vec4(1.0) - v;
+}
+
+[test]
+uniform vec4 v 0 1 0 1
+
+draw rect -1 -1 2 2
+probe rgb 0 0 1 0 1
+probe rgb 1 0 0 1 0
+probe rgb 2 0 1 0 1
+probe rgb 3 0 0 1 0
+
-- 
1.7.9.5
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] glsl-1.30: add basic test for testing textureOffset functionality.

2013-03-22 Thread sroland
From: Roland Scheidegger 

This is pretty rough and doesn't really test all that much (just
textureOffsetLod, but there's other texturing functions with offsets),
doesn't test different wrap modes, NPOT sizes etc., but there's no
other test using "ordinary" texture opcodes and texel offsets, so
it's a start (and in fact it exposed a bug in the mesa state tracker).
Tested with llvmpipe (pass) and softpipe (fail) which is as expected -
hopefully the math is ok...
Inspired from fs-texelFetchOffset.

v2: some minor comment and code fixes

Reviewed-by: Jose Fonseca 
Reviewed-by: Brian Paul 
---
 tests/spec/glsl-1.30/execution/CMakeLists.gl.txt   |1 +
 .../spec/glsl-1.30/execution/fs-textureOffset-2D.c |  156 
 2 files changed, 157 insertions(+)
 create mode 100644 tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c

diff --git a/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt 
b/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt
index 6737bb1..3c0b2d5 100644
--- a/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt
+++ b/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt
@@ -13,6 +13,7 @@ link_libraries (
 piglit_add_executable (fs-discard-exit-2 fs-discard-exit-2.c)
 piglit_add_executable (fs-texelFetch-2D fs-texelFetch-2D.c)
 piglit_add_executable (fs-texelFetchOffset-2D fs-texelFetchOffset-2D.c)
+piglit_add_executable (fs-textureOffset-2D fs-textureOffset-2D.c)
 IF (NOT MSVC)
piglit_add_executable (isinf-and-isnan isinf-and-isnan.c)
 ENDIF (NOT MSVC)
diff --git a/tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c 
b/tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c
new file mode 100644
index 000..7ce2ec4
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2013 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file fs-textureOffset-2D.c
+ *
+ * Tests the built-in function textureLodOffset() in the fragment shader.
+ *
+ * Creates a mipmapped 64x32 2D texture and draws a series of squares whose
+ * color contains a texel fetched from each quadrant of the rgbw texture.
+ *
+ * Author: Roland Scheidegger
+ */
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 10;
+
+   config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+const int tex_size = 64;
+
+static int pos_location, lod_location;
+
+static const char vert[] =
+"#version 130\n"
+"void main()\n"
+"{\n"
+"  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+"}\n";
+
+static const char fragtexlodoffset[] =
+"#version 130\n"
+"uniform vec2 pos;\n"
+"uniform float lod;\n"
+"uniform sampler2D tex;\n"
+"void main()\n"
+"{\n"
+"   const ivec2 offset = ivec2(-2, 2);\n"
+"   vec4 texel = textureLodOffset(tex, pos, lod, offset);\n"
+"  gl_FragColor = texel;\n"
+"}\n";
+
+#ifdef _MSC_VER
+#undef max
+#endif
+static float max(float x, float y) { return (x > y) ? x : y; }
+
+enum piglit_result
+piglit_display(void)
+{
+   int l, q;
+   bool pass = true;
+   float red[4]   = {1.0, 0.0, 0.0, 1.0};
+   float green[4]   = {0.0, 1.0, 0.0, 1.0};
+   float blue[4]  = {0.0, 0.0, 1.0, 1.0};
+   float white[4]  = {1.0, 1.0, 1.0, 1.0};
+   float undefined[4] = {0.0, 0.0, 0.0, 0.0};
+
+   piglit_ortho_projection(piglit_width, piglit_height, false);
+
+   glClearColor(0.5, 0.5, 0.5, 1.0);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   /* TODO: test other wrap modes */   
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+   for (l = 0; (tex_size >> l) > 0; l++) {
+   const int width = tex_size >> l;
+   const int height = max(width / 2, 1);
+   const int y = 10 + 20 * l;
+
+   

[Piglit] [PATCH] glsl-1.30: add basic test for testing textureOffset functionality.

2013-03-05 Thread sroland
From: Roland Scheidegger 

This is pretty rough and doesn't really test all that much (just
textureOffsetLod, but there's other texturing functions with offsets),
doesn't test different wrap modes, NPOT sizes etc., but there's no
other test using "ordinary" texture opcodes and texel offsets, so
it's a start (and in fact it exposed a bug in the mesa state tracker).
Tested with llvmpipe (pass) and softpipe (fail) which is as expected -
hopefully the math is ok...
Inspired from fs-texelFetchOffset.
---
 tests/spec/glsl-1.30/execution/CMakeLists.gl.txt   |1 +
 .../spec/glsl-1.30/execution/fs-textureOffset-2D.c |  158 
 2 files changed, 159 insertions(+)
 create mode 100644 tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c

diff --git a/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt 
b/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt
index 6737bb1..3c0b2d5 100644
--- a/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt
+++ b/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt
@@ -13,6 +13,7 @@ link_libraries (
 piglit_add_executable (fs-discard-exit-2 fs-discard-exit-2.c)
 piglit_add_executable (fs-texelFetch-2D fs-texelFetch-2D.c)
 piglit_add_executable (fs-texelFetchOffset-2D fs-texelFetchOffset-2D.c)
+piglit_add_executable (fs-textureOffset-2D fs-textureOffset-2D.c)
 IF (NOT MSVC)
piglit_add_executable (isinf-and-isnan isinf-and-isnan.c)
 ENDIF (NOT MSVC)
diff --git a/tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c 
b/tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c
new file mode 100644
index 000..4c050fb
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2013 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file fs-textureOffset-2D.c
+ *
+ * Tests the built-in function textureLodOffset() in the fragment shader.
+ *
+ * Creates a mipmapped 64x32 2D texture and draws a series of squares whose
+ * color contains a texel fetched from each quadrant of the rgbw texture.
+ *
+ * Author: Roland Scheidegger
+ */
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 10;
+
+   config.window_width = 90;
+   config.window_height = 150;
+   config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+const int tex_size = 64;
+
+static int pos_location, lod_location;
+
+static const char vert[] =
+"#version 130\n"
+"void main()\n"
+"{\n"
+"  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+"}\n";
+
+static const char fragtexlodoffset[] =
+"#version 130\n"
+"uniform vec2 pos;\n"
+"uniform float lod;\n"
+"uniform sampler2D tex;\n"
+"void main()\n"
+"{\n"
+"   const ivec2 offset = ivec2(-2, 2);\n"
+"   vec4 texel = textureLodOffset(tex, pos, lod, offset);\n"
+"  gl_FragColor = texel;\n"
+"}\n";
+
+#ifdef _MSC_VER
+#undef max
+#endif
+static float max(float x, float y) { return (x > y) ? x : y; }
+
+enum piglit_result
+piglit_display(void)
+{
+   int l, q;
+   bool pass = true;
+   float red[4]   = {1.0, 0.0, 0.0, 1.0};
+   float green[4]   = {0.0, 1.0, 0.0, 1.0};
+   float blue[4]  = {0.0, 0.0, 1.0, 1.0};
+   float white[4]  = {1.0, 1.0, 1.0, 1.0};
+   float undefined[4] = {0.0, 0.0, 0.0, 0.0};
+
+   glClearColor(0.5, 0.5, 0.5, 1.0);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   /* XXX: test other wrap modes */
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+   for (l = 0; (tex_size >> l) > 0; l++) {
+   const int width = tex_size >> l;
+   const int height = max(width / 2, 1);
+   const int y = 10 + 20 * l;
+
+   glUniform1f(lod_location, (float)l);
+
+   /* Draw 4 squares with a color

[Piglit] [PATCH] glsl-1.30: add basic test for testing textureOffset functionality.

2013-03-04 Thread sroland
From: Roland Scheidegger 

This is pretty rough and doesn't really test all that much (just
textureOffsetLod, but there's other texturing functions with offsets),
doesn't test different wrap modes, NPOT sizes etc., but there's no
other test using "ordinary" texture opcodes and texel offsets, so
it's a start (and in fact it exposed a bug in the mesa state tracker).
Tested with llvmpipe (pass) and softpipe (fail) which is as expected -
hopefully the math is ok...
Inspired from fs-texelFetchOffset.
---
 tests/spec/glsl-1.30/execution/CMakeLists.gl.txt |1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt 
b/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt
index 6737bb1..3c0b2d5 100644
--- a/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt
+++ b/tests/spec/glsl-1.30/execution/CMakeLists.gl.txt
@@ -13,6 +13,7 @@ link_libraries (
 piglit_add_executable (fs-discard-exit-2 fs-discard-exit-2.c)
 piglit_add_executable (fs-texelFetch-2D fs-texelFetch-2D.c)
 piglit_add_executable (fs-texelFetchOffset-2D fs-texelFetchOffset-2D.c)
+piglit_add_executable (fs-textureOffset-2D fs-textureOffset-2D.c)
 IF (NOT MSVC)
piglit_add_executable (isinf-and-isnan isinf-and-isnan.c)
 ENDIF (NOT MSVC)
-- 
1.7.9.5
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] texture-integer-glsl130: fix wrong expected G/B values for L/LA/I formats

2013-01-30 Thread sroland
From: Roland Scheidegger 

The tests expects the green and blue values to be the same as the luminance
(or intensity) value but it should be zero.
(Mesa used to do the former for readpixels probably due to complex wording
in earlier gl specs but this was considered an error and subsequently changed
in ad897fff7730298c21289768d9b1b55f3d166ac5.)
---
 tests/spec/ext_texture_integer/fbo-blending.c |   17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/tests/spec/ext_texture_integer/fbo-blending.c 
b/tests/spec/ext_texture_integer/fbo-blending.c
index 58827d3..89c1c1b 100644
--- a/tests/spec/ext_texture_integer/fbo-blending.c
+++ b/tests/spec/ext_texture_integer/fbo-blending.c
@@ -204,24 +204,15 @@ test_format(const struct format_info *info)
expected_color[3] = 1;
break;
case GL_LUMINANCE_INTEGER_EXT:
-   expected_color[1] = expected_color[0];
-   expected_color[2] = expected_color[0];
+   expected_color[1] = expected_color[2] = 0;
expected_color[3] = 1;
break;
case GL_LUMINANCE_ALPHA_INTEGER_EXT:
-   expected_color[1] = expected_color[0];
-   expected_color[2] = expected_color[0];
+   expected_color[1] = expected_color[2] = 0;
break;
case GL_RED_INTEGER:
-   if (strstr(info->name, "INTENSITY")) {
-   expected_color[1] = expected_color[0];
-   expected_color[2] = expected_color[0];
-   expected_color[3] = expected_color[0];
-   } else {
-   expected_color[1] = 0;
-   expected_color[2] = 0;
-   expected_color[3] = 1;
-   }
+   expected_color[1] = expected_color[2] = 0;
+   expected_color[3] = 1;
break;
case GL_RG_INTEGER:
expected_color[2] = 0;
-- 
1.7.9.5
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] texture-integer-glsl130: fix random failures with wrong expected alpha values

2013-01-09 Thread sroland
From: Roland Scheidegger 

The logic failed whenever the random number was 0 for formats which don't have
an alpha channel. In this case all of expected/bias/value were 0 but the actual
correct read back value is 1.0 (default value for alpha channel sampling for
integer textures is 1 just like it is 1.0 for ordinary texture formats).
---
 .../ext_texture_integer/texture-integer-glsl130.c  |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/spec/ext_texture_integer/texture-integer-glsl130.c 
b/tests/spec/ext_texture_integer/texture-integer-glsl130.c
index 17b02bc..bc0d598 100644
--- a/tests/spec/ext_texture_integer/texture-integer-glsl130.c
+++ b/tests/spec/ext_texture_integer/texture-integer-glsl130.c
@@ -373,10 +373,11 @@ test_format(const struct format_info *info)
value[0] = temp;
break;
case GL_RGB_INTEGER_EXT:
-   expected[3] = 0.0;
+   value[3] = 1.0;
break;
case GL_RG_INTEGER:
-   expected[2] = expected[3] = 0.0;
+   value[2] = 0.0;
+   value[3] = 1.0;
break;
case GL_ALPHA_INTEGER_EXT:
expected[0] = expected[1] = expected[2] = 0.0;
@@ -404,7 +405,8 @@ test_format(const struct format_info *info)
expected[0] = expected[1] = expected[2] = expected[3] = 
0.25;
value[1] = value[2] = value[3] = value[0];
} else {
-   expected[1] = expected[2] = expected[3] = 0.0;
+   value[1] = value[2] = 0.0;
+   value[3] = 1.0;
}   
break;
default:
-- 
1.7.9.5
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] fs-texelFetchOffset-2D: don't assume undefined values to be solid black

2012-11-28 Thread sroland
From: Roland Scheidegger 

core GL specifies out-of-bound texel fetches return undefined results,
except in a robust context with ARB_robust_buffer_access_behavior supported
(which is core in 4.3), in which case texel fetch will return 0 (OpenGL 4.3
compatibility profile, page 387, subsection 11.1.3.2 Texel Fetches).
Since the test requires neither robust context nor that extension it cannot
assume any specific result value. In any case even returning zero is not what
the test expected, since it wanted [0,0,0,1] instead.
(With this change softpipe passes the test, as it clamps the coords.)

v2: fix black->undefined, formatting, comments
---
 .../glsl-1.30/execution/fs-texelFetchOffset-2D.c   |   29 
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c 
b/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
index 19e3654..8bdca7a 100644
--- a/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
+++ b/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
@@ -76,7 +76,7 @@ piglit_display(void)
bool pass = true;
float red[4]   = {1.0, 0.0, 0.0, 1.0};
float blue[4]  = {0.0, 0.0, 1.0, 1.0};
-   float black[4] = {0.0, 0.0, 0.0, 1.0};
+   float undefined[4] = {0.0, 0.0, 0.0, 0.0};
 
glClearColor(0.5, 0.5, 0.5, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
@@ -92,12 +92,29 @@ piglit_display(void)
for (q = 0; q < 4; q++) {
const int tex_x = (q / 2) * ((width / 2));
const int tex_y = (q % 2) * ((height / 2));
-   float *c = black;
+   float *c = undefined;
const int x = 10+20*q;
 
-   /* fancy stuff - we should see red and blue
-  due to the offset for 3 levels, 
-  otherwise we get lots of black border color */
+   /* fancy stuff - we should see some red and blue
+* due to the offset for 3 levels, all the rest is
+* undefined due to out-of-bounds.
+* Only with ARB_robust_buffer_access_behavior
+* (and a robust context) the undefined result would
+* be guaranteed to be zero instead.
+*
+* From the GL 3.0 spec, page 105 ("Texel Fetches"):
+*
+* "The results of the texel fetch are
+*  undefined if any of the following
+*  conditions hold:
+*
+*  ...
+*
+*  - The texel coordinates refer to a
+*border texel outside of the defined
+*extents of the specified LOD"
+*/
+
if (l < 3) {
if (q == 2) c = red;
else if (q == 3) c = blue;
@@ -107,7 +124,7 @@ piglit_display(void)
piglit_Uniform2i(pos_location, tex_x, tex_y);
piglit_draw_rect(x, y, 10, 10);
 
-   if (width > 2) /* below 1 wide no test */
+   if (width > 2 && c != undefined) /* below 1 wide no 
test */
pass &= piglit_probe_rect_rgba(x, y, 10, 10, c);
}
}
-- 
1.7.9.5

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] fs-texelFetchOffset-2D: don't assume undefined values to be solid black

2012-11-27 Thread sroland
From: Roland Scheidegger 

core GL specifies out-of-bound texel fetches return undefined results,
except in a robust context with ARB_robust_buffer_access_behavior supported
(which is core in 4.3), in which case texel fetch will return 0 (OpenGL 4.3
compatibility profile, page 387, subsection 11.1.3.2 Texel Fetches).
Since the test requires neither robust context nor that extension it cannot
assume any specific result value. In any case even returning zero is not what
the test expected, since it wanted [0,0,0,1] instead.
(With this change softpipe passes the test, as it clamps the coords.)

v2: fix black->undefined, formatting, comments
---
 .../glsl-1.30/execution/fs-texelFetchOffset-2D.c   |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c 
b/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
index 19e3654..de9a0f5 100644
--- a/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
+++ b/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
@@ -76,7 +76,7 @@ piglit_display(void)
bool pass = true;
float red[4]   = {1.0, 0.0, 0.0, 1.0};
float blue[4]  = {0.0, 0.0, 1.0, 1.0};
-   float black[4] = {0.0, 0.0, 0.0, 1.0};
+   float undefined[4] = {0.0, 0.0, 0.0, 0.0};
 
glClearColor(0.5, 0.5, 0.5, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
@@ -92,12 +92,15 @@ piglit_display(void)
for (q = 0; q < 4; q++) {
const int tex_x = (q / 2) * ((width / 2));
const int tex_y = (q % 2) * ((height / 2));
-   float *c = black;
+   float *c = undefined;
const int x = 10+20*q;
 
/* fancy stuff - we should see red and blue
-  due to the offset for 3 levels, 
-  otherwise we get lots of black border color */
+  due to the offset for 3 levels, all the rest is
+  undefined due to out-of-bounds.
+  Only with ARB_robust_buffer_access_behavior
+  (and a robust context) the undefined result would
+  be guaranteed to be zero. */
if (l < 3) {
if (q == 2) c = red;
else if (q == 3) c = blue;
@@ -107,7 +110,7 @@ piglit_display(void)
piglit_Uniform2i(pos_location, tex_x, tex_y);
piglit_draw_rect(x, y, 10, 10);
 
-   if (width > 2) /* below 1 wide no test */
+   if (width > 2 && c != undefined) /* below 1 wide no 
test */
pass &= piglit_probe_rect_rgba(x, y, 10, 10, c);
}
}
-- 
1.7.9.5

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] fs-texelFetchOffset-2D: don't assume undefined values to be solid black

2012-11-27 Thread sroland
From: Roland Scheidegger 

core GL specifies out-of-bound texel fetches return undefined results,
except in a robust context with ARB_robust_buffer_access_behavior supported
(which is core in 4.3), in which case texel fetch will return 0 (OpenGL 4.3
compatibility profile, page 387, subsection 11.1.3.2 Texel Fetches).
Since the test requires neither robust context nor that extension it cannot
assume any specific result value. In any case even returning zero is not what
the test expected, since it wanted [0,0,0,1] instead.
(With this change softpipe passes the test, as it clamps the coords.)
---
 .../glsl-1.30/execution/fs-texelFetchOffset-2D.c   |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c 
b/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
index 19e3654..c490ff3 100644
--- a/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
+++ b/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
@@ -76,7 +76,7 @@ piglit_display(void)
bool pass = true;
float red[4]   = {1.0, 0.0, 0.0, 1.0};
float blue[4]  = {0.0, 0.0, 1.0, 1.0};
-   float black[4] = {0.0, 0.0, 0.0, 1.0};
+   float undefined[4] = {0.0, 0.0, 0.0, 0.0};
 
glClearColor(0.5, 0.5, 0.5, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
@@ -92,12 +92,15 @@ piglit_display(void)
for (q = 0; q < 4; q++) {
const int tex_x = (q / 2) * ((width / 2));
const int tex_y = (q % 2) * ((height / 2));
-   float *c = black;
+   float *c = undefined;
const int x = 10+20*q;
 
/* fancy stuff - we should see red and blue
-  due to the offset for 3 levels, 
-  otherwise we get lots of black border color */
+  due to the offset for 3 levels, all the rest is
+   undefined due to out-of-bounds.
+   Only with ARB_robust_buffer_access_behavior
+   (and a robust context) the undefined result would
+   be guaranteed to be zero. */
if (l < 3) {
if (q == 2) c = red;
else if (q == 3) c = blue;
@@ -107,7 +110,7 @@ piglit_display(void)
piglit_Uniform2i(pos_location, tex_x, tex_y);
piglit_draw_rect(x, y, 10, 10);
 
-   if (width > 2) /* below 1 wide no test */
+   if (width > 2 && c != undefined) /* below 1 wide no 
test */
pass &= piglit_probe_rect_rgba(x, y, 10, 10, c);
}
}
-- 
1.7.9.5

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] fs-texelFetchOffset-2D: don't assume undefined values to be solid black

2012-11-26 Thread sroland
From: Roland Scheidegger 

core GL specifies out-of-bound accesses have undefined behavior,
which includes crashes.
Crashes are very much undesired, but ARB_robustness still allows undefined
values to be returned (with a recommendation to return 0).
Only ARB_robust_buffer_access_behavior would require to return zero, but the
test doesn't need this extension. In any case even returning zero is not what
the test expected, since it wanted [0,0,0,1].
(With this change softpipe passes the test, as it clamps the coords.)
---
 .../glsl-1.30/execution/fs-texelFetchOffset-2D.c   |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c 
b/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
index 19e3654..f61dfce 100644
--- a/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
+++ b/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
@@ -96,8 +96,8 @@ piglit_display(void)
const int x = 10+20*q;
 
/* fancy stuff - we should see red and blue
-  due to the offset for 3 levels, 
-  otherwise we get lots of black border color */
+  due to the offset for 3 levels, all the rest is
+   undefined due to out-of-bounds */
if (l < 3) {
if (q == 2) c = red;
else if (q == 3) c = blue;
@@ -107,7 +107,7 @@ piglit_display(void)
piglit_Uniform2i(pos_location, tex_x, tex_y);
piglit_draw_rect(x, y, 10, 10);
 
-   if (width > 2) /* below 1 wide no test */
+   if (width > 2 && c != black) /* below 1 wide no test */
pass &= piglit_probe_rect_rgba(x, y, 10, 10, c);
}
}
-- 
1.7.9.5
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] tests/spec/arb_robustness/draw-vbo-bounds.c: add clipping

2012-10-29 Thread sroland
From: Roland Scheidegger 

Make sure clipping is needed sometimes, and more often use small index counts,
to expose issues and excercise more paths in mesa's draw module.
---
 tests/spec/arb_robustness/draw-vbo-bounds.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/spec/arb_robustness/draw-vbo-bounds.c 
b/tests/spec/arb_robustness/draw-vbo-bounds.c
index 4351ac9..c780a3a 100644
--- a/tests/spec/arb_robustness/draw-vbo-bounds.c
+++ b/tests/spec/arb_robustness/draw-vbo-bounds.c
@@ -95,7 +95,7 @@ random_vertices(GLsizei offset, GLsizei stride, GLsizei count)
 
 for (i = 0; i < count; ++i) {
 GLfloat *vertex = (GLfloat *)(vertices + offset + i*stride);
-vertex[0] = (rand() % 1000) * .001;
+vertex[0] = (rand() % 1000) * ((rand() % 1000) ? 0.001 : 1.0);
 vertex[1] = (rand() % 1000) * .001;
 }
 
@@ -145,7 +145,7 @@ static void test(void)
 vertex_count = 1 + rand() % 0x;
 
 index_offset = (rand() % 0xff) * sizeof(GLushort);
-index_count = 1 + rand() % 0x;
+index_count = rand() % 10 ? 1 + rand() % 0x : 1 + rand() % 0x7ff;
 min_index = rand() % vertex_count;
 max_index = min_index + rand() % (vertex_count - min_index);
 
-- 
1.7.9.5

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] tests/fbo-blit-stretch: add a 1x1 -> nxm stretch test case

2012-10-15 Thread sroland
From: Roland Scheidegger 

---
 tests/fbo/fbo-blit-stretch.cpp |   16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tests/fbo/fbo-blit-stretch.cpp b/tests/fbo/fbo-blit-stretch.cpp
index fd2e187..55ed750 100644
--- a/tests/fbo/fbo-blit-stretch.cpp
+++ b/tests/fbo/fbo-blit-stretch.cpp
@@ -444,17 +444,29 @@ tests[] = {
{
SRCW, SRCH,
SRCXMIN, SRCYMIN, SRCXMAX, SRCYMAX,
-   DSTXMIN, DSTYMIN, DSTXMAX + 3*DX, DSTYMAX + 3*DY, // strech x y
+   DSTXMIN, DSTYMIN, DSTXMAX + 3*DX, DSTYMAX + 3*DY, // stretch x y
GL_NEAREST,
},
{
SRCW, SRCH,
SRCXMIN, SRCYMIN, SRCXMAX, SRCYMAX,
-   DSTXMIN, DSTYMIN, DSTXMAX + 3*DX, DSTYMAX + 3*DY, // strech x y
+   DSTXMIN, DSTYMIN, DSTXMAX + 3*DX, DSTYMAX + 3*DY, // stretch x y
GL_NEAREST,
},
 
/*
+* Stretch of a single pixel.
+*/
+
+   {
+   SRCW, SRCH,
+   SRCXMIN, SRCYMIN, SRCXMIN + 1, SRCYMIN + 1,
+   DSTXMIN, DSTYMIN, DSTXMIN + 7, DSTYMIN + 7, // stretch x y
+   GL_NEAREST,
+   },
+
+
+   /*
 * Clip
 */
 
-- 
1.7.9.5

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit