[Piglit] [PATCH v2 0/2] Vulkan testing with VkRunner

2018-11-03 Thread Neil Roberts
Here is a second attempt at incorporating VkRunner into Piglit. This
time, instead of copying the source code into Piglit, it now just
executes the VkRunner executable is an external dependency. I think
there is now more interest in maintaining VkRunner as a separate repo
because it may later be integrated into other testing frameworks as
well such as CTS.

If the executable is not found then Piglit will automatically report
the test as skipped. It will normally be searched for in the PATH, but
its location can be overridden with the PIGLIT_VKRUNNER_BINARY
environment variable.

The VkRunner repo can be found here:
https://github.com/igalia/vkrunner

In the meantime since the last patch series, VkRunner has been
continuously developed and has gained features. Notably for Piglit, it
now works on Windows including building with Visual Studio. It has
also switched to using CMake for the build system.

Neil Roberts (2):
  framework: Add a vulkan tests profile
  vulkan: Add some tests for glsl450 builtin functions using doubles

 framework/test/piglit_test.py | 17 
 tests/vulkan.py   | 33 +++
 .../face-forward-double.vk_shader_test| 88 +++
 .../glsl450/frexp-double.vk_shader_test   | 61 +
 .../glsl450/isinf-double.vk_shader_test   | 81 +
 .../glsl450/reflect-double.vk_shader_test | 55 
 .../glsl450/refract-double.vk_shader_test | 88 +++
 7 files changed, 423 insertions(+)
 create mode 100644 tests/vulkan.py
 create mode 100644 tests/vulkan/glsl450/face-forward-double.vk_shader_test
 create mode 100644 tests/vulkan/glsl450/frexp-double.vk_shader_test
 create mode 100644 tests/vulkan/glsl450/isinf-double.vk_shader_test
 create mode 100644 tests/vulkan/glsl450/reflect-double.vk_shader_test
 create mode 100644 tests/vulkan/glsl450/refract-double.vk_shader_test

-- 
2.17.1

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


[Piglit] [PATCH v3 1/2] framework: Add a vulkan tests profile

2018-11-03 Thread Neil Roberts
This searches for files named *.vk_shader_test in the tests/vulkan
directory and runs them with VkRunner. VkRunner is executed as an
external dependency. It is found either in the path or by setting the
PIGLIT_VKRUNNER_BINARY environment variable.

v2: Move VkShaderTest to piglit_test.py and rename to VkRunnerTest.
Add future imports. Remove unused import.
v3: Support the PIGLIT_VKRUNNER_BINARY variable to specify the
location of VkRunner.
---
 framework/test/piglit_test.py | 17 +
 tests/vulkan.py   | 33 +
 2 files changed, 50 insertions(+)
 create mode 100644 tests/vulkan.py

diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py
index f52915d18..e56f3a37d 100644
--- a/framework/test/piglit_test.py
+++ b/framework/test/piglit_test.py
@@ -44,6 +44,7 @@ __all__ = [
 'PiglitCLTest',
 'PiglitGLTest',
 'PiglitBaseTest',
+'VkRunnerTest',
 'CL_CONCURRENT',
 'ROOT_DIR',
 'TEST_BIN_DIR',
@@ -229,3 +230,19 @@ class CLProgramTester(PiglitCLTest):
 command = super(CLProgramTester, self).command
 command.insert(1, os.path.join(ROOT_DIR, self.filename))
 return command
+
+
+class VkRunnerTest(PiglitBaseTest):
+""" Make a PiglitTest instance for a VkRunner shader test file """
+
+def __init__(self, filename):
+super(VkRunnerTest, self).__init__(
+[os.getenv('PIGLIT_VKRUNNER_BINARY', 'vkrunner'), filename],
+run_concurrent=True)
+
+@PiglitBaseTest.command.getter
+def command(self):
+# This is overriden because we don’t want PiglitBaseTest to
+# prepend TEST_BIN_DIR so that it will look for vkrunner in
+# the search path.
+return self._command
diff --git a/tests/vulkan.py b/tests/vulkan.py
new file mode 100644
index 0..7058f3108
--- /dev/null
+++ b/tests/vulkan.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""All Vulkan tests that come with piglit, using default settings."""
+
+from __future__ import (
+absolute_import, division, print_function, unicode_literals
+)
+
+import os
+
+from framework.profile import TestProfile
+from framework import grouptools
+from framework.test.piglit_test import VkRunnerTest
+from .py_modules.constants import TESTS_DIR, GENERATED_TESTS_DIR
+
+__all__ = ['profile']
+
+profile = TestProfile()
+
+# Find and add all shader tests.
+for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
+_basedir = os.path.join(basedir, 'vulkan')
+for dirpath, _, filenames in os.walk(_basedir):
+groupname = grouptools.from_path(os.path.relpath(dirpath, _basedir))
+for filename in filenames:
+testname, ext = os.path.splitext(filename)
+if ext != '.vk_shader_test':
+continue
+test = VkRunnerTest(os.path.join(dirpath, filename))
+group = grouptools.join(groupname, testname)
+assert group not in profile.test_list, group
+
+profile.test_list[group] = test
-- 
2.17.1

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


[Piglit] [PATCH 2/2] vulkan: Add some tests for glsl450 builtin functions using doubles

2018-11-03 Thread Neil Roberts
---
 .../face-forward-double.vk_shader_test| 88 +++
 .../glsl450/frexp-double.vk_shader_test   | 61 +
 .../glsl450/isinf-double.vk_shader_test   | 81 +
 .../glsl450/reflect-double.vk_shader_test | 55 
 .../glsl450/refract-double.vk_shader_test | 88 +++
 5 files changed, 373 insertions(+)
 create mode 100644 tests/vulkan/glsl450/face-forward-double.vk_shader_test
 create mode 100644 tests/vulkan/glsl450/frexp-double.vk_shader_test
 create mode 100644 tests/vulkan/glsl450/isinf-double.vk_shader_test
 create mode 100644 tests/vulkan/glsl450/reflect-double.vk_shader_test
 create mode 100644 tests/vulkan/glsl450/refract-double.vk_shader_test

diff --git a/tests/vulkan/glsl450/face-forward-double.vk_shader_test 
b/tests/vulkan/glsl450/face-forward-double.vk_shader_test
new file mode 100644
index 0..3ad439059
--- /dev/null
+++ b/tests/vulkan/glsl450/face-forward-double.vk_shader_test
@@ -0,0 +1,88 @@
+[require]
+shaderFloat64
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 430
+
+layout(std140, push_constant) uniform block {
+dvec2 arg0;
+dvec2 arg1;
+dvec2 arg2;
+double tolerance;
+dvec2 expected;
+};
+
+layout(location = 0) out vec4 color_out;
+
+void
+main()
+{
+dvec2 result = faceforward(arg0, arg1, arg2);
+
+color_out = (distance(result, expected) <= tolerance ?
+ vec4(0.0, 1.0, 0.0, 1.0) :
+ vec4(1.0, 0.0, 0.0, 1.0));
+}
+
+[test]
+clear color 0.0 0.0 1.0 0.0
+clear
+
+uniform dvec2 0 -0.10001 -1.2
+uniform dvec2 16 -0.10001 -1.2
+uniform dvec2 32 -0.10001 -1.2
+uniform dvec2 64 0.10001 1.2
+uniform double 48 1.2041594578792297e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.10001 -1.2
+uniform dvec2 16 -0.10001 -1.2
+uniform dvec2 32 -0.41998 0.47998
+uniform dvec2 64 -0.10001 -1.2
+uniform double 48 1.2041594578792297e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.10001 -1.2
+uniform dvec2 16 -0.41998 0.47998
+uniform dvec2 32 -0.10001 -1.2
+uniform dvec2 64 -0.10001 -1.2
+uniform double 48 1.2041594578792297e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.10001 -1.2
+uniform dvec2 16 -0.41998 0.47998
+uniform dvec2 32 -0.41998 0.47998
+uniform dvec2 64 0.10001 1.2
+uniform double 48 1.2041594578792297e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.41998 0.47998
+uniform dvec2 16 -0.10001 -1.2
+uniform dvec2 32 -0.10001 -1.2
+uniform dvec2 64 0.41998 -0.47998
+uniform double 48 6.3780874876407897e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.41998 0.47998
+uniform dvec2 16 -0.10001 -1.2
+uniform dvec2 32 -0.41998 0.47998
+uniform dvec2 64 -0.41998 0.47998
+uniform double 48 6.3780874876407897e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.41998 0.47998
+uniform dvec2 16 -0.41998 0.47998
+uniform dvec2 32 -0.10001 -1.2
+uniform dvec2 64 -0.41998 0.47998
+uniform double 48 6.3780874876407897e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.41998 0.47998
+uniform dvec2 16 -0.41998 0.47998
+uniform dvec2 32 -0.41998 0.47998
+uniform dvec2 64 0.41998 -0.47998
+uniform double 48 6.3780874876407897e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/vulkan/glsl450/frexp-double.vk_shader_test 
b/tests/vulkan/glsl450/frexp-double.vk_shader_test
new file mode 100644
index 0..1fbae50b1
--- /dev/null
+++ b/tests/vulkan/glsl450/frexp-double.vk_shader_test
@@ -0,0 +1,61 @@
+[require]
+shaderFloat64
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 430
+
+layout(location = 0) out vec4 color;
+
+layout(std140, push_constant) uniform block {
+dvec4 given_doub;
+dvec4 expected_mantissa;
+ivec4 expected_exponent;
+};
+
+void main()
+{
+   /* Green if both pass. */
+   color = vec4(0.0, 1.0, 0.0, 1.0);
+
+   ivec4 exponent;
+   dvec4 mantissa;
+
+   mantissa = frexp(given_doub, exponent);
+
+   if (mantissa != expected_mantissa) {
+   color.r = 1.0;
+   }
+
+   if (exponent != expected_exponent) {
+   color.b = 1.0;
+   }
+}
+
+[test]
+uniform dvec4 0 0.0 -0.0 0.5 -0.5
+uniform dvec4 32 0.0 -0.0 0.5 -0.5
+uniform ivec4