[Piglit] [PATCH] unittests: include new elapsed time from the console summary output

2017-11-03 Thread Andres Gomez
Fixes: e76ecd048 ("framework: also print elapsed time with piglit-summary.py")

Cc: Brian Paul 
Cc: Dylan Baker 
Signed-off-by: Andres Gomez 
---
 unittests/framework/summary/test_console.py | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/unittests/framework/summary/test_console.py 
b/unittests/framework/summary/test_console.py
index 0f7b06772..6e6ae8a7d 100644
--- a/unittests/framework/summary/test_console.py
+++ b/unittests/framework/summary/test_console.py
@@ -53,6 +53,7 @@ _ENUMS = {
 13: 'fixes',
 14: 'regressions',
 15: 'total',
+16: 'time',
 }
 
 class TestPrintSummary(object):
@@ -67,11 +68,11 @@ class TestPrintSummary(object):
 """
 names = [grouptools.join('foo', 'bar', 'oink', 'foobar', 'boink'),
  'foo', 'bar']
-template = '{: >20.20} {: >6.6}'
+template = '{: >20.20} {: >12.12}'
 
 expected = console_._SUMMARY_TEMPLATE.format(
-names=' '.join(['this is a really rea', 'a name']),
-divider=' '.join(['', '--']),
+names=' '.join(['this is a really rea', 'another name']),
+divider=' '.join(['', '']),
 pass_=template.format('1', '2'),
 fail=template.format('2', '0'),
 crash=template.format('0', '0'),
@@ -84,7 +85,8 @@ class TestPrintSummary(object):
 changes=template.format('0', '2'),
 fixes=template.format('0', '1'),
 regressions=template.format('0', '0'),
-total=template.format('3', '3')).split('\n')
+total=template.format('3', '3'),
+time=template.format('00:01:39', '02:14:05')).split('\n')
 
 res1 = results.TestrunResult()
 res1.name = 'this is a really really really really long name'
@@ -92,14 +94,16 @@ class TestPrintSummary(object):
 res1.tests[names[1]] = results.TestResult('fail')
 res1.tests[names[2]] = results.TestResult('notrun')
 res1.tests[names[2]].subtests['1'] = 'fail'
+res1.time_elapsed = results.TimeAttribute(1509747121.4873962, 
1509747220.544042)
 res1.calculate_group_totals()
 
 res2 = results.TestrunResult()
-res2.name = 'a name'
+res2.name = 'another name'
 res2.tests[names[0]] = results.TestResult('pass')
 res2.tests[names[1]] = results.TestResult('pass')
 res2.tests[names[2]] = results.TestResult('notrun')
 res2.tests[names[2]].subtests['1'] = 'skip'
+res2.time_elapsed = results.TimeAttribute(1464820707.4581327, 
1464828753.201948)
 res2.calculate_group_totals()
 
 reses = common.Results([res1, res2])
-- 
2.14.2

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


[Piglit] [PATCH 5/7] cl: Adjust sincos expected values to account for fp32 rounding

2017-11-03 Thread Jan Vesely
Signed-off-by: Jan Vesely 
---
 generated_tests/gen_cl_math_builtins.py | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/generated_tests/gen_cl_math_builtins.py 
b/generated_tests/gen_cl_math_builtins.py
index bd1a859b7..149322ca6 100644
--- a/generated_tests/gen_cl_math_builtins.py
+++ b/generated_tests/gen_cl_math_builtins.py
@@ -674,8 +674,10 @@ tests = {
 'arg_types' : [F, F, F],
 'function_type': 'ttt',
 'values' : [
-[0.0, 1.0,   0.0, -1.0,   0.0,sin(2.234567), sin(7), 
sin(8), sin(pow(2,20)), sin(pow(2,24)), sin(pow(2,120)), float("nan")], # 
Result0
-[1.0, 0.0,-1.0, 0.0,1.0,cos(1.12345), cos(7), 
cos(8), cos(pow(2,20)), cos(pow(2,24)), cos(pow(2,120)), float("nan")], # 
Result1
+[0.0, 1.0,   sin(M_PI_F), -1.0,   sin(2 * M_PI_F),
sin(2.234567), sin(7), sin(8), sin(pow(2,20)), sin(pow(2,24)), sin(pow(2,120)), 
float("nan")], # Result0
+# using libm cosf(3.0f * M_PI / 2.0f) == 0x1.99bc5cp-27
+# this is different form what python gives us
+[1.0, cos(M_PI_F / 2),-1.0, float.fromhex('0x1.99bc5cp-27'),   
 1.0,cos(2.234567), cos(7), cos(8), cos(pow(2,20)), cos(pow(2,24)), 
cos(pow(2,120)), float("nan")], # Result1
 [0.0, pi / 2, pi, 3 * pi / 2, 2 * pi, 2.234567, 7, 8, pow(2,20), 
pow(2,24), pow(2,120), float("nan")] # Arg0
 ],
 'tolerance': 4,
-- 
2.13.6

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


[Piglit] [PATCH 7/7] cl: Fix sinpi expected values

2017-11-03 Thread Jan Vesely
account for fp32 rounding.
sinpi(n) should return 0 for any integer n

Signed-off-by: Jan Vesely 
---
 generated_tests/gen_cl_math_builtins.py | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/generated_tests/gen_cl_math_builtins.py 
b/generated_tests/gen_cl_math_builtins.py
index a4cae5314..98950c3ac 100644
--- a/generated_tests/gen_cl_math_builtins.py
+++ b/generated_tests/gen_cl_math_builtins.py
@@ -696,12 +696,11 @@ tests = {
 'arg_types' : [F, F],
 'function_type': 'ttt',
 'values' : [
-[0.0, 0.0, sin(pi*pi/2), sin(pi*3*pi/2), sin(2*pi*pi),
- sin(pi*1.12345), sin(pi*7), sin(pi*8), sin(pi*pow(2,20)),
- sin(pi*pow(2,24)), sin(pi*pow(2,120)), float("nan")],#Result
+[0.0, 0.0, sin(pi*pi/2), sin(pi*3*pi/2), sin(2* M_PI_F * pi),
+ sin(pi*1.12345), 0.0, 0.0, 0.0, 0.0, 0.0, float("nan")],#Result
 [0.0, 1.0, pi / 2,   3 * pi / 2, 2 * pi,
- 1.12345, 7, 8, pow(2,20),
- pow(2,24), pow(2,120), float("nan")] #Arg0
+ 1.12345, 7.0, 8.0, pow(2,20), pow(2,24), pow(2,120),
+ float("nan")] #Arg0
 ],
 'tolerance' : 4
 },
-- 
2.13.6

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


[Piglit] [PATCH 3/7] cl: Adjust tanpi epxected results to account for fp32 rounding

2017-11-03 Thread Jan Vesely
Signed-off-by: Jan Vesely 
---
 generated_tests/gen_cl_math_builtins.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/generated_tests/gen_cl_math_builtins.py 
b/generated_tests/gen_cl_math_builtins.py
index 5bbc72a0a..e6abbf50a 100644
--- a/generated_tests/gen_cl_math_builtins.py
+++ b/generated_tests/gen_cl_math_builtins.py
@@ -734,8 +734,9 @@ tests = {
 'arg_types': [F, F],
 'function_type': 'ttt',
 'values': [
-[0.0, 1.0,  0.0, sqrt(3), -1.0,   tan(pi * 2.234567), float("nan") 
], # Result
-[0.0, 1/4, 1,  1/3,3/4, 2.234567 , float("nan") ], # Arg1
+#fp32 representation of 2.234567 is 0x1.1e064ap+1
+[0.0, 1.0,  0.0, sqrt(3), -1.0,   tan(M_PI_F * 
float.fromhex('0x1.1e064ap+1')), float("nan") ], # Result
+[0.0, 1/4, 1,  1/3,3/4, 2.234567, float("nan") ], # Arg1
 ],
 'tolerance': 6
 },
-- 
2.13.6

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


[Piglit] [PATCH 2/7] cl: Adjust tan expected values to account for fp32 rounding

2017-11-03 Thread Jan Vesely
Signed-off-by: Jan Vesely 
---
 generated_tests/gen_cl_math_builtins.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/generated_tests/gen_cl_math_builtins.py 
b/generated_tests/gen_cl_math_builtins.py
index 726ac9652..5bbc72a0a 100644
--- a/generated_tests/gen_cl_math_builtins.py
+++ b/generated_tests/gen_cl_math_builtins.py
@@ -716,8 +716,8 @@ tests = {
 'arg_types': [F, F],
 'function_type': 'ttt',
 'values': [
-[0.0, 1.0,  0.0, sqrt(3), -1.0,   tan(2.234567), float("nan") ], # 
Result
-[0.0, pi/4, pi,  pi/3,3*pi/4, 2.234567 , float("nan") ], # 
Arg1
+[0.0, 1.0,  tan(M_PI_F), sqrt(3), -1.0,   tan(2.234567), 
float("nan") ], # Result
+[0.0, pi/4, M_PI_F,  pi/3,3*pi/4, 2.234567 , float("nan") 
], # Arg1
 ],
 'tolerance': 5
 },
-- 
2.13.6

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


[Piglit] [PATCH 6/7] cl: Adjust cospi expected values to account for fp32 rounding

2017-11-03 Thread Jan Vesely
Signed-off-by: Jan Vesely 
---
 generated_tests/gen_cl_math_builtins.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/generated_tests/gen_cl_math_builtins.py 
b/generated_tests/gen_cl_math_builtins.py
index 149322ca6..a4cae5314 100644
--- a/generated_tests/gen_cl_math_builtins.py
+++ b/generated_tests/gen_cl_math_builtins.py
@@ -271,7 +271,7 @@ tests = {
 'arg_types' : [F, F],
 'function_type': 'ttt',
 'values' : [
-[1.0, cos(pi*pi/2), cos(pi*3*pi/2), cos(2*pi*pi), cos(pi*1.12345), 
cos(pi*pow(2,20)), cos(pi*pow(2,24)), 1.0, float("nan")], # Result
+[1.0, cos(pi * M_PI_F / 2), cos(pi*3*pi/2), cos(2 * M_PI_F * pi), 
cos(pi*1.12345), cos(pi*pow(2,20)), cos(pi*pow(2,24)), 1.0, float("nan")], # 
Result
 [0.0, pi / 2,   3 * pi / 2, 2 * pi,   1.12345, 
pow(2,20), pow(2,24), pow(2,120), float("nan")]  # Arg0
 ],
 'tolerance' : 4
-- 
2.13.6

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


[Piglit] [PATCH 1/7] cl: Adjust cos test expected values to account for fp32 rounding

2017-11-03 Thread Jan Vesely
using libm cosf(3.0f * M_PI / 2.0f) == 0x1.99bc5cp-27

Signed-off-by: Jan Vesely 
---
 generated_tests/gen_cl_math_builtins.py | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/generated_tests/gen_cl_math_builtins.py 
b/generated_tests/gen_cl_math_builtins.py
index 47a1a1eb5..726ac9652 100644
--- a/generated_tests/gen_cl_math_builtins.py
+++ b/generated_tests/gen_cl_math_builtins.py
@@ -114,6 +114,8 @@ U = {
 'float' : 'uint'
 }
 
+M_PI_F = float.fromhex('0x1.921fb6p+1')
+
 def quo(x, y):
 return int(round(x/y))
 
@@ -249,8 +251,10 @@ tests = {
 'arg_types' : [F, F],
 'function_type': 'ttt',
 'values' : [
-[1.0, 0.0,-1.0, 0.0,1.0,cos(1.12345), cos(7), 
cos(8), cos(pow(2,20)), cos(pow(2,24)), cos(pow(2,120)), float("nan")], # Result
-[0.0, pi / 2, pi,   3 * pi / 2, 2 * pi, 1.12345, 7, 8, pow(2,20), 
pow(2,24), pow(2,120), float("nan")] # Arg0
+# using libm cosf(3.0f * M_PI / 2.0f) == 0x1.99bc5cp-27
+# this is different form what python gives us
+[1.0, cos(M_PI_F / 2),-1.0, float.fromhex('0x1.99bc5cp-27'),   
 1.0,cos(1.12345), cos(7), cos(8), cos(pow(2,20)), cos(pow(2,24)), 
cos(pow(2,120)), float("nan")], # Result
+[0.0, M_PI_F / 2, pi,   3 * M_PI_F / 2, 2 * pi, 1.12345, 7, 8, 
pow(2,20), pow(2,24), pow(2,120), float("nan")] # Arg0
 ],
 'tolerance' : 4
 },
-- 
2.13.6

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


[Piglit] [PATCH 4/7] cl: Adjust sin expected values to acount for fp32 rounding

2017-11-03 Thread Jan Vesely
Signed-off-by: Jan Vesely 
---
 generated_tests/gen_cl_math_builtins.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/generated_tests/gen_cl_math_builtins.py 
b/generated_tests/gen_cl_math_builtins.py
index e6abbf50a..bd1a859b7 100644
--- a/generated_tests/gen_cl_math_builtins.py
+++ b/generated_tests/gen_cl_math_builtins.py
@@ -665,7 +665,7 @@ tests = {
 'arg_types' : [F, F],
 'function_type': 'ttt',
 'values' : [
-[0.0, 1.0,   0.0, -1.0,   0.0,sin(2.234567), sin(7), 
sin(8), sin(pow(2,20)), sin(pow(2,24)), sin(pow(2,120)), float("nan")], # Result
+[0.0, 1.0,   sin(M_PI_F), -1.0,   sin(2 * M_PI_F),
sin(2.234567), sin(7), sin(8), sin(pow(2,20)), sin(pow(2,24)), sin(pow(2,120)), 
float("nan")], # Result
 [0.0, pi / 2, pi, 3 * pi / 2, 2 * pi, 2.234567, 7, 8, pow(2,20), 
pow(2,24), pow(2,120), float("nan")] # Arg0
 ],
 'tolerance': 4
-- 
2.13.6

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


Re: [Piglit] [PATCH] cmake: create Win10 manifest files for particular executables

2017-11-03 Thread Jose Fonseca

On 27/10/17 17:12, Brian Paul wrote:

On Windows10 (and possibly older versions), UAC (User Account Control)
intervenes when starting an executables with "patch", "update" or "setup"
in their name.  This requires the user to approve execution by clicking
in a dialog window (and even then, causes test failures).  With Cygwin,
you simply get "Permission Denied".

Currently, there are four Piglit tests which need this special treatment:
bin/arb_compute_shader-zero-dispatch-size
bin/arb_tessellation_shader-invalid-patch-vertices-range
bin/glsl-uniform-update
bin/mipmap-setup

A work-around is to create a manifest file for each effected executable.
This patch creates a .exe.manifest file if "foo" contains any of
the above strings.  There's no effect on non-Windows platforms.

Note: this solution uses the cmake file(GENERATE ...) function.  I think
add_custom_command() is probably the proper approach, but I've been
unsuccessful in getting that to work.
---
  cmake/piglit_util.cmake  | 30 ++
  cmake/win10-manifest.txt | 12 
  2 files changed, 42 insertions(+)
  create mode 100644 cmake/win10-manifest.txt

diff --git a/cmake/piglit_util.cmake b/cmake/piglit_util.cmake
index 411fa54..9b85761 100644
--- a/cmake/piglit_util.cmake
+++ b/cmake/piglit_util.cmake
@@ -58,6 +58,8 @@ endfunction(piglit_include_target_api)
  #
  function(piglit_add_executable name)
  
+piglit_create_manifest_file(${name})

+
  list(REMOVE_AT ARGV 0)
  add_executable(${name} ${ARGV})
  add_dependencies(${name} piglit_dispatch_gen)






@@ -89,3 +91,31 @@ function(piglit_add_library name)
  endif() >
  endfunction(piglit_add_library)
+
+
+# This is lame, but Windows 10 (and maybe Win8) asks for confirmation
+# before running .exe files containing the strings "patch", "setup",
+# "update", etc.  In Cygwin, we simply get "Permission Denied".
+# This causes the Piglit test to fail.
+# The work-around is to create a "manifest" file for such executables.
+# This function examines the target name and creates the manifest file
+# if needed.  The file will be named "${target}.exe.manifest".
+# See 
https://answers.microsoft.com/en-us/windows/forum/windows_7-security/uac-prompts-on-any-program-with-the-word-patch-or/c5359497-d16e-43c6-99f2-db3d8eecc9c0?auth=1
+function(piglit_create_manifest_file target)
+   if (WIN32)
+  # look for known strings
+  string(FIND ${target} "patch" r1)
+  string(FIND ${target} "setup" r2)
+  string(FIND ${target} "update" r3)
+
+  # if any of those strings is in the target filename
+  if((${r1} GREATER -1) OR (${r2} GREATER -1) OR (${r3} GREATER -1))
+   # XXX we should probably use add_custom_command() here to copy
+   # the manifest file, but I've been unsuccessful in getting
+   # that to work.
+   file(GENERATE
+OUTPUT bin/${target}.exe.manifest
+INPUT ${CMAKE_SOURCE_DIR}/cmake/win10-manifest.txt)


Neat. I hadn't realized the manifest files could exist as free standing 
.exe.manifest files (I presumed one would always have to build)


I think you'll need to add a

  install (FILES bin/${target}.exe.manifest DESTINATION 
${PIGLIT_INSTALL_LIBDIR}/bin)


inside piglit_add_executable() macro, so that the manifest files get 
copied and installed


I think things would probably get easier to do this if you merged 
piglit_create_manifest_file macro into the piglit_add_executable macro body.


Jose


+   endif()
+   endif()
+endfunction(piglit_create_manifest_file)
diff --git a/cmake/win10-manifest.txt b/cmake/win10-manifest.txt
new file mode 100644
index 000..5abd234
--- /dev/null
+++ b/cmake/win10-manifest.txt
@@ -0,0 +1,12 @@
+
+
+  
+
+  
+
+
+  
+
+  
+



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


Re: [Piglit] [PATCH v2] shaders: Test using a bound program after an unsuccessful relink

2017-11-03 Thread Neil Roberts
Oops, I used the wrong message ID in --in-reply-to. That’s what I get
for trying to be too clever with git-send-email. Sorry about that.

Regards,
- Neil

Neil Roberts  writes:

> Timothy Arceri  writes:
>
>> Thanks for the test! The idea is great, the only problem I see is
>> that the minimum GL version seems too high. This test would not run
>> on the i915 driver which is a problem IMO. Can you lower the
>> requirements?
>
> Good point. Here is a v2 that should work with GL2.0. However I’m not
> exactly sure what is the minimun requirements for i915. I read that
> the default version has been lowered to 1.4. Were you suggesting that
> it should go as low as using the GL_ARB_shader_objects extension? I
> guess there are two i915 drivers as well so I’m not sure which one you
> are referring to.
>
> Regards,
> - Neil
>
> -- >8 -- (use git am -c to cut here)
>
> If a bound program is relinked unsuccessfully it is supposed to keep
> the executable and the program state such as the uniforms. This adds a
> test for that which updates a uniform, does a failed relink and
> verifies that a render succeeds with the new uniform value. This is
> currently causing a use-after-free error in Mesa. The test has some
> redundant allocations to try and encourage it to fail which it does
> about 98% of the time.
>
> v2: Adapt to work with GL2.0. Change the order of the colours so that
> a successful run ends with green. Delete the program after use.
> ---
>  tests/all.py|   1 +
>  tests/shaders/CMakeLists.gl.txt |   1 +
>  tests/shaders/unsuccessful-relink.c | 203 
> 
>  3 files changed, 205 insertions(+)
>  create mode 100644 tests/shaders/unsuccessful-relink.c
>
> diff --git a/tests/all.py b/tests/all.py
> index 9e63fa9..ae4a995 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -624,6 +624,7 @@ with profile.test_list.group_manager(PiglitGLTest, 
> 'shaders') as g:
>  g(['point-vertex-id', 'gl_InstanceID', 'divisor'])
>  g(['point-vertex-id', 'gl_VertexID', 'gl_InstanceID', 'divisor'])
>  g(['glsl-vs-int-attrib'])
> +g(['unsuccessful-relink'])
>  g(['glsl-link-initializer-03'],
>'GLSL link two programs, global initializer')
>  g(['glsl-getactiveuniform-count',
> diff --git a/tests/shaders/CMakeLists.gl.txt b/tests/shaders/CMakeLists.gl.txt
> index 1c06843..7090d94 100644
> --- a/tests/shaders/CMakeLists.gl.txt
> +++ b/tests/shaders/CMakeLists.gl.txt
> @@ -164,5 +164,6 @@ piglit_add_executable (useshaderprogram-bad-program 
> useshaderprogram-bad-program
>  piglit_add_executable (useshaderprogram-flushverts-1 
> useshaderprogram-flushverts-1.c)
>  piglit_add_executable (version-mixing version-mixing.c)
>  piglit_add_executable (glsl-vs-int-attrib glsl-vs-int-attrib.c)
> +piglit_add_executable (unsuccessful-relink unsuccessful-relink.c)
>  
>  # vim: ft=cmake:
> diff --git a/tests/shaders/unsuccessful-relink.c 
> b/tests/shaders/unsuccessful-relink.c
> new file mode 100644
> index 000..b652fe9
> --- /dev/null
> +++ b/tests/shaders/unsuccessful-relink.c
> @@ -0,0 +1,203 @@
> +/*
> + * Copyright © 2017 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 unsuccessful-relink.c
> + *
> + * Render using a program with a uniform. Modify the uniform and then
> + * do a relink that will fail. This shouldn’t affect the original
> + * program and it should render with the new uniform value.
> + *
> + * GLSL 4.6 spec section 7.3:
> + *
> + * “If a program object that is active for any shader stage is
> + *  re-linked unsuccessfully, the link status will be set to FALSE,
> + *  but any existing executables and associated state will remain part
> + *  of the current rendering state until a subsequent call to
> + *  UseProgram, 

[Piglit] [PATCH v2] shaders: Test using a bound program after an unsuccessful relink

2017-11-03 Thread Neil Roberts
Timothy Arceri  writes:

> Thanks for the test! The idea is great, the only problem I see is
> that the minimum GL version seems too high. This test would not run
> on the i915 driver which is a problem IMO. Can you lower the
> requirements?

Good point. Here is a v2 that should work with GL2.0. However I’m not
exactly sure what is the minimun requirements for i915. I read that
the default version has been lowered to 1.4. Were you suggesting that
it should go as low as using the GL_ARB_shader_objects extension? I
guess there are two i915 drivers as well so I’m not sure which one you
are referring to.

Regards,
- Neil

-- >8 -- (use git am -c to cut here)

If a bound program is relinked unsuccessfully it is supposed to keep
the executable and the program state such as the uniforms. This adds a
test for that which updates a uniform, does a failed relink and
verifies that a render succeeds with the new uniform value. This is
currently causing a use-after-free error in Mesa. The test has some
redundant allocations to try and encourage it to fail which it does
about 98% of the time.

v2: Adapt to work with GL2.0. Change the order of the colours so that
a successful run ends with green. Delete the program after use.
---
 tests/all.py|   1 +
 tests/shaders/CMakeLists.gl.txt |   1 +
 tests/shaders/unsuccessful-relink.c | 203 
 3 files changed, 205 insertions(+)
 create mode 100644 tests/shaders/unsuccessful-relink.c

diff --git a/tests/all.py b/tests/all.py
index 9e63fa9..ae4a995 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -624,6 +624,7 @@ with profile.test_list.group_manager(PiglitGLTest, 
'shaders') as g:
 g(['point-vertex-id', 'gl_InstanceID', 'divisor'])
 g(['point-vertex-id', 'gl_VertexID', 'gl_InstanceID', 'divisor'])
 g(['glsl-vs-int-attrib'])
+g(['unsuccessful-relink'])
 g(['glsl-link-initializer-03'],
   'GLSL link two programs, global initializer')
 g(['glsl-getactiveuniform-count',
diff --git a/tests/shaders/CMakeLists.gl.txt b/tests/shaders/CMakeLists.gl.txt
index 1c06843..7090d94 100644
--- a/tests/shaders/CMakeLists.gl.txt
+++ b/tests/shaders/CMakeLists.gl.txt
@@ -164,5 +164,6 @@ piglit_add_executable (useshaderprogram-bad-program 
useshaderprogram-bad-program
 piglit_add_executable (useshaderprogram-flushverts-1 
useshaderprogram-flushverts-1.c)
 piglit_add_executable (version-mixing version-mixing.c)
 piglit_add_executable (glsl-vs-int-attrib glsl-vs-int-attrib.c)
+piglit_add_executable (unsuccessful-relink unsuccessful-relink.c)
 
 # vim: ft=cmake:
diff --git a/tests/shaders/unsuccessful-relink.c 
b/tests/shaders/unsuccessful-relink.c
new file mode 100644
index 000..b652fe9
--- /dev/null
+++ b/tests/shaders/unsuccessful-relink.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright © 2017 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 unsuccessful-relink.c
+ *
+ * Render using a program with a uniform. Modify the uniform and then
+ * do a relink that will fail. This shouldn’t affect the original
+ * program and it should render with the new uniform value.
+ *
+ * GLSL 4.6 spec section 7.3:
+ *
+ * “If a program object that is active for any shader stage is
+ *  re-linked unsuccessfully, the link status will be set to FALSE,
+ *  but any existing executables and associated state will remain part
+ *  of the current rendering state until a subsequent call to
+ *  UseProgram, UseProgramStages, or BindProgramPipeline removes them
+ *  from use.”
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+config.supports_gl_compat_version = 20;
+config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char vs_source[] =
+"attribute vec4 piglit_vertex;\n"
+"void main()\n"
+