[Piglit] [PATCH] glShaderSource must not change compile status.

2016-04-25 Thread Jamey Sharp
OpenGL 4.5 Core Profile section 7.1, in the documentation for
CompileShader, says: "Changing the source code of a shader object with
ShaderSource does not change its compile status or the compiled shader
code." (I haven't checked older versions of the spec.)

According to Karol Herbst, the game "Divinity: Original Sin - Enhanced
Edition" depends on this odd quirk of the spec. See:
https://lists.freedesktop.org/archives/mesa-dev/2016-March/109789.html

This patch, together with MESA_GL_VERSION_OVERRIDE=4.2, allows
"Divinity" to start up successfully on i965, though rendering bugs
remain.

Signed-off-by: Jamey Sharp 
Cc: Karol Herbst 
---
 src/mesa/main/shaderapi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index b28b5ce..fc2e885 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -949,7 +949,6 @@ shader_source(struct gl_shader *sh, const GLchar *source)
/* free old shader source string and install new one */
free((void *)sh->Source);
sh->Source = source;
-   sh->CompileStatus = GL_FALSE;
 #ifdef DEBUG
sh->SourceChecksum = _mesa_str_checksum(sh->Source);
 #endif
-- 
2.6.2

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


[Piglit] [PATCH] Test that glShaderSource does not change compile status.

2016-04-25 Thread Jamey Sharp
OpenGL 4.5 Core Profile section 7.1, in the documentation for
CompileShader, says: "Changing the source code of a shader object with
ShaderSource does not change its compile status or the compiled shader
code." (I haven't checked older versions of the spec.)

This test creates a shader, compiles it, changes its source, and links
it. The spec requires rendering done with this shader to be consistent
with the old source, not the new source, since the shader isn't compiled
again after the source is changed.

According to Karol Herbst, the game "Divinity: Original Sin - Enhanced
Edition" depends on this odd quirk of the spec. See:
https://lists.freedesktop.org/archives/mesa-dev/2016-March/109789.html

This test fails against current Mesa master, but passes with a one-line
patch to src/mesa/main/shaderapi.c. That patch, together with
MESA_GL_VERSION_OVERRIDE=4.2, also allowed "Divinity" to start up
successfully on i965, though rendering bugs remain.

Based on Karol's report, I expect this test should pass on Catalyst, but
I only have Intel hardware to test on.

Signed-off-by: Jamey Sharp 
Cc: Karol Herbst 
---
 tests/all.py|   1 +
 tests/shaders/CMakeLists.gl.txt |   1 +
 tests/shaders/shadersource-no-compile.c | 107 
 3 files changed, 109 insertions(+)
 create mode 100644 tests/shaders/shadersource-no-compile.c

diff --git a/tests/all.py b/tests/all.py
index 93d64e6..9f5c019 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -572,6 +572,7 @@ with profile.group_manager(PiglitGLTest, 'shaders') as g:
 g(['glsl-kwin-blur-2'])
 g(['gpu_shader4_attribs'])
 g(['link-unresolved-function'])
+g(['shadersource-no-compile'])
 g(['sso-simple'])
 g(['sso-uniforms-01'])
 g(['sso-uniforms-02'])
diff --git a/tests/shaders/CMakeLists.gl.txt b/tests/shaders/CMakeLists.gl.txt
index afbcc4b..2db2ded 100644
--- a/tests/shaders/CMakeLists.gl.txt
+++ b/tests/shaders/CMakeLists.gl.txt
@@ -150,6 +150,7 @@ ENDIF (UNIX)
 piglit_add_executable (glsl-kwin-blur-1 glsl-kwin-blur-1.c)
 piglit_add_executable (glsl-kwin-blur-2 glsl-kwin-blur-2.c)
 piglit_add_executable (link-unresolved-function link-unresolved-function.c)
+piglit_add_executable (shadersource-no-compile shadersource-no-compile.c)
 piglit_add_executable (sso-simple sso-simple.c)
 piglit_add_executable (sso-uniforms-01 sso-uniforms-01.c)
 piglit_add_executable (sso-uniforms-02 sso-uniforms-02.c)
diff --git a/tests/shaders/shadersource-no-compile.c 
b/tests/shaders/shadersource-no-compile.c
new file mode 100644
index 000..922f0f3
--- /dev/null
+++ b/tests/shaders/shadersource-no-compile.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright © 2016 Jamey Sharp
+ *
+ * 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 shadersource-no-compile.c
+ * OpenGL 4.5 Core Profile section 7.1, in the documentation for CompileShader,
+ * says: "Changing the source code of a shader object with ShaderSource does 
not
+ * change its compile status or the compiled shader code."
+ *
+ * This test creates a shader, compiles it, changes its source, and links it.
+ * The spec requires rendering done with this shader to be consistent with the
+ * old source, not the new source, since the shader isn't compiled again after
+ * the source is changed.
+ *
+ * According to Karol Herbst, the game "Divinity: Original Sin - Enhanced
+ * Edition" depends on this odd quirk of the spec. See:
+ * https://lists.freedesktop.org/archives/mesa-dev/2016-March/109789.html
+ *
+ * \author Jamey Sharp 
+ */
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 10;
+
+   config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char vs_text[] =
+   "void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; "
+   "gl_FrontColor = vec4(0.0, 1.

Re: [Piglit] [PATCH] util: Fix texture name returned by piglit_integer_texture()

2016-04-25 Thread Nicolai Hähnle

Hi Chad,

I saw Matt's email and went ahead and just did this before seeing your 
email. Sorry about that!


Nicolai

On 25.04.2016 16:49, Chad Versace wrote:

The function always returned texture name 0.  Fix to to return the
actual texture name.

Found by GCC warning:
 tests/util/piglit-util-gl.c:2623:1: warning: control reaches end of
  non-void function [-Wreturn-type]
---
  tests/util/piglit-util-gl.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 09eb99d..b288a67 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -2620,6 +2620,8 @@ GLuint piglit_integer_texture(GLenum internalFormat, int 
w, int h, int b, int a)
 GL_RGBA_INTEGER, GL_INT, img);

free(img);
+
+   return tex;
  }

  /**


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


Re: [Piglit] [PATCH 1/8] shader_runner: support integer textures

2016-04-25 Thread Nicolai Hähnle

On 25.04.2016 13:08, Matt Turner wrote:

On Wed, Apr 6, 2016 at 6:10 PM, Nicolai Hähnle  wrote:

From: Nicolai Hähnle 

---
  tests/shaders/shader_runner.c | 17 +
  tests/util/piglit-util-gl.c   | 35 +++
  tests/util/piglit-util-gl.h   |  1 +
  3 files changed, 53 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 8d2a9bd..206258c 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -3102,6 +3102,23 @@ piglit_display(void)
 GL_UNSIGNED_NORMALIZED);
 if (!piglit_is_core_profile)
 glEnable(GL_TEXTURE_2D);
+   } else if (sscanf(line, "texture integer %d ( %d", &tex, &w) == 
2) {
+   GLenum int_fmt;
+   int b, a;
+   int num_scanned =
+   sscanf(line,
+  "texture integer %d ( %d , %d ) ( %d, %d ) 
%31s",
+  &tex, &w, &h, &b, &a, s);
+   if (num_scanned < 6) {
+   fprintf(stderr,
+   "invalid texture integer command!\n");
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   int_fmt = piglit_get_gl_enum_from_name(s);
+
+   glActiveTexture(GL_TEXTURE0 + tex);
+   piglit_integer_texture(int_fmt, w, h, b, a);
 } else if (sscanf(line, "texture miptree %d", &tex) == 1) {
 glActiveTexture(GL_TEXTURE0 + tex);
 piglit_miptree_texture();
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index dbdfb13..e8a47c5 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -2494,6 +2494,41 @@ piglit_rgbw_texture(GLenum internalFormat, int w, int h, 
GLboolean mip,
  }

  /**
+ * Generates a texture with the given integer internal format.
+ * Pixel data will be filled as R = x, G = y, B = b, A = a.
+ */
+GLuint piglit_integer_texture(GLenum internalFormat, int w, int h, int b, int 
a)


Returns GLuint, but there's no return in the function, and the call
site doesn't use the result. I think you meant to make this void.


Thanks for pointing this out. I actually meant to have it return the 
texture object, like the other piglit_*_texture functions do. I've just 
pushed a minor change for this.


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


[Piglit] [PATCH] util: Fix texture name returned by piglit_integer_texture()

2016-04-25 Thread Chad Versace
The function always returned texture name 0.  Fix to to return the
actual texture name.

Found by GCC warning:
tests/util/piglit-util-gl.c:2623:1: warning: control reaches end of
 non-void function [-Wreturn-type]
---
 tests/util/piglit-util-gl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 09eb99d..b288a67 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -2620,6 +2620,8 @@ GLuint piglit_integer_texture(GLenum internalFormat, int 
w, int h, int b, int a)
 GL_RGBA_INTEGER, GL_INT, img);
 
free(img);
+
+   return tex;
 }
 
 /**
-- 
2.8.1

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


[Piglit] [Bug 95053] Piglit option for running tests in a pre-defined way

2016-04-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95053

--- Comment #1 from Dylan Baker  ---
Hi Daniela,

There isn't such an option currently in piglit to sort tests. It shouldn't be
too hard to add such an option, It could easily be hooked into the
TestProfile._prepare_test_list in framework/profile.py, and I'd be happy to
review any patches that are sent.

Dylan

-- 
You are receiving this mail because:
You are the QA Contact for the bug.___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH v2] glx_arb_sync_control/wait_for_msc: Add a missing timeout

2016-04-25 Thread Martin Peres

On 20/04/16 14:58, Lofstedt, Marta wrote:




-Original Message-
From: Martin Peres [mailto:martin.pe...@linux.intel.com]
Sent: Wednesday, April 20, 2016 12:30 PM
To: Marta Lofstedt ;
piglit@lists.freedesktop.org
Cc: Lofstedt, Marta 
Subject: Re: [PATCH v2] glx_arb_sync_control/wait_for_msc: Add a missing
timeout

On 19/04/16 11:51, Marta Lofstedt wrote:

From: Marta Lofstedt 

This test requests via GLX to wait until a certain vertical retrace
event (based on the Media Stream Counter, AKA MSC) before being
unblocked by the X-Server. Since there can be bugs in the
implementation, it is possible for the test to not terminate.
Re-enforcing this idea is that all the other glx_arb_sync_control
tests already have a timeout set.

This change adds a timeout to guard against this case and report a failure.

V2: Only added timeout to waitformsc and updated commit message.

Signed-off-by: Marta Lofstedt 


Thanks! Looks good now :)

Reviewed-by: Martin Peres 

I will push it tomorrow!



Thanks Martin!


Pushed:
To ssh://mpe...@git.freedesktop.org/git/piglit
   8e08a5c..8d6a864  master -> master

Sorry for the delay!
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 1/8] shader_runner: support integer textures

2016-04-25 Thread Matt Turner
On Wed, Apr 6, 2016 at 6:10 PM, Nicolai Hähnle  wrote:
> From: Nicolai Hähnle 
>
> ---
>  tests/shaders/shader_runner.c | 17 +
>  tests/util/piglit-util-gl.c   | 35 +++
>  tests/util/piglit-util-gl.h   |  1 +
>  3 files changed, 53 insertions(+)
>
> diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
> index 8d2a9bd..206258c 100644
> --- a/tests/shaders/shader_runner.c
> +++ b/tests/shaders/shader_runner.c
> @@ -3102,6 +3102,23 @@ piglit_display(void)
> GL_UNSIGNED_NORMALIZED);
> if (!piglit_is_core_profile)
> glEnable(GL_TEXTURE_2D);
> +   } else if (sscanf(line, "texture integer %d ( %d", &tex, &w) 
> == 2) {
> +   GLenum int_fmt;
> +   int b, a;
> +   int num_scanned =
> +   sscanf(line,
> +  "texture integer %d ( %d , %d ) ( %d, 
> %d ) %31s",
> +  &tex, &w, &h, &b, &a, s);
> +   if (num_scanned < 6) {
> +   fprintf(stderr,
> +   "invalid texture integer command!\n");
> +   piglit_report_result(PIGLIT_FAIL);
> +   }
> +
> +   int_fmt = piglit_get_gl_enum_from_name(s);
> +
> +   glActiveTexture(GL_TEXTURE0 + tex);
> +   piglit_integer_texture(int_fmt, w, h, b, a);
> } else if (sscanf(line, "texture miptree %d", &tex) == 1) {
> glActiveTexture(GL_TEXTURE0 + tex);
> piglit_miptree_texture();
> diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
> index dbdfb13..e8a47c5 100644
> --- a/tests/util/piglit-util-gl.c
> +++ b/tests/util/piglit-util-gl.c
> @@ -2494,6 +2494,41 @@ piglit_rgbw_texture(GLenum internalFormat, int w, int 
> h, GLboolean mip,
>  }
>
>  /**
> + * Generates a texture with the given integer internal format.
> + * Pixel data will be filled as R = x, G = y, B = b, A = a.
> + */
> +GLuint piglit_integer_texture(GLenum internalFormat, int w, int h, int b, 
> int a)

Returns GLuint, but there's no return in the function, and the call
site doesn't use the result. I think you meant to make this void.
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 6/8] arb_gpu_shader_fp64: use generator to test in/out attributes

2016-04-25 Thread Andres Gomez
Dylan, do you think we can get an R-b or Ack-b from you for this second
version of the patch?

Thanks!

On Wed, 2016-03-16 at 17:39 +0200, Andres Gomez wrote:
> From: "Juan A. Suarez Romero" 
> 
> Vertex shader inputs and fragment shader outputs can only be
> single-precision values.
> 
> From GL_ARB_gpu_shader_fp64 spec:
> 
> "Modify Section 4.3.4, Inputs, p. 31
> 
> (modify third paragraph of the section, p. 31) ... Vertex shader
> inputs
> can only be single-precision floating-point scalars, vectors, or
> matrices, or signed and unsigned integers and integer
> vectors.  Vertex
> shader inputs can also form arrays of these types, but not
> structures."
> 
> "Modify Section 4.3.6, Outputs, p. 33
> 
> (modify third paragraph of the section, p. 33) They can only be
> float,
> double, single- or double-precision floating-point vectors or
> matrices,
> signed or unsigned integers or integer vectors, or arrays or
> structures
> of any these.
> 
> (modify last paragraph, p. 33) ... Fragment outputs can only be
> float,
> single-precision floating-point vectors, signed or unsigned integers
> or
> integer vectors, or arrays of these. ..."
> 
> Contributed by Andres Gomez.
> ---
>  generated_tests/CMakeLists.txt |   8 ++
>  generated_tests/gen_inout_fp64.py  | 151
> +
>  .../templates/gen_inout_fp64/template.frag.mako|  29 
>  .../gen_inout_fp64/template.shader_test.mako   |  28 ++--
>  .../templates/gen_inout_fp64/template.vert.mako|  30 
>  .../execution/vs-out-fs-in-double.shader_test  |  43 --
>  .../preprocessor/fs-output-double.frag |  23 
>  .../preprocessor/vs-input-double.vert  |  24 
>  8 files changed, 237 insertions(+), 99 deletions(-)
>  create mode 100644 generated_tests/gen_inout_fp64.py
>  create mode 100644
> generated_tests/templates/gen_inout_fp64/template.frag.mako
>  rename tests/spec/arb_gpu_shader_fp64/execution/vs-out-fs-in-double-
> 2.shader_test =>
> generated_tests/templates/gen_inout_fp64/template.shader_test.mako
> (56%)
>  create mode 100644
> generated_tests/templates/gen_inout_fp64/template.vert.mako
>  delete mode 100644 tests/spec/arb_gpu_shader_fp64/execution/vs-out-
> fs-in-double.shader_test
>  delete mode 100644 tests/spec/arb_gpu_shader_fp64/preprocessor/fs-
> output-double.frag
>  delete mode 100644 tests/spec/arb_gpu_shader_fp64/preprocessor/vs-
> input-double.vert
> 
> diff --git a/generated_tests/CMakeLists.txt
> b/generated_tests/CMakeLists.txt
> index 0dc617b..569ca21 100644
> --- a/generated_tests/CMakeLists.txt
> +++ b/generated_tests/CMakeLists.txt
> @@ -117,6 +117,13 @@ piglit_make_generated_tests(
>   gen_constant_array_size_tests_fp64.py
>   builtin_function_fp64.py)
>  piglit_make_generated_tests(
> + inout_fp64.list
> + gen_inout_fp64.py
> + templates/gen_inout_fp64/template.frag.mako
> + templates/gen_inout_fp64/template.vert.mako
> + templates/gen_inout_fp64/template.shader_test.mako
> + )
> +piglit_make_generated_tests(
>   shader_precision_tests.list
>   gen_shader_precision_tests.py
>   builtin_function.py
> @@ -173,6 +180,7 @@ add_custom_target(gen-gl-tests
>   interpolation-qualifier-built-in-
> variable.list
>   builtin_uniform_tests_fp64.list
>   constant_array_size_tests_fp64.list
> + inout_fp64.list
>   shader_precision_tests.list
>   shader_image_load_store_tests.list
>   variable_index_read_tests.list
> diff --git a/generated_tests/gen_inout_fp64.py
> b/generated_tests/gen_inout_fp64.py
> new file mode 100644
> index 000..844f2a9
> --- /dev/null
> +++ b/generated_tests/gen_inout_fp64.py
> @@ -0,0 +1,151 @@
> +# coding=utf-8
> +#
> +# Copyright © 2016 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

Re: [Piglit] [PATCH 0/8] Additional tests for ARB_gpu_shader_fp64 extension

2016-04-25 Thread Andres Gomez
On Tue, 2016-04-19 at 07:12 +1000, Dave Airlie wrote:
> On 18 April 2016 at 23:01, Andres Gomez  wrote:
> > 
> > Hi Dave,
> > 
> > can I, then, assume a "ack-b" from you for the all the patches but
> > the
> > 3/8 and 5/8?
> Yup, you should be able to run the SSBO one against softpipe now in
> master,

It seems not. I run today with current master and keeps skipping.

> I'm not sure why the GetUniform test would fail, probably should push
> it and we can
> investigate.

OK, thanks!

-- 
Br,

Andres



signature.asc
Description: This is a digitally signed message part
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] shader_runner: Same method to get u/int based type uniforms

2016-04-25 Thread Andres Gomez
u/ivec* was already support to read hexadecimals. Now, this is also
supported for u/int uniforms.

Signed-off-by: Andres Gomez 
---
 tests/shaders/shader_runner.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 239735c..eb63ba4 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1687,14 +1687,13 @@ set_uniform(const char *line, int ubo_array_index)
glUniform1fv(loc, 1, f);
return;
} else if (string_match("int", type)) {
-   int val = atoi(line);
-   glUniform1i(loc, val);
+   get_ints(line, ints, 1);
+   glUniform1iv(loc, 1, ints);
return;
} else if (string_match("uint", type)) {
-   unsigned val;
check_unsigned_support();
-   val = strtoul(line, NULL, 0);
-   glUniform1ui(loc, val);
+   get_uints(line, uints, 1);
+   glUniform1uiv(loc, 1, uints);
return;
} else if (string_match("double", type)) {
check_double_support();
-- 
2.8.0.rc3

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


[Piglit] [PATCH] shader_runner: allow GL_MAX_VERTEX_ATTRIBS in requirements

2016-04-25 Thread Andres Gomez
Signed-off-by: Andres Gomez 
---
 tests/shaders/shader_runner.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 239735c..2f6bec8 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -89,6 +89,7 @@ static struct component_version glsl_req_version;
 static int gl_max_vertex_output_components;
 static int gl_max_fragment_uniform_components;
 static int gl_max_vertex_uniform_components;
+static int gl_max_vertex_attribs;
 static int gl_max_varying_components;
 static int gl_max_clip_planes;
 
@@ -724,6 +725,11 @@ process_requirement(const char *line)
"vertex uniform components",
},
{
+   "GL_MAX_VERTEX_ATTRIBS",
+   &gl_max_vertex_attribs,
+   "vertex attribs",
+   },
+   {
"GL_MAX_VARYING_COMPONENTS",
&gl_max_varying_components,
"varying components",
@@ -3323,9 +3329,12 @@ piglit_init(int argc, char **argv)
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS,
  &gl_max_fragment_uniform_components);
if (piglit_get_gl_version() >= 20 ||
-   piglit_is_extension_supported("GL_ARB_vertex_shader"))
+   piglit_is_extension_supported("GL_ARB_vertex_shader")) {
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS,
  &gl_max_vertex_uniform_components);
+   glGetIntegerv(GL_MAX_VERTEX_ATTRIBS,
+ &gl_max_vertex_attribs);
+   }
if (piglit_get_gl_version() >= 30 ||
piglit_is_extension_supported("GL_ARB_geometry_shader4") ||
piglit_is_extension_supported("GL_EXT_geometry_shader4"))
@@ -3346,6 +3355,12 @@ piglit_init(int argc, char **argv)
gl_max_vertex_uniform_components *= 4;
gl_max_varying_components *= 4;
gl_max_clip_planes = 0;
+#if defined(PIGLIT_USE_OPENGL_ES3) || defined(PIGLIT_USE_OPENGL_ES2)
+   glGetIntegerv(GL_MAX_VERTEX_ATTRIBS,
+ &gl_max_vertex_attribs);
+#else
+   gl_max_vertex_attribs = 16;
+#endif
 #endif
if (argc < 2) {
printf("usage: shader_runner \n");
-- 
2.8.0.rc3

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


[Piglit] [PATCH] util: Add array_index support to [vertex data]

2016-04-25 Thread Andres Gomez
This allows data to be set for arbitrary array sized attributes in
shader runner.

For example to set mat2x3[2]:
attname[0]/mat2x3/3/1 attname[0]/mat2x3/3/2 attname[1]/mat2x3/3/1 
attname[1]/mat2x3/3/2

The syntax has been extended so the recommended type to specify in the
[vertex data] header line is the GLSL corresponding one, not just
"float", "double", "int" or "uint".

In any case, the extended syntax is backward compatible so it is still
possible to specify a vec3 attribute like:
attname/float/3

In addition to the now recommended format:
attname/vec3/3

Signed-off-by: Andres Gomez 
---
 tests/util/piglit-vbo.cpp | 154 +++---
 1 file changed, 118 insertions(+), 36 deletions(-)

diff --git a/tests/util/piglit-vbo.cpp b/tests/util/piglit-vbo.cpp
index 11a4adc..749a1ed 100644
--- a/tests/util/piglit-vbo.cpp
+++ b/tests/util/piglit-vbo.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2011 Intel Corporation
+ * Copyright © 2011, 2016 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -28,29 +28,33 @@
  * tests using a columnar text format, for example:
  *
  *   \verbatim
- *   vertex/float/3 foo/uint/1 bar/int/2
- *   0.0 0.0 0.010 0 0 # comment
- *   0.0 1.0 0.0 5 1 1
- *   1.0 1.0 0.0 0 0 1
+ *   vertex/vec3/3 foo/uint/1 bar[0]/int/1 bar[1]/int/1
+ *   0.0 0.0 0.0   10 00 # comment
+ *   0.0 1.0 0.05 11
+ *   1.0 1.0 0.00 01
  *   \endverbatim
  *
  * The format consists of a row of column headers followed by any
  * number of rows of data.  Each column header has the form
- * "ATTRNAME/TYPE/COUNT/MATRIX_COLUMN", where ATTRNAME is the name of
- * the vertex attribute to be bound to this column, TYPE is the type
- * of data that follows ("float", "int", or "uint"), COUNT is the
- * vector length of the data (e.g. "3" for vec3 data) and
- * MATRIX_COLUMN is the column number of the data in case of being a
- * matrix. MATRIX_COLUMN can also be used for arrays of
- * arrays. MATRIX_COLUMN doesn't need to be be specified if it is not
- * a matrix column as in the example before. So another example, if
- * you want to specify the data of a mat2x3:
+ * "ATTRNAME[ARRAY_INDEX]/TYPE/COUNT/MATRIX_COLUMN", where ATTRNAME is
+ * the name of the vertex attribute to be bound to this column,
+ * ARRAY_INDEX is the index, TYPE is the GLSL type of data that
+ * follows ("float", "double", "int", "uint" or any derived type like
+ * vec2, dmat4, etc.), COUNT is the vector length of the data
+ * (e.g. "3" for vec3 data or "2" for mat4x2) and MATRIX_COLUMN is the
+ * column number of the data in case of being a matrix. [ARRAY_INDEX]
+ * is optional and needs to be specified only in case of array
+ * attributes. COUNT is a redundant value that is already specified in
+ * the data type but that has been kept for backward
+ * compatibility. MATRIX_COLUMN doesn't need to be specified if it is
+ * not a matrix column as in the example before. So another example,
+ * if you want to specify the data of a mat2x3:
  *
- *  \verbatim
- *  foomatrix/float/3/0 foomatrix/float/3/1
- *  0.0 1.0 2.0 3.0 4.0 5.0
- *  6.0 7.0 8.0 9.0 10.0 11.0
- *  \endverbatim
+ *   \verbatim
+ *   foomatrix/mat2x3/3/0 foomatrix/mat2x3/3/1
+ *   0.0 1.0 2.0  3.0 4.0 5.0
+ *   6.0 7.0 8.0  9.0 10.0 11.0
+ *   \endverbatim
  *
  * The data follows the column headers in space-separated form.  "#"
  * can be used for comments, as in shell scripts.
@@ -95,6 +99,23 @@
  * glEnableVertexAttribArray(foo_index);
  * glEnableVertexAttribArray(bar_index);
  * \endcode
+ *
+ * Which could correspond to a vertex shader of this type:
+ *
+ * \code
+ * in vec3 vertex;
+ * in uint foo;
+ * in int bar[2];
+ *
+ * void main()
+ * {
+ *  if (bar[0] + bar[1] == foo) {
+ *   gl_Position = vec4(vertex, 1.0);
+ *  } else {
+ *   gl_Position = vec4(1.0, vertex);
+ *  }
+ * }
+ * \endcode
  */
 
 #include 
@@ -116,7 +137,7 @@ const int ATTRIBUTE_SIZE = 4;
  * Convert a type name string to a GLenum.
  */
 GLenum
-decode_type(const char *type)
+decode_type(const char *type, size_t *rows, size_t *cols)
 {
static struct type_table_entry {
const char *type; /* NULL means end of table */
@@ -126,13 +147,38 @@ decode_type(const char *type)
{ "uint",GL_UNSIGNED_INT   },
{ "float",   GL_FLOAT  },
{ "double",  GL_DOUBLE },
+   { "ivec",GL_INT},
+   { "uvec",GL_UNSIGNED_INT   },
+   { "vec", GL_FLOAT  },
+   { "dvec",GL_DOUBLE },
+   { "mat", GL_FLOAT  },
+   { "dmat",GL_DOUBLE },
{ NULL,  0 }
};
 
 
for (int i = 0; type_t

[Piglit] [PATCH] util: Wrappers to load hex values for floats

2016-04-25 Thread Andres Gomez
For some cases we want to have shaders where we load an exact bit
pattern into a float or double. We already have this in place for
uniforms. Now, the methods have been refactorized so they can be used in
VBOs too.

Signed-off-by: Andres Gomez 
---
 tests/shaders/shader_runner.c | 35 +--
 tests/util/piglit-util.h  | 48 +++
 tests/util/piglit-vbo.cpp |  9 
 3 files changed, 58 insertions(+), 34 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 239735c..e0d3416 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 
+#include "piglit-util.h"
 #include "piglit-util-gl.h"
 #include "piglit-vbo.h"
 
@@ -1371,21 +1372,8 @@ get_floats(const char *line, float *f, unsigned count)
 {
unsigned i;
 
-   for (i = 0; i < count; i++) {
-   line = eat_whitespace(line);
-
-   if (strncmp(line, "0x", 2) == 0) {
-   union {
-   uint32_t u;
-   float f;
-   } x;
-
-   x.u = strtoul(line, (char **) &line, 16);
-   f[i] = x.f;
-   } else {
-   f[i] = strtod_inf(line, (char **) &line);
-   }
-   }
+   for (i = 0; i < count; i++)
+   f[i] = strtof_hex(line, (char **) &line);
 }
 
 static void
@@ -1393,21 +1381,8 @@ get_doubles(const char *line, double *d, unsigned count)
 {
unsigned i;
 
-   for (i = 0; i < count; i++) {
-   line = eat_whitespace(line);
-
-   if (strncmp(line, "0x", 2) == 0) {
-   union {
-   uint64_t u64;
-   double d;
-   } x;
-
-   x.u64 = strtoull(line, (char **) &line, 16);
-   d[i] = x.d;
-   } else {
-   d[i] = strtod_inf(line, (char **) &line);
-   }
-   }
+   for (i = 0; i < count; i++)
+   d[i] = strtod_hex(line, (char **) &line);
 }
 
 
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 985ebbd..1e57215 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -221,6 +221,54 @@ strtod_inf(const char *nptr, char **endptr)
return strtod(nptr, endptr);
 }
 
+/**
+ * Wrapper for strtod_inf() which allows using an exact hex bit
+ * pattern to generate a float value.
+ */
+static inline float
+strtof_hex(const char *nptr, char **endptr)
+{
+   /* skip spaces and tabs */
+   while (*nptr == ' ' || *nptr == '\t')
+   nptr++;
+
+   if (strncmp(nptr, "0x", 2) == 0) {
+   union {
+   uint32_t u;
+   float f;
+   } x;
+
+   x.u = strtoul(nptr, endptr, 16);
+   return x.f;
+   } else {
+   return strtod_inf(nptr, endptr);
+   }
+}
+
+/**
+ * Wrapper for strtod_inf() which allows using an exact hex bit
+ * pattern to generate a double value.
+ */
+static inline double
+strtod_hex(const char *nptr, char **endptr)
+{
+   /* skip spaces and tabs */
+   while (*nptr == ' ' || *nptr == '\t')
+   nptr++;
+
+   if (strncmp(nptr, "0x", 2) == 0) {
+   union {
+   uint64_t u64;
+   double d;
+   } x;
+
+   x.u64 = strtoull(nptr, endptr, 16);
+   return x.d;
+   } else {
+   return strtod_inf(nptr, endptr);
+   }
+}
+
 #ifndef HAVE_STRCHRNUL
 static inline char *
 strchrnul(const char *s, int c)
diff --git a/tests/util/piglit-vbo.cpp b/tests/util/piglit-vbo.cpp
index 11a4adc..5147234 100644
--- a/tests/util/piglit-vbo.cpp
+++ b/tests/util/piglit-vbo.cpp
@@ -102,6 +102,7 @@
 #include 
 #include 
 
+#include "piglit-util.h"
 #include "piglit-util-gl.h"
 #include "piglit-vbo.h"
 
@@ -271,16 +272,16 @@ vertex_attrib_description::parse_datum(const char **text, 
void *data) const
errno = 0;
switch (this->data_type) {
case GL_FLOAT: {
-   double value = strtod(*text, &endptr);
+   float value = strtof_hex(*text, &endptr);
if (errno == ERANGE) {
-   printf("Could not parse as double\n");
+   printf("Could not parse as float\n");
return false;
}
-   *((GLfloat *) data) = (float) value;
+   *((GLfloat *) data) = value;
break;
}
case GL_DOUBLE: {
-   double value = strtod(*text, &endptr);
+   double value = strtod_hex(*text, &endptr);
if (errno == ERANGE) {
printf("Could not parse as double\n");
return