[Piglit] [PATCH] shader_runner: some extra skip reasong logging

2019-06-12 Thread Alejandro Piñeiro
---
 tests/shaders/shader_runner.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 44aa5da37..a2a1d43fb 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1143,13 +1143,17 @@ process_requirement(const char *line)
 
if (parse_str(line, "GL_", NULL) &&
parse_word_copy(line, buffer, sizeof(buffer), )) {
-   if (!piglit_is_extension_supported(buffer))
+   if (!piglit_is_extension_supported(buffer)) {
+   printf("Test requires unsupported extension %s\n", 
buffer);
return PIGLIT_SKIP;
+   }
} else if (parse_str(line, "!", ) &&
   parse_str(line, "GL_", NULL) &&
   parse_word_copy(line, buffer, sizeof(buffer), )) {
-   if (piglit_is_extension_supported(buffer))
+   if (piglit_is_extension_supported(buffer)) {
+   printf("Test requires unsupported extension %s\n", 
buffer);
return PIGLIT_SKIP;
+   }
} else if (parse_str(line, "GLSL", )) {
enum comparison cmp;
 
@@ -4727,8 +4731,11 @@ piglit_init(int argc, char **argv)
 #endif
 
if (use_get_program_binary) {
-   if (gl_num_program_binary_formats == 0)
+   if (gl_num_program_binary_formats == 0) {
+   printf("Trying to use get_program_binary, but "
+  "GL_NUM_PROGRAM_BINARY == 0\n");
piglit_report_result(PIGLIT_SKIP);
+   }
}
 
/* Automatic mode can run multiple tests per session. */
-- 
2.19.1

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

[Piglit] [PATCH] tests/deqp: add configuration option to control caselist generation

2019-06-06 Thread Alejandro Piñeiro
Right now, each time any deqp-like profile ask for the case list, it
calls to generate the caselist. As by default it doesn't pass any
parameter, it creates all the possible caselist. And there are some
test sets (like khr_gles) that calls this method several time. On slow
machines this means a significant startup time.

This commit adds a envvar that allows to keep the current
behaviour. But if disabled, if the caselist already exists, compare
the creation times with the deqp binary. If the binary is older that
the caselist, it assumes that the caselist is recent enough, and skips
calling the caselist generation method.
---
 framework/test/deqp.py | 8 
 piglit.conf.example| 6 ++
 2 files changed, 14 insertions(+)

diff --git a/framework/test/deqp.py b/framework/test/deqp.py
index 5db2a922f..aea335079 100644
--- a/framework/test/deqp.py
+++ b/framework/test/deqp.py
@@ -66,6 +66,9 @@ _EXTRA_ARGS = get_option('PIGLIT_DEQP_EXTRA_ARGS',
  ('deqp', 'extra_args'),
  default='').split()
 
+force_caselist_regen = get_option('PIGLIT_DEQP_FORCE_CASELIST_REGEN',
+  ('deqp', 'force_caselist_regen'),
+  default='True')
 
 def select_source(bin_, filename, mustpass, extra_args):
 """Return either the mustpass list or the generated list."""
@@ -116,6 +119,11 @@ def gen_caselist_txt(bin_, caselist, extra_args):
 basedir = os.path.dirname(bin_)
 caselist_path = os.path.join(basedir, caselist)
 
+if (force_caselist_regen == 'False' and
+os.path.exists(caselist_path) and
+os.path.getmtime(caselist_path) > os.path.getmtime(bin_)):
+return caselist_path
+
 # TODO: need to catch some exceptions here...
 with open(os.devnull, 'w') as d:
 env = os.environ.copy()
diff --git a/piglit.conf.example b/piglit.conf.example
index 1877187df..5bb1ddff9 100644
--- a/piglit.conf.example
+++ b/piglit.conf.example
@@ -37,6 +37,12 @@ testB
 ; Options that affect all deqp based suites
 ;extra_args=--deqp-visibility=hidden
 
+; If we regenerate the caselist files everytime we ask them, or if we
+; reuse them if already present and more recent that the deqp
+; binary. The environment variable PIGLIT_DEQP_FORGE_CASELIST_REGEN
+; overrides de value set here.
+; force_caselist_regen=True
+
 [deqp-egl]
 ; Path to the deqp-egl executable
 ; Can be overwritten by PIGLIT_DEQP_EGL_BIN environment variable
-- 
2.19.1

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

[Piglit] [PATCH] tests/deqp: use --deqp-case when generating case-list

2019-06-06 Thread Alejandro Piñeiro
Without this commit, generating the case list is called without any
parameter by default, so it would generate all the caselist, even if
you don't need it, or if you have just called the method before (like
in khr_gles where you call several time gen_caselist).

For the latter an alternative would just check if the caselist files
are already created, and return if they exist. But in that case, we
would need to add a mechanism to force creating them.
---
 framework/test/deqp.py |  6 --
 tests/cts_gl.py| 20 ++--
 tests/cts_gl45.py  |  2 +-
 tests/cts_gles.py  |  9 -
 tests/gtf_gles.py  |  6 +++---
 tests/khr_gl.py| 22 +++---
 tests/khr_gles.py  | 11 +--
 tests/khr_noctx.py |  2 +-
 8 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/framework/test/deqp.py b/framework/test/deqp.py
index 5db2a922f..7c1a82c2a 100644
--- a/framework/test/deqp.py
+++ b/framework/test/deqp.py
@@ -114,7 +114,7 @@ def gen_caselist_txt(bin_, caselist, extra_args):
 #  differ then we cannot pre-generate the caselist on the build host:
 #  we must *dynamically* generate it during the testrun.
 basedir = os.path.dirname(bin_)
-caselist_path = os.path.join(basedir, caselist)
+caselist_path = os.path.join(basedir, caselist + '-cases.txt')
 
 # TODO: need to catch some exceptions here...
 with open(os.devnull, 'w') as d:
@@ -123,8 +123,10 @@ def gen_caselist_txt(bin_, caselist, extra_args):
 env['MESA_GLES_VERSION_OVERRIDE'] = '3.2'
 
 subprocess.check_call(
-[bin_, '--deqp-runmode=txt-caselist'] + extra_args, cwd=basedir,
+[bin_, '--deqp-runmode=txt-caselist' , '--deqp-case=' , caselist, 
'.*']
++ extra_args, cwd=basedir,
 stdout=d, stderr=d, env=env)
+
 assert os.path.exists(caselist_path)
 return caselist_path
 
diff --git a/tests/cts_gl.py b/tests/cts_gl.py
index 935df7a7c..fa36ea4f9 100644
--- a/tests/cts_gl.py
+++ b/tests/cts_gl.py
@@ -70,24 +70,24 @@ class DEQPCTSTest(deqp.DEQPBaseTest):
 profile = deqp.make_profile(  # pylint: disable=invalid-name
 itertools.chain(
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL30-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL30-CTS', _EXTRA_ARGS)),
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL31-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL31-CTS', _EXTRA_ARGS)),
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL32-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL32-CTS', _EXTRA_ARGS)),
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL33-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL33-CTS', _EXTRA_ARGS)),
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL40-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL40-CTS', _EXTRA_ARGS)),
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL41-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL41-CTS', _EXTRA_ARGS)),
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL42-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL42-CTS', _EXTRA_ARGS)),
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL43-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL43-CTS', _EXTRA_ARGS)),
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL44-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL44-CTS', _EXTRA_ARGS)),
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL45-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL45-CTS', _EXTRA_ARGS)),
 ),
 DEQPCTSTest)
diff --git a/tests/cts_gl45.py b/tests/cts_gl45.py
index d033c3efc..070ed8026 100644
--- a/tests/cts_gl45.py
+++ b/tests/cts_gl45.py
@@ -64,6 +64,6 @@ class DEQPCTSTest(deqp.DEQPBaseTest):
 profile = deqp.make_profile(  # pylint: disable=invalid-name
 itertools.chain(
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'GL45-CTS-cases.txt', 
_EXTRA_ARGS)),
+deqp.gen_caselist_txt(_CTS_BIN, 'GL45-CTS', _EXTRA_ARGS)),
 ),
 DEQPCTSTest)
diff --git a/tests/cts_gles.py b/tests/cts_gles.py
index 4ee28a89e..d65a9d56e 100644
--- a/tests/cts_gles.py
+++ b/tests/cts_gles.py
@@ -72,13 +72,12 @@ class DEQPCTSTest(deqp.DEQPBaseTest):
 profile = deqp.make_profile(  # pylint: disable=invalid-name
 itertools.chain(
 deqp.iter_deqp_test_cases(
-deqp.gen_caselist_txt(_CTS_BIN, 'ES2-CTS-cases.txt', 

[Piglit] [PATCH] README.md: update test sets documentation

2019-06-05 Thread Alejandro Piñeiro
Since commit "tests: use meta profiles"
(400dcd5cf18ac51ab8e9681d8ecab4132986efbd) some test sets are not
represented anymore as python scripts. So first, it would be good to
mention it, and second it would be good to mention that it would be
better to run the test sets using the set name, not directly the
python script.
---
 README.md | 48 
 1 file changed, 32 insertions(+), 16 deletions(-)

Thanks Dylan for the feedback for the RFC one.

I have just included your feedback, and removed the RFC. Im plenty
sure that there are some grammar mistakes, but I think that this is
more or less the info that we need.

diff --git a/README.md b/README.md
index 7366893f8..e4b3c651b 100644
--- a/README.md
+++ b/README.md
@@ -313,28 +313,44 @@ available, then this completion file will be installed 
system-wide.
 
 ## 4. Available test sets
 
-Test sets are specified as Python scripts in the tests directory.
-The following test sets are currently available:
+Test sets are specified as Python scripts or as xml files in the tests
+directory. As there are two different formats, the easier way to run a
+test set is using the name. So for example, although the following
+would work:
 
+   ./piglit run tests/opengl.py opengl_results -c
+
+It is more convenient to do the following:
+
+   ./piglit run opengl opengl_results -c
+
+As for running the all test suite you need to do this:
+
+   ./piglit run all all_results -c
 
 ### 4.1 OpenGL Tests
 
-  - **sanity.py** This suite contains minimal OpenGL sanity tests. These tests
+  - **sanity** This suite contains minimal OpenGL sanity tests. These tests
 must pass, otherwise the other tests will not generate reliable results.
-  - **all.py** This suite contains all OpenGL tests.
-  - **quick.py** Run all tests, but cut down significantly on their runtime
-(and thus on the number of problems they can find).
-  - **gpu.py** A further reduced set of tests from quick.py, this runs tests
-only for hardware functionality and not tests for the software stack.
-  - **llvmpipe.py** A reduced set of tests from gpu.py removing tests that are
-problematic using llvmpipe
-  - **cpu.py** This profile runs tests that don't touch the gpu, in other words
-all of the tests in quick.py that are not run by gpu.py
-  - **glslparser.py** A subset of all.py which runs only glslparser tests
-  - **shader.py** A subset of all.py which runs only shader tests
-  - **no_error.py** A modified version of the test list run as khr_no_error
+  - **glslparser** test set that includes the tests run by glslparser.
+  - **shader** all shader_test tests, being run by shader_runner.
+  - **no_error** A modified version of the test list run as khr_no_error
 variants
-
+  - **quick_gl**: This profile filters out a number of very slow
+  opengl tests, and tests that are very exhaustively tested, since
+  they add a good deal of runtime to piglit.
+  - **quick_shader**: Equivalent to quick_gl, but for shader_test (run
+  by shader_runner) tests.
+  - **llvmpipe_gl** A filtered test set, removing tests that are
+  problematic using llvmpipe
+  - **llvmpipe** llvmpipe + quick_shader test set
+  - **gpu**: Profile that includes the "quick" test sets that are
+  efectively executed (not just compiled), so it includes quick_gl
+  + quick_shader
+  - **quick** Profile with including all the "quick" test sets. So
+  it includes quick_gl + quick_shader + glslparser
+  - **all** This suite contains all OpenGL tests. So it is opengl +
+  shader + glslparser
 
 ### 4.2 OpenCL Tests
 
-- 
2.19.1

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

[Piglit] [PATCH] RFC: README.md: update test sets documentation

2019-06-03 Thread Alejandro Piñeiro
Since commit "tests: use meta profiles"
(400dcd5cf18ac51ab8e9681d8ecab4132986efbd) some test sets are not
represented anymore as python scripts. So first, it would be good to
mention it, and second it would be good to mention that it would be
better to run the test sets using the set name, not directly the
python script.

RFC because I have been struggling with the wording.
---

Basically I was not understanding why ./piglit run tests/all.py was
not working, and the README.md didn't help me. So somehow it needs to
be tweaked, but not sure how. Current patch tries to be as small as
possible, but perhaps it is too small.


 README.md | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 7366893f8..b3267cd58 100644
--- a/README.md
+++ b/README.md
@@ -313,26 +313,28 @@ available, then this completion file will be installed 
system-wide.
 
 ## 4. Available test sets
 
-Test sets are specified as Python scripts in the tests directory.
-The following test sets are currently available:
+Test sets are specified as Python scripts in the tests directory or as
+meta profiles (for that reason it is better to run the test suite
+name, not the python script).  The following test sets are currently
+available:
 
 
 ### 4.1 OpenGL Tests
 
-  - **sanity.py** This suite contains minimal OpenGL sanity tests. These tests
+  - **sanity** This suite contains minimal OpenGL sanity tests. These tests
 must pass, otherwise the other tests will not generate reliable results.
-  - **all.py** This suite contains all OpenGL tests.
-  - **quick.py** Run all tests, but cut down significantly on their runtime
+  - **all** This suite contains all OpenGL tests.
+  - **quick** Run all tests, but cut down significantly on their runtime
 (and thus on the number of problems they can find).
-  - **gpu.py** A further reduced set of tests from quick.py, this runs tests
+  - **gpu** A further reduced set of tests from quick.py, this runs tests
 only for hardware functionality and not tests for the software stack.
-  - **llvmpipe.py** A reduced set of tests from gpu.py removing tests that are
+  - **llvmpipe** A reduced set of tests from gpu.py removing tests that are
 problematic using llvmpipe
-  - **cpu.py** This profile runs tests that don't touch the gpu, in other words
+  - **cpu** This profile runs tests that don't touch the gpu, in other words
 all of the tests in quick.py that are not run by gpu.py
-  - **glslparser.py** A subset of all.py which runs only glslparser tests
-  - **shader.py** A subset of all.py which runs only shader tests
-  - **no_error.py** A modified version of the test list run as khr_no_error
+  - **glslparser** A subset of all.py which runs only glslparser tests
+  - **shader** A subset of all.py which runs only shader tests
+  - **no_error** A modified version of the test list run as khr_no_error
 variants
 
 
-- 
2.19.1

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

[Piglit] [PATCH 2/2] shader_runner: get proper access bitfield when calling MapBufferRange

2019-04-11 Thread Alejandro Piñeiro
Current workaround assumes that glMapBuffer and glMapBufferRange
'access' bitfield uses the same values, when it is not.
---
 .../shaders/shader_runner_gles_workarounds.h  | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/tests/shaders/shader_runner_gles_workarounds.h 
b/tests/shaders/shader_runner_gles_workarounds.h
index 77956f6b9..bbcdc9b4a 100644
--- a/tests/shaders/shader_runner_gles_workarounds.h
+++ b/tests/shaders/shader_runner_gles_workarounds.h
@@ -72,17 +72,32 @@ unsupported_function(const char *name, ...)
 #undef glMapBuffer
 
 static GLvoid*
-glMapBuffer(GLenum target, GLbitfield access)
+glMapBuffer(GLenum target, GLbitfield map_buffer_access)
 {
/* Emulate with glMapBufferRange. */
 
GLsizeiptr length = 0;
+   GLbitfield map_buffer_range_access;
 
glGetBufferParameteri64v(target, GL_BUFFER_SIZE, (GLint64*) );
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
 
-   return glMapBufferRange(target, 0, length, access);
+   switch (map_buffer_access) {
+   case GL_READ_ONLY:
+   map_buffer_range_access = GL_MAP_READ_BIT;
+   break;
+   case GL_WRITE_ONLY:
+   map_buffer_range_access = GL_MAP_WRITE_BIT;
+   break;
+   case GL_READ_WRITE:
+   map_buffer_range_access = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
+   break;
+   default:
+   map_buffer_range_access = 0;
+   break;
+   }
+   return glMapBufferRange(target, 0, length, map_buffer_range_access);
 }
 #endif /* PIGLIT_USE_OPENGL_ES3 */
 
-- 
2.19.1

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

[Piglit] [PATCH 0/2] shader_runner: fix gles3 glMapBuffer workaround

2019-04-11 Thread Alejandro Piñeiro
Alejandro Piñeiro (2):
  shader_runner: fix error checking on MapBuffer gles workaround
  shader_runner: get proper access bitfield when calling MapBufferRange

 .../shaders/shader_runner_gles_workarounds.h  | 21 ---
 1 file changed, 18 insertions(+), 3 deletions(-)

-- 
2.19.1

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

[Piglit] [PATCH 1/2] shader_runner: fix error checking on MapBuffer gles workaround

2019-04-11 Thread Alejandro Piñeiro
---
 tests/shaders/shader_runner_gles_workarounds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/shaders/shader_runner_gles_workarounds.h 
b/tests/shaders/shader_runner_gles_workarounds.h
index d3ab77506..77956f6b9 100644
--- a/tests/shaders/shader_runner_gles_workarounds.h
+++ b/tests/shaders/shader_runner_gles_workarounds.h
@@ -79,7 +79,7 @@ glMapBuffer(GLenum target, GLbitfield access)
GLsizeiptr length = 0;
 
glGetBufferParameteri64v(target, GL_BUFFER_SIZE, (GLint64*) );
-   if (piglit_check_gl_error(GL_NO_ERROR))
+   if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
 
return glMapBufferRange(target, 0, length, access);
-- 
2.19.1

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

[Piglit] [PATCH 62/63] shader_runner/spirv: skip for GL extensions without SPIR-V equivalent

2019-02-23 Thread Alejandro Piñeiro
There are some GL extensions/features, like shader subroutines, that
doesn't have their equivalent on SPIR-V, so those tests should be
skipped on SPIR-V mode. We reuse the code that checks if a given
SPIR-V extension equivalent to a GL extension is supported, by setting
the mapping to a string that will never be the name of a SPIR-V
extension.
---
 tests/shaders/shader_runner.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 796a61178..92861c5fc 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1041,12 +1041,15 @@ parse_version_comparison(const char *line, enum 
comparison *cmp,
version_init(v, tag, core, compat, es, full_num);
 }
 
-#define KNOWN_GL_SPV_MAPPING 3
+#define KNOWN_GL_SPV_MAPPING 6
 
 static const char* table[KNOWN_GL_SPV_MAPPING][2] =
 {{ "GL_AMD_shader_trinary_minmax", "SPV_AMD_shader_trinary_minmax"},
  {"GL_ARB_shader_group_vote", "SPV_KHR_subgroup_vote"},
- {"GL_ARB_shader_ballot", "SPV_KHR_shader_ballot"}};
+ {"GL_ARB_shader_ballot", "SPV_KHR_shader_ballot"},
+ {"GL_ARB_shader_subroutine", "not supported"},
+ {"GL_ARB_geometry_shader4", "not supported"},
+ {"GL_MESA_shader_integer_functions", "not supported"},};
 
 /*
  * Returns the SPIR-V extension that defines the equivalent
-- 
2.19.1

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

[Piglit] [PATCH 61/63] shader_runner/spirv: add check for SPV extension support

2019-02-23 Thread Alejandro Piñeiro
This only affects the case where SPIR-V shaders are run, specially
when using tests coming from other extensions.

In several cases, OpenGL supports an extension with a given
functionality. And such functionality it is not supported on core
SPIR-V but on a equivalent SPV functionality.

But it is not mandatory to support such SPV extension even if you
support the equivalent OpenGL one.

So for that case, we need to check for the equivalent SPV extension
and check if it is supported.
---
 tests/shaders/shader_runner.c | 82 ++-
 1 file changed, 80 insertions(+), 2 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 33b2fe6df..796a61178 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1041,6 +1041,84 @@ parse_version_comparison(const char *line, enum 
comparison *cmp,
version_init(v, tag, core, compat, es, full_num);
 }
 
+#define KNOWN_GL_SPV_MAPPING 3
+
+static const char* table[KNOWN_GL_SPV_MAPPING][2] =
+{{ "GL_AMD_shader_trinary_minmax", "SPV_AMD_shader_trinary_minmax"},
+ {"GL_ARB_shader_group_vote", "SPV_KHR_subgroup_vote"},
+ {"GL_ARB_shader_ballot", "SPV_KHR_shader_ballot"}};
+
+/*
+ * Returns the SPIR-V extension that defines the equivalent
+ * funcionality provided by the OpenGL extension @gl_name
+ */
+static const char *
+check_spv_extension_equivalent(const char *gl_name)
+{
+unsigned int i;
+
+for (i = 0 ; i < KNOWN_GL_SPV_MAPPING; i++)
+if (strcmp(gl_name, table[i][0]) == 0)
+return table[i][1];
+
+   return NULL;
+}
+
+
+/* Perhaps we could move this to piglit-util. For now it is only used
+ * on shader_runner
+ */
+static const char **spirv_extensions = NULL;
+
+static void
+initialize_spv_extensions(void)
+{
+   int loop, num_spir_v_extensions;
+
+   if (spirv_extensions != NULL)
+   return;
+
+   glGetIntegerv(GL_NUM_SPIR_V_EXTENSIONS, _spir_v_extensions);
+   spirv_extensions = malloc (sizeof(char*) * (num_spir_v_extensions + 1));
+   assert (spirv_extensions != NULL);
+
+   for (loop = 0; loop < num_spir_v_extensions; loop++) {
+   spirv_extensions[loop] = (const char*) 
glGetStringi(GL_SPIR_V_EXTENSIONS, loop);
+   }
+
+   spirv_extensions[loop] = NULL;
+}
+
+static bool
+spv_is_extension_supported(const char *name)
+{
+   initialize_spv_extensions();
+   return piglit_is_extension_in_array(spirv_extensions, name);
+}
+
+/*
+ * Wrapper for extension checking.  If using a GLSL shader, this
+ * method is equivalent to call piglit_is_extension_supported.
+ *
+ * But with SPIR-V shaders we can't just check for the OpenGL
+ * extension, but also for the SPV equivalent if using a SPIR-V
+ * binary, as it is not mandatory to support the SPV extension even if
+ * the equivalent OpenGL one is.
+ */
+static bool
+shader_runner_is_extension_supported(const char *name)
+{
+   bool result = true;
+   if (spirv_replaces_glsl) {
+   const char *spv_name = check_spv_extension_equivalent(name);
+
+   if (spv_name != NULL)
+   result = result && spv_is_extension_supported(spv_name);
+   }
+
+   return result && piglit_is_extension_supported(name);
+}
+
 /**
  * Parse and check a line from the requirement section of the test
  */
@@ -1161,12 +1239,12 @@ process_requirement(const char *line)
 
if (parse_str(line, "GL_", NULL) &&
parse_word_copy(line, buffer, sizeof(buffer), )) {
-   if (!piglit_is_extension_supported(buffer))
+   if (!shader_runner_is_extension_supported(buffer))
return PIGLIT_SKIP;
} else if (parse_str(line, "!", ) &&
   parse_str(line, "GL_", NULL) &&
   parse_word_copy(line, buffer, sizeof(buffer), )) {
-   if (piglit_is_extension_supported(buffer))
+   if (shader_runner_is_extension_supported(buffer))
return PIGLIT_SKIP;
} else if (parse_str(line, "GLSL", )) {
enum comparison cmp;
-- 
2.19.1

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

[Piglit] [PATCH 58/63] generated_tests: remove extra space before #extension

2019-02-23 Thread Alejandro Piñeiro
glslang doesn't like those spaces, failing to generate SPIR-V.
Additionally this improves readibility of the generated shader
(although this is subjective).
---
 .../templates/gen_extensions_defined/disabled.glsl.mako   | 2 +-
 .../templates/gen_extensions_defined/enabled.glsl.mako| 2 +-
 .../gen_extensions_defined/undefined-require.glsl.mako| 2 +-
 .../templates/gen_vs_in_fp64/columns.shader_test.mako | 4 ++--
 .../templates/gen_vs_in_fp64/regular.shader_test.mako | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/generated_tests/templates/gen_extensions_defined/disabled.glsl.mako 
b/generated_tests/templates/gen_extensions_defined/disabled.glsl.mako
index f4fc92f56..fe71b5954 100644
--- a/generated_tests/templates/gen_extensions_defined/disabled.glsl.mako
+++ b/generated_tests/templates/gen_extensions_defined/disabled.glsl.mako
@@ -30,7 +30,7 @@
 
 #version ${str(version)}
 % for ext in extra_extensions:
-  #extension ${ext} : require
+#extension ${ext} : require
 % endfor
 
 #if defined ${extension}
diff --git a/generated_tests/templates/gen_extensions_defined/enabled.glsl.mako 
b/generated_tests/templates/gen_extensions_defined/enabled.glsl.mako
index 09a82fab1..5ec1288ca 100644
--- a/generated_tests/templates/gen_extensions_defined/enabled.glsl.mako
+++ b/generated_tests/templates/gen_extensions_defined/enabled.glsl.mako
@@ -31,7 +31,7 @@
 #version ${str(version)}
 #extension ${extension} : require
 % for ext in extra_extensions:
-  #extension ${ext} : require
+#extension ${ext} : require
 % endfor
 
 #if !defined ${extension}
diff --git 
a/generated_tests/templates/gen_extensions_defined/undefined-require.glsl.mako 
b/generated_tests/templates/gen_extensions_defined/undefined-require.glsl.mako
index 5edec34c6..14a1d167c 100644
--- 
a/generated_tests/templates/gen_extensions_defined/undefined-require.glsl.mako
+++ 
b/generated_tests/templates/gen_extensions_defined/undefined-require.glsl.mako
@@ -30,7 +30,7 @@
 
 #version ${str(version)}
 % for ext in extra_extensions:
-  #extension ${ext}: require
+#extension ${ext}: require
 % endfor
 #extension ${extension} : require
 
diff --git a/generated_tests/templates/gen_vs_in_fp64/columns.shader_test.mako 
b/generated_tests/templates/gen_vs_in_fp64/columns.shader_test.mako
index f094a0315..4a79d7091 100644
--- a/generated_tests/templates/gen_vs_in_fp64/columns.shader_test.mako
+++ b/generated_tests/templates/gen_vs_in_fp64/columns.shader_test.mako
@@ -44,8 +44,8 @@ GLSL >= ${glsl}
 [vertex shader]
 #version ${glsl_int}
 % if ver == 'GL_ARB_vertex_attrib_64bit':
-  #extension GL_ARB_gpu_shader_fp64 : require
-  #extension GL_ARB_vertex_attrib_64bit : require
+#extension GL_ARB_gpu_shader_fp64 : require
+#extension GL_ARB_vertex_attrib_64bit : require
 % endif
 
 % for vidx in range(4):
diff --git a/generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako 
b/generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako
index 5620cbe33..2c91e0dda 100644
--- a/generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako
+++ b/generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako
@@ -45,8 +45,8 @@ GL_MAX_VERTEX_ATTRIBS >= ${num_vs_in}
 [vertex shader]
 #version ${glsl_int}
 % if ver == 'GL_ARB_vertex_attrib_64bit':
-  #extension GL_ARB_gpu_shader_fp64 : require
-  #extension GL_ARB_vertex_attrib_64bit : require
+#extension GL_ARB_gpu_shader_fp64 : require
+#extension GL_ARB_vertex_attrib_64bit : require
 % endif
 
 % for idx, in_type in enumerate(in_types):
-- 
2.19.1

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

[Piglit] [PATCH 55/63] CMake: search for glslangValidator, spirv-dis if needed

2019-02-23 Thread Alejandro Piñeiro
If we are generating SPIR-V tests using already existing tests, we
would need both programs.

Note that we are not removing the option to configure where those
binaries are on the script using envvars, as that can be handy if you
want to use glslang from master compiled by yourself, and having
glslang from system installed.
---
 CMakeLists.txt | 17 +
 1 file changed, 17 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 435c40ea5..d5e9de3a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,23 @@ option(PIGLIT_BUILD_CL_TESTS "Build tests for OpenCL" OFF)
 option(PIGLIT_GENERATE_GL_SPIRV_TESTS
"Generate ARB_gl_spirv tests by converting GLSL shader_tests to SPIR-V" 
OFF)
 
+if (PIGLIT_GENERATE_GL_SPIRV_TESTS)
+   find_program(GLSLANG_VALIDATOR_FOUND glslangValidator)
+   find_program(SPIRV_DIS_FOUND spirv-dis)
+
+   if(NOT GLSLANG_VALIDATOR_FOUND)
+   message(FATAL_ERROR "Failed fo find glslangValidator, needed to 
"
+   "generate the ARB_gl_spirv generated tests."
+   )
+   endif()
+
+   if(NOT SPIRV_DIS_FOUND)
+   message(FATAL_ERROR "Failed to find spirv-dis, needed "
+   "to generate the ARB_gl_spirv generated tests."
+   )
+   endif()
+endif()
+
 if(PIGLIT_BUILD_GL_TESTS)
find_package(OpenGL REQUIRED)
 endif()
-- 
2.19.1

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

[Piglit] [PATCH 60/63] shader_runner/spirv: check if test really includes spirv

2019-02-23 Thread Alejandro Piñeiro
SPIRV YES/ONLY assumes that the test includes the SPIR-V shader, and
that you should use it. This commit checks that this really happens,
and prints a proper error message if that is not the case.

Without this commit, a SPIRV YES/ONLY test that by mistake didn't
include the [spirv xx] sections would be just skipped with the
following non-intuitive message:

   "Function "glDeleteProgramsARB" not supported on this implementation"
---
 tests/shaders/shader_runner.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 7c6810099..33b2fe6df 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1728,6 +1728,7 @@ process_test_script(const char *script_name)
enum states state = none;
const char *line = text;
enum piglit_result result;
+   bool test_really_contains_spirv = false;
 
if (line == NULL) {
printf("could not read file \"%s\"\n", script_name);
@@ -1770,6 +1771,7 @@ process_test_script(const char *script_name)
shader_string_size = strlen(shader_string);
} else if (parse_str(line, "[vertex shader spirv]", 
NULL)) {
state = vertex_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[vertex shader 
specializations]", NULL)) {
state = vertex_shader_specializations;
@@ -1778,6 +1780,7 @@ process_test_script(const char *script_name)
shader_string = NULL;
} else if (parse_str(line, "[tessellation control 
shader spirv]", NULL)) {
state = tess_ctrl_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[tessellation control 
shader specializations]", NULL)) {
state = tess_ctrl_shader_specializations;
@@ -1786,6 +1789,7 @@ process_test_script(const char *script_name)
shader_string = NULL;
} else if (parse_str(line, "[tessellation evaluation 
shader spirv]", NULL)) {
state = tess_eval_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[tessellation evaluation 
shader specializations]", NULL)) {
state = tess_eval_shader_specializations;
@@ -1796,6 +1800,7 @@ process_test_script(const char *script_name)
state = geometry_shader_specializations;
} else if (parse_str(line, "[geometry shader spirv]", 
NULL)) {
state = geometry_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[geometry shader 
specializations]", NULL)) {
state = geometry_shader_specializations;
@@ -1812,6 +1817,7 @@ process_test_script(const char *script_name)
state = fragment_shader_specializations;
} else if (parse_str(line, "[fragment shader spirv]", 
NULL)) {
state = fragment_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[fragment shader 
specializations]", NULL)) {
state = fragment_shader_specializations;
@@ -1820,6 +1826,7 @@ process_test_script(const char *script_name)
shader_string = NULL;
} else if (parse_str(line, "[compute shader spirv]", 
NULL)) {
state = compute_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[compute shader 
specializations]", NULL)) {
state = compute_shader_specializations;
@@ -1833,6 +1840,15 @@ process_test_script(const char *script_name)
test_start_line_num = line_num + 1;
if (test_start[0] != '\0')
test_start++;
+
+   if (!test_really_contains_spirv &&
+   spirv_replaces_glsl) {
+   fprintf(stderr, "SPIRV YES/ONLY test, 
but"
+ 

[Piglit] [PATCH 57/63] generated_tests: Generate SPIR-V equivalents for builtin tests

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

Adds a script based on gen_builtin_uniform_tests.py which directly
generates the equivalent SPIR-V assembly to test with the ARB_gl_spirv
extension. The main reason to do this rather than converting the GLSL
tests with glslang is that not all of the GLSL builtins have direct
equivalents in SPIR-V. For example most of them only work when the
operands all have the same type. If we tested different combinations
of types we’d just be testing glslang’s ability to add the opcodes
needed to promote the arguments. Additionally it’s nice not to depend
on glslang which tends to change a lot between versions.

Note that the script has the code needed to generate tests for vertex,
geometry, tessellation, fragment and compute shaders but everything
but the fragment shaders is commented out. This reduces the number of
test cases to a fifth. The assumption is that there probably isn’t
that much difference between the codepaths taken for the builtins in
the driver for the different stages so it’s not really worth testing
all of them.

v2: stop to use OriginLowerLeft always, as it is only valid for
fragment shaders, and mesa has recently added an assert for it
(Alejandro)
---
 generated_tests/CMakeLists.txt|5 +
 .../gen_builtin_uniform_spirv_tests.py| 1225 +
 unittests/generators/test_generators.py   |1 +
 3 files changed, 1231 insertions(+)
 create mode 100644 generated_tests/gen_builtin_uniform_spirv_tests.py

diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 3242885b9..797478857 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -41,6 +41,10 @@ piglit_make_generated_tests(
builtin_uniform_tests.list
gen_builtin_uniform_tests.py
builtin_function.py)
+piglit_make_generated_tests(
+   builtin_uniform_spirv_tests.list
+   gen_builtin_uniform_spirv_tests.py
+   builtin_function.py)
 piglit_make_generated_tests(
constant_array_size_tests.list
gen_constant_array_size_tests.py
@@ -260,6 +264,7 @@ add_custom_target(gen-gl-tests
outerproduct_tests.list
outerproduct_invalid_params.list
builtin_uniform_tests.list
+   builtin_uniform_spirv_tests.list
constant_array_size_tests.list
const_builtin_equal_tests.list
builtin_packing_tests.list
diff --git a/generated_tests/gen_builtin_uniform_spirv_tests.py 
b/generated_tests/gen_builtin_uniform_spirv_tests.py
new file mode 100644
index 0..160549d1d
--- /dev/null
+++ b/generated_tests/gen_builtin_uniform_spirv_tests.py
@@ -0,0 +1,1225 @@
+# coding=utf-8
+#
+# Copyright © 2011, 2018 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.
+
+# Generate a set of shader_runner tests for every overloaded version
+# of every built-in function, based on the test vectors computed by
+# builtin_function.py. The sources are generated directly as SPIR-V
+# assembly.
+#
+# In each set of generated tests, one test exercises the built-in
+# function in each type of shader (vertex, geometry, and fragment). In
+# all cases, the inputs to the built-in function come from uniforms,
+# so that the effectiveness of the test won't be circumvented by
+# constant folding in the GLSL compiler. Note that all but the
+# fragment shader tests are currently commented out on the asumption
+# that there won’t be much difference between the codepaths taken by
+# the driver for the various stages that aren’t already tested in the
+# GLSL versions of the tests.
+#
+# For built-in functions whose result type is a matrix, the test
+# checks one column at a time.
+#
+# This program outputs, to stdout, the name of each file it generates.
+# With the optional argument --names-only, it only outputs the names
+# 

[Piglit] [PATCH 54/63] CMake: Add PIGLIT_GENERATE_GL_SPIRV_TESTS option

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

Adds an option to CMake which can be enabled to generate additional
shader_tests for ARB_gl_spirv by translating shader_tests written for
other specifications to SPIR-V. Specifically, uses the gen_gl_spirv.py
script to translate the shader_tests under the 'tests' directory,
excluding those pertaining to unsupported extensions or listed in the
tests/gl_spirv.exclude file.
---
 CMakeLists.txt |  3 +++
 generated_tests/CMakeLists.txt | 31 +++
 2 files changed, 34 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b416cacb2..435c40ea5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,6 +49,9 @@ option(PIGLIT_BUILD_GLES2_TESTS "Build tests for OpenGL ES2" 
${PIGLIT_BUILD_GLES
 option(PIGLIT_BUILD_GLES3_TESTS "Build tests for OpenGL ES3" 
${PIGLIT_BUILD_GLES_TESTS_DEFAULT})
 option(PIGLIT_BUILD_CL_TESTS "Build tests for OpenCL" OFF)
 
+option(PIGLIT_GENERATE_GL_SPIRV_TESTS
+   "Generate ARB_gl_spirv tests by converting GLSL shader_tests to SPIR-V" 
OFF)
+
 if(PIGLIT_BUILD_GL_TESTS)
find_package(OpenGL REQUIRED)
 endif()
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index adec9b4cb..3242885b9 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -18,6 +18,14 @@ function(piglit_make_generated_tests file_list 
generator_script)
VERBATIM)
 endfunction(piglit_make_generated_tests custom_target generator_script)
 
+function(piglit_make_generated_tests_for_gl_spirv file_list generator_script 
source_prefix source_tests)
+   add_custom_command(
+   OUTPUT ${file_list}
+   COMMAND ${PYTHON_EXECUTABLE} 
${CMAKE_CURRENT_SOURCE_DIR}/${generator_script} ${source_tests} 
--prefix=${source_prefix} ${ARGN}
+   DEPENDS ${generator_script} ${source_prefix}/${source_tests}
+   VERBATIM)
+endfunction(piglit_make_generated_tests_for_gl_spirv)
+
 # Generators for OpenGL tests
 piglit_make_generated_tests(
builtin_packing_tests.list
@@ -202,6 +210,17 @@ piglit_make_generated_tests(
 piglit_make_generated_tests(
shader_framebuffer_fetch_tests.list
gen_shader_framebuffer_fetch_tests.py)
+piglit_make_generated_tests_for_gl_spirv(
+   gl_spirv_tests.list
+   gen_gl_spirv_tests.py
+   ${CMAKE_SOURCE_DIR}
+   tests
+   --excludes-from-file=${CMAKE_SOURCE_DIR}/tests/gl_spirv.exclude
+   --success-list-file=gl_spirv_tests.list
+   --mirror=spec/arb_gl_spirv/translated
+   --keep-going
+   --strip-names
+   --jobs=4)
 
 # OpenCL Test generators
 piglit_make_generated_tests(
@@ -285,6 +304,12 @@ add_custom_target(gen-cl-tests
cl_vload_tests.list
 )
 
+# Create a custom target for generating ARB_gl_spirv shader_tests
+# This is not added to the default target, instead it is added
+# as a dependency of gen-tests if the generation of the
+# ARB_gl_spirv shader_tests is enabled
+add_custom_target(gen-gl-spirv-tests DEPENDS gl_spirv_tests.list)
+
 # Add a "gen-tests" target that can be used to generate all the
 # tests without doing any other compilation.
 add_custom_target(gen-tests ALL COMMENT "meta-target for other test 
generators")
@@ -299,3 +324,9 @@ endif(${PIGLIT_BUILD_GL_TESTS} OR 
${PIGLIT_BUILD_GLES2_TESTS} OR ${PIGLIT_BUILD_
 if(${PIGLIT_BUILD_CL_TESTS})
add_dependencies(gen-tests gen-cl-tests)
 endif(${PIGLIT_BUILD_CL_TESTS})
+
+# Add gen-gl-spirv-tests as a dependency of the gen-tests if they are
+# requested.
+if(${PIGLIT_GENERATE_GL_SPIRV_TESTS})
+   add_dependencies(gen-tests gen-gl-spirv-tests)
+endif(${PIGLIT_GENERATE_GL_SPIRV_TESTS})
-- 
2.19.1

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

[Piglit] [PATCH 48/63] util: add piglit_is_file_older_than helper

2019-02-23 Thread Alejandro Piñeiro
From: Nicolai Hähnle 

This will be used by shader_runner to check whether SPIRV object files
are up-to-date.
---
 tests/util/piglit-util.c | 34 ++
 tests/util/piglit-util.h |  1 +
 2 files changed, 35 insertions(+)

diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 3a8f9bcfb..c7398c60a 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -507,6 +507,40 @@ char *piglit_load_text_file(const char *file_name, 
unsigned *size)
 #endif
 }
 
+/**
+ * Return true if file A is older than file B. A file that does not exist is
+ * considered "infinitely old".
+ */
+bool piglit_is_file_older_than(const char *file_name_a, const char 
*file_name_b)
+{
+#ifdef USE_STDIO
+   return false;
+#else
+   struct stat stat_a;
+   struct stat stat_b;
+   int ret;
+
+   ret = stat(file_name_b, _b);
+   if (ret < 0) {
+   printf("Failed to stat %s\n", file_name_b);
+   return false;
+   }
+
+   ret = stat(file_name_a, _a);
+   if (ret < 0) {
+   printf("Failed to stat %s\n", file_name_a);
+   return true;
+   }
+
+   if (stat_a.st_mtim.tv_sec < stat_b.st_mtim.tv_sec ||
+   (stat_a.st_mtim.tv_sec == stat_b.st_mtim.tv_sec &&
+stat_a.st_mtim.tv_nsec < stat_b.st_mtim.tv_nsec))
+   return true;
+
+   return false;
+#endif
+}
+
 const char*
 piglit_source_dir(void)
 {
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 53cffedbb..70dbfd91f 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -369,6 +369,7 @@ void piglit_general_init(void);
 extern void piglit_set_rlimit(unsigned long lim);
 
 char *piglit_load_text_file(const char *file_name, unsigned *size);
+bool piglit_is_file_older_than(const char *file_name_a, const char 
*file_name_b);
 
 /**
  * \brief Read environment variable PIGLIT_SOURCE_DIR.
-- 
2.19.1

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

[Piglit] [PATCH 45/63] arb_gl_spirv: add tests equivalent to component-layout SSO

2019-02-23 Thread Alejandro Piñeiro
From: Arcady Goldmints-Orlov 

The difference is that we explicitly specify locations for inputs and outputs in
component-layout tests.

The current version of glslang doesn't handle a mixture of explicit and implicit
locations for inputs and outputs, so make all locations explicit.
---
 ...-sso-vs-gs-fs-array-interleave.shader_test | 438 ++
 ...mponent-layout-vs-gs-fs-double.shader_test | 312 +
 .../component-layout-vs-gs-fs.shader_test | 291 
 3 files changed, 1041 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/component-layout-sso-vs-gs-fs-array-interleave.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/component-layout-vs-gs-fs-double.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/component-layout-vs-gs-fs.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/component-layout-sso-vs-gs-fs-array-interleave.shader_test
 
b/tests/spec/arb_gl_spirv/execution/component-layout-sso-vs-gs-fs-array-interleave.shader_test
new file mode 100644
index 0..5b9d672b7
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/component-layout-sso-vs-gs-fs-array-interleave.shader_test
@@ -0,0 +1,438 @@
+# Test layout component qualifier between multiple shader stages with SSO
+# enabled.
+#
+# Copied from
+# 
arb_enhanced_layouts/execution/component-layout/sso-vs-gs-fs-array-interleave.shader_test,
+# the difference is that we explicitly specify locations for inputs and outputs
+# in component-layout tests.  The current version of glslang doesn't handle a
+# mixture of explicit and implicit locations for inputs and outputs, so we made
+# all locations explicit.
+
+[require]
+SPIRV YES
+GLSL >= 1.50
+GL_ARB_enhanced_layouts
+GL_ARB_separate_shader_objects
+SSO ENABLED
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by gen_gl_spirv_tests.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 64
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %a %b %vertex_to_gs 
%piglit_vertex %gl_VertexID %gl_InstanceID
+   OpSource GLSL 450
+   OpSourceExtension "GL_ARB_enhanced_layouts"
+   OpSourceExtension "GL_ARB_separate_shader_objects"
+   OpDecorate %a Location 0
+   OpDecorate %b Component 3
+   OpDecorate %b Location 0
+   OpDecorate %vertex_to_gs Location 6
+   OpDecorate %piglit_vertex Location 0
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v3float = OpTypeVector %float 3
+   %uint = OpTypeInt 32 0
+ %uint_6 = OpConstant %uint 6
+%_arr_v3float_uint_6 = OpTypeArray %v3float %uint_6
+%_ptr_Output__arr_v3float_uint_6 = OpTypePointer Output %_arr_v3float_uint_6
+  %a = OpVariable %_ptr_Output__arr_v3float_uint_6 Output
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%float_0 = OpConstant %float 0
+ %16 = OpConstantComposite %v3float %float_0 %float_0 %float_0
+%_ptr_Output_v3float = OpTypePointer Output %v3float
+  %int_1 = OpConstant %int 1
+%float_1 = OpConstant %float 1
+ %21 = OpConstantComposite %v3float %float_1 %float_1 %float_1
+  %int_2 = OpConstant %int 2
+%float_2 = OpConstant %float 2
+ %25 = OpConstantComposite %v3float %float_2 %float_2 %float_2
+  %int_3 = OpConstant %int 3
+%float_3 = OpConstant %float 3
+ %29 = OpConstantComposite %v3float %float_3 %float_3 %float_3
+  %int_4 = OpConstant %int 4
+%float_4 = OpConstant %float 4
+ %33 = OpConstantComposite %v3float %float_4 %float_4 %float_4
+  %int_5 = OpConstant %int 5
+%float_5 = OpConstant %float 5
+ %37 = OpConstantComposite %v3float %float_5 %float_5 %float_5
+%_arr_float_uint_6 = OpTypeArray %float %uint_6
+%_ptr_Output__arr_float_uint_6 = OpTypePointer Output %_arr_float_uint_6
+  %b = OpVariable %_ptr_Output__arr_float_uint_6 Output
+%float_6 = OpConstant %float 6
+%_ptr_Output_float = OpTypePointer Output %float
+%float_7 = OpConstant %float 7
+%float_8 = OpConstant %float 8
+%float_9 = OpConstant %float 9
+   %float_10 = OpConstant %float 10
+   %float_11 = OpConstant %float 11
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%vertex_to_gs = OpVariable %_ptr_Output_v4float Output
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+   %main = OpFunction %void None %3
+  

[Piglit] [PATCH 56/63] generated_tests/builtin_function: Add templates for equivalent SPIR-V

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

The test signatures now have an additional member called
template_spirv. If this is not None then it is a template which can be
used to generate an equivalent line of SPIR-V assembly.
---
 generated_tests/builtin_function.py | 547 ++--
 1 file changed, 428 insertions(+), 119 deletions(-)

diff --git a/generated_tests/builtin_function.py 
b/generated_tests/builtin_function.py
index a5eafb278..d11f270ab 100644
--- a/generated_tests/builtin_function.py
+++ b/generated_tests/builtin_function.py
@@ -215,7 +215,7 @@ glsl_u64vec4  = GlslBuiltinType('u64vec4', glsl_uint64_t,  
1, 4, 400)
 #   argtypes=('float', 'vec3'))
 Signature = collections.namedtuple(
 'Signature',
-('name', 'template', 'version_introduced', 'extension', 'rettype', 
'argtypes'))
+('name', 'template', 'version_introduced', 'extension', 'rettype', 
'argtypes', 'template_spirv'))
 
 
 # Named tuple representing a single piece of test data for testing a
@@ -736,7 +736,7 @@ def _vectorize_test_vectors(test_vectors, 
scalar_arg_indices, vector_length):
 
 
 def _store_test_vector(test_suite_dict, name, glsl_version, extension, 
test_vector,
-   template=None):
+   template=None, template_spirv=None):
 """Store a test vector in the appropriate place in
 test_suite_dict.  The dictionary key (which is a Signature tuple)
 is generated by consulting the argument and return types of the
@@ -747,6 +747,12 @@ def _store_test_vector(test_suite_dict, name, 
glsl_version, extension, test_vect
 
 If template is supplied, it is used insted as the template for the
 Signature objects generated.
+
+If template_spirv is supplied it will stored in the signature as
+an alternative template to generate SPIR-V sources. If it is a
+callable object it will be called with the argument types as
+arguments and it is expected to return a generated template or
+None if the test is not possible on SPIR-V.
 """
 if template is None:
 arg_indices = range(len(test_vector.arguments))
@@ -757,24 +763,31 @@ def _store_test_vector(test_suite_dict, name, 
glsl_version, extension, test_vect
 adjusted_glsl_version = max(
 glsl_version, rettype.version_introduced,
 *[t.version_introduced for t in argtypes])
+if callable(template_spirv):
+template_spirv = template_spirv(*argtypes)
 signature = Signature(
-name, template, adjusted_glsl_version, extension, rettype, argtypes)
+name, template, adjusted_glsl_version,
+extension, rettype, argtypes, template_spirv)
 if signature not in test_suite_dict:
 test_suite_dict[signature] = []
 test_suite_dict[signature].append(test_vector)
 
 
 def _store_test_vectors(test_suite_dict, name, glsl_version, extension,
-test_vectors, template=None):
+test_vectors, template=None, template_spirv=None):
 """Store multiple test vectors in the appropriate places in
 test_suite_dict.
 
 If template is supplied, it is used insted as the template for the
 Signature objects generated.
+
+template_spirv can also be supplied as a template to generate
+SPIR-V sources. See the comment for _store_test_vector.
 """
 for test_vector in test_vectors:
 _store_test_vector(test_suite_dict, name, glsl_version, extension,
-   test_vector, template=template)
+   test_vector, template=template,
+   template_spirv=template_spirv)
 
 
 def make_arguments(input_generators):
@@ -815,10 +828,25 @@ def _make_componentwise_test_vectors(test_suite_dict):
 uints = [np.uint32(x) for x in [0, 1, 2, 5, 34]]
 bools = [True, False]
 
+def spirv_match_types(opcode, *types):
+for t in types:
+if t != types[0]:
+return None
+return '{} {{}} {}'.format(
+opcode, " ".join(itertools.repeat('{}', len(types
+
+def spirv_match_types_ext(opcode, ext, *types):
+for t in types:
+if t != types[0]:
+return None
+return 'OpExtInst {{}} {} {} {}'.format(
+ext, opcode, " ".join(itertools.repeat('{}', len(types
+
 def f(name, arity, glsl_version, python_equivalent,
   alternate_scalar_arg_indices, test_inputs,
   tolerance_function=_strict_tolerance,
-  extension=None):
+  extension=None,
+  template_spirv=None):
 """Create test vectors for the function with the given name
 and arity, which was introduced in the given glsl_version.
 
@@ -839,11 +867,15 @@ def _make_componentwise_test_vectors(test_suite_dict):
 If tolerance_function is supplied, it is a function which
 should be used to compute the tolerance for the test vectors.
 Otherwise, _strict_tolerance is used.
+
+template_spirv will be 

[Piglit] [PATCH 63/63] shader_runner/spirv: skip compat profile tests on SPIR-V mode

2019-02-23 Thread Alejandro Piñeiro
From ARB_gl_spirv spec:

  "Changes to Chapter 3 of the OpenGL Shading Language 4.50 Specification
   (Basics)

After describing the compatibility profile rules, add:

   "Compatibility-profile features are not available when
generating SPIR-V.""

With this commit, tests that require a compatibility profile are
skipped if trying to be run on SPIR-V mode. This includes if we
specify force spirv on the command line or if the test includes a
SPIRV YES. The latter can happen as the GLSL from those tests can be
compatible, so glslang (or any other GLSL->SPIR-V backend) could be
able to generate the SPIRV.
---
 tests/shaders/shader_runner.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 92861c5fc..faf78b2d2 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -2033,7 +2033,8 @@ struct requirement_parse_results {
 
 static void
 parse_required_config(struct requirement_parse_results *results,
- const char *script_name)
+ const char *script_name,
+ bool force_spirv)
 {
unsigned text_size;
char *text = piglit_load_text_file(script_name, _size);
@@ -2077,6 +2078,11 @@ parse_required_config(struct requirement_parse_results 
*results,
results->found_glsl = true;
version_copy(>glsl_version, 
);
}
+
+   if (version.compat && force_spirv) {
+   printf("ARB_gl_spirv is not compatible 
with compatibility profile\n");
+   piglit_report_result(PIGLIT_SKIP);
+   }
} else if (parse_str(line, "GL", )) {
enum comparison cmp;
struct component_version version;
@@ -2089,6 +2095,10 @@ parse_required_config(struct requirement_parse_results 
*results,
results->found_gl = true;
version_copy(>gl_version, 
);
}
+   if (version.compat && force_spirv) {
+   printf("ARB_gl_spirv is not compatible 
with compatibility profile\n");
+   piglit_report_result(PIGLIT_SKIP);
+   }
} else if (parse_str(line, "SIZE", )) {
results->found_size = true;
parse_uints(line, results->size, 2, NULL);
@@ -2165,7 +2175,7 @@ get_required_config(const char *script_name, bool 
force_spirv,
struct requirement_parse_results parse_results;
struct component_version required_gl_version;
 
-   parse_required_config(_results, script_name);
+   parse_required_config(_results, script_name, force_spirv);
choose_required_gl_version(_results, _gl_version);
 
if (force_spirv || parse_results.found_spirv) {
-- 
2.19.1

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

[Piglit] [PATCH 44/63] arb_gl_spirv: Add test equivalent to CS basic-ssbo

2019-02-23 Thread Alejandro Piñeiro
From: Arcady Goldmints-Orlov 

The difference with
arb_compute_shader/execution/basic-ssbo.shader_test is that we
explicitly assign a binding to the SSBO.  Without a binding number
specified, glslang implicitly assigns a binding number of 1 to the
SSBO, while Mesa assigns a binding number of 0. To ensure the test
runs consistently in both cases, assign the binding explicitly.
---
 .../execution/cs-basic-ssbo.shader_test   | 82 +++
 1 file changed, 82 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/cs-basic-ssbo.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/cs-basic-ssbo.shader_test 
b/tests/spec/arb_gl_spirv/execution/cs-basic-ssbo.shader_test
new file mode 100644
index 0..2f286f3f6
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/cs-basic-ssbo.shader_test
@@ -0,0 +1,82 @@
+# This is copied from arb_compute_shader/execution/basic-ssbo.shader_test
+#
+# The difference is that we explicitly assign a binding to the SSBO.
+# Without a binding number specified, glslang implicitly assigns a
+# binding number of 1 to the SSBO, while Mesa assigns a binding number
+# of 0. To ensure the test runs consistently in both cases, assign the
+# binding explicitly.
+
+[require]
+GLSL >= 3.30
+GL_ARB_compute_shader
+GL_ARB_shader_storage_buffer_object
+GL_ARB_shader_atomic_counters
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: enable
+#extension GL_ARB_shader_storage_buffer_object: require
+#extension GL_ARB_shader_atomic_counters: require
+
+#define SIZE 256u
+
+layout(local_size_x = SIZE) in;
+
+layout(binding = 0) uniform atomic_uint counter;
+
+layout(std430, binding = 0)
+buffer SSBO {
+   uintu[SIZE];
+};
+
+uniform uint mode;
+
+void main()
+{
+   uint index = gl_LocalInvocationIndex;
+
+   switch (mode) {
+   case 0u:
+   u[index] = SIZE;
+   break;
+   case 1u:
+   u[index] = index;
+   break;
+   case 2u:
+   if (u[index] == SIZE)
+   atomicCounterIncrement(counter);
+   break;
+   case 3u:
+   if (u[index] == index)
+   atomicCounterIncrement(counter);
+   break;
+   }
+}
+
+[test]
+atomic counters 1
+ssbo 0 1024
+
+uniform uint mode 0
+compute 1 1 1
+probe atomic counter 0 == 0
+
+uniform uint mode 3
+compute 1 1 1
+probe atomic counter 0 == 0
+
+uniform uint mode 2
+compute 1 1 1
+probe atomic counter 0 == 256
+
+uniform uint mode 1
+compute 1 1 1
+probe atomic counter 0 == 256
+
+uniform uint mode 2
+compute 1 1 1
+probe atomic counter 0 == 256
+
+uniform uint mode 3
+compute 1 1 1
+probe atomic counter 0 == 512
-- 
2.19.1

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

[Piglit] [PATCH 50/63] framework: add --spirv option

2019-02-23 Thread Alejandro Piñeiro
So when executing shader tests, they will be executed with -spirv.

So for example:
./piglit run tests/shader.py -t ARB_explicit_uniform_location --spirv 
results/explicit_uniform_location-spirv

Will run all the shader tests for that extension using -spirv.
---
 framework/options.py  | 1 +
 framework/programs/run.py | 7 +++
 framework/test/shader_test.py | 2 ++
 3 files changed, 10 insertions(+)

diff --git a/framework/options.py b/framework/options.py
index 0abe1f63d..fa5de34be 100644
--- a/framework/options.py
+++ b/framework/options.py
@@ -61,6 +61,7 @@ class _Options(object):  # pylint: 
disable=too-many-instance-attributes
 self.process_isolation = True
 self.jobs = None
 self.force_glsl = False
+self.spirv = False
 
 # env is used to set some base environment variables that are not going
 # to change across runs, without sending them to os.environ which is
diff --git a/framework/programs/run.py b/framework/programs/run.py
index d0a3fcfe9..b3e04ccf8 100644
--- a/framework/programs/run.py
+++ b/framework/programs/run.py
@@ -239,10 +239,15 @@ def _run_parser(input_):
 type=path.realpath,
 metavar="",
 help="Path to results folder")
+
 parser.add_argument("--glsl",
 action="store_true",
 help="Run shader runner tests with the -glsl (force 
GLSL) option")
 
+parser.add_argument("--spirv",
+action="store_true",
+help="Run shader runner tests with the -spirv (try 
SPIR-V) option")
+
 return parser.parse_args(unparsed)
 
 
@@ -322,6 +327,7 @@ def run(input_):
 options.OPTIONS.process_isolation = args.process_isolation
 options.OPTIONS.jobs = args.jobs
 options.OPTIONS.force_glsl = args.glsl
+options.OPTIONS.spirv = args.spirv
 
 # Set the platform to pass to waffle
 options.OPTIONS.env['PIGLIT_PLATFORM'] = args.platform
@@ -437,6 +443,7 @@ def resume(input_):
 options.OPTIONS.jobs = args.jobs
 options.OPTIONS.no_retry = args.no_retry
 options.OPTIONS.force_glsl = results.options['force_glsl']
+options.OPTIONS.spirv = results.options['spirv']
 
 core.get_config(args.config_file)
 
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index 3f6f7bb0f..63d840d0f 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -193,6 +193,8 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
 
 if options.OPTIONS.force_glsl:
 return [command[0]] + [shaderfile, '-auto', '-fbo', '-glsl']
+elif options.OPTIONS.spirv:
+return [command[0]] + [shaderfile, '-auto', '-fbo', '-spirv']
 else:
 return [command[0]] + [shaderfile, '-auto', '-fbo']
 
-- 
2.19.1

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

[Piglit] [PATCH 59/63] shader_runner/spirv: log skip reason on ARB_gl_spirv extension check

2019-02-23 Thread Alejandro Piñeiro
---
 tests/shaders/shader_runner.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 927926a35..7c6810099 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -850,6 +850,8 @@ static enum piglit_result
 assemble_spirv(GLenum target)
 {
if (!piglit_is_extension_supported("GL_ARB_gl_spirv")) {
+   printf("GL_ARB_gl_spirv not supported, but required "
+   "to run SPIR-V shaders\n");
return PIGLIT_SKIP;
}
 
-- 
2.19.1

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

[Piglit] [PATCH 51/63] generated_tests: Add script to translate shader_tests to SPIR-V

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

Utility script which translates GLSL shader_tests to OpenGL SPIR-V
shader_tests (ARB_gl_spirv), using glslang and SPIR-V tools.

The translation to SPIR-V is done using glslangValidator with the
--auto-map-locations option.

Names for uniforms, UBOs and vertex attributes in the [test] and
[vertex data] sections are remapped. In order to do that, the
generated SPIR-V is parsed to get the locations, bindings, offsets,
matrix stride and row major, array indices and the tree of types.

--aml can’t handle allocating the same varying locations across
multiple stages because it only sees the shaders for one stage at a
time. To work around this the script reads overwrites the locations
for the inputs in the generated SPIR-V with the locations with the
same name in the outputs from the previous stage.

Based on Nicolai Hänle's work who wrote the script when glslang did
not provide the --auto-map-location option and the GLSL code was
parsed by the script. The script was modified to use such option,
remove the GLSL parsing and implement the remapping of uniforms, UBOs
and vertex attributes, add more command line options and other
improvements.

Signed-off-by: Nicolai Hänle 
Signed-off-by: Alejandro Piñeiro 
Signed-off-by: Neil Roberts 
Signed-off-by: Antia Puentes 
---
 generated_tests/gen_gl_spirv_tests.py | 1424 +
 1 file changed, 1424 insertions(+)
 create mode 100644 generated_tests/gen_gl_spirv_tests.py

diff --git a/generated_tests/gen_gl_spirv_tests.py 
b/generated_tests/gen_gl_spirv_tests.py
new file mode 100644
index 0..43ce92050
--- /dev/null
+++ b/generated_tests/gen_gl_spirv_tests.py
@@ -0,0 +1,1424 @@
+#!/usr/bin/env python3
+#
+# Copyright 2015 Advanced Micro Devices, Inc.
+# Copyright © 2018 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.
+#
+
+from __future__ import (
+absolute_import, division, print_function, unicode_literals
+)
+
+import argparse
+import glob
+import os
+import re
+import stat
+import subprocess
+import sys
+import tempfile
+import itertools
+import collections
+
+num_mark_skipped = 0
+
+RE_spirv_shader_groupname = re.compile(r'(.*) shader spirv$')
+RE_glsl_shader_groupname = re.compile(r'(.*) shader$')
+RE_if_start = re.compile(r'\s*#\s*if\s+([0-9]+)\s*$')
+RE_else = re.compile(r'\s*#\s*else\s*$')
+RE_endif = re.compile(r'\s*#\s*endif\s*$')
+
+def make_spirv_variable_re(storage_mode):
+return re.compile(r'^\s*%(\w+)\s*=\s*OpVariable\s+%(\w+)\s+' +
+  re.escape(storage_mode) +
+  r'(?: +%\w+)?\s*$',
+  re.MULTILINE)
+
+RE_spirv_output_var = make_spirv_variable_re('Output')
+RE_spirv_input_var = make_spirv_variable_re('Input')
+RE_spirv_uniform_var = make_spirv_variable_re('UniformConstant')
+RE_spirv_ubo_var = make_spirv_variable_re('Uniform')
+RE_spirv_location = re.compile(r'^\s*(?:%\w+\s*=\s*)?OpDecorate\s+%(\w+)\s+' +
+   r'Location\s+(\d+)\s*$',
+   re.MULTILINE)
+RE_spirv_binding = re.compile(r'^\s*(?:%\w+\s*=\s*)?OpDecorate\s+%(\w+)\s+' +
+  r'Binding\s+(\d+)\s*$',
+  re.MULTILINE)
+RE_spirv_array_stride = 
re.compile(r'^\s*(?:%\w+\s*=\s*)?OpDecorate\s+%(\w+)\s+' +
+   r'ArrayStride\s+(\d+)\s*$',
+   re.MULTILINE)
+RE_spirv_name = re.compile(r'^\s*(?:%\w+\s*=\s*)?OpName\s+%(\w+)\s+' +
+   r'"([^"]+)"\s*$',
+   re.MULTILINE)
+RE_spirv_member_name = re.compile(r'^\s*(?:%\w+\s*=\s*)?OpMemberName\s+' +
+  r'%(\w+)\s+(\d+)\s+"([^"]+)"\s*$',
+  re.MULTILINE)
+RE_spirv_member_offset = re.compile(r'^\s*(?:%\w+\s*=\s*)?OpMemberDecorate\s+' 
+
+ 

[Piglit] [PATCH 52/63] arb_gl_spirv: add gl_spirv.exclude file

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

Contains the list GLSL shader_tests which can not be translated to
SPIR-V or we are not interested in running as part of the ARB_gl_spirv
testing.

The tests are grouped by reason of exclusion, which may be:

* The translation to SPIR-V failed or is incorrect. Due to a glslang
limitation or an error in the GLSL shader which is detected by
glslang. The later can happen for linking tests which expect a linking
error to happen as glslang is able to detect intrastage linking
errors.

* The translation to SPIR-V succeded but what the test wants to check
does not make sense for ARB_gl_spirv. For example, if the test makes
checks based on names (names are optional in SPIR-V) or the
shader_test expects an interstage linking error (glslang does not cope
with that and in ARB_gl_spirv a GLSL-like validation is not needed).

Based on previous work done by Nicolai Hähnle, who wrote the first
version of the file.

Several people have contributed:

Signed-off-by: Nicolai Hänle 
Signed-off-by: Antia Puentes 
Signed-off-by: Alejandro Piñeiro 
Signed-off-by: Neil Roberts 
Signed-off-by: Eleni Maria Stea 
Signed-off-by: Arcady Goldmints-Orlov 
---
 tests/gl_spirv.exclude | 305 +
 1 file changed, 305 insertions(+)
 create mode 100644 tests/gl_spirv.exclude

diff --git a/tests/gl_spirv.exclude b/tests/gl_spirv.exclude
new file mode 100644
index 0..de23d1b07
--- /dev/null
+++ b/tests/gl_spirv.exclude
@@ -0,0 +1,305 @@
+# SPIR-V not generated because 'array size must be a constant integer
+# expression':
+tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/const-fma-double.shader_test
+tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-const-ldexp-double.shader_test
+tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-const-packDouble2x32.shader_test
+tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-const-unpackDouble2x32.shader_test
+tests/spec/arb_gpu_shader5/execution/built-in-functions/const-bitCount.shader_test
+tests/spec/arb_gpu_shader5/execution/built-in-functions/const-bitfieldExtract.shader_test
+tests/spec/arb_gpu_shader5/execution/built-in-functions/const-bitfieldInsert.shader_test
+tests/spec/arb_gpu_shader5/execution/built-in-functions/const-bitfieldReverse.shader_test
+tests/spec/arb_gpu_shader5/execution/built-in-functions/const-findLSB.shader_test
+tests/spec/arb_gpu_shader5/execution/built-in-functions/const-findMSB.shader_test
+tests/spec/arb_gpu_shader5/execution/built-in-functions/const-fma.shader_test
+tests/spec/arb_gpu_shader5/execution/built-in-functions/const-ldexp.shader_test
+# ... or because 'array must be redeclared with a size before being indexed 
with
+# a variable':
+tests/spec/arb_gpu_shader5/execution/samplemaskin-indirect.shader_test
+#
+# The tests specify the layout in a different compilation unit and glslang does
+# not cope with it (SPIR-V generation failed):
+tests/spec/arb_compute_shader/execution/separate-global-id.shader_test
+tests/spec/arb_compute_shader/execution/separate-global-id-2.shader_test
+tests/spec/arb_compute_shader/linker/matched_local_work_sizes.shader_test
+tests/spec/arb_compute_shader/linker/one_local_work_size.shader_test
+tests/spec/arb_gpu_shader5/execution/invocations-conflicting.shader_test
+tests/spec/arb_gpu_shader5/execution/invocations-matching.shader_test
+tests/spec/arb_gpu_shader5/execution/invocation-id-in-separate-gs.shader_test
+tests/spec/arb_tessellation_shader/linker/tcs-output-size-declared-in-other-shader.shader_test
+tests/spec/glsl-1.50/execution/gs-input-sizing-layout-consistent-with-static-usage.shader_test
+tests/spec/glsl-1.50/execution/gs-input-sizing-layout-larger-than-static-usage.shader_test
+tests/spec/glsl-1.50/linker/gs-different-max-vertices-multiple-shader-objects.shader_test
+tests/spec/glsl-1.50/linker/gs-different-output-type-multiple-shader-objects.shader_test
+# .. same when there are unsized arrays, functions, in different compilation
+# units (SPIR-V generation failed):
+tests/spec/arb_arrays_of_arrays/linker/intrastage-interface-field.shader_test
+tests/spec/arb_arrays_of_arrays/linker/intrastage-interface.shader_test
+tests/spec/glsl-1.50/execution/unsized-in-named-interface-block-multiple.shader_test
+tests/spec/glsl-1.50/linker/intrastage-unsized-interface-array.shader_test
+tests/spec/glsl-1.50/linker/intrastage-unsized-interface-array2.shader_test
+tests/spec/glsl-1.50/linker/versions-mingled-multiple-shader-objects.shader_test
+#
+# The explicit location requirement makes the shaders reach the maximum number
+# of locations limit, as vars won't be grouped to occupy less locations. The
+# SPIR-V is generated but the tests will fail when executed because of reaching
+# this limit.
+tests/spec/arb_tessellation_shader/execution/variable-indexing/tes-both-input-array-float-index-rd.shader_test
+tests/spec/arb_tessellation_shader/execution/variable-indexing/tes-both-input-array-vec2-index-rd.shader_test
+tests

[Piglit] [PATCH 53/63] gitignore: add *.spv

2019-02-23 Thread Alejandro Piñeiro
From: Nicolai Hähnle 

---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 0f4c952c2..b8008d0a2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
 *.tar.bz2
 *.zip
 *~
+*.spv
 
 .ninja_log
 build.ninja
-- 
2.19.1

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

[Piglit] [PATCH 49/63] shader_runner/spirv: Load a replacement .shader_test

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

This adds a new new command line option "-spirv". If no SPIRV line is
found in the require section and "-spirv" is passed to the command
line, then it will try to load a replacement script by appending .spv
to the name of the file.

In that way, now "SPIRV YES" meaning changes slightly, from "Use by
default the SPIR-V on this shader test" to "We have a SPIR-V on this
shader, by default use it without looking for a external replacement
file".

We also added a "SPIRV NO" line that points that the shader is not
compatible with SPIR-V, so would be skipped even using -spirv.

"-spirv" is the counter-part command line option to "-glsl". The new
"-spirv" option is used to try to run tests on SPIR-V mode even if
they doesn't have a SPIR-V included, while "-glsl" is for tests that
even having SPIR-V included, we want them to run on GLSL mode.

Obviously it is a mistake to use "-spirv" and "-glsl" at the same
time.

v2: update on the code and commit message due the addition of the
    "-glsl" command line option, plus command line options

Signed-off-by: Neil Roberts 
Signed-off-by: Alejandro Piñeiro 
---
 tests/shaders/shader_runner.c | 79 +--
 1 file changed, 66 insertions(+), 13 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index c53980b20..927926a35 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -57,12 +57,17 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
config.khr_no_error_support = PIGLIT_NO_ERRORS;
 
-   /* By default SPIR-V mode is false. It will not be enabled
-* unless the script includes SPIRV YES or SPIRV ONLY lines at
-* [require] section, so it will be handled later.
-*/
if (argc > 1) {
-   get_required_config(argv[1], spirv_replaces_glsl, );
+   bool spirv = spirv_replaces_glsl;
+
+   for (int i = 1; i < argc; ++i) {
+   if (!strcmp(argv[i], "-spirv")) {
+   spirv = true;
+   break;
+   }
+   }
+
+   get_required_config(argv[1], spirv, );
} else {
config.supports_gl_compat_version = 10;
}
@@ -180,6 +185,7 @@ static bool glsl_in_use = false;
 static bool force_glsl = false;
 static bool spirv_in_use = false;
 static bool force_no_names = false;
+static bool test_contains_spirv = false;
 static GLchar *prog_err_info = NULL;
 static GLuint vao = 0;
 static GLuint draw_fbo, read_fbo;
@@ -1220,15 +1226,21 @@ process_requirement(const char *line)
spirv_replaces_glsl = !force_glsl;
 
if (parse_str(line, "ONLY", NULL)) {
+   spirv_replaces_glsl = true;
+   test_contains_spirv = true;
+
if (force_glsl) {
printf("This shader is not compatible with 
GLSL\n");
return PIGLIT_SKIP;
}
} else if (parse_str(line, "YES", NULL)) {
-   /* Empty. Everything already set. Just parsing
-* correct options
-*/
-   } else {
+   test_contains_spirv = true;
+   } else if (parse_str(line, "NO", )) {
+   if (spirv_replaces_glsl) {
+   printf("This shader is not compatible with 
SPIR-V\n");
+   return PIGLIT_SKIP;
+   }
+} else {
printf("Unknown SPIRV line in [require]\n");
return PIGLIT_FAIL;
}
@@ -1651,6 +1663,26 @@ process_specialization(enum states state, const char 
*line)
return PIGLIT_FAIL;
 }
 
+static char *
+spirv_replacement_script(const char *script_name)
+{
+   int len = strlen(script_name);
+   char *buf = malloc(len + 5);
+   memcpy(buf, script_name, len);
+   strcpy(buf + len, ".spv");
+
+   if (piglit_is_file_older_than(buf, script_name)) {
+   printf("SPIR-V shader_test %s is older than "
+  "corresponding GLSL shader_test"
+  "or does not exist.\n",
+  buf);
+   free(buf);
+   return NULL;
+   }
+
+   return buf;
+}
+
 static enum piglit_result
 process_elements(enum states state, const char *line)
 {
@@ -1704,6 +1736,19 @@ process_test_script(const char *script_name)
 
while (line[0] != '\0') {
 

[Piglit] [PATCH 46/63] arb_gl_spirv: fix wrong extension name for atomic-uint-fs test

2019-02-23 Thread Alejandro Piñeiro
---
 .../{atomic-uint-fs.shader_runner => atomic-uint-fs.shader_test}  | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename tests/spec/arb_gl_spirv/execution/uniform/{atomic-uint-fs.shader_runner 
=> atomic-uint-fs.shader_test} (100%)

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-fs.shader_runner 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-fs.shader_test
similarity index 100%
rename from 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-fs.shader_runner
rename to tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-fs.shader_test
-- 
2.19.1

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

[Piglit] [PATCH 38/63] arb_gl_spirv: Add a test for PixelCenterInteger

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

This is forbidden in Vulkan but it is available in GLSL and the SPIR-V
spec allows it. It isn’t mentioned in the ARB_gl_spirv spec but it
seems likely that it’s intended to work.
---
 .../execution/pixel-center-half.shader_test   | 123 +
 .../pixel-center-integer.shader_test  | 127 ++
 2 files changed, 250 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/pixel-center-half.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/pixel-center-integer.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/pixel-center-half.shader_test 
b/tests/spec/arb_gl_spirv/execution/pixel-center-half.shader_test
new file mode 100644
index 0..7320c8c33
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/pixel-center-half.shader_test
@@ -0,0 +1,123 @@
+# Tests that not using PixelCenterInteger puts the pixel center at
+# 0.5.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 47
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %gl_FragCoord %color_out
+   OpExecutionMode %main PixelCenterInteger
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %frac_is_zero_f1_ "frac_is_zero(f1;"
+   OpName %val "val"
+   OpName %gl_FragCoord "gl_FragCoord"
+   OpName %param "param"
+   OpName %param_0 "param"
+   OpName %color_out "color_out"
+   OpDecorate %gl_FragCoord BuiltIn FragCoord
+   OpDecorate %color_out Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%_ptr_Function_float = OpTypePointer Function %float
+   %bool = OpTypeBool
+  %9 = OpTypeFunction %bool %_ptr_Function_float
+%float_0_0010005 = OpConstant %float 0.0010005
+%v4float = OpTypeVector %float 4
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%gl_FragCoord = OpVariable %_ptr_Input_v4float Input
+   %uint = OpTypeInt 32 0
+ %uint_0 = OpConstant %uint 0
+%_ptr_Input_float = OpTypePointer Input %float
+ %uint_1 = OpConstant %uint 1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color_out = OpVariable %_ptr_Output_v4float Output
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %44 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+ %46 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+  %param = OpVariable %_ptr_Function_float Function
+%param_0 = OpVariable %_ptr_Function_float Function
+ %27 = OpAccessChain %_ptr_Input_float %gl_FragCoord %uint_0
+ %28 = OpLoad %float %27
+   OpStore %param %28
+ %29 = OpFunctionCall %bool %frac_is_zero_f1_ %param
+   OpSelectionMerge %31 None
+   OpBranchConditional %29 %30 %31
+ %30 = OpLabel
+ %34 = OpAccessChain %_ptr_Input_float %gl_FragCoord %uint_1
+ %35 = OpLoad %float %34
+   OpStore %param_0 %35
+ %36 = OpFunctionCall %bool %frac_is_zero_f1_ %param_0
+   OpBranch %31
+ %31 = OpLabel
+ %37 = OpPhi %bool %29 %5 %36 %30
+   OpSelectionMerge %39 None
+   OpBranchConditional %37 %38 %45
+ %38 = OpLabel
+   OpStore %color_out %44
+   OpBranch %39
+ %45 = OpLabel
+   OpStore %color_out %46
+   OpBranch %39
+ %39 = OpLabel
+   OpReturn
+   OpFunctionEnd
+%frac_is_zero_f1_ = OpFunction %bool None %9
+%val = OpFunctionParameter %_ptr_Function_float
+ %12 = OpLabel
+ %13 = OpLoad %float %val
+ %14 = OpExtInst %float %1 Fract %13
+ %15 = OpExtInst %float %1 FAbs %14
+ %17 = OpFOrdLessThan %bool %15 %float_0_0010005
+   OpReturnValue %17
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) out vec4 color_out;
+
+bool
+frac_is_half(float val)
+{
+/* Allow for a bit of tolerance */
+return abs(0.5 - fract(val)) < 0.001;
+}
+
+void
+main()
+{
+/* With PixelCenterInteger all of the fractional parts of
+ * gl_FragCoord should be zero.
+ */
+if (frac_is_half(gl_FragCoord.x) && frac_is_half(gl_FragCoord.y))
+color_out = vec4(0.0, 1.0, 0.0, 1.0);
+else
+color_out = vec4(1.0, 0.0, 0.0, 1.0);

[Piglit] [PATCH 37/63] arb_gl_spirv: Add tests for the gl_FragCoord origin

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

Using OriginLowerLeft isn’t allowed on Vulkan but explicitly allowed
by ARB_gl_spirv so it’s probably worth testing.
---
 .../execution/origin-lower-left.shader_test   | 191 +
 .../execution/origin-upper-left.shader_test   | 192 ++
 2 files changed, 383 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/origin-lower-left.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/origin-upper-left.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/origin-lower-left.shader_test 
b/tests/spec/arb_gl_spirv/execution/origin-lower-left.shader_test
new file mode 100644
index 0..4dc15256d
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/origin-lower-left.shader_test
@@ -0,0 +1,191 @@
+# Tests that OriginLowerLeft works. This isn’t allowed on Vulkan but
+# is explicitly allowed on ARB_gl_spirv so it’s probably worth
+# testing.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.5
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 26
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %_ %pos_in %pos_out 
%gl_VertexID %gl_InstanceID
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+   OpName %_ ""
+   OpName %pos_in "pos_in"
+   OpName %pos_out "pos_out"
+   OpName %gl_VertexID "gl_VertexID"
+   OpName %gl_InstanceID "gl_InstanceID"
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %pos_in Location 0
+   OpDecorate %pos_out Location 0
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+ %pos_in = OpVariable %_ptr_Input_v4float Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%pos_out = OpVariable %_ptr_Output_v4float Output
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpLoad %v4float %pos_in
+ %20 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %20 %18
+ %22 = OpLoad %v4float %pos_in
+   OpStore %pos_out %22
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+layout(location = 0) in vec4 pos_in;
+layout(location = 0) out vec4 pos_out;
+
+void
+main()
+{
+gl_Position = pos_in;
+pos_out = pos_in;
+}
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 51
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %gl_FragCoord %pos_in 
%color_out
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %frag_coord "frag_coord"
+   OpName %gl_FragCoord "gl_FragCoord"
+   OpName %pos_in "pos_in"
+   OpName %color_out "color_out"
+   OpDecorate %gl_FragCoord BuiltIn FragCoord
+   OpDecorate %pos_in Location 0
+   OpDecorate %color_out Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v2float = OpTypeVector %float 2
+%_ptr_Function_v2float = 

[Piglit] [PATCH 42/63] arb_gl_spirv: Add test for atomic memory ops (shared uint)

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

---
 ...ared-uint-atomic-mem-functions.shader_test | 262 ++
 1 file changed, 262 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/shared-uint-atomic-mem-functions.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/shared-uint-atomic-mem-functions.shader_test
 
b/tests/spec/arb_gl_spirv/execution/shared-uint-atomic-mem-functions.shader_test
new file mode 100644
index 0..06337be06
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/shared-uint-atomic-mem-functions.shader_test
@@ -0,0 +1,262 @@
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[compute shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 86
+; Schema: 0
+   OpCapability Shader
+   OpCapability AtomicStorage
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint GLCompute %main "main"
+   OpExecutionMode %main LocalSize 1 1 1
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %uishared "uishared"
+   OpName %a0 "a0"
+   OpName %a1 "a1"
+   OpName %a2 "a2"
+   OpName %a3 "a3"
+   OpName %a4 "a4"
+   OpName %a5 "a5"
+   OpName %a6 "a6"
+   OpName %a7 "a7"
+   OpDecorate %a0 Offset 0
+   OpDecorate %a0 DescriptorSet 0
+   OpDecorate %a0 Binding 0
+   OpDecorate %a1 Offset 4
+   OpDecorate %a1 DescriptorSet 0
+   OpDecorate %a1 Binding 0
+   OpDecorate %a2 Offset 8
+   OpDecorate %a2 DescriptorSet 0
+   OpDecorate %a2 Binding 0
+   OpDecorate %a3 Offset 12
+   OpDecorate %a3 DescriptorSet 0
+   OpDecorate %a3 Binding 0
+   OpDecorate %a4 Offset 16
+   OpDecorate %a4 DescriptorSet 0
+   OpDecorate %a4 Binding 0
+   OpDecorate %a5 Offset 20
+   OpDecorate %a5 DescriptorSet 0
+   OpDecorate %a5 Binding 0
+   OpDecorate %a6 Offset 24
+   OpDecorate %a6 DescriptorSet 0
+   OpDecorate %a6 Binding 0
+   OpDecorate %a7 Offset 28
+   OpDecorate %a7 DescriptorSet 0
+   OpDecorate %a7 Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+   %uint = OpTypeInt 32 0
+%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint
+   %uishared = OpVariable %_ptr_Workgroup_uint Workgroup
+%uint_10 = OpConstant %uint 10
+ %uint_1 = OpConstant %uint 1
+ %uint_0 = OpConstant %uint 0
+ %uint_2 = OpConstant %uint 2
+   %bool = OpTypeBool
+%_ptr_AtomicCounter_uint = OpTypePointer AtomicCounter %uint
+ %a0 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+%uint_15 = OpConstant %uint 15
+%uint_12 = OpConstant %uint 12
+ %a1 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_3 = OpConstant %uint 3
+ %a2 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_6 = OpConstant %uint 6
+%uint_11 = OpConstant %uint 11
+ %a3 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_4 = OpConstant %uint 4
+ %a4 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_5 = OpConstant %uint 5
+ %a5 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %a6 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %a7 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %12 = OpAtomicExchange %uint %uishared %uint_1 %uint_0 %uint_10
+ %14 = OpAtomicIAdd %uint %uishared %uint_1 %uint_0 %uint_2
+ %16 = OpIEqual %bool %14 %uint_10
+   OpSelectionMerge %18 None
+   OpBranchConditional %16 %17 %18
+ %17 = OpLabel
+ %21 = OpAtomicIIncrement %uint %a0 %uint_1 %uint_0
+   OpBranch %18
+ %18 = OpLabel
+ %23 = OpAtomicUMin %uint %uishared %uint_1 %uint_0 %uint_15
+ %25 = OpIEqual %bool %23 %uint_12
+   OpSelectionMerge %27 None
+   OpBranchConditional %25 %26 %27
+ %26 = OpLabel
+ %29 = OpAtomicIIncrement %uint %a1 %uint_1 %uint_0
+   OpBranch %27
+ %27 = OpLabel
+ %31 = OpAtomicUMin %uint %uishared %uint_1 %uint_0 %uint_3
+ %32 = OpIEqual %bool %31 %uint_12
+   OpSelectionMerge %34 None
+   OpBranchConditional %32 %33 %34
+ %33 = OpLabel
+ %35 = OpAtomicIIncrement %uint %a1 %uint_1 %uint_0
+   OpBranch %34
+ %34 = OpLabel
+ %36 = OpAtomicUMax %uint %uishared %uint_1 %uint_0 %uint_1
+ %37 = OpIEqual 

[Piglit] [PATCH 41/63] arb_gl_spirv: add test for atomic images

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

---
 .../execution/atomic-image.shader_test| 425 ++
 1 file changed, 425 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/atomic-image.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/atomic-image.shader_test 
b/tests/spec/arb_gl_spirv/execution/atomic-image.shader_test
new file mode 100644
index 0..060a8baad
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/atomic-image.shader_test
@@ -0,0 +1,425 @@
+[require]
+SPIRV YES
+GL >= 4.5
+GLSL >= 4.5
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 24
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %_ %piglit_vertex %gl_VertexID 
%gl_InstanceID
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+   OpName %_ ""
+   OpName %piglit_vertex "piglit_vertex"
+   OpName %gl_VertexID "gl_VertexID"
+   OpName %gl_InstanceID "gl_InstanceID"
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %piglit_vertex Location 0
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpLoad %v4float %piglit_vertex
+ %20 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %20 %18
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 450
+in vec4 piglit_vertex;
+
+void main()
+{
+   gl_Position = piglit_vertex;
+}
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 131
+; Schema: 0
+   OpCapability Shader
+   OpCapability AtomicStorage
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color %gl_FragCoord
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %coord "coord"
+   OpName %gl_FragCoord "gl_FragCoord"
+   OpName %img "img"
+   OpName %a0 "a0"
+   OpName %a1 "a1"
+   OpName %a2 "a2"
+   OpName %a3 "a3"
+   OpName %a4 "a4"
+   OpName %a5 "a5"
+   OpName %a6 "a6"
+   OpName %a7 "a7"
+   OpDecorate %color Location 0
+   OpDecorate %gl_FragCoord BuiltIn FragCoord
+   OpDecorate %img Location 0
+   OpDecorate %img DescriptorSet 0
+   OpDecorate %img Binding 0
+   OpDecorate %img Coherent
+   OpDecorate %a0 Offset 0
+   OpDecorate %a0 DescriptorSet 0
+   OpDecorate %a0 Binding 0
+   OpDecorate %a1 Offset 4
+   OpDecorate %a1 DescriptorSet 0
+   OpDecorate %a1 Binding 0
+   OpDecorate %a2 Offset 8
+   OpDecorate %a2 DescriptorSet 0
+   OpDecorate %a2 Binding 0
+   OpDecorate %a3 Offset 12
+   OpDecorate %a3 DescriptorSet 0
+   

[Piglit] [PATCH 35/63] arb_gl_spirv: Add a test for gl_InstanceID

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

This value is different from InstanceID in Vulkan because it shouldn’t
include the baseinstance.
---
 .../execution/vs-instance-id.shader_test  | 165 ++
 1 file changed, 165 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/vs-instance-id.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/vs-instance-id.shader_test 
b/tests/spec/arb_gl_spirv/execution/vs-instance-id.shader_test
new file mode 100644
index 0..b3447ec4e
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/vs-instance-id.shader_test
@@ -0,0 +1,165 @@
+# Tests that gl_InstanceID does not include the ‘baseinstance’
+# parameter of the draw call.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.5
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 37
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %expected_instance_id 
%gl_InstanceID %color %_ %piglit_vertex %gl_VertexID
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %expected_instance_id "expected_instance_id"
+   OpName %gl_InstanceID "gl_InstanceID"
+   OpName %color "color"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+   OpName %_ ""
+   OpName %piglit_vertex "piglit_vertex"
+   OpName %gl_VertexID "gl_VertexID"
+   OpDecorate %expected_instance_id Location 1
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   OpDecorate %color Location 0
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %piglit_vertex Location 0
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%_ptr_Input_int = OpTypePointer Input %int
+%expected_instance_id = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+   %bool = OpTypeBool
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %22 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+ %24 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+  %int_0 = OpConstant %int 0
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+  %9 = OpLoad %int %expected_instance_id
+ %11 = OpLoad %int %gl_InstanceID
+ %13 = OpIEqual %bool %9 %11
+   OpSelectionMerge %15 None
+   OpBranchConditional %13 %14 %23
+ %14 = OpLabel
+   OpStore %color %22
+   OpBranch %15
+ %23 = OpLabel
+   OpStore %color %24
+   OpBranch %15
+ %15 = OpLabel
+ %34 = OpLoad %v4float %piglit_vertex
+ %35 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %35 %34
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+layout(location = 0) in vec4 piglit_vertex;
+layout(location = 1) in int expected_instance_id;
+layout(location = 0) out vec4 color;
+
+void
+main()
+{
+if (expected_instance_id == gl_InstanceID)
+   color = vec4(0.0, 1.0, 0.0, 1.0);
+else
+   color = vec4(1.0, 0.0, 0.0, 1.0);
+
+gl_Position = piglit_vertex;
+}
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 13
+; Schema: 0
+   OpCapability Shader

[Piglit] [PATCH 36/63] arb_gl_spirv: Add a test for the OpFUnord* opcodes

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

These opcodes are not available via GLSL so it seems worth testing
them separately. This involves generating NaN values which apparently
isn’t required by the spec at least on GLSL. The tests therefore try
to calculate the square root of -1 and if check if it actually
generated a NaN with isnan. If it didn’t generate NaN then the test is
assumed to just pass.

As mentioned, those opcodes are not available on GLSL, so the test is
SPIRV ONLY.
---
 .../unordered-comparison.shader_test  | 784 ++
 1 file changed, 784 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/unordered-comparison.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/unordered-comparison.shader_test 
b/tests/spec/arb_gl_spirv/execution/unordered-comparison.shader_test
new file mode 100644
index 0..40ee2928a
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/unordered-comparison.shader_test
@@ -0,0 +1,784 @@
+# Tests the various OpFUnord* comparisons. These opcodes are not
+# available in GLSL so they are interesting to test in SPIR-V. They
+# are supposed to evaluate to true if the operands are unordered (ie,
+# they are NaN). Apparently GLSL implementations are not required to
+# generate NaN values so to cope with implementations that don’t this
+# test tries to generates a NaN value by takning the square root of -1
+# and then checking whether it actually did generate a NaN with
+# isnan().
+
+[require]
+SPIRV ONLY
+GL >= 3.3
+GLSL >= 4.5
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+
+; Automatically generated from the GLSL by shader_test_spirv.py and
+; then edited to manually replace the second set of comparisons with
+; the OpFUnord* versions.
+
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 176
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color_out
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %i "i"
+   OpName %operands "operands"
+   OpName %operands_squared "operands_squared"
+   OpName %result "result"
+   OpName %operator "operator"
+   OpName %test_passes "test_passes"
+   OpName %expected_value "expected_value"
+   OpName %color_out "color_out"
+   OpDecorate %operands_squared Location 0
+   OpDecorate %operands_squared DescriptorSet 0
+   OpDecorate %operands_squared Binding 0
+   OpDecorate %operator Location 2
+   OpDecorate %operator DescriptorSet 0
+   OpDecorate %operator Binding 1
+   OpDecorate %expected_value Location 3
+   OpDecorate %expected_value DescriptorSet 0
+   OpDecorate %expected_value Binding 2
+   OpDecorate %color_out Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+  %int_0 = OpConstant %int 0
+  %int_2 = OpConstant %int 2
+   %bool = OpTypeBool
+  %float = OpTypeFloat 32
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr_float_uint_2 = OpTypeArray %float %uint_2
+%_ptr_Function__arr_float_uint_2 = OpTypePointer Function %_arr_float_uint_2
+%_ptr_UniformConstant__arr_float_uint_2 = OpTypePointer UniformConstant 
%_arr_float_uint_2
+%operands_squared = OpVariable %_ptr_UniformConstant__arr_float_uint_2 
UniformConstant
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+%_ptr_Function_float = OpTypePointer Function %float
+  %int_1 = OpConstant %int 1
+%_ptr_Function_bool = OpTypePointer Function %bool
+   %true = OpConstantTrue %bool
+%_ptr_UniformConstant_uint = OpTypePointer UniformConstant %uint
+   %operator = OpVariable %_ptr_UniformConstant_uint UniformConstant
+  %false = OpConstantFalse %bool
+%float_0 = OpConstant %float 0
+%_ptr_UniformConstant_bool = OpTypePointer UniformConstant %bool
+%expected_value = OpVariable %_ptr_UniformConstant_bool UniformConstant
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color_out = OpVariable %_ptr_Output_v4float Output
+%float_1 = OpConstant %float 1
+%173 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+%175 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+  %i = OpVariable %_ptr_Function_int Function
+   %operands = OpVariable %_ptr_Function__arr_float_uint_2 Function
+ %result = OpVariable %_ptr_Function_bool Function
+%test_passes = OpVariable %_ptr_Function_bool Function
+   OpStore %i 

[Piglit] [PATCH 40/63] arb_gl_spirv: Add a test for gl_PatchVerticesIn

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

---
 .../tcs-patch-vertices-in.shader_test | 373 ++
 1 file changed, 373 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/tcs-patch-vertices-in.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/tcs-patch-vertices-in.shader_test 
b/tests/spec/arb_gl_spirv/execution/tcs-patch-vertices-in.shader_test
new file mode 100644
index 0..409efc899
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/tcs-patch-vertices-in.shader_test
@@ -0,0 +1,373 @@
+# A simple test that gl_PatchVerticesIn has the right value.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[tessellation control shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 67
+; Schema: 0
+   OpCapability Tessellation
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint TessellationControl %main "main" %gl_out 
%gl_InvocationID %gl_in %gl_TessLevelOuter %gl_TessLevelInner 
%gl_PatchVerticesIn %color_out
+   OpExecutionMode %main OutputVertices 3
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+   OpName %gl_out "gl_out"
+   OpName %gl_InvocationID "gl_InvocationID"
+   OpName %gl_PerVertex_0 "gl_PerVertex"
+   OpMemberName %gl_PerVertex_0 0 "gl_Position"
+   OpMemberName %gl_PerVertex_0 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex_0 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex_0 3 "gl_CullDistance"
+   OpName %gl_in "gl_in"
+   OpName %gl_TessLevelOuter "gl_TessLevelOuter"
+   OpName %gl_TessLevelInner "gl_TessLevelInner"
+   OpName %gl_PatchVerticesIn "gl_PatchVerticesIn"
+   OpName %expected "expected"
+   OpName %color_out "color_out"
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %gl_InvocationID BuiltIn InvocationId
+   OpMemberDecorate %gl_PerVertex_0 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex_0 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex_0 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex_0 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex_0 Block
+   OpDecorate %gl_TessLevelOuter Patch
+   OpDecorate %gl_TessLevelOuter BuiltIn TessLevelOuter
+   OpDecorate %gl_TessLevelInner Patch
+   OpDecorate %gl_TessLevelInner BuiltIn TessLevelInner
+   OpDecorate %gl_PatchVerticesIn BuiltIn PatchVertices
+   OpDecorate %expected Location 0
+   OpDecorate %expected DescriptorSet 0
+   OpDecorate %expected Binding 0
+   OpDecorate %color_out Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+ %uint_3 = OpConstant %uint 3
+%_arr_gl_PerVertex_uint_3 = OpTypeArray %gl_PerVertex %uint_3
+%_ptr_Output__arr_gl_PerVertex_uint_3 = OpTypePointer Output 
%_arr_gl_PerVertex_uint_3
+ %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_3 Output
+%int = OpTypeInt 32 1
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_InvocationID = OpVariable %_ptr_Input_int Input
+  %int_0 = OpConstant %int 0
+%gl_PerVertex_0 = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+%uint_32 = OpConstant %uint 32
+%_arr_gl_PerVertex_0_uint_32 = OpTypeArray %gl_PerVertex_0 %uint_32
+%_ptr_Input__arr_gl_PerVertex_0_uint_32 = OpTypePointer Input 
%_arr_gl_PerVertex_0_uint_32
+  %gl_in = OpVariable %_ptr_Input__arr_gl_PerVertex_0_uint_32 Input
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %uint_4 = OpConstant %uint 4
+%_arr_float_uint_4 = OpTypeArray %float %uint_4
+%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4
+%gl_TessLevelOuter = OpVariable 

[Piglit] [PATCH 33/63] shader_runner: Add a “draw arrays instanced base” command

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

This is just like “draw arrays instanced” but has an extra parameter
to set the baseinstance.
---
 tests/shaders/shader_runner.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 778229e2a..c53980b20 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -4855,6 +4855,16 @@ piglit_display(void)
size_t primcount = (size_t) z;
draw_arrays_common(first, count);
glDrawArraysInstanced(mode, first, count, primcount);
+   } else if (sscanf(line, "draw arrays instanced base %31s %d %d 
%d %d", s, , , , ) == 5) {
+   GLenum mode = decode_drawing_mode(s);
+   int first = x;
+   size_t count = (size_t) y;
+   size_t primcount = (size_t) z;
+   GLuint baseinstance = (GLuint) w;
+   draw_arrays_common(first, count);
+   glDrawArraysInstancedBaseInstance(mode, first, count,
+ primcount,
+ baseinstance);
} else if (sscanf(line, "draw arrays %31s %d %d", s, , ) == 
3) {
GLenum mode = decode_drawing_mode(s);
int first = x;
-- 
2.19.1

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

[Piglit] [PATCH 19/63] shader_runner: Add commands to query index, loc, loc-index.

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

Tests glGetProgramResourceIndex(), glGetProgramLocation() and
glGetProgramLocationIndex().
---
 tests/shaders/shader_runner.c | 97 +--
 1 file changed, 92 insertions(+), 5 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 893a99422..58da5e7b1 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -3244,6 +3244,35 @@ query_resource_name(unsigned interface_type, GLuint 
index,
   expected_name, got_name);
 }
 
+static void
+query_resource_index(unsigned interface_type, const char *name, GLuint 
expected,
+const char *query_str)
+{
+   GLuint got = glGetProgramResourceIndex(prog, interface_type, name);
+
+   query_check_error_int(query_str, expected, got);
+}
+
+static void
+query_resource_location(unsigned interface_type, const char *name,
+   GLint expected, const char *query_str)
+{
+
+   GLint got = glGetProgramResourceLocation(prog, interface_type, name);
+
+   query_check_error_int(query_str, expected, got);
+}
+
+static void
+query_resource_location_index(unsigned interface_type, const char *name,
+ GLint expected, const char *query_str)
+{
+   GLint got = glGetProgramResourceLocationIndex(prog, interface_type,
+ name);
+
+   query_check_error_int(query_str, expected, got);
+}
+
 static void
 parse_resource_info(const char **line, unsigned interface_type,
struct resource_info *resource)
@@ -3624,6 +3653,69 @@ verify_program_interface_query(const char *line,
   expected, query_str, block_data);
}
 
+   }
+   break;
+   case QUERY_RESOURCE_INDEX: {
+   static const struct string_to_enum invalid_index[] = {
+   ENUM_STRING(GL_INVALID_INDEX),
+   { NULL, 0 }
+   };
+
+   char name[512];
+   GLuint expected;
+
+   if (parse_str(line, "\"\"", ))
+   name[0] = '\0';
+   else
+   REQUIRE(parse_word_copy(line, name, sizeof(name),
+   ),
+   "Bad name at: %s\n", line);
+
+   REQUIRE(parse_enum_tab(invalid_index, line,
+  (unsigned *) , ) ||
+   parse_uint(line, , ),
+   "Bad expected index at: %s\n", line);
+
+   snprintf(query_str, sizeof(query_str),
+"glGetProgramResourceIndex (%s, %s)",
+piglit_get_gl_enum_name(interface_type),
+name);
+
+   query_resource_index(interface_type, name, expected, query_str);
+   }
+   break;
+   case QUERY_RESOURCE_LOCATION:
+   case QUERY_RESOURCE_LOCATION_INDEX: {
+   char name[512];
+   GLint expected;
+
+   if (parse_str(line, "\"\"", ))
+   name[0] = '\0';
+   else
+   REQUIRE(parse_word_copy(line, name, sizeof(name),
+   ),
+   "Bad name at: %s\n", line);
+
+   REQUIRE(parse_int(line, , ),
+   "Bad expected value at: %s\n", line);
+
+   if (query == QUERY_RESOURCE_LOCATION) {
+   snprintf(query_str, sizeof(query_str),
+"glGetProgramResourceLocation(%s, %s)",
+piglit_get_gl_enum_name(interface_type),
+name);
+
+   query_resource_location(interface_type, name, expected,
+   query_str);
+   } else {
+   snprintf(query_str, sizeof(query_str),
+"glGetProgramResourceLocationIndex(%s, %s)",
+piglit_get_gl_enum_name(interface_type),
+name);
+
+   query_resource_location_index(interface_type, name,
+ expected, query_str);
+   }
}
break;
case QUERY_RESOURCE_NAME: {
@@ -3664,11 +3756,6 @@ verify_program_interface_query(const char *line,
expected_length, expected_name, query_str);
}
break;
-   case QUERY_RESOURCE_INDEX:
-   case QUERY_RESOURCE_LOCATION:
-   case QUERY_RESOURCE_LOCATION_INDEX:
-   assert(!"Not implemented.");
-   break;
default:
assert(!"Should not get here.");
}
-- 
2.19.1


[Piglit] [PATCH 25/63] arb_gl_spirv: add xfb tests

2019-02-23 Thread Alejandro Piñeiro
Testing different things, from very basic types, to something more
complex like arrays of blocks where just one member is captured.

All of them are VS, as it is the most common use case.
---
 .../execution/xfb/vs_aoa.shader_test  | 131 +
 .../execution/xfb/vs_block.shader_test| 121 
 .../execution/xfb/vs_block_array.shader_test  | 158 
 ..._block_array_offset_per_member.shader_test | 154 
 .../execution/xfb/vs_double.shader_test   | 126 +
 .../execution/xfb/vs_simple.shader_test   |  80 
 .../vs_simple_multiple_samples.shader_test|  88 +
 .../execution/xfb/vs_struct.shader_test   | 116 
 .../execution/xfb/vs_struct_array.shader_test | 153 
 .../execution/xfb/vs_two_block.shader_test| 170 +
 .../execution/xfb/vs_two_sets.shader_test | 160 
 .../execution/xfb/vs_two_sets_ifc.shader_test | 165 +
 .../xfb/vs_two_sets_struct.shader_test| 173 ++
 13 files changed, 1795 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/xfb/vs_aoa.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/xfb/vs_block.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/xfb/vs_block_array.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/xfb/vs_block_array_offset_per_member.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/xfb/vs_double.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/xfb/vs_simple.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/xfb/vs_simple_multiple_samples.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/xfb/vs_struct.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/xfb/vs_struct_array.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/xfb/vs_two_block.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/xfb/vs_two_sets.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/xfb/vs_two_sets_ifc.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/xfb/vs_two_sets_struct.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/xfb/vs_aoa.shader_test 
b/tests/spec/arb_gl_spirv/execution/xfb/vs_aoa.shader_test
new file mode 100644
index 0..be9e5ddfb
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/xfb/vs_aoa.shader_test
@@ -0,0 +1,131 @@
+# XFB test using an array of arrays input variable
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 41
+; Schema: 0
+   OpCapability Shader
+   OpCapability TransformFeedback
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %color %var %extra 
%gl_VertexID %gl_InstanceID
+   OpExecutionMode %main Xfb
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpDecorate %color XfbBuffer 0
+   OpDecorate %color XfbStride 28
+   OpDecorate %var Location 1
+   OpDecorate %var XfbBuffer 0
+   OpDecorate %var XfbStride 28
+   OpDecorate %var Offset 0
+   OpDecorate %extra Location 10
+   OpDecorate %extra XfbBuffer 0
+   OpDecorate %extra XfbStride 28
+   OpDecorate %extra Offset 24
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %12 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+   %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_arr_float_uint_3 = OpTypeArray %float %uint_3
+ %uint_2 = OpConstant %uint 2
+%_arr__arr_float_uint_3_uint_2 = OpTypeArray %_arr_float_uint_3 %uint_2
+%_ptr_Output__arr__arr_float_uint_3_uint_2 = OpTypePointer Output 
%_arr__arr_float_uint_3_uint_2
+%var = OpVariable %_ptr_Output__arr__arr_float_uint_3_uint_2 Output
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Output_float = OpTypePointer Output %float
+  %int_1 = OpConstant %int 1
+%float_2 = OpConstant %float 2
+  %int_2 = OpConstant %int 2
+%float_3 = OpConstant %float 3
+%float_4 = OpConstant %float 4
+%float_5 = OpConstant %float 5
+%float_6 = OpConstant %float 6
+  %extra = OpVariable %_ptr_Output_float 

[Piglit] [PATCH 26/63] arb_gl_spirv: Add TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH test

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

---
 .../program/max-length-xfb-query.shader_test  | 79 +++
 1 file changed, 79 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/queries/program/max-length-xfb-query.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/queries/program/max-length-xfb-query.shader_test
 
b/tests/spec/arb_gl_spirv/execution/queries/program/max-length-xfb-query.shader_test
new file mode 100644
index 0..c3dd65d4c
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/queries/program/max-length-xfb-query.shader_test
@@ -0,0 +1,79 @@
+# TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH test for a shader without
+# names, making this SPIRV ONLY, as such option is not possible on
+# GLSL. Main objective is checking that it is returning the default
+# value for this case.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 20
+; Schema: 0
+   OpCapability Shader
+   OpCapability TransformFeedback
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %color %xfb_out %gl_VertexID 
%gl_InstanceID
+   OpExecutionMode %main Xfb
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpDecorate %color XfbBuffer 0
+   OpDecorate %color XfbStride 4
+   OpDecorate %xfb_out Location 1
+   OpDecorate %xfb_out XfbBuffer 0
+   OpDecorate %xfb_out XfbStride 4
+   OpDecorate %xfb_out Offset 0
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %12 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+%_ptr_Output_float = OpTypePointer Output %float
+%xfb_out = OpVariable %_ptr_Output_float Output
+%float_1_2305 = OpConstant %float 1.2305
+%int = OpTypeInt 32 1
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+   OpStore %color %12
+   OpStore %xfb_out %float_1_2305
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+layout(location = 0) out vec4 color;
+layout(location = 1, xfb_buffer=0, xfb_offset = 0) out float xfb_out;
+
+void main() {
+  color = vec4(0.0, 1.0, 0.0, 1.0);
+  xfb_out = 1.231;
+}
+
+[test]
+
+xfb buffer object 0 4
+xfb draw arrays GL_POINTS 0 1
+
+expected buffer 4
+expected buffer float 0 1.231
+
+probe xfb buffer float 0 1
+
+verify program_query GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 1
\ No newline at end of file
-- 
2.19.1

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

[Piglit] [PATCH 28/63] arb_gl_spirv: add a basic geometry shader

2019-02-23 Thread Alejandro Piñeiro
---
 .../execution/simple-geometry.shader_test | 241 ++
 1 file changed, 241 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/simple-geometry.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/simple-geometry.shader_test 
b/tests/spec/arb_gl_spirv/execution/simple-geometry.shader_test
new file mode 100644
index 0..0480f1884
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/simple-geometry.shader_test
@@ -0,0 +1,241 @@
+# Test a very simple vertex-geometry-fragment shader pipeline with two
+# uniforms with explicit location, using glsl as base.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 4
+; Bound: 24
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %_ %piglit_vertex %gl_VertexID 
%gl_InstanceID
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+   OpName %_ ""
+   OpName %piglit_vertex "piglit_vertex"
+   OpName %gl_VertexID "gl_VertexID"
+   OpName %gl_InstanceID "gl_InstanceID"
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %piglit_vertex Location 0
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpLoad %v4float %piglit_vertex
+ %20 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %20 %18
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 430
+
+layout(location = 0) in vec4 piglit_vertex;
+
+void main() {
+   gl_Position = piglit_vertex;
+}
+
+[geometry shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 4
+; Bound: 41
+; Schema: 0
+   OpCapability Geometry
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Geometry %main "main" %_ %gl_in
+   OpExecutionMode %main Triangles
+   OpExecutionMode %main Invocations 1
+   OpExecutionMode %main OutputTriangleStrip
+   OpExecutionMode %main OutputVertices 3
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %i "i"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+   OpName %_ ""
+   OpName %gl_PerVertex_0 "gl_PerVertex"
+   OpMemberName %gl_PerVertex_0 0 "gl_Position"
+   OpMemberName %gl_PerVertex_0 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex_0 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex_0 3 "gl_CullDistance"
+   OpName %gl_in "gl_in"
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate 

[Piglit] [PATCH 32/63] shader_runner: Add support for indexed draw calls

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

There is now an [elements] section which can contain a list of indices
as well as a draw elements command to draw with it.
---
 tests/shaders/shader_runner.c | 99 +++
 1 file changed, 99 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 851d66b04..778229e2a 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -185,6 +185,9 @@ static GLuint vao = 0;
 static GLuint draw_fbo, read_fbo;
 static GLint render_width, render_height;
 static GLint read_width, read_height;
+static uint16_t *elements_buffer;
+static size_t num_elements;
+static size_t elements_buffer_size;
 
 static bool use_get_program_binary = false;
 
@@ -313,6 +316,7 @@ enum states {
compute_shader_spirv,
compute_shader_specializations,
vertex_data,
+   elements,
test,
 };
 
@@ -1395,6 +1399,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
vertex_data_end = line;
break;
 
+   case elements:
+   break;
+
case test:
break;
 
@@ -1644,6 +1651,40 @@ process_specialization(enum states state, const char 
*line)
return PIGLIT_FAIL;
 }
 
+static enum piglit_result
+process_elements(enum states state, const char *line)
+{
+   const char *end = strchrnul(line, '\n');
+
+   while (true) {
+   while (line < end && isspace(*line))
+   line++;
+   if (line >= end  || *line == '#')
+   return PIGLIT_PASS;
+
+   if (num_elements >= elements_buffer_size) {
+   if (elements_buffer_size == 0)
+   elements_buffer_size = 1;
+   else
+   elements_buffer_size *= 2;
+   elements_buffer = realloc(elements_buffer,
+ elements_buffer_size *
+ sizeof *elements_buffer);
+   }
+
+   unsigned val;
+   if (parse_uints(line, , 1, ) != 1 ||
+   val > UINT16_MAX) {
+   fprintf(stderr, "Invalid elements line\n");
+   return PIGLIT_FAIL;
+   }
+
+   elements_buffer[num_elements++] = val;
+   }
+
+   return PIGLIT_PASS;
+}
+
 static enum piglit_result
 process_test_script(const char *script_name)
 {
@@ -1738,6 +1779,8 @@ process_test_script(const char *script_name)
} else if (parse_str(line, "[vertex data]", NULL)) {
state = vertex_data;
vertex_data_start = NULL;
+   } else if (parse_str(line, "[elements]", NULL)) {
+   state = elements;
} else if (parse_str(line, "[test]", NULL)) {
test_start = strchrnul(line, '\n');
test_start_line_num = line_num + 1;
@@ -1802,6 +1845,14 @@ process_test_script(const char *script_name)
vertex_data_start = line;
break;
 
+   case elements: {
+   enum piglit_result result =
+   process_elements(state, line);
+   if (result != PIGLIT_PASS)
+   return result;
+   break;
+   }
+
case test:
break;
}
@@ -4467,6 +4518,26 @@ draw_arrays_common(int first, size_t count)
return result;
 }
 
+static enum piglit_result
+draw_elements_common(int basevertex, int count)
+{
+   enum piglit_result result = program_must_be_in_use();
+   if (basevertex < 0) {
+   printf("draw elements 'basevertex' must be >= 0\n");
+   piglit_report_result(PIGLIT_FAIL);
+   }
+   if (count <= 0) {
+   printf("draw elements 'count' must be > 0\n");
+   piglit_report_result(PIGLIT_FAIL);
+   } else if (count > num_elements) {
+   printf("draw elements cannot draw beyond %lu\n",
+   (unsigned long) num_elements);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+   bind_vao_if_supported();
+   return result;
+}
+
 static bool
 probe_atomic_counter(unsigned buffer_num, GLint counter_num, const char *op,
 uint32_t value, bool uses_layout_qualifiers)
@@ -4790,6 +4861,19 @@ piglit_display(void)
size_t count = (size_t) y;
result = draw_arrays_common(first, count);
glDrawArrays(mode, first, count);
+   } else if (sscanf(line, 

[Piglit] [PATCH 34/63] arb_gl_spirv: Add a test for gl_VertexID

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

This value is different from Vulkan because it should include the
firstvertex and basevertex parameters.
---
 .../execution/vs-vertex-id.shader_test| 192 ++
 1 file changed, 192 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/vs-vertex-id.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/vs-vertex-id.shader_test 
b/tests/spec/arb_gl_spirv/execution/vs-vertex-id.shader_test
new file mode 100644
index 0..23566
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/vs-vertex-id.shader_test
@@ -0,0 +1,192 @@
+# Tests that gl_VertexID includes the ‘first’ parameter of non-indexed
+# draw calls and the ‘baseVertex’ parameter of indexed draws.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.5
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 44
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %expected_vertex_id 
%gl_VertexID %color %_ %piglit_vertex %gl_InstanceID
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %expected_vertex_id "expected_vertex_id"
+   OpName %gl_VertexID "gl_VertexID"
+   OpName %color "color"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+   OpName %_ ""
+   OpName %piglit_vertex "piglit_vertex"
+   OpName %gl_InstanceID "gl_InstanceID"
+   OpDecorate %expected_vertex_id Location 1
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   OpDecorate %color Location 0
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %piglit_vertex Location 0
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%_ptr_Input_int = OpTypePointer Input %int
+%expected_vertex_id = OpVariable %_ptr_Input_int Input
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+   %bool = OpTypeBool
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %22 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+  %float_255 = OpConstant %float 255
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+  %int_0 = OpConstant %int 0
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+  %9 = OpLoad %int %expected_vertex_id
+ %11 = OpLoad %int %gl_VertexID
+ %13 = OpIEqual %bool %9 %11
+   OpSelectionMerge %15 None
+   OpBranchConditional %13 %14 %23
+ %14 = OpLabel
+   OpStore %color %22
+   OpBranch %15
+ %23 = OpLabel
+ %24 = OpLoad %int %expected_vertex_id
+ %25 = OpConvertSToF %float %24
+ %27 = OpFDiv %float %25 %float_255
+ %28 = OpLoad %int %gl_VertexID
+ %29 = OpConvertSToF %float %28
+ %30 = OpFDiv %float %29 %float_255
+ %31 = OpCompositeConstruct %v4float %float_1 %27 %30 %float_1
+   OpStore %color %31
+   OpBranch %15
+ %15 = OpLabel
+ %41 = OpLoad %v4float %piglit_vertex
+ %42 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %42 %41
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+layout(location = 0) in vec4 piglit_vertex;
+layout(location = 1) in int expected_vertex_id;
+layout(location = 0) out vec4 color;
+
+void
+main()
+{
+if (expected_vertex_id == gl_VertexID) {
+color = vec4(0.0, 1.0, 0.0, 1.0);
+} else {
+

[Piglit] [PATCH 24/63] shader_runner: add xfb query object support

2019-02-23 Thread Alejandro Piñeiro
This commit adds query objects for GL_PRIMITIVES_GENERATED and
GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, and only for xfb
drawing. Those query objects are created implicitly during xfb
drawing.

We don't add general query object support for two reasons:
  * Right now only xfb tests would be using it.

  * Adding general support would make the test section more
complicated, as we would need to add beginquery/endquery like
commands, making [test] section too much of a GL pseudocode.

If in the future we need general query object support, we can just
expand this.

It also add them always for any xfb drawing, instead of
conditionally. Again, to make things easier.

So it introduces just one [test] command, that can be used as:

  * "verify query_object GL_PRIMITIVES_GENERATED "

  * "verify query_object GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 
"
---
 tests/shaders/shader_runner.c | 76 +++
 1 file changed, 76 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 795f30682..851d66b04 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -154,6 +154,7 @@ static GLuint xfb[MAX_XFB_BUFFERS];
 
 /* Store expected xfb values. Used for floats and doubles values */
 static void *expected_buffer = NULL;
+static GLuint queries[2];
 
 #define SHADER_TYPES 6
 static GLuint *subuniform_locations[SHADER_TYPES];
@@ -3563,6 +3564,68 @@ enum program_interface_queries {
QUERY_RESOURCE_NAME,
 };
 
+/**
+ * Checks if the GL_QUERY_RESULT of a given query object has the
+ * expected value.
+ *
+ * Note that right now it only supports the following two queries:
+ ** GL_PRIMITIVES_GENERATED
+ ** GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
+ *
+ * As right now we are only creating those query objects with xfb
+ * rendering.
+ *
+ * Format of the command:
+ *
+ *  verify query_object GL_PRIMITIVES_GENERATED integer
+ *
+ * or
+ *
+ *  verify query_object GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN integer
+ */
+static void
+verify_query_object_result(const char *line)
+{
+   static const struct string_to_enum all_targets[] = {
+   ENUM_STRING(GL_PRIMITIVES_GENERATED),
+   ENUM_STRING(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN),
+   { NULL, 0 }
+   };
+
+   unsigned target;
+   unsigned expected;
+   unsigned value = 0;
+   unsigned index = 0;
+
+   REQUIRE(parse_enum_tab(all_targets, line,
+  , ),
+   "Bad query object target at: %s\n", line);
+
+   REQUIRE(parse_uint(line, , ),
+   "Bad expected value at: %s\n", line);
+
+/* Previous require already checks if the target is one of the
+ * supported ones.
+ */
+index = target == GL_PRIMITIVES_GENERATED ? 0 : 1;
+
+   if (queries[index]) {
+   glGetQueryObjectuiv(queries[index], GL_QUERY_RESULT, );
+   } else {
+   fprintf(stderr, "query object for target %s is not initialized. 
"
+   "Did you forget to call \"xfb draw arrays\"?\n",
+   piglit_get_gl_enum_name(target));
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   if (expected != value) {
+   fprintf(stderr, "glGetQueryObjectuiv(GL_QUERY_RESULT) for a %s "
+"query object: expected %d, got %d\n",
+   piglit_get_gl_enum_name(target), expected, value);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+}
+
 /**
  * Query properties of interfaces and resources used by a program
  * using ARB_program_interface_query queries.
@@ -4350,6 +4413,10 @@ teardown_xfb(void)
}
if (expected_buffer != NULL)
free(expected_buffer);
+   for (unsigned i = 0; i < 2 ; ++i) {
+   if (queries[0])
+   glDeleteQueries(1, [i]);
+   }
 }
 
 static enum piglit_result
@@ -4508,6 +4575,10 @@ piglit_xfb_draw_arrays(GLenum mode, int first, size_t 
count)
 {
GLenum primitive_mode = piglit_xfb_primitive_mode(mode);
 
+   glGenQueries(2, queries);
+   glBeginQuery(GL_PRIMITIVES_GENERATED, queries[0]);
+   glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queries[1]);
+
glEnable(GL_RASTERIZER_DISCARD);
 
/* We don't need to call glBindBufferBase here, it is done on
@@ -4521,6 +4592,9 @@ piglit_xfb_draw_arrays(GLenum mode, int first, size_t 
count)
glDisable(GL_RASTERIZER_DISCARD);
 
glFlush();
+
+   glEndQuery(GL_PRIMITIVES_GENERATED);
+   glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
 }
 
 enum piglit_result
@@ -5518,6 +5592,8 @@ piglit_display(void)
 verify_program_query(rest);
} else if (parse_str(line, "verify program_interface_query ", 
)) {
verify_program_interface_query(rest, block_data);
+   } else if (parse_str(line, 

[Piglit] [PATCH 29/63] arb_gl_spirv: added tests for functions and function calls

2019-02-23 Thread Alejandro Piñeiro
From: Eleni Maria Stea 

---
 .../execution/simple-function.shader_test |  98 +++
 .../linker/simple-function-call.shader_test   | 112 ++
 2 files changed, 210 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/simple-function.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/linker/simple-function-call.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/simple-function.shader_test 
b/tests/spec/arb_gl_spirv/execution/simple-function.shader_test
new file mode 100644
index 0..44711ec60
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/simple-function.shader_test
@@ -0,0 +1,98 @@
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 5
+; Bound: 47
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %out_color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %ambient_f1_vf4_ "ambient(f1;vf4;"
+   OpName %a "a"
+   OpName %color "color"
+   OpName %out_color "out_color"
+   OpName %param "param"
+   OpName %param_0 "param"
+   OpDecorate %out_color Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%_ptr_Function_float = OpTypePointer Function %float
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+ %10 = OpTypeFunction %v4float %_ptr_Function_float 
%_ptr_Function_v4float
+   %uint = OpTypeInt 32 0
+ %uint_0 = OpConstant %uint 0
+ %uint_1 = OpConstant %uint 1
+ %uint_2 = OpConstant %uint 2
+ %uint_3 = OpConstant %uint 3
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %out_color = OpVariable %_ptr_Output_v4float Output
+  %float_0_1 = OpConstant %float 0.1
+  %float_0_3 = OpConstant %float 0.3
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %43 = OpConstantComposite %v4float %float_0_3 %float_0 %float_0 
%float_1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+  %param = OpVariable %_ptr_Function_float Function
+%param_0 = OpVariable %_ptr_Function_v4float Function
+   OpStore %param %float_0_1
+   OpStore %param_0 %43
+ %46 = OpFunctionCall %v4float %ambient_f1_vf4_ %param %param_0
+   OpStore %out_color %46
+   OpReturn
+   OpFunctionEnd
+%ambient_f1_vf4_ = OpFunction %v4float None %10
+  %a = OpFunctionParameter %_ptr_Function_float
+  %color = OpFunctionParameter %_ptr_Function_v4float
+ %14 = OpLabel
+ %17 = OpAccessChain %_ptr_Function_float %color %uint_0
+ %18 = OpLoad %float %17
+ %19 = OpLoad %float %a
+ %20 = OpFAdd %float %18 %19
+ %22 = OpAccessChain %_ptr_Function_float %color %uint_1
+ %23 = OpLoad %float %22
+ %24 = OpLoad %float %a
+ %25 = OpFAdd %float %23 %24
+ %27 = OpAccessChain %_ptr_Function_float %color %uint_2
+ %28 = OpLoad %float %27
+ %29 = OpLoad %float %a
+ %30 = OpFAdd %float %28 %29
+ %32 = OpAccessChain %_ptr_Function_float %color %uint_3
+ %33 = OpLoad %float %32
+ %34 = OpCompositeConstruct %v4float %20 %25 %30 %33
+   OpReturnValue %34
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) out vec4 out_color;
+const vec4 color = vec4(0.3, 0.0, 0.0, 1.0);
+
+vec4 ambient(float a, vec4 color) {
+   return vec4(color.r + a, color.g + a, color.b + a, color.a);
+}
+
+void main()
+{
+   out_color = ambient(0.1, color);
+}
+
+[test]
+draw rect -1 -1 2 2
+probe all rgba 0.4 0.1 0.1 1.0
diff --git a/tests/spec/arb_gl_spirv/linker/simple-function-call.shader_test 
b/tests/spec/arb_gl_spirv/linker/simple-function-call.shader_test
new file mode 100644
index 0..27d09b01e
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/linker/simple-function-call.shader_test
@@ -0,0 +1,112 @@
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+GL_ARB_separate_shader_objects
+
+; The test uses a very simple function call in the fragment shader
+; (the ambient function from the second fragment shader).
+; For the moment, making the function slightly more complex (by adding
+; uniforms or varyings makes testing impossible because of this glslang
+; error: https://github.com/KhronosGroup/glslang/issues/1285
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT 

[Piglit] [PATCH 31/63] arb_gl_spirv: Add a test for matching a block by location with SSOs

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

This is copied from
arb_enhanced_layouts/execution/block-member-locations
---
 ...o-block-member-layout-location.shader_test | 257 ++
 1 file changed, 257 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/sso-block-member-layout-location.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/sso-block-member-layout-location.shader_test
 
b/tests/spec/arb_gl_spirv/execution/sso-block-member-layout-location.shader_test
new file mode 100644
index 0..a796252c8
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/sso-block-member-layout-location.shader_test
@@ -0,0 +1,257 @@
+// Test that interface block members are correctly matched by explicit
+// location.
+//
+// This is copied from arb_enhanced_layouts/execution/block-member-locations/
+
+[require]
+SPIRV YES
+GLSL >= 4.40
+SSO ENABLED
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 40
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %name %_ %piglit_vertex 
%gl_VertexID %gl_InstanceID
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %block "block"
+   OpMemberName %block 0 "c"
+   OpMemberName %block 1 "d"
+   OpMemberName %block 2 "a"
+   OpMemberName %block 3 "b"
+   OpName %name "name"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+   OpName %_ ""
+   OpName %piglit_vertex "piglit_vertex"
+   OpName %gl_VertexID "gl_VertexID"
+   OpName %gl_InstanceID "gl_InstanceID"
+   OpMemberDecorate %block 0 Location 2
+   OpMemberDecorate %block 1 Location 3
+   OpMemberDecorate %block 2 Location 0
+   OpMemberDecorate %block 3 Location 1
+   OpDecorate %block Block
+   OpDecorate %name Location 0
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %piglit_vertex Location 0
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+  %block = OpTypeStruct %v4float %v4float %v4float %v4float
+%_ptr_Output_block = OpTypePointer Output %block
+   %name = OpVariable %_ptr_Output_block Output
+%int = OpTypeInt 32 1
+  %int_2 = OpConstant %int 2
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %15 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %int_3 = OpConstant %int 3
+ %19 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+  %int_0 = OpConstant %int 0
+ %22 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1
+  %int_1 = OpConstant %int 1
+ %25 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %17 = OpAccessChain %_ptr_Output_v4float %name %int_2
+   OpStore %17 %15
+ %20 = OpAccessChain %_ptr_Output_v4float %name %int_3
+   OpStore %20 %19
+ %23 = OpAccessChain %_ptr_Output_v4float %name %int_0
+   OpStore %23 %22
+ %26 = OpAccessChain %_ptr_Output_v4float %name %int_1
+   OpStore %26 %25
+ %35 = OpLoad %v4float %piglit_vertex
+ %36 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %36 %35
+

[Piglit] [PATCH 20/63] shader_runner: Check compatibility for resource name queries

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

For several queries defined at ARB_program_interface_query, OpenGL
already provided and API to query such information.

With this patch we test that the queries defined at
ARB_program_interface_query returns the same values that such API
alread existing. On the patch, we refer the latter for "old APIs".

This helps us to test that the old APIs return the desired values when
no name reflection is available as defined in the ARB_gl_spirv
specification:

"22. How do the program interface query APIs work when no name reflection
information is available?
...
GetUniformLocation(.., name) -> -1
GetActiveUniformName(.., length, uniformName) -> length=0, uniformName = ""
GetUniformIndices(..,uniformNames, uniformIndices) -> 
uniformIndices=INVALID_INDEX
GetActiveUniform(..,length,.., name) -> length = 0, name = ""
GetActiveUniformsiv(..,pname=UNIFORM_NAME_LENGTH,..) -> params = 1
GetUniformBlockIndex(.., uniformBlockName) -> INVALID_INDEX
GetActiveUniformBlockName(..,length,uniformBlockName) -> length=0, 
uniformBlockName=""
GetActiveUniformBlockiv(.., pname=UNIFORM_BLOCK_NAME_LENGTH, ..) -> params 
= 1
GetActiveAttrib(..) -> length = 0, name = ""
GetAttribLocation(.., name) -> -1
GetFragDataLocation(.., name) -> -1
GetFragDataIndex(.., name) -> -1"

v2: tweak the commit message to explain better what "old APIs" means
on this patch (Alejandro Piñeiro)
---
 tests/shaders/shader_runner.c | 204 +++---
 1 file changed, 187 insertions(+), 17 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 58da5e7b1..624817b59 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -2977,36 +2977,57 @@ active_uniform(const char *line)
 }
 
 static void
-query_check_error_int(const char *query_str, int expected, int got)
+query_check_error_int(const char *query_str, const char *old_query_str,
+ int expected, int got)
 {
if (!piglit_check_gl_error(GL_NO_ERROR)) {
-   fprintf(stderr, "%s error\n", query_str);
+   fprintf(stderr, "%s error\n",
+   old_query_str ? old_query_str : query_str);
piglit_report_result(PIGLIT_FAIL);
}
 
if (got != expected) {
-   fprintf(stderr, "%s: expected = %d, got = %d\n",
-   query_str, expected, got);
+   if (old_query_str) {
+   fprintf(stderr,
+   "%s returns a different value than %s: "
+   "expected = %d, got = %d\n",
+   old_query_str, query_str,
+   expected, got);
+   } else {
+   fprintf(stderr, "%s: expected = %d, got = %d\n",
+   query_str, expected, got);
+   }
piglit_report_result(PIGLIT_FAIL);
}
 }
 
 static void
-query_check_error_name(const char *query_str,
+query_check_error_name(const char *query_str, const char *old_query_str,
   int expected_length, int got_length,
   const char *expected_name, const char *got_name)
 {
if (!piglit_check_gl_error(GL_NO_ERROR)) {
-   fprintf(stderr, "%s error\n", query_str);
+   fprintf(stderr, "%s error\n",
+   old_query_str ? old_query_str : query_str);
piglit_report_result(PIGLIT_FAIL);
}
 
if (got_length != expected_length || strcmp(got_name, expected_name)) {
-   fprintf(stderr,
-   "%s: expected (length = %d, name = \"%s\"),"
-   "got (length = %d, name = \"%s\")\n", query_str,
-   expected_length, expected_name,
-   got_length, got_name);
+   if (old_query_str != NULL) {
+   fprintf(stderr,
+   "%s returns different values than %s: "
+   "expected (length = %d, name = \"%s\"), "
+   "got (length = %d, name = \"%s\")\n",
+   old_query_str, query_str,
+   expected_length, expected_name,
+   got_length, got_name);
+   } else {
+   fprintf(stderr,
+   "%s: expected (length = %d, name = \"%s\"),"
+   "got (length = %d, name = \"%s\")\n", query_str,
+   expected_len

[Piglit] [PATCH 27/63] arb_gl_spirv: array of interface block test

2019-02-23 Thread Alejandro Piñeiro
---
 .../array_of_input_output_block.shader_test   | 171 ++
 1 file changed, 171 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/array_of_input_output_block.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/array_of_input_output_block.shader_test 
b/tests/spec/arb_gl_spirv/execution/array_of_input_output_block.shader_test
new file mode 100644
index 0..a1c266291
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/array_of_input_output_block.shader_test
@@ -0,0 +1,171 @@
+# This tests defines an array of interface block output on the vertex
+# shader, and consume it as an array of blocks input on the fragment
+# shader.
+
+[require]
+SPIRV YES
+GLSL >= 4.50
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 44
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %_ %piglit_vertex %x 
%gl_VertexID %gl_InstanceID
+   OpSource GLSL 450
+   OpName %_ ""
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %piglit_vertex Location 0
+   OpDecorate %block Block
+   OpDecorate %x Location 0
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %block = OpTypeStruct %v4float %v4float
+ %uint_2 = OpConstant %uint 2
+%_arr_block_uint_2 = OpTypeArray %block %uint_2
+%_ptr_Output__arr_block_uint_2 = OpTypePointer Output %_arr_block_uint_2
+  %x = OpVariable %_ptr_Output__arr_block_uint_2 Output
+%float_0 = OpConstant %float 0
+%float_0_10001 = OpConstant %float 0.10001
+ %28 = OpConstantComposite %v4float %float_0 %float_0_10001 
%float_0 %float_0_10001
+  %int_1 = OpConstant %int 1
+%float_0_20003 = OpConstant %float 0.20003
+ %32 = OpConstantComposite %v4float %float_0 %float_0_20003 
%float_0 %float_0_20003
+%float_0_30012 = OpConstant %float 0.30012
+ %35 = OpConstantComposite %v4float %float_0 %float_0_30012 
%float_0 %float_0_30012
+%float_0_40006 = OpConstant %float 0.40006
+  %float_0_5 = OpConstant %float 0.5
+ %39 = OpConstantComposite %v4float %float_0 %float_0_40006 
%float_0 %float_0_5
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpLoad %v4float %piglit_vertex
+ %20 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %20 %18
+ %29 = OpAccessChain %_ptr_Output_v4float %x %int_0 %int_0
+   OpStore %29 %28
+ %33 = OpAccessChain %_ptr_Output_v4float %x %int_0 %int_1
+   OpStore %33 %32
+ %36 = OpAccessChain %_ptr_Output_v4float %x %int_1 %int_0
+   OpStore %36 %35
+ %40 = OpAccessChain %_ptr_Output_v4float %x %int_1 %int_1
+   OpStore %40 %39
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+out block {
+vec4 v;
+vec4 v2;
+} x[2];
+
+layout(location=0) in vec4 piglit_vertex;
+
+void main() {
+  gl_Position = piglit_vertex;
+
+  x[0].v  = vec4(0.0, 0.1, 0.0, 0.1);
+  x[0].v2 = vec4(0.0, 0.2, 0.0, 0.2);
+
+  x[1].v  = vec4(0.0, 0.3, 0.0, 0.3);
+  x[1].v2 = vec4(0.0, 0.4, 0.0, 0.5);
+}
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 31
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" 

[Piglit] [PATCH 23/63] shader_runner: add xfb testing support

2019-02-23 Thread Alejandro Piñeiro
Limited to capture doubles and floats, for simplicity. This patch
introduces the following [test] commands:

   * "expected buffer ": it allocates a expected buffer of the
 given  in bytes. It frees any previous one if already
 allocated.

   * "expected buffer float  ": sets 
 at the expected buffer  position, it assumes that the
 expected buffer will be used to store floats.

   * "expected buffer double  ": sets
  at the expected buffer  position, it
 assumes that the expected buffer will be used to store doubles.

   * "xfb buffer object  ": generates and allocates
 one TRANSFORM_FEEDBACK_BUFFER buffer object, with declared buffer
  (so xfb_buffer =  on the shader) and a given
  in bytes.

   * "xfb draw arrays   ": equivalent to the
 already existing command "draw arrays", but under a transform
 feedback operation, and enabling GL_RASTERIZER_DISCARD.

   * "probe xfb buffer   ":
 compares  of the expected value buffer with the xfb
 buffer . It does a comparison using ,
 being the allowed values "float" or "double". Both expected
 buffer and the xfb buffer are expected to be already allocated,
 and of the proper size.
---
 tests/shaders/shader_runner.c | 106 ++
 1 file changed, 106 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index d786963bd..795f30682 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -149,6 +149,11 @@ static GLenum geometry_layout_output_type = 
GL_TRIANGLE_STRIP;
 static GLint geometry_layout_vertices_out = 0;
 static GLuint atomics_bos[8];
 static GLuint ssbo[32];
+#define MAX_XFB_BUFFERS 4 /* Same value used at nir_xfb_info */
+static GLuint xfb[MAX_XFB_BUFFERS];
+
+/* Store expected xfb values. Used for floats and doubles values */
+static void *expected_buffer = NULL;
 
 #define SHADER_TYPES 6
 static GLuint *subuniform_locations[SHADER_TYPES];
@@ -4337,6 +4342,16 @@ teardown_atomics(void)
}
 }
 
+static void
+teardown_xfb(void)
+{
+   for (unsigned i = 0; i < MAX_XFB_BUFFERS; ++i) {
+   glDeleteBuffers(MAX_XFB_BUFFERS, [i]);
+   }
+   if (expected_buffer != NULL)
+   free(expected_buffer);
+}
+
 static enum piglit_result
 program_must_be_in_use(void)
 {
@@ -4464,6 +4479,50 @@ probe_ssbo_uint(GLint ssbo_index, GLint ssbo_offset, 
const char *op, uint32_t va
return true;
 }
 
+GLenum piglit_xfb_primitive_mode(GLenum draw_arrays_mode)
+{
+   switch (draw_arrays_mode) {
+   case GL_POINTS:
+   return GL_POINTS;
+   case GL_LINES:
+   case GL_LINE_LOOP:
+   case GL_LINE_STRIP:
+   case GL_LINES_ADJACENCY:
+   case GL_LINE_STRIP_ADJACENCY:
+   return GL_LINES;
+   case GL_TRIANGLES:
+   case GL_TRIANGLE_STRIP:
+   case GL_TRIANGLE_FAN:
+   case GL_TRIANGLES_ADJACENCY:
+   case GL_TRIANGLE_STRIP_ADJACENCY:
+   return GL_TRIANGLES;
+   }
+
+   printf("glDrawArrays mode %s not supported for a transform feedback 
operation\n",
+  piglit_get_gl_enum_name(draw_arrays_mode));
+   piglit_report_result(PIGLIT_FAIL);
+}
+
+static void
+piglit_xfb_draw_arrays(GLenum mode, int first, size_t count)
+{
+   GLenum primitive_mode = piglit_xfb_primitive_mode(mode);
+
+   glEnable(GL_RASTERIZER_DISCARD);
+
+   /* We don't need to call glBindBufferBase here, it is done on
+* the "xfb buffer object" command
+*/
+
+   glBeginTransformFeedback(primitive_mode);
+   glDrawArrays(mode, first, count);
+   glEndTransformFeedback();
+
+   glDisable(GL_RASTERIZER_DISCARD);
+
+   glFlush();
+}
+
 enum piglit_result
 piglit_display(void)
 {
@@ -5082,6 +5141,52 @@ piglit_display(void)
glBufferData(GL_SHADER_STORAGE_BUFFER, y,
 ssbo_init, GL_DYNAMIC_DRAW);
free(ssbo_init);
+   } else if (sscanf(line, "expected buffer %d", ) == 1) {
+   if (expected_buffer)
+   free(expected_buffer);
+   expected_buffer = calloc(x, 1);
+   } else if (sscanf(line, "expected buffer float %u %f", , 
[0]) == 2) {
+   float *float_buffer = (float *) expected_buffer;
+   if (!expected_buffer) {
+   fprintf(stderr, "No expected buffer 
allocated\n");
+   piglit_report_result(PIGLIT_FAIL);
+   }
+   float_buffer[ux] = c[0];
+   } else if (sscanf(line, "expected buffer double %u %lf", , 
[0])) {
+   double *double_buffer = (double *) expected_buffer;
+   if (!expected_buffer) {
+   fprintf(stderr, "No expected buffer 
allocated\n");
+   

[Piglit] [PATCH 30/63] arb_gl_spirv: adding basic vertex attrib 64-bit tests

2019-02-23 Thread Alejandro Piñeiro
For now just:
  * Simple
  * Simple with array.

In general ARB_gl_spirv implementation didn't need to add too many
specifics. Those two were enough to catch the minor things, and enough
to cover the barebone testing. For a more detailed testing it is more
practical to borrow the extensive testing done on the
arb_vertex_attrib_64bit generated tests.
---
 .../execution/va64/array.shader_test  | 202 ++
 .../execution/va64/simple.shader_test | 175 +++
 2 files changed, 377 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/va64/array.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/va64/simple.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/va64/array.shader_test 
b/tests/spec/arb_gl_spirv/execution/va64/array.shader_test
new file mode 100644
index 0..9a165ef18
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/va64/array.shader_test
@@ -0,0 +1,202 @@
+# 64-bit vertex attrib test using an array. Assumes that 64-bit
+# uniform support is working
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 6
+; Bound: 56
+; Schema: 0
+   OpCapability Shader
+   OpCapability Float64
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %_ %piglit_vertex %fs_color 
%array_value %gl_VertexID %gl_InstanceID
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpMemberName %gl_PerVertex 3 "gl_CullDistance"
+   OpName %_ ""
+   OpName %piglit_vertex "piglit_vertex"
+   OpName %fs_color "fs_color"
+   OpName %array_value "array_value"
+   OpName %expected0 "expected0"
+   OpName %expected1 "expected1"
+   OpName %gl_VertexID "gl_VertexID"
+   OpName %gl_InstanceID "gl_InstanceID"
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %piglit_vertex Location 2
+   OpDecorate %fs_color Location 0
+   OpDecorate %array_value Location 0
+   OpDecorate %expected0 Location 0
+   OpDecorate %expected0 DescriptorSet 0
+   OpDecorate %expected1 Location 1
+   OpDecorate %expected1 DescriptorSet 0
+   OpDecorate %gl_VertexID BuiltIn VertexId
+   OpDecorate %gl_InstanceID BuiltIn InstanceId
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %fs_color = OpVariable %_ptr_Output_v4float Output
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %24 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+ %double = OpTypeFloat 64
+   %v2double = OpTypeVector %double 2
+ %uint_2 = OpConstant %uint 2
+%_arr_v2double_uint_2 = OpTypeArray %v2double %uint_2
+%_ptr_Input__arr_v2double_uint_2 = OpTypePointer Input %_arr_v2double_uint_2
+%array_value = OpVariable %_ptr_Input__arr_v2double_uint_2 Input
+%_ptr_Input_v2double = OpTypePointer Input %v2double
+%_ptr_UniformConstant_v2double = OpTypePointer UniformConstant %v2double
+  %expected0 = OpVariable %_ptr_UniformConstant_v2double UniformConstant
+   %bool = OpTypeBool
+ %v2bool = OpTypeVector %bool 2
+ %43 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+  %int_1 = OpConstant %int 1
+  %expected1 = OpVariable %_ptr_UniformConstant_v2double UniformConstant
+%_ptr_Input_int = OpTypePointer Input %int
+%gl_VertexID = OpVariable %_ptr_Input_int Input
+%gl_InstanceID = OpVariable %_ptr_Input_int Input
+   %main = OpFunction %void None %3
+  

[Piglit] [PATCH 14/63] shader_runner: Add skeleton to support more query commands

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

---
 tests/shaders/shader_runner.c | 372 ++
 1 file changed, 283 insertions(+), 89 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 7d24c50bc..97cb89079 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -3049,100 +3049,15 @@ confirm_program_resource(GLenum interface_type, GLuint 
resource_index,
return true;
 }
 
-/**
- * Query an active resource using ARB_program_interface_query functions
- *
- * Format of the command:
- *
- *  verify program_interface_query GL_INTERFACE_TYPE_ENUM name GL_PNAME_ENUM 
integer
- *
- * or
- *
- *  verify program_interface_query GL_INTERFACE_TYPE_ENUM name GL_PNAME_ENUM 
GL_TYPE_ENUM
- */
 static void
-active_program_interface(const char *line, struct block_info block_data)
+query_resource_by_name(unsigned interface_type, const char *name, unsigned 
prop,
+  int expected, const char *query_str,
+  struct block_info block_data)
 {
-   static const struct string_to_enum all_props[] = {
-   ENUM_STRING(GL_TYPE),
-   ENUM_STRING(GL_ARRAY_SIZE),
-   ENUM_STRING(GL_NAME_LENGTH),
-   ENUM_STRING(GL_BLOCK_INDEX),
-   ENUM_STRING(GL_OFFSET),
-   ENUM_STRING(GL_ARRAY_STRIDE),
-   ENUM_STRING(GL_MATRIX_STRIDE),
-   ENUM_STRING(GL_IS_ROW_MAJOR),
-   ENUM_STRING(GL_ATOMIC_COUNTER_BUFFER_INDEX),
-   ENUM_STRING(GL_BUFFER_BINDING),
-   ENUM_STRING(GL_BUFFER_DATA_SIZE),
-   ENUM_STRING(GL_NUM_ACTIVE_VARIABLES),
-   ENUM_STRING(GL_REFERENCED_BY_VERTEX_SHADER),
-   ENUM_STRING(GL_REFERENCED_BY_TESS_CONTROL_SHADER),
-   ENUM_STRING(GL_REFERENCED_BY_TESS_EVALUATION_SHADER),
-   ENUM_STRING(GL_REFERENCED_BY_GEOMETRY_SHADER),
-   ENUM_STRING(GL_REFERENCED_BY_FRAGMENT_SHADER),
-   ENUM_STRING(GL_REFERENCED_BY_COMPUTE_SHADER),
-   ENUM_STRING(GL_TOP_LEVEL_ARRAY_SIZE),
-   ENUM_STRING(GL_TOP_LEVEL_ARRAY_STRIDE),
-   ENUM_STRING(GL_LOCATION),
-   ENUM_STRING(GL_LOCATION_INDEX),
-   ENUM_STRING(GL_LOCATION_COMPONENT),
-   ENUM_STRING(GL_IS_PER_PATCH),
-   ENUM_STRING(GL_NUM_COMPATIBLE_SUBROUTINES),
-   ENUM_STRING(GL_COMPATIBLE_SUBROUTINES),
-   { NULL, 0 }
-   };
-
-   static const struct string_to_enum all_program_interface[] = {
-   ENUM_STRING(GL_UNIFORM),
-   ENUM_STRING(GL_UNIFORM_BLOCK),
-   ENUM_STRING(GL_PROGRAM_INPUT),
-   ENUM_STRING(GL_PROGRAM_OUTPUT),
-   ENUM_STRING(GL_BUFFER_VARIABLE),
-   ENUM_STRING(GL_SHADER_STORAGE_BLOCK),
-   ENUM_STRING(GL_ATOMIC_COUNTER_BUFFER),
-   ENUM_STRING(GL_VERTEX_SUBROUTINE),
-   ENUM_STRING(GL_TESS_CONTROL_SUBROUTINE),
-   ENUM_STRING(GL_TESS_EVALUATION_SUBROUTINE),
-   ENUM_STRING(GL_GEOMETRY_SUBROUTINE),
-   ENUM_STRING(GL_FRAGMENT_SUBROUTINE),
-   ENUM_STRING(GL_COMPUTE_SUBROUTINE),
-   ENUM_STRING(GL_VERTEX_SUBROUTINE_UNIFORM),
-   ENUM_STRING(GL_TESS_CONTROL_SUBROUTINE_UNIFORM),
-   ENUM_STRING(GL_TESS_EVALUATION_SUBROUTINE_UNIFORM),
-   ENUM_STRING(GL_GEOMETRY_SUBROUTINE_UNIFORM),
-   ENUM_STRING(GL_FRAGMENT_SUBROUTINE_UNIFORM),
-   ENUM_STRING(GL_COMPUTE_SUBROUTINE_UNIFORM),
-   ENUM_STRING(GL_TRANSFORM_FEEDBACK_VARYING),
-   { NULL, 0 }
-   };
-
-   char name[512];
char name_buf[512];
-   unsigned prop, interface_type;
-   int expected;
int i;
int num_active_buffers;
 
-   if (!piglit_is_extension_supported("GL_ARB_program_interface_query") &&
-   piglit_get_gl_version() < 43) {
-   fprintf(stderr,
-   "GL_ARB_program_interface_query not supported or "
-   "OpenGL version < 4.3\n");
-   return;
-   }
-
-   REQUIRE(parse_enum_tab(all_program_interface, line,
-  _type, ),
-   "Bad program interface at: %s\n", line);
-   REQUIRE(parse_word_copy(line, name, sizeof(name), ),
-   "Bad program resource name at: %s\n", line);
-   REQUIRE(parse_enum_tab(all_props, line, , ),
-   "Bad glGetProgramResourceiv pname at: %s\n", line);
-   REQUIRE(parse_enum_tab(all_types, line, (unsigned *), ) ||
-   parse_int(line, , ),
-   "Bad expected value at: %s\n", line);
-
glGetProgramInterfaceiv(prog, interface_type,
GL_ACTIVE_RESOURCES, _active_buffers);
for (i = 0; i < num_active_buffers; i++) {
@@ -3193,6 +3108,285 @@ 

[Piglit] [PATCH 09/63] arb_gl_spirv: Add a test for SSBOs with an unsized array

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

This tests handling of the OpTypeRuntimeArray opcode.
---
 .../execution/ssbo/unsized-array.shader_test  | 119 ++
 1 file changed, 119 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/unsized-array.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/ssbo/unsized-array.shader_test 
b/tests/spec/arb_gl_spirv/execution/ssbo/unsized-array.shader_test
new file mode 100644
index 0..67d93f0ef
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ssbo/unsized-array.shader_test
@@ -0,0 +1,119 @@
+# As SSBO with the last member being an unsized array.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.30
+GL_ARB_gl_spirv
+GL_ARB_shader_storage_buffer_object
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 27
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color_out
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpDecorate %color_out Location 0
+   OpDecorate %_runtimearr_v4float ArrayStride 16
+   OpMemberDecorate %ssbo 0 Offset 0
+   OpMemberDecorate %ssbo 1 Offset 16
+   OpDecorate %ssbo BufferBlock
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 0
+   OpDecorate %color_num Location 0
+   OpDecorate %color_num DescriptorSet 0
+   OpDecorate %color_num Binding 1
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color_out = OpVariable %_ptr_Output_v4float Output
+%_runtimearr_v4float = OpTypeRuntimeArray %v4float
+   %ssbo = OpTypeStruct %v4float %_runtimearr_v4float
+%_ptr_Uniform_ssbo = OpTypePointer Uniform %ssbo
+  %_ = OpVariable %_ptr_Uniform_ssbo Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+  %int_1 = OpConstant %int 1
+   %uint = OpTypeInt 32 0
+%_ptr_UniformConstant_uint = OpTypePointer UniformConstant %uint
+  %color_num = OpVariable %_ptr_UniformConstant_uint UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %17 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0
+ %18 = OpLoad %v4float %17
+ %23 = OpLoad %uint %color_num
+ %24 = OpAccessChain %_ptr_Uniform_v4float %_ %int_1 %23
+ %25 = OpLoad %v4float %24
+ %26 = OpFAdd %v4float %18 %25
+   OpStore %color_out %26
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+
+#version 430
+
+layout(location = 0) out vec4 color_out;
+
+layout(std430, binding = 0) buffer ssbo
+{
+vec4 base_color;
+vec4 other_colors[];
+};
+
+layout(location = 0) uniform uint color_num;
+
+void main()
+{
+color_out = base_color + other_colors[color_num];
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+ssbo 0 128 # size, 8 vec4s
+
+ssbo 0 subdata float 0 -8
+ssbo 0 subdata float 4 6
+ssbo 0 subdata float 8 3
+ssbo 0 subdata float 12 1
+ssbo 0 subdata float 32 8
+ssbo 0 subdata float 36 -5.2
+ssbo 0 subdata float 40 -3
+ssbo 0 subdata float 44 0
+
+uniform uint 0 1
+draw rect -1 -1 1 2
+
+ssbo 0 subdata float 0 8
+ssbo 0 subdata float 4 42
+ssbo 0 subdata float 8 5
+ssbo 0 subdata float 12 9
+ssbo 0 subdata float 96 -8
+ssbo 0 subdata float 100 -41.2
+ssbo 0 subdata float 104 -5
+ssbo 0 subdata float 108 -8
+
+uniform uint 0 5
+draw rect 0 -1 1 2
+
+block binding 0
+verify program_interface_query GL_SHADER_STORAGE_BLOCK ssbo 
GL_NUM_ACTIVE_VARIABLES 2
+
+verify program_query GL_ACTIVE_UNIFORMS 1
+
+probe all rgba 0.0 0.8 0.0 1.0
-- 
2.19.1

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

[Piglit] [PATCH 12/63] arb_gl_spirv: add some arrays of arrays ubo/ssbo tests

2019-02-23 Thread Alejandro Piñeiro
Arrays of arrays of ubo/ssbo doesn't need to be supported on Vulkan,
but, from ARB_gl_spirv spec:

"Changes of system features, relative to Vulkan:

  . Vulkan does not allow multi-dimensional arrays of resources like
UBOs and SSBOs in its SPIR-V environment spec. SPIR-V supports
it and OpenGL already allows this for GLSL shaders. SPIR-V
for OpenGL also allows it."
---
 .../execution/ssbo/aoa-2.shader_test  | 294 ++
 .../execution/ssbo/aoa.shader_test| 199 
 .../execution/ubo/aoa-2.shader_test   | 281 +
 .../execution/ubo/aoa.shader_test | 197 
 4 files changed, 971 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/ssbo/aoa-2.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ssbo/aoa.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/aoa-2.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/aoa.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/ssbo/aoa-2.shader_test 
b/tests/spec/arb_gl_spirv/execution/ssbo/aoa-2.shader_test
new file mode 100644
index 0..efeba3843
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ssbo/aoa-2.shader_test
@@ -0,0 +1,294 @@
+# SSBO test using an array of arrays of ubos. UBO with two members.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 120
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpMemberDecorate %AOA 0 Offset 0
+   OpMemberDecorate %AOA 1 Offset 16
+   OpDecorate %AOA BufferBlock
+   OpDecorate %arr DescriptorSet 0
+   OpDecorate %arr Binding 5
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+%v2float = OpTypeVector %float 2
+%AOA = OpTypeStruct %v4float %v2float
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr_AOA_uint_2 = OpTypeArray %AOA %uint_2
+%_arr__arr_AOA_uint_2_uint_2 = OpTypeArray %_arr_AOA_uint_2 %uint_2
+%_ptr_Uniform__arr__arr_AOA_uint_2_uint_2 = OpTypePointer Uniform 
%_arr__arr_AOA_uint_2_uint_2
+%arr = OpVariable %_ptr_Uniform__arr__arr_AOA_uint_2_uint_2 Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+%float_610_072205 = OpConstant %float 610.072205
+%float_24998_1719 = OpConstant %float 24998.1719
+%float_8190_74414 = OpConstant %float 8190.74414
+%float_26479_0312 = OpConstant %float 26479.0312
+ %33 = OpConstantComposite %v4float %float_610_072205 
%float_24998_1719 %float_8190_74414 %float_26479_0312
+   %bool = OpTypeBool
+ %v4bool = OpTypeVector %bool 4
+  %int_1 = OpConstant %int 1
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+%float_n27681_2891 = OpConstant %float -27681.2891
+%float_9081_78711 = OpConstant %float 9081.78711
+ %47 = OpConstantComposite %v2float %float_n27681_2891 
%float_9081_78711
+ %v2bool = OpTypeVector %bool 2
+%float_15538_2891 = OpConstant %float 15538.2891
+%float_5642_53711 = OpConstant %float 5642.53711
+%float_n23131_3867 = OpConstant %float -23131.3867
+%float_18541_5391 = OpConstant %float 18541.5391
+ %60 = OpConstantComposite %v4float %float_15538_2891 
%float_5642_53711 %float_n23131_3867 %float_18541_5391
+%float_n12496_1973 = OpConstant %float -12496.1973
+%float_n5854_81055 = OpConstant %float -5854.81055
+ %70 = OpConstantComposite %v2float %float_n12496_1973 
%float_n5854_81055
+%float_n32637_8945 = OpConstant %float -32637.8945
+%float_12265_4824 = OpConstant %float 12265.4824
+%float_n13669_0615 = OpConstant %float -13669.0615
+%float_27760_8262 = OpConstant %float 27760.8262
+ %82 = OpConstantComposite %v4float %float_n32637_8945 
%float_12265_4824 %float_n13669_0615 %float_27760_8262
+%float_20530_7109 = OpConstant %float 20530.7109
+%float_n10508_5107 = OpConstant %float -10508.5107
+ %92 = OpConstantComposite %v2float 

[Piglit] [PATCH 22/63] arb_gl_spirv: Add ARB_program_interface_query tests

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

Added tests to check that the ARB_program_interface_query queries
involving names behave as described in the ARB_gl_spirv extension.

The SPIR-V used do not contain names. As names are optional in SPIR-V
this is useful to test the behaviour of the name related queries when
no name reflection is available.

Adds also tests to check that the queries not involving names work as
normally, as defined in the ARB_gl_spirv_extension specification.
---
 .../aggregate-types-name-queries.shader_test  | 225 +
 .../aggregate-types-other-queries.shader_test | 309 ++
 .../atomic-counter-other-queries.shader_test  | 286 
 .../simple-types-name-queries.shader_test | 242 ++
 .../simple-types-other-queries.shader_test| 297 +
 .../ubo-matrices-other-queries.shader_test| 175 ++
 ...o-nested-structs-other-queries.shader_test | 232 +
 7 files changed, 1766 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/queries/program-interface/aggregate-types-name-queries.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/queries/program-interface/aggregate-types-other-queries.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/queries/program-interface/atomic-counter-other-queries.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/queries/program-interface/simple-types-name-queries.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/queries/program-interface/simple-types-other-queries.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/queries/program-interface/ubo-matrices-other-queries.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/queries/program-interface/ubo-nested-structs-other-queries.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/queries/program-interface/aggregate-types-name-queries.shader_test
 
b/tests/spec/arb_gl_spirv/execution/queries/program-interface/aggregate-types-name-queries.shader_test
new file mode 100644
index 0..10e1577c4
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/queries/program-interface/aggregate-types-name-queries.shader_test
@@ -0,0 +1,225 @@
+# Tests the program interface queries related with names over aggregate
+# types (arrays, structs, arrays of arrays) in shaders constructed from
+# SPIR-V binaries where no name reflection information is available.
+#
+# ATOMIC_COUNTER_BUFFER interface is excluded, since active atomic
+# counter buffer resources are not assigned name strings
+# (ARB_program_interface_query) so that interface is not an allowed argument in
+# such queries.
+#
+# Queries which accept 'name' as parameter like GetProgramResourceIndex,
+# GetProgramResourceLocation and GetProgramResourceLocationIndex are tested in
+# another file.
+#
+# ARB_gl_spirv:
+#
+# 22. How do the program interface query APIs work when no name reflection
+# information is available?
+#
+#RESOLVED: The following naturally follows from the specification:
+#
+#GetProgramInterfaceiv(.., pname=MAX_NAME_LENGTH, ..) -> params = 1
+#...
+#GetProgramResourceName(.., length, name) -> length=0, name = ""
+#GetProgramResourceiv(.., props=NAME_LENGTH, ..) -> params = 1
+#...
+
+[require]
+SPIRV ONLY
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 45
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %outColor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %outColor Location 0
+   OpDecorate %u Location 1
+   OpDecorate %u DescriptorSet 0
+   OpDecorate %u Binding 1
+   OpDecorate %_arr_v4float_uint_2 ArrayStride 16
+   OpDecorate %_arr__arr_v4float_uint_2_uint_3 ArrayStride 32
+   OpDecorate %_arr__arr__arr_v4float_uint_2_uint_3_uint_2 
ArrayStride 96
+   OpDecorate %_arr_v4float_uint_2_0 ArrayStride 16
+   OpDecorate %_arr__arr_v4float_uint_2_0_uint_2 ArrayStride 32
+   OpMemberDecorate %ComponentsBlock 0 Offset 0
+   OpMemberDecorate %ComponentsBlock 1 Offset 192
+   OpDecorate %ComponentsBlock Block
+   OpDecorate %components DescriptorSet 0
+   OpDecorate %components Binding 5
+   OpMemberDecorate %parts_0 0 Offset 0
+   OpMemberDecorate %parts_0 1 Offset 16
+   OpMemberDecorate %SSBOComponentsBlock 0 Offset 0
+   OpDecorate %SSBOComponentsBlock BufferBlock
+   OpDecorate %ssbo_components 

[Piglit] [PATCH 10/63] arb_gl_spirv: add ssbo test using std140 and std430

2019-02-23 Thread Alejandro Piñeiro
The test includes two ssbos, with the same content but different
layouts, in order to ensure that works in both cases.

Note that std140 and std430 layouts are used on the base GLSL shader
used to generate the SPIR-V shaders. SPIR-V shaders doesn't include
info about the layout. From ARB_gl_spirv spec:

"Mapping of layouts

  std140/std430 -> explicit *Offset*, *ArrayStride*, and
 *MatrixStride* Decoration on struct members"

So the SPIR-V generated may have different explicit
offset/strides. For this test we include types on the ssbo that gets
different offsets/strides based on the layouts.
---
 .../two-ssbo-different-layouts.shader_test| 372 ++
 1 file changed, 372 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo-different-layouts.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo-different-layouts.shader_test 
b/tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo-different-layouts.shader_test
new file mode 100644
index 0..5a51c85bf
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo-different-layouts.shader_test
@@ -0,0 +1,372 @@
+# SSBO test with two ssbos, using different layouts (std140 and
+# std430) on the base GLSL shader. Just one stage.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 159
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpDecorate %_arr_v2float_uint_3 ArrayStride 16
+   OpMemberDecorate %ssbo1 0 Offset 0
+   OpMemberDecorate %ssbo1 1 ColMajor
+   OpMemberDecorate %ssbo1 1 Offset 48
+   OpMemberDecorate %ssbo1 1 MatrixStride 16
+   OpMemberDecorate %ssbo1 2 Offset 80
+   OpDecorate %ssbo1 BufferBlock
+   OpDecorate %ssbo140 DescriptorSet 0
+   OpDecorate %ssbo140 Binding 5
+   OpDecorate %_arr_v2float_uint_3_0 ArrayStride 8
+   OpMemberDecorate %ssbo2 0 Offset 0
+   OpMemberDecorate %ssbo2 1 ColMajor
+   OpMemberDecorate %ssbo2 1 Offset 24
+   OpMemberDecorate %ssbo2 1 MatrixStride 8
+   OpMemberDecorate %ssbo2 2 Offset 48
+   OpDecorate %ssbo2 BufferBlock
+   OpDecorate %ssbo430 DescriptorSet 0
+   OpDecorate %ssbo430 Binding 8
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+   %bool = OpTypeBool
+%v2float = OpTypeVector %float 2
+   %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_arr_v2float_uint_3 = OpTypeArray %v2float %uint_3
+%mat2v2float = OpTypeMatrix %v2float 2
+  %ssbo1 = OpTypeStruct %_arr_v2float_uint_3 %mat2v2float %v4float
+%_ptr_Uniform_ssbo1 = OpTypePointer Uniform %ssbo1
+%ssbo140 = OpVariable %_ptr_Uniform_ssbo1 Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+%float_5720_54443 = OpConstant %float 5720.54443
+%float_n21857_1582 = OpConstant %float -21857.1582
+ %32 = OpConstantComposite %v2float %float_5720_54443 
%float_n21857_1582
+ %v2bool = OpTypeVector %bool 2
+%_arr_v2float_uint_3_0 = OpTypeArray %v2float %uint_3
+  %ssbo2 = OpTypeStruct %_arr_v2float_uint_3_0 %mat2v2float %v4float
+%_ptr_Uniform_ssbo2 = OpTypePointer Uniform %ssbo2
+%ssbo430 = OpVariable %_ptr_Uniform_ssbo2 Uniform
+  %int_1 = OpConstant %int 1
+%float_n711_078674 = OpConstant %float -711.078674
+%float_8904_7334 = OpConstant %float 8904.7334
+ %58 = OpConstantComposite %v2float %float_n711_078674 %float_8904_7334
+  %int_2 = OpConstant %int 2
+%float_3164_0835 = OpConstant %float 3164.0835
+%float_20808_1934 = OpConstant %float 20808.1934
+ %79 = OpConstantComposite %v2float %float_3164_0835 %float_20808_1934
+%float_16690_9727 = OpConstant %float 16690.9727
+%float_9081_78711 = OpConstant %float 9081.78711
+ %99 = OpConstantComposite %v2float %float_16690_9727 %float_9081_78711

[Piglit] [PATCH 07/63] arb_gl_spirv: Add tests for UBOs with explicit offsets

2019-02-23 Thread Alejandro Piñeiro
From: Neil Roberts 

Adds two tests, one which has an explicit offset in GLSL using the
layout(offset) decoration on an interface member, and another which
has a struct embedded in an interface. On SPIR-V it is possible to set
an explicit offset even within this embedded struct (note that this
test is SPIR-V ONLY).
---
 .../explicit-offset-nested-struct.shader_test | 83 +++
 .../execution/ubo/explicit-offset.shader_test | 82 ++
 2 files changed, 165 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test
 
b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test
new file mode 100644
index 0..a23ff21e4
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test
@@ -0,0 +1,83 @@
+# Test a UBO with a member at an explicit offset. The member is itself
+# a struct with its own explicit offset.
+
+[require]
+SPIRV ONLY
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py, and then 
edited manually. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 20
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %outcolor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %outcolor "outcolor"
+   OpName %InnerThing "InnerThing"
+   OpMemberName %InnerThing 0 "ignored"
+   OpMemberName %InnerThing 1 "a"
+   OpName %Block "Block"
+   OpMemberName %Block 0 "thing"
+   OpName %_ ""
+   OpDecorate %outcolor Location 0
+   OpMemberDecorate %InnerThing 0 Offset 0
+   OpMemberDecorate %InnerThing 1 Offset 64
+   OpMemberDecorate %Block 0 Offset 64
+   OpDecorate %Block Block
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outcolor = OpVariable %_ptr_Output_v4float Output
+ %InnerThing = OpTypeStruct %float %v4float
+  %Block = OpTypeStruct %InnerThing
+%_ptr_Uniform_Block = OpTypePointer Uniform %Block
+  %_ = OpVariable %_ptr_Uniform_Block Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+  %int_1 = OpConstant %int 1
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_1
+ %19 = OpLoad %v4float %18
+   OpStore %outcolor %19
+   OpReturn
+   OpFunctionEnd
+
+[test]
+clear color 0.8 0.0 0.0 1.0
+
+# Set the value at a few locations. This shouldn’t affect the result
+# unless the shader is ignoring the offset.
+block binding 0
+block offset 0
+uniform vec4 a 0.9 0.0 0.0 1.0
+block offset 64
+uniform vec4 a 0.9 0.0 0.0 1.0
+block offset 80
+uniform vec4 a 0.9 0.0 0.0 1.0
+
+block offset 128
+uniform vec4 a 0.0 1.0 0.0 1.0
+
+verify program_interface_query GL_UNIFORM_BLOCK Block GL_BUFFER_DATA_SIZE 144
+verify program_query GL_ACTIVE_UNIFORMS 2
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
diff --git a/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test 
b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test
new file mode 100644
index 0..a2d77fb62
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test
@@ -0,0 +1,82 @@
+# Test a UBO with a member at an explicit offset
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 18
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %outcolor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpDecorate %outcolor Location 0
+   OpMemberDecorate %Block 0 Offset 16
+   OpDecorate %Block Block
+   OpDecorate %_ DescriptorSet 0
+

[Piglit] [PATCH 21/63] shader_runner: add UNSIGNED_INT_ATOMIC_COUNTER as allowed type

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

---
 tests/shaders/shader_runner.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 624817b59..d786963bd 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -393,6 +393,7 @@ static const struct string_to_enum all_types[] = {
ENUM_STRING(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY),
ENUM_STRING(GL_UNSIGNED_INT_SAMPLER_BUFFER),
ENUM_STRING(GL_UNSIGNED_INT_SAMPLER_2D_RECT),
+   ENUM_STRING(GL_UNSIGNED_INT_ATOMIC_COUNTER),
{ NULL, 0 }
 };
 
-- 
2.19.1

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

[Piglit] [PATCH 18/63] shader_runner: Add command to query the resource name

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

Tests glGetProgramResourceName().
---
 tests/shaders/shader_runner.c | 74 ++-
 1 file changed, 73 insertions(+), 1 deletion(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 51c31c9d8..893a99422 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -2991,6 +2991,26 @@ query_check_error_int(const char *query_str, int 
expected, int got)
}
 }
 
+static void
+query_check_error_name(const char *query_str,
+  int expected_length, int got_length,
+  const char *expected_name, const char *got_name)
+{
+   if (!piglit_check_gl_error(GL_NO_ERROR)) {
+   fprintf(stderr, "%s error\n", query_str);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   if (got_length != expected_length || strcmp(got_name, expected_name)) {
+   fprintf(stderr,
+   "%s: expected (length = %d, name = \"%s\"),"
+   "got (length = %d, name = \"%s\")\n", query_str,
+   expected_length, expected_name,
+   got_length, got_name);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+}
+
 static int
 resource_info_get_block_or_atomic_buffer_index(struct resource_info *resource)
 {
@@ -3209,6 +3229,21 @@ query_resource_by_name(unsigned interface_type, const 
char *name, unsigned prop,
return;
 }
 
+static void
+query_resource_name(unsigned interface_type, GLuint index,
+   GLsizei expected_length, const char *expected_name,
+   const char *query_str)
+{
+   GLsizei got_length;
+   char got_name[512];
+
+   glGetProgramResourceName(prog, interface_type, index, sizeof(got_name),
+_length, got_name);
+
+   query_check_error_name(query_str, expected_length, got_length,
+  expected_name, got_name);
+}
+
 static void
 parse_resource_info(const char **line, unsigned interface_type,
struct resource_info *resource)
@@ -3589,12 +3624,49 @@ verify_program_interface_query(const char *line,
   expected, query_str, block_data);
}
 
+   }
+   break;
+   case QUERY_RESOURCE_NAME: {
+   struct resource_info resource = {GL_NONE, -1, -1, -1, -1, 
false};
+   GLuint index;
+   GLsizei expected_length;
+   char expected_name[512];
+
+   parse_resource_info(, interface_type, );
+   index = resource_info_get_index();
+
+   REQUIRE(parse_int(line, _length, ),
+   "Bad expected length at: %s\n", line);
+
+   if (parse_str(line, "\"\"", ))
+   expected_name[0] = '\0';
+   else
+   REQUIRE(parse_word_copy(line, expected_name,
+   sizeof(expected_name), ),
+   "Bad expected name at: %s\n", line);
+
+   if (strlen(expected_name) != expected_length) {
+   fprintf(stderr,
+   "Expected values for length and name do not "
+   "match: length = %d, name = \"%s\" "
+   "(name's real length = %zu)\n",
+   expected_length, expected_name,
+   strlen(expected_name));
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   snprintf(query_str, sizeof(query_str),
+"glGetProgramResourceName(%s, %d)",
+piglit_get_gl_enum_name(interface_type),
+index);
+
+   query_resource_name(interface_type, index,
+   expected_length, expected_name, query_str);
}
break;
case QUERY_RESOURCE_INDEX:
case QUERY_RESOURCE_LOCATION:
case QUERY_RESOURCE_LOCATION_INDEX:
-   case QUERY_RESOURCE_NAME:
assert(!"Not implemented.");
break;
default:
-- 
2.19.1

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

[Piglit] [PATCH 11/63] arb_gl_spirv: add ubo array test with copy between arrays

2019-02-23 Thread Alejandro Piñeiro
For tests that triggered the lowering nir_split_vars to split arrays,
we found some crashes on ARB_gl_spirv if we didn't take into account
the explicit array stride on the splitted type. This is basically a
regression catching test.

This test is based on spec/glsl-1.40/uniform_buffer/fs-array-copy test
that was crashing when converted to a SPIR-V shader during the
development of ARB_gl_spirv support.
---
 .../ubo/array-inside-ubo-copy.shader_test | 137 ++
 1 file changed, 137 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test 
b/tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test
new file mode 100644
index 0..14ba9955f
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test
@@ -0,0 +1,137 @@
+# UBO test using an array inside an ubos, and a temporal array that
+# copy from it.
+
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 45
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpDecorate %_arr_v4float_uint_4_0 ArrayStride 16
+   OpMemberDecorate %Block 0 Offset 0
+   OpDecorate %Block Block
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 6
+   OpDecorate %color Location 0
+   OpDecorate %index Location 4
+   OpDecorate %index DescriptorSet 0
+   OpDecorate %index Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+   %uint = OpTypeInt 32 0
+ %uint_4 = OpConstant %uint 4
+%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4
+%_ptr_Function__arr_v4float_uint_4 = OpTypePointer Function 
%_arr_v4float_uint_4
+%_arr_v4float_uint_4_0 = OpTypeArray %v4float %uint_4
+  %Block = OpTypeStruct %_arr_v4float_uint_4_0
+%_ptr_Uniform_Block = OpTypePointer Uniform %Block
+  %_ = OpVariable %_ptr_Uniform_Block Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform__arr_v4float_uint_4_0 = OpTypePointer Uniform 
%_arr_v4float_uint_4_0
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+  %int_1 = OpConstant %int 1
+  %int_2 = OpConstant %int 2
+  %int_3 = OpConstant %int 3
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %36 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_0
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+%_ptr_UniformConstant_int = OpTypePointer UniformConstant %int
+  %index = OpVariable %_ptr_UniformConstant_int UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+   %temp = OpVariable %_ptr_Function__arr_v4float_uint_4 Function
+ %20 = OpAccessChain %_ptr_Uniform__arr_v4float_uint_4_0 %_ %int_0
+ %21 = OpLoad %_arr_v4float_uint_4_0 %20
+ %22 = OpCompositeExtract %v4float %21 0
+ %24 = OpAccessChain %_ptr_Function_v4float %temp %int_0
+   OpStore %24 %22
+ %25 = OpCompositeExtract %v4float %21 1
+ %27 = OpAccessChain %_ptr_Function_v4float %temp %int_1
+   OpStore %27 %25
+ %28 = OpCompositeExtract %v4float %21 2
+ %30 = OpAccessChain %_ptr_Function_v4float %temp %int_2
+   OpStore %30 %28
+ %31 = OpCompositeExtract %v4float %21 3
+ %33 = OpAccessChain %_ptr_Function_v4float %temp %int_3
+   OpStore %33 %31
+ %37 = OpAccessChain %_ptr_Function_v4float %temp %int_0
+   OpStore %37 %36
+ %42 = OpLoad %int %index
+ %43 = OpAccessChain %_ptr_Function_v4float %temp %42
+ %44 = OpLoad %v4float %43
+   OpStore %color %44
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 4) uniform int index;
+
+layout (location = 0) out vec4 color;
+
+layout (std140, binding = 6) uniform Block {
+   vec4 colors[4];
+};
+
+void main()
+{
+   vec4 temp[4] = colors;
+   temp[0] = vec4(1.0, 0.0, 0.0, 0.0);
+   color = temp[index];
+}
+
+[test]
+
+block binding 6
+block offset 0
+uniform vec4 colors[0] 0.0 0.0 0.0 0.0
+block offset 16
+uniform vec4 colors[1] 0.0 1.0 0.0 0.0
+block offset 32
+uniform vec4 colors[2] 0.0 1.0 

[Piglit] [PATCH 04/63] arb_gl_spirv: add some simple ubo/ssbo tests

2019-02-23 Thread Alejandro Piñeiro
Those include:
   * Simple test with just one ubo
   * Two different ubo on the same stage
   * Same ubo used on two different stages
   * Array and array using indirect index of ubos

Finally this also includes a test for a shader that was crashing on a
early version of the SPIR-V support. Included here just in case the
codebase regresses.

v2: don't check if the block content is correct with additions and
substractions of the ubo content (Timothy)
---
 .../execution/ssbo/array-indirect.shader_test | 121 
 .../ssbo/array-inside-ssbo.shader_test| 190 
 .../array-of-arrays-inside-ssbo.shader_test   | 204 +
 .../execution/ssbo/array.shader_test  | 173 +++
 .../execution/ssbo/simple.shader_test | 138 +
 .../execution/ssbo/two-ssbo.shader_test   | 151 ++
 .../execution/ssbo/two-stages.shader_test | 279 ++
 .../execution/ubo/array-indirect.shader_test  | 108 +++
 .../ubo/array-inside-ubo.shader_test  | 155 ++
 .../array-of-arrays-inside-ubo.shader_test| 185 
 .../execution/ubo/array.shader_test   | 140 +
 .../ubo/location-0-crash.shader_test  |  94 ++
 .../execution/ubo/simple.shader_test  | 131 
 .../execution/ubo/two-stages.shader_test  | 276 +
 .../execution/ubo/two-ubos.shader_test| 141 +
 15 files changed, 2486 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/array-indirect.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/array-inside-ssbo.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/array-of-arrays-inside-ssbo.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ssbo/array.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ssbo/simple.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/two-stages.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-indirect.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-of-arrays-inside-ubo.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/array.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/location-0-crash.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/simple.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/two-stages.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/two-ubos.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/ssbo/array-indirect.shader_test 
b/tests/spec/arb_gl_spirv/execution/ssbo/array-indirect.shader_test
new file mode 100644
index 0..62bb39d59
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ssbo/array-indirect.shader_test
@@ -0,0 +1,121 @@
+# SSBO test using an array of ssbo and indirect(dynamically uniform)
+# indexing. Just uses one stage.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 24
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpMemberDecorate %ssbo 0 Offset 0
+   OpDecorate %ssbo BufferBlock
+   OpDecorate %components DescriptorSet 0
+   OpDecorate %components Binding 5
+   OpDecorate %u_idx Location 10
+   OpDecorate %u_idx DescriptorSet 0
+   OpDecorate %u_idx Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+   %ssbo = OpTypeStruct %v4float
+   %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_arr_ssbo_uint_3 = OpTypeArray %ssbo %uint_3
+%_ptr_Uniform__arr_ssbo_uint_3 = OpTypePointer Uniform %_arr_ssbo_uint_3
+ %components = OpVariable %_ptr_Uniform__arr_ssbo_uint_3 Uniform
+%int = OpTypeInt 32 1
+%_ptr_UniformConstant_int = OpTypePointer UniformConstant %int
+  %u_idx = OpVariable %_ptr_UniformConstant_int UniformConstant
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %19 = OpLoad %int %u_idx
+   

[Piglit] [PATCH 02/63] arb_gl_spirv: add GL_ACTIVE_UNIFORMS checks

2019-02-23 Thread Alejandro Piñeiro
Right now the main reason is to check that we are expanding uniforms
for arrays and array of arrays of structs properly. This would be even
more important with UBO/SSBO tests.

The other reason is to check that hidden uniforms are really
hidden. As far as we know, current arb_gl_spirv tests doesn't use
internally any hidden uniform, at least on the i965 driver. But we
know of cases that will be send as tests in the future.
---
 tests/spec/arb_gl_spirv/execution/uniform/array.shader_test   | 2 ++
 .../execution/uniform/arrays-of-arrays.shader_test| 2 ++
 .../execution/uniform/atomic-uint-aoa-cs.shader_test  | 2 ++
 .../execution/uniform/atomic-uint-aoa-fs.shader_test  | 2 ++
 .../execution/uniform/atomic-uint-array-cs.shader_test| 2 ++
 .../execution/uniform/atomic-uint-array-fs.shader_test| 2 ++
 .../arb_gl_spirv/execution/uniform/atomic-uint-cs.shader_test | 2 ++
 .../execution/uniform/atomic-uint-fs.shader_runner| 1 +
 .../atomic-uint-mixing-with-normal-uniforms.shader_test   | 2 ++
 .../execution/uniform/atomic-uint-several-slots.shader_test   | 2 ++
 .../execution/uniform/embedded-structs.shader_test| 2 ++
 .../execution/uniform/index-matches-location.shader_test  | 2 ++
 .../execution/uniform/initializer-complex.shader_test | 2 ++
 .../execution/uniform/initializer-dvec4.shader_test   | 3 +++
 .../execution/uniform/initializer-mat4x3.shader_test  | 4 
 .../arb_gl_spirv/execution/uniform/initializer.shader_test| 2 ++
 .../execution/uniform/nonsequential-locations.shader_test | 2 ++
 .../execution/uniform/sampler2d-binding-array.shader_test | 2 ++
 .../execution/uniform/sampler2d-binding.shader_test   | 2 ++
 .../uniform/sampler2d-nonconst-nested-array.shader_test   | 2 ++
 .../execution/uniform/sampler2d-struct.shader_test| 2 ++
 .../spec/arb_gl_spirv/execution/uniform/sampler2d.shader_test | 2 ++
 .../execution/uniform/simple-without-names.shader_test| 2 ++
 tests/spec/arb_gl_spirv/execution/uniform/simple.shader_test  | 2 ++
 .../arb_gl_spirv/execution/uniform/struct-array.shader_test   | 2 ++
 tests/spec/arb_gl_spirv/execution/uniform/struct.shader_test  | 2 ++
 .../arb_gl_spirv/execution/uniform/two-uniforms.shader_test   | 2 ++
 27 files changed, 56 insertions(+)

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
index 54ac66b42..18ae3ca09 100644
--- a/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
+++ b/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
@@ -133,5 +133,7 @@ clear
 uniform vec4 0 0.2 0.1 0.1 1.6
 uniform vec4 1 0.5 2.0 3.0 0.25
 
+verify program_query GL_ACTIVE_UNIFORMS 1
+
 draw rect -1 -1 2 2
 probe all rgba 0.1 0.2 0.3 0.4
diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test
index 07e32560b..5c9b97fed 100644
--- a/tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test
+++ b/tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test
@@ -73,5 +73,7 @@ uniform vec4 11 0.4 0.5 0.6 0.7
 uniform vec4 12 0.8 0.9 1.0 1.1
 uniform vec4 13 0.1 0.2 0.3 0.4
 
+verify program_query GL_ACTIVE_UNIFORMS 2
+
 draw rect -1 -1 1 1
 relative probe rect rgb (0.0, 0.0, 0.5, 0.5) (0.1, 0.3, 0.5)
diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
index 5bc3850bf..eafc6e2e2 100644
--- a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
+++ b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
@@ -216,6 +216,8 @@ uniform uint 11 14  # a01_expected[5]
 
 uniform uint 12 30  # a12_expected
 
+verify program_query GL_ACTIVE_UNIFORMS 8
+
 # Check original values for the atomic counters
 
 probe atomic counter buffer 0 0 == 0
diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
index f259d3c0f..f24dd8659 100644
--- a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
+++ b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
@@ -197,6 +197,8 @@ uniform uint 0 3
 uniform uint 1 15
 uniform uint 2 17
 
+verify program_query GL_ACTIVE_UNIFORMS 5
+
 # Check original values for the atomic counters
 
 probe atomic counter buffer 0 0 == 0   # outside array (offset qualifier was 4)
diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-array-cs.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-array-cs.shader_test
index a9f831dbd..0f76c03c9 100644
--- a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-array-cs.shader_test
+++ 

[Piglit] [PATCH 17/63] shader_runner: Add command to query program interfaces

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

Tests glGetProgramInterfaceiv().
---
 tests/shaders/shader_runner.c | 30 +-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 331221449..51c31c9d8 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -3483,6 +3483,35 @@ verify_program_interface_query(const char *line,
"Bad program interface at: %s\n", line);
 
switch (query) {
+   case QUERY_INTERFACE: {
+   static const struct string_to_enum all_pnames[] = {
+   ENUM_STRING(GL_ACTIVE_RESOURCES),
+   ENUM_STRING(GL_MAX_NAME_LENGTH),
+   ENUM_STRING(GL_MAX_NUM_ACTIVE_VARIABLES),
+   ENUM_STRING(GL_MAX_NUM_COMPATIBLE_SUBROUTINES),
+   { NULL, 0 }
+   };
+
+   unsigned pname;
+   int expected;
+   GLint got;
+
+   REQUIRE(parse_enum_tab(all_pnames, line, , ),
+   "Bad glGetProgramInterfaceiv pname at: %s\n", line);
+   REQUIRE(parse_int(line, , ),
+   "Bad expected value at: %s\n", line);
+
+   snprintf(query_str, sizeof(query_str),
+"glGetProgramInterfaceiv(%s, %s)",
+piglit_get_gl_enum_name(interface_type),
+piglit_get_gl_enum_name(pname));
+
+   /* Do the actual query. */
+   got = ~expected;
+   glGetProgramInterfaceiv(prog, interface_type, pname, );
+   query_check_error_int(query_str, expected, got);
+   }
+   break;
case QUERY_RESOURCE_BY_DATA:
case QUERY_RESOURCE_BY_NAME: {
static const struct string_to_enum all_props[] = {
@@ -3562,7 +3591,6 @@ verify_program_interface_query(const char *line,
 
}
break;
-   case QUERY_INTERFACE:
case QUERY_RESOURCE_INDEX:
case QUERY_RESOURCE_LOCATION:
case QUERY_RESOURCE_LOCATION_INDEX:
-- 
2.19.1

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

[Piglit] [PATCH 08/63] arb_gl_spirv: add ubo tests with different matrix/array strides

2019-02-23 Thread Alejandro Piñeiro
ARB_gl_spirv requires that the SPIR-V includes the explicit matrix and
array stride. GLSL layouts are mapped in SPIR-V with explicit values
for offset, matrix stride and array stride, but as far as it respect
alignments and minimum offsets, the strides doesn't need to be exactly
what OpenGL GLSL computes for any of the allowed layouts, and in fact,
the rules are more similar to SPIR-V under Vulkan.

The tests defines two UBOs, with the same content (on type and data)
but that each one uses a different array/matrix stride. As they
contains the same content, you should be able to compare one and the
other on the code.

As you can't define different stride on GLSL, those are "SPIRV ONLY"
test. GLSL is there as a reference, as it was used to create the
SPIR-V shader, but then tweaked manually.

v2: no expected final substractions/additions value of content, but
check for real values (Timothy)
---
 ...ray-different-array-stride-ubo.shader_test | 272 ++
 .../different-matrix-stride.shader_test   | 260 +
 2 files changed, 532 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/matrix/different-matrix-stride.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
 
b/tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
new file mode 100644
index 0..02e41af9b
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
@@ -0,0 +1,272 @@
+# UBO test using two ubos, with an array with the same size and type,
+# but setting a different array stride for each one. Used to test that
+# the size is properly computed, and the content properly accessed in
+# both cases.
+
+[require]
+SPIRV ONLY
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py, and then 
edited by hand to set the proper array stride
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 123
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpName %__0 ""
+   OpDecorate %color Location 0
+   OpDecorate %_arr_v4float_uint_3 ArrayStride 16
+   OpMemberDecorate %block16 0 Offset 0
+   OpDecorate %block16 Block
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 5
+   OpDecorate %_arr_v4float_uint_3_0 ArrayStride 32
+   OpMemberDecorate %block32 0 Offset 0
+   OpDecorate %block32 Block
+   OpDecorate %__0 DescriptorSet 0
+   OpDecorate %__0 Binding 6
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+   %bool = OpTypeBool
+   %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_arr_v4float_uint_3 = OpTypeArray %v4float %uint_3
+%block16 = OpTypeStruct %_arr_v4float_uint_3
+%_ptr_Uniform_block16 = OpTypePointer Uniform %block16
+  %_ = OpVariable %_ptr_Uniform_block16 Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+%float_20530_7109 = OpConstant %float 20530.7109
+%float_n10508_5107 = OpConstant %float -10508.5107
+%float_n23051_9961 = OpConstant %float -23051.9961
+%float_n23564_0664 = OpConstant %float -23564.0664
+ %32 = OpConstantComposite %v4float %float_20530_7109 
%float_n10508_5107 %float_n23051_9961 %float_n23564_0664
+ %v4bool = OpTypeVector %bool 4
+  %int_1 = OpConstant %int 1
+%float_n27681_2891 = OpConstant %float -27681.2891
+%float_9081_78711 = OpConstant %float 9081.78711
+%float_n12496_1973 = OpConstant %float -12496.1973
+%float_n5854_81055 = OpConstant %float -5854.81055
+ %46 = OpConstantComposite %v4float %float_n27681_2891 
%float_9081_78711 %float_n12496_1973 %float_n5854_81055
+  %int_2 = OpConstant %int 2
+%float_5217_75732 = OpConstant %float 5217.75732
+%float_26363_8359 = OpConstant %float 26363.8359
+%float_n29557_3516 = OpConstant %float -29557.3516
+%float_30238_998 

[Piglit] [PATCH 13/63] arb_gl_spirv: Added tests for glGetProgramiv()

2019-02-23 Thread Alejandro Piñeiro
From: Antia Puentes 

The SPIR-V used does not contain names. As names are optional in
SPIR-V this is useful to test the behaviour of the name related
queries when no name reflection is available.
---
 .../program/max-length-queries.shader_test| 211 +
 .../queries/program/other-queries.shader_test | 212 ++
 2 files changed, 423 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/queries/program/max-length-queries.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/queries/program/other-queries.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/queries/program/max-length-queries.shader_test
 
b/tests/spec/arb_gl_spirv/execution/queries/program/max-length-queries.shader_test
new file mode 100644
index 0..54f87d48b
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/queries/program/max-length-queries.shader_test
@@ -0,0 +1,211 @@
+# Tests the program pname queries (glGetProgramiv) related with names in
+# shaders constructed from SPIR-V binaries where no name reflection
+# information is available.
+#
+# ARB_gl_spirv:
+#
+# 22. How do the program interface query APIs work when no name reflection
+# information is available?
+#
+#RESOLVED: The following naturally follows from the specification:
+#...
+#GetProgramiv(.., pname=ACTIVE_ATTRIBUTE_MAX_LENGTH, ..) -> params = 1
+#GetProgramiv(.., pname=ACTIVE_UNIFORM_MAX_LENGTH, ..) -> params = 1
+#GetProgramiv(.., pname=TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, ..) -> 
params = 1
+#GetProgramiv(.., pname=ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, ..) -> 
params = 1
+
+[require]
+SPIRV ONLY
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[geometry shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 41
+; Schema: 0
+   OpCapability Geometry
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Geometry %main "main" %_ %gl_in
+   OpExecutionMode %main Triangles
+   OpExecutionMode %main Invocations 1
+   OpExecutionMode %main OutputTriangleStrip
+   OpExecutionMode %main OutputVertices 3
+   OpSource GLSL 450
+   OpName %_ ""
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex Block
+   OpMemberDecorate %gl_PerVertex_0 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex_0 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex_0 2 BuiltIn ClipDistance
+   OpMemberDecorate %gl_PerVertex_0 3 BuiltIn CullDistance
+   OpDecorate %gl_PerVertex_0 Block
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+  %int_0 = OpConstant %int 0
+  %int_3 = OpConstant %int 3
+   %bool = OpTypeBool
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+%gl_PerVertex_0 = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1
+ %uint_3 = OpConstant %uint 3
+%_arr_gl_PerVertex_0_uint_3 = OpTypeArray %gl_PerVertex_0 %uint_3
+%_ptr_Input__arr_gl_PerVertex_0_uint_3 = OpTypePointer Input 
%_arr_gl_PerVertex_0_uint_3
+  %gl_in = OpVariable %_ptr_Input__arr_gl_PerVertex_0_uint_3 Input
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %int_1 = OpConstant %int 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+  %i = OpVariable %_ptr_Function_int Function
+   OpStore %i %int_0
+   OpBranch %10
+ %10 = OpLabel
+   OpLoopMerge %12 %13 None
+   OpBranch %14
+ %14 = OpLabel
+ %15 = OpLoad %int %i
+ %18 = OpSLessThan %bool %15 %int_3
+   OpBranchConditional %18 %11 %12
+ %11 = OpLabel
+ %32 = OpLoad %int %i
+ %34 = OpAccessChain %_ptr_Input_v4float %gl_in %32 %int_0
+ %35 = OpLoad %v4float %34
+ %37 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %37 %35
+   OpEmitVertex
+   OpBranch %13
+ %13 = OpLabel
+ %38 = OpLoad %int %i
+ %40 = 

[Piglit] [PATCH 06/63] arb_gl_spirv: add a array of ubo test, with complex ubo content

2019-02-23 Thread Alejandro Piñeiro
Specifically the ubo contains some basic types, a struct type, with
array and matrices members.

v2:
  * Add some layer of complexity (to include some cases mentioned by
Timothy on the mesa-dev review)
  * No expected final substractions/additions value of content, but
check for real values (Timothy)
---
 .../execution/ubo/array-complex.shader_test   | 360 ++
 1 file changed, 360 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-complex.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/ubo/array-complex.shader_test 
b/tests/spec/arb_gl_spirv/execution/ubo/array-complex.shader_test
new file mode 100644
index 0..cf6baed77
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/array-complex.shader_test
@@ -0,0 +1,360 @@
+# UBO test using an array of ubos, with complex content.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 159
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpDecorate %_arr_v3float_uint_3 ArrayStride 16
+   OpDecorate %_arr_mat2v2float_uint_3 ArrayStride 32
+   OpMemberDecorate %S 0 Offset 0
+   OpMemberDecorate %S 1 Offset 48
+   OpMemberDecorate %S 2 RowMajor
+   OpMemberDecorate %S 2 Offset 64
+   OpMemberDecorate %S 2 MatrixStride 16
+   OpDecorate %_arr_S_uint_3 ArrayStride 160
+   OpMemberDecorate %ComponentsBlock 0 Offset 0
+   OpMemberDecorate %ComponentsBlock 1 Offset 8
+   OpMemberDecorate %ComponentsBlock 2 Offset 16
+   OpDecorate %ComponentsBlock Block
+   OpDecorate %components DescriptorSet 0
+   OpDecorate %components Binding 5
+   OpDecorate %struct_array Location 6
+   OpDecorate %struct_array DescriptorSet 0
+   OpDecorate %struct_array Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+%v2float = OpTypeVector %float 2
+%v3float = OpTypeVector %float 3
+   %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_arr_v3float_uint_3 = OpTypeArray %v3float %uint_3
+%mat2v2float = OpTypeMatrix %v2float 2
+%_arr_mat2v2float_uint_3 = OpTypeArray %mat2v2float %uint_3
+  %S = OpTypeStruct %_arr_v3float_uint_3 %v4float 
%_arr_mat2v2float_uint_3
+%_arr_S_uint_3 = OpTypeArray %S %uint_3
+%ComponentsBlock = OpTypeStruct %float %v2float %_arr_S_uint_3
+ %uint_2 = OpConstant %uint 2
+%_arr_ComponentsBlock_uint_2 = OpTypeArray %ComponentsBlock %uint_2
+%_ptr_Uniform__arr_ComponentsBlock_uint_2 = OpTypePointer Uniform 
%_arr_ComponentsBlock_uint_2
+ %components = OpVariable %_ptr_Uniform__arr_ComponentsBlock_uint_2 Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_float = OpTypePointer Uniform %float
+%float_5720_54443 = OpConstant %float 5720.54443
+   %bool = OpTypeBool
+  %int_1 = OpConstant %int 1
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+%float_n21857_1582 = OpConstant %float -21857.1582
+%float_n711_078674 = OpConstant %float -711.078674
+ %47 = OpConstantComposite %v2float %float_n21857_1582 
%float_n711_078674
+ %v2bool = OpTypeVector %bool 2
+  %int_2 = OpConstant %int 2
+%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
+%float_8904_7334 = OpConstant %float 8904.7334
+%float_3164_0835 = OpConstant %float 3164.0835
+%float_20808_1934 = OpConstant %float 20808.1934
+ %61 = OpConstantComposite %v3float %float_8904_7334 %float_3164_0835 
%float_20808_1934
+ %v3bool = OpTypeVector %bool 3
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+%float_n6150_84961 = OpConstant %float -6150.84961
+%float_n10267_4893 = OpConstant %float -10267.4893
+%float_26495_5859 = OpConstant %float 26495.5859
+%float_n12496_1973 = OpConstant %float -12496.1973
+ %75 = OpConstantComposite %v4float %float_n6150_84961 
%float_n10267_4893 %float_26495_5859 %float_n12496_1973
+ %v4bool = 

[Piglit] [PATCH 01/63] shader_runner: add support for glGetProgram queries

2019-02-23 Thread Alejandro Piñeiro
Similar to the already existing verify program_interface_query, but
with the glGetProgramiv queries.

Useful, for example, to verify the current number of active uniforms
(via GL_ACTIVE_UNIFORMS).

Note that now there are two ways to verify link success. With the
already existing "link succes" shader runner query, or using this one:

   vefiry program_query GL_LINK_STATUS GL_TRUE

Although internally they are checked in a different way. It is pending
to check if there are corner cases where they return a different
value.

v2: Add GL_LINE_STRIP and GL_TRIANGLE_STRIP as valid results for the
query (Antia Puentes).

Signed-off-by: Alejandro Piñeiro 
Signed-off-by: Antia Puentes 
---
 tests/shaders/shader_runner.c | 80 +++
 1 file changed, 80 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 6df8bd860..c1c757d1b 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -2659,6 +2659,84 @@ set_subroutine_uniform(const char *line)
return;
 }
 
+/**
+ * Query values from current program using glGetProgram.
+ *
+ * Format of the command:
+ *   verify program_query GL_PNAME_ENUM integer
+ *
+ * or
+ *
+ *   verify program_query GL_PNAME_ENUM 
+ *
+ * Note: GL_COMPUTE_WORK_GROUP_SIZE is not supported, as is the only
+ * query that requires a params with more than one component, and we
+ * want to keep things simple.
+ *
+ */
+static void
+verify_program_query(const char *line)
+{
+   static const struct string_to_enum all_pnames[] = {
+   ENUM_STRING(GL_DELETE_STATUS),
+   ENUM_STRING(GL_LINK_STATUS),
+   ENUM_STRING(GL_VALIDATE_STATUS),
+   ENUM_STRING(GL_INFO_LOG_LENGTH),
+   ENUM_STRING(GL_ATTACHED_SHADERS),
+   ENUM_STRING(GL_ACTIVE_ATOMIC_COUNTER_BUFFERS),
+   ENUM_STRING(GL_ACTIVE_ATTRIBUTES),
+   ENUM_STRING(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH),
+   ENUM_STRING(GL_ACTIVE_UNIFORMS),
+   ENUM_STRING(GL_ACTIVE_UNIFORM_BLOCKS),
+   ENUM_STRING(GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH),
+   ENUM_STRING(GL_ACTIVE_UNIFORM_MAX_LENGTH),
+   ENUM_STRING(GL_COMPUTE_WORK_GROUP_SIZE),
+   ENUM_STRING(GL_PROGRAM_BINARY_LENGTH),
+   ENUM_STRING(GL_TRANSFORM_FEEDBACK_BUFFER_MODE),
+   ENUM_STRING(GL_TRANSFORM_FEEDBACK_VARYINGS),
+   ENUM_STRING(GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH),
+   ENUM_STRING(GL_GEOMETRY_VERTICES_OUT),
+   ENUM_STRING(GL_GEOMETRY_INPUT_TYPE),
+   ENUM_STRING(GL_GEOMETRY_OUTPUT_TYPE),
+   { NULL, 0 }
+   };
+
+   static const struct string_to_enum all_possible_param_enums[] = {
+   ENUM_STRING(GL_TRUE),
+   ENUM_STRING(GL_FALSE),
+   ENUM_STRING(GL_SEPARATE_ATTRIBS),
+   ENUM_STRING(GL_INTERLEAVED_ATTRIBS),
+   ENUM_STRING(GL_POINTS),
+   ENUM_STRING(GL_LINES),
+   ENUM_STRING(GL_LINES_ADJACENCY),
+   ENUM_STRING(GL_TRIANGLES),
+   ENUM_STRING(GL_TRIANGLES_ADJACENCY),
+   ENUM_STRING(GL_LINE_STRIP),
+   ENUM_STRING(GL_TRIANGLE_STRIP),
+   { NULL, 0 }
+   };
+
+   unsigned pname;
+   int expected;
+   int value;
+
+   REQUIRE(parse_enum_tab(all_pnames, line,
+  , ),
+   "Bad glGetProgram pname at: %s\n", line);
+
+   REQUIRE(parse_enum_tab(all_possible_param_enums, line, (unsigned 
*), ) ||
+   parse_int(line, , ),
+   "Bad expected value at: %s\n", line);
+
+   glGetProgramiv(prog, pname, );
+
+   if (expected != value) {
+   fprintf(stderr, "glGetProgram(%s): expected %d, got %d\n",
+   piglit_get_gl_enum_name(pname), expected, value);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+}
+
 /**
  * Query a uniform using glGetActiveUniformsiv
  *
@@ -4396,6 +4474,8 @@ piglit_display(void)
parse_ints(rest, _array_index, 1, NULL);
} else if (parse_str(line, "active uniform ", )) {
active_uniform(rest);
+   } else if (parse_str(line, "verify program_query", )) {
+verify_program_query(rest);
} else if (parse_str(line, "verify program_interface_query ", 
)) {
active_program_interface(rest);
} else if (parse_str(line, "vertex attrib ", )) {
-- 
2.19.1

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

[Piglit] [PATCH 00/63] ARB_gl_spirv full series

2019-02-23 Thread Alejandro Piñeiro
Hi,

so finally we finished the cleaning up of the piglit series for the
ARB_gl_spirv support that we send to Mesa some weeks ago (see [1]).

As with Mesa, we preferred to send all the patches we thought that
were finished, instead of keeping sending subseries with specific
sub-features.

Again, we want to thanks Nicolai Hähnle, that was the one that started
this work.

A high-level, TL;DR, overview of this series is the following one:

  * Patches 01-47: more barebone tests for ARB_gl_spirv, including
more support on shader_runner if needed.

  * Patches 48-58: support for generation of ARB_gl_spirv tests. This
includes direct generation of SPIR-V tests through templates, and
support to transform existing GLSL tests from other specs, through
glslang (using a wrapper).

  * Patches 59-63: minor clean-ups and fixes.

And now going more into detail:

  * Patches 01-02: support for GL_ACTIVE_UNIFORMS queries, plus
modifying existing ARB_gl_spirv tests to include this query.

  * Patches 03-12: general (so both GLSL and SPIR-V) support for
running UBO/SSBO tests without using any name, plus UBO/SSBO
tests.

  * Patches 13-22: added further support for several shader
introspection queries, like program interface queries, plus tests
related with them. Here we have a lot of SPIRV ONLY tests (so
tests that shouldn't be run on GLSL), because those are tests
stripped of names, so several NAME related queries should return
specific values defined by ARB_gl_spirv.

  * Patches 23-27: added transform feedback support, transform
feedback related query object support, and the transform feedback
tests. One could wonder why it was added, as it was avoided for a
long time. On our experience, adding and editing tests was far
easier as soon as we added support for xfb on shader_runner, even
if it was really basic, and allowed to test several scenarios,
that would be more complex by adding C-programs like on existing
transform feedback tests.

  * Patches 28-47: miscellaneous barebone tests, and some basic extra
support on shader runner. A little of everything.

  * Patches 48-50: added support to load SPIR-V from a external
file. This would allow to have a GLSL test, and its SPIR-V
equivalent on a different file. This was useful on the developing
stages, in the case we wanted to reuse a existing GLSL test
without modifying it too much.

  * Patches 51-53: added script that tries to generate a SPIR-V test,
or tests, from a existing GLSL shader runner test, or set of
tests. This script serves as a wrapper over glslang, providing
extra features, like automatic skipping, mark existing tests,
parse SPIR-V shader for locations, etc. The script can include the
SPIR-V on the same test or generate a different file, on the same
directory or on a mirror one (more about that below).

  * Patches 54-55: integration of previous script with CMake. By
default OFF, as it adds a significant extra time while
building. On this integration, the SPIR-V tests are generated to a
new ("mirror") directory, as any other generated tests. As
mentioned, the script by default generates the SPIR-V on the same
directory, but that is only useful while developing. As a new
source of generated tests, it makes more sense on a new
directory. It is worth to note that it only converts tests from
the 'tests' directory, but we tested also converting tests from
'generated_tests'. But the latter can require even more time, ~45
min on an average machine, so we initially assume that that would
not be accepted even as an optional flag. We could be wrong
though.

  * Patches 56-58: add scripts that directly generates SPIR-V
shader_runner, using templates, as some other existing GLSL
generators.

  * Patches 59-64: as mentioned, minor clean-ups and fixes.

[1] https://gitlab.freedesktop.org/mesa/mesa/merge_requests/178



Alejandro Piñeiro (26):
  shader_runner: add support for glGetProgram queries
  arb_gl_spirv: add GL_ACTIVE_UNIFORMS checks
  shader_runner: add force_no_names mode
  arb_gl_spirv: add some simple ubo/ssbo tests
  arb_gl_spirv: add ubo/ssbo tests with matrices
  arb_gl_spirv: add a array of ubo test, with complex ubo content
  arb_gl_spirv: add ubo tests with different matrix/array strides
  arb_gl_spirv: add ssbo test using std140 and std430
  arb_gl_spirv: add ubo array test with copy between arrays
  arb_gl_spirv: add some arrays of arrays ubo/ssbo tests
  shader_runner: add xfb testing support
  shader_runner: add xfb query object support
  arb_gl_spirv: add xfb tests
  arb_gl_spirv: array of interface block test
  arb_gl_spirv: add a basic geometry shader
  arb_gl_spirv: adding basic vertex attrib 64-bit tests
  arb_gl_spirv: added regression catching function call test
  arb_gl_spirv: fix wrong extension name for atomic-uint-fs test
  framework: add --spirv opti

[Piglit] [PATCH 03/63] shader_runner: add force_no_names mode

2019-02-23 Thread Alejandro Piñeiro
Right now UBO data filling is based on using the name of the ubo and
their components, in order to get the block and uniform index. It also
uses it to set the binding (so it forces block_index and block_binding
to be equal).

Since ARB_shading_language_420pack it is possible to set a explicit
ubo binding, so it would be interesting to try to use it directly
without such re-binding, and gather the info without using the names
at all.

We extend this idea to the already existing program interface query
support, so we can do a subset of the queries using only the explicit
binding.

This will be specially interesting for ARB_gl_spirv testing, where
SPIR-V shaders should work without names, and explicit binding is not
just optional but mandatory. For that reason, if running using SPIR-V
instead of GLSL, we use this mode automatically, as it would fail
otherwise. Another alternative is not set a different mode, but
working this way when we are using SPIR-V shaders. But as mentioned,
there would be GLSL cases where this would be interesting, and we are
also interested on a sanity check when writing a SPIR-V test.

In order this to work on all cases, we need to also explicitly set
other info when filling the data:
  * offsets for each individual component
  * matrix stride
  * row major

Using the same approach used to fill the array index info. Note that
for arrays we are not adding array stride, as this can be done by
using the explicit offset. This allow us to not add another variable.

We extended this idea for SSBO, so we gather the info in a generic
"block_info" struct. Although this is not needed for ssbo data
filling, as it already uses the explicit binding, it became useful to
keep using program interface queries.

It is worth to note that some of the queries already supported by
shader_runner will not be supported on this mode, as they are based on
the names.

v2: improve legibility by avoiding so many indentation changes (Ian).

v3: fix length check for GL_NAME_LENGTH pname taking into account that
glGetProgramResourceName does not consider the NULL terminator when
returning the name length and glGetProgramResourceiv does, and
improved the error message (Antia Puentes).

Signed-off-by: Alejandro Piñeiro 
---
 tests/shaders/shader_runner.c | 392 ++
 1 file changed, 300 insertions(+), 92 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index c1c757d1b..7d24c50bc 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -93,6 +93,14 @@ struct component_version {
char _string[100];
 };
 
+struct block_info {
+   int array_index;
+   int binding;
+   int offset;
+   int matrix_stride;
+   int row_major; /* int as we don't have a parse_bool */
+};
+
 #define ENUM_STRING(e) { #e, e }
 
 extern float piglit_tolerance[4];
@@ -126,6 +134,7 @@ static GLuint compute_shaders[256];
 static unsigned num_compute_shaders = 0;
 static int num_uniform_blocks;
 static GLuint *uniform_block_bos;
+static int *uniform_block_indexes; /* ubo block index, indexed by ubo binding 
*/
 static GLenum geometry_layout_input_type = GL_TRIANGLES;
 static GLenum geometry_layout_output_type = GL_TRIANGLE_STRIP;
 static GLint geometry_layout_vertices_out = 0;
@@ -155,6 +164,7 @@ static bool sso_in_use = false;
 static bool glsl_in_use = false;
 static bool force_glsl = false;
 static bool spirv_in_use = false;
+static bool force_no_names = false;
 static GLchar *prog_err_info = NULL;
 static GLuint vao = 0;
 static GLuint draw_fbo, read_fbo;
@@ -1202,6 +1212,9 @@ process_requirement(const char *line)
printf("Unknown SPIRV line in [require]\n");
return PIGLIT_FAIL;
}
+
+   if (spirv_replaces_glsl)
+   force_no_names = true;
}
return PIGLIT_PASS;
 }
@@ -1243,6 +1256,10 @@ leave_state(enum states state, const char *line, const 
char *script_name)
if (spirv_replaces_glsl) {
printf("Running on SPIR-V mode\n");
}
+   if (force_no_names && !spirv_replaces_glsl) {
+   printf("Running on GLSL mode, forcing not using "
+   "uniform/uniform block names\n");
+   }
break;
 
case vertex_shader:
@@ -2010,17 +2027,28 @@ check_texture_handle_support(void)
piglit_report_result(PIGLIT_SKIP);
 }
 
+static bool
+get_indexes_and_offset_from_ubo(char *name, struct block_info block_data,
+   GLuint *uniform_index_out,
+   GLint *block_index_out,
+   GLint *offset_out);
+
 /**
  * Handles uploads of UBO uniforms by mapping the buffer and storing
  * the data.  If the uniform is not in a uniform block, returns false.
  */

[Piglit] [PATCH 2/3] arb_enhanced_layouts: Fix error in subtest result reporting

2019-02-20 Thread Alejandro Piñeiro
From: Antia Puentes 

---
 .../arb_enhanced_layouts/transform-feedback-layout-query-api.c  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/tests/spec/arb_enhanced_layouts/transform-feedback-layout-query-api.c 
b/tests/spec/arb_enhanced_layouts/transform-feedback-layout-query-api.c
index 44d1aef9a..05175b588 100644
--- a/tests/spec/arb_enhanced_layouts/transform-feedback-layout-query-api.c
+++ b/tests/spec/arb_enhanced_layouts/transform-feedback-layout-query-api.c
@@ -139,7 +139,7 @@ piglit_init(int argc, char **argv)
max_active = false;
}
 
-   piglit_report_subtest_result(active_res ? PIGLIT_PASS : PIGLIT_FAIL,
+   piglit_report_subtest_result(max_active ? PIGLIT_PASS : PIGLIT_FAIL,
"Query MAX_NUM_ACTIVE_VARIABLES");
 
GLenum props[] = {GL_BUFFER_BINDING, GL_NUM_ACTIVE_VARIABLES,
-- 
2.19.1

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

[Piglit] [PATCH 1/3] arb_enhanced_layouts: don't call glLinkProgram twice

2019-02-20 Thread Alejandro Piñeiro
GLSL codepath uses piglit_build_simple_program_multiple_shaders, that
already calls glLinkProgram.

Minor thing, but makes debug the test more easy.
---
 .../transform-feedback-layout-qualifiers.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/tests/spec/arb_enhanced_layouts/transform-feedback-layout-qualifiers.c 
b/tests/spec/arb_enhanced_layouts/transform-feedback-layout-qualifiers.c
index 709df75f8..f2a558e34 100644
--- a/tests/spec/arb_enhanced_layouts/transform-feedback-layout-qualifiers.c
+++ b/tests/spec/arb_enhanced_layouts/transform-feedback-layout-qualifiers.c
@@ -131,6 +131,8 @@ compile_spirv_program(GLenum shader_type,
glAttachShader(prog, shader);
glDeleteShader(shader);
 
+   glLinkProgram(prog);
+
return prog;
 }
 
@@ -187,7 +189,6 @@ build_and_use_program(const struct test_config *config)
free(gs_text);
}
 
-   glLinkProgram(prog);
if (!piglit_link_check_status(prog))
piglit_report_result(PIGLIT_FAIL);
if (!piglit_check_gl_error(GL_NO_ERROR))
-- 
2.19.1

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

[Piglit] [PATCH 3/3] arb_enhanced_layouts: use consistent test names

2019-02-20 Thread Alejandro Piñeiro
Before this commit a piglit run like this:
   ./piglit run tests/all.py -t arb_enhanced_layouts-transform-feedback 
../piglit_results/foo

Would include the layout-qualifiers tests, but not the layout-query
one.
---
 tests/opengl.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/opengl.py b/tests/opengl.py
index 8e84e2cfc..35a49b443 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -2335,7 +2335,7 @@ with profile.test_list.group_manager(
   'arb_enhanced_layouts-transform-feedback-layout-qualifiers_gs_max',
   run_concurrent=False)
 g(['arb_enhanced_layouts-transform-feedback-layout-query-api'],
-   'transform-feedback-layout-query-api')
+  'arb_enhanced_layouts-transform-feedback-layout-query-api')
 
 # Group ARB_explicit_attrib_location
 with profile.test_list.group_manager(
-- 
2.19.1

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

[Piglit] [PATCH 0/3] arb_enhanced_layouts: minor clean-up and one bugfix

2019-02-20 Thread Alejandro Piñeiro
We found this issues while working with ARB_gl_spirv, but all those
are independent of it, so we are sending independently.

Alejandro Piñeiro (2):
  arb_enhanced_layouts: don't call glLinkProgram twice
  arb_enhanced_layouts: use consistent test names

Antia Puentes (1):
  arb_enhanced_layouts: Fix error in subtest result reporting

 tests/opengl.py| 2 +-
 .../transform-feedback-layout-qualifiers.c | 3 ++-
 .../arb_enhanced_layouts/transform-feedback-layout-query-api.c | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

-- 
2.19.1

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

[Piglit] [PATCH] shader_runner: skip GLSL version check when running SPIR-V shaders

2019-02-02 Thread Alejandro Piñeiro
Because after all, you are not running GLSL shaders in that
case. SPIR-V requirements are OpenGL version >= 3.30 and having
ARB_gl_spirv available.

About why this is needed: most SPIR-V tests include the GLSL used to
generate the SPIR-V, so the SPIR-V could be regenerated easily if we
test needs any fix, and also to run the test on GLSL mode, that was
found to be useful for debug. For the latter, it is needed to keep the
GLSL version required, that is usually 4.50 (ARB_gl_spirv is written
against GLSL 4.50, without requiring it, so it is easier to just use
4.50 GLSL shaders).

Without this change, on systems with OpenGL 3.30, the SPIR-V shader
will not run for not fullfilling the GLSL version required.
---
 tests/shaders/shader_runner.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 6df8bd860..285f83944 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1130,7 +1130,7 @@ process_requirement(const char *line)
   parse_word_copy(line, buffer, sizeof(buffer), )) {
if (piglit_is_extension_supported(buffer))
return PIGLIT_SKIP;
-   } else if (parse_str(line, "GLSL", )) {
+   } else if (parse_str(line, "GLSL", ) && !spirv_replaces_glsl) {
enum comparison cmp;
 
parse_version_comparison(line, , _req_version,
-- 
2.19.1

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


[Piglit] [PATCH] vulkan: Add some tests for block member decorations

2019-01-24 Thread Alejandro Piñeiro
From: Neil Roberts 

v2: imported to piglit from a example vkrunner examples branch, also
updated description on the top comment (Alejandro Piñeiro)

v3: use location 1 instead of location 0 for one of the tests (Lionel)

Reviewed-by: Lionel Landwerlin 
---
 .../block-layout-location.vk_shader_test  | 121 +
 ...lock-member-layout-location.vk_shader_test |  69 ++
 ...block-mixed-layout-location.vk_shader_test | 126 ++
 3 files changed, 316 insertions(+)
 create mode 100644 tests/vulkan/shaders/block-layout-location.vk_shader_test
 create mode 100644 
tests/vulkan/shaders/block-member-layout-location.vk_shader_test
 create mode 100644 
tests/vulkan/shaders/block-mixed-layout-location.vk_shader_test

diff --git a/tests/vulkan/shaders/block-layout-location.vk_shader_test 
b/tests/vulkan/shaders/block-layout-location.vk_shader_test
new file mode 100644
index 0..32adf5a2c
--- /dev/null
+++ b/tests/vulkan/shaders/block-layout-location.vk_shader_test
@@ -0,0 +1,121 @@
+# Test that interface block members are correctly matched by explicit
+# location, when only the main variable has a location, so the
+# location of the members should be derived from this.
+#
+# Note that we include the spirv assembly. This is because although we
+# used a GLSL shader as reference, we tweaked the SPIR-V generated
+
+[vertex shader spirv]
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %name %_ %piglit_vertex
+   OpSource GLSL 440
+   OpName %main "main"
+   OpName %block "block"
+   OpMemberName %block 0 "a"
+   OpMemberName %block 1 "b"
+   OpMemberName %block 2 "c"
+   OpMemberName %block 3 "d"
+   OpName %name "name"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpName %_ ""
+   OpName %piglit_vertex "piglit_vertex"
+   OpDecorate %block Block
+; Only the main name variable has a location. The locations of the members
+; should be derived from this.
+   OpDecorate %name Location 1
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %piglit_vertex Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+  %block = OpTypeStruct %v4float %v4float %v4float %v4float
+%_ptr_Output_block = OpTypePointer Output %block
+   %name = OpVariable %_ptr_Output_block Output
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %15 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %int_1 = OpConstant %int 1
+ %19 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+  %int_2 = OpConstant %int 2
+ %22 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1
+  %int_3 = OpConstant %int 3
+ %25 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %17 = OpAccessChain %_ptr_Output_v4float %name %int_0
+   OpStore %17 %15
+ %20 = OpAccessChain %_ptr_Output_v4float %name %int_1
+   OpStore %20 %19
+ %23 = OpAccessChain %_ptr_Output_v4float %name %int_2
+   OpStore %23 %22
+ %26 = OpAccessChain %_ptr_Output_v4float %name %int_3
+   OpStore %26 %25
+ %35 = OpLoad %v4float %piglit_vertex
+ %36 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %36 %35
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 440
+
+layout(location = 1) in vec4 a;
+layout(location = 2) in vec4 b;
+layout(location = 3) in vec4 c;
+lay

[Piglit] [PATCH] vulkan: Add tests for double vertex inputs

2019-01-24 Thread Alejandro Piñeiro
From: Neil Roberts 

v2: (changes made by Alejandro Piñeiro)
   * Imported to piglit from a example vkrunner examples branch, also
 updated description on the top comment (Alejandro Piñeiro)
   * Fixed the fact that the interface type was not being properly
 assigned the Block OpDecorate.
---
 .../double-vertex-input-block.vk_shader_test  | 99 +++
 1 file changed, 99 insertions(+)
 create mode 100644 
tests/vulkan/shaders/double-vertex-input-block.vk_shader_test

diff --git a/tests/vulkan/shaders/double-vertex-input-block.vk_shader_test 
b/tests/vulkan/shaders/double-vertex-input-block.vk_shader_test
new file mode 100644
index 0..e49436229
--- /dev/null
+++ b/tests/vulkan/shaders/double-vertex-input-block.vk_shader_test
@@ -0,0 +1,99 @@
+# Tests that the driver assigns the correct locations to a vertex
+# input with doubles in it. The inputs are declared in a block with a
+# location so that the driver itself has to decide the locations of
+# the members. The first attribute is a dvec4 so the driver should
+# assign two locations to it.
+
+[require]
+shaderFloat64
+
+[vertex shader spirv]
+   OpCapability Shader
+   OpCapability Float64
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %_ %piglit_vertex %color_out 
%name
+   OpSource GLSL 440
+   OpName %main "main"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpName %_ ""
+   OpName %piglit_vertex "piglit_vertex"
+   OpName %color_out "color_out"
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpDecorate %name Location 1
+   OpDecorate %block Block
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %piglit_vertex Location 0
+   OpDecorate %color_out Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+  %int_1 = OpConstant %int 1
+ %double = OpTypeFloat 64
+   %v4double = OpTypeVector %double 4
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%_ptr_Input_v4double = OpTypePointer Input %v4double
+%_ptr_Input_double = OpTypePointer Input %double
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color_out = OpVariable %_ptr_Output_v4float Output
+  %block = OpTypeStruct %v4double %double
+%_ptr_Input_block = OpTypePointer Input %block
+   %name = OpVariable %_ptr_Input_block Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpLoad %v4float %piglit_vertex
+ %20 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %20 %18
+ %color_in = OpAccessChain %_ptr_Input_v4double %name %int_0
+ %multiplier = OpAccessChain %_ptr_Input_double %name %int_1
+ %26 = OpLoad %v4double %color_in
+ %29 = OpLoad %double %multiplier
+ %30 = OpVectorTimesScalar %v4double %26 %29
+ %31 = OpFConvert %v4float %30
+   OpStore %color_out %31
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 440
+
+layout(location = 0) in vec4 color_in;
+layout(location = 0) out vec4 color_out;
+
+void main()
+{
+color_out = color_in;
+}
+
+[vertex data]
+# pos   / color / multiplier
+0/r32g32_sfloat   1/r64g64b64a64_sfloat   3/r64_sfloat
+-1 -1 0.0 0.8 0.0 1.0 1.0
+1 -1  0.0 0.4 0.0 0.5 2.0
+-1 1  0.0 0.2 0.0 0.254.0
+1 -1  0.0 0.1 0.0 0.125   8.0
+-1 1  0.0 0.05 0.0 0.0625 16.0
+1 1   0.0 0.025 0.0 0.03125   32.0
+
+[test]
+clear color 0.8 0.0 0.0 1.0
+clear
+
+draw arrays TRIANGLE_LIST 0 6
+
+probe all rgba 0.0 0.8 0.0 1.0
-- 
2.19.1

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


[Piglit] [PATCH] vulkan: Add some tests for block member decorations

2019-01-23 Thread Alejandro Piñeiro
From: Neil Roberts 

v2: imported to piglit from a example vkrunner examples branch, also
updated description on the top comment (Alejandro Piñeiro)
---

This tests are intended to test the patches at the following mesa MR:

https://gitlab.freedesktop.org/mesa/mesa/merge_requests/142

Although FWIW, block-layout-location.vk_shader_test is passing right
now with just master. The other two tests require the first patch
included on that MR.

 .../block-layout-location.vk_shader_test  | 121 +
 ...lock-member-layout-location.vk_shader_test |  69 ++
 ...block-mixed-layout-location.vk_shader_test | 126 ++
 3 files changed, 316 insertions(+)
 create mode 100644 tests/vulkan/shaders/block-layout-location.vk_shader_test
 create mode 100644 
tests/vulkan/shaders/block-member-layout-location.vk_shader_test
 create mode 100644 
tests/vulkan/shaders/block-mixed-layout-location.vk_shader_test

diff --git a/tests/vulkan/shaders/block-layout-location.vk_shader_test 
b/tests/vulkan/shaders/block-layout-location.vk_shader_test
new file mode 100644
index 0..3eb2c0402
--- /dev/null
+++ b/tests/vulkan/shaders/block-layout-location.vk_shader_test
@@ -0,0 +1,121 @@
+# Test that interface block members are correctly matched by explicit
+# location, when only the main variable has a location, so the
+# location of the members should be derived from this.
+#
+# Note that we include the spirv assembly. This is because although we
+# used a GLSL shader as reference, we tweaked the SPIR-V generated
+
+[vertex shader spirv]
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %name %_ %piglit_vertex
+   OpSource GLSL 440
+   OpName %main "main"
+   OpName %block "block"
+   OpMemberName %block 0 "a"
+   OpMemberName %block 1 "b"
+   OpMemberName %block 2 "c"
+   OpMemberName %block 3 "d"
+   OpName %name "name"
+   OpName %gl_PerVertex "gl_PerVertex"
+   OpMemberName %gl_PerVertex 0 "gl_Position"
+   OpMemberName %gl_PerVertex 1 "gl_PointSize"
+   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
+   OpName %_ ""
+   OpName %piglit_vertex "piglit_vertex"
+   OpDecorate %block Block
+; Only the main name variable has a location. The locations of the members
+; should be derived from this.
+   OpDecorate %name Location 0
+   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
+   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
+   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
+   OpDecorate %gl_PerVertex Block
+   OpDecorate %piglit_vertex Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+  %block = OpTypeStruct %v4float %v4float %v4float %v4float
+%_ptr_Output_block = OpTypePointer Output %block
+   %name = OpVariable %_ptr_Output_block Output
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %15 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %int_1 = OpConstant %int 1
+ %19 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+  %int_2 = OpConstant %int 2
+ %22 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1
+  %int_3 = OpConstant %int 3
+ %25 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1
+%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
+  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+%piglit_vertex = OpVariable %_ptr_Input_v4float Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %17 = OpAccessChain %_ptr_Output_v4float %name %int_0
+   OpStore %17 %15
+ %20 = OpAccessChain %_ptr_Output_v4float %name %int_1
+   OpStore %20 %19
+ %23 = OpAccessChain %_ptr_Output_v4float %name %int_2
+   OpStore %23 %22
+ %26 = OpAccessChain %_ptr_Output_v4float %name %int_3
+   OpStore %26 %25
+ %35 = OpLoad %v4float %piglit_vertex
+ %36 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %36 %35
+   OpReturn
+  

[Piglit] [PATCH] arb_gl_spirv: simple test, use correct reference colors

2018-12-06 Thread Alejandro Piñeiro
It was using the same color for the base color, drawing color and
expected color.

As we are here, we also remove the debug names, as the test should
work without names.
---
 .../execution/vs-ps-simple.shader_test| 23 +--
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/tests/spec/arb_gl_spirv/execution/vs-ps-simple.shader_test 
b/tests/spec/arb_gl_spirv/execution/vs-ps-simple.shader_test
index 88e38540f..dcaf01eba 100644
--- a/tests/spec/arb_gl_spirv/execution/vs-ps-simple.shader_test
+++ b/tests/spec/arb_gl_spirv/execution/vs-ps-simple.shader_test
@@ -10,7 +10,7 @@ GLSL >= 4.50
 ; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
 ; SPIR-V
 ; Version: 1.0
-; Generator: Khronos Glslang Reference Front End; 4
+; Generator: Khronos Glslang Reference Front End; 7
 ; Bound: 24
 ; Schema: 0
OpCapability Shader
@@ -18,16 +18,7 @@ GLSL >= 4.50
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %_ %piglit_vertex %gl_VertexID 
%gl_InstanceID
OpSource GLSL 450
-   OpName %main "main"
-   OpName %gl_PerVertex "gl_PerVertex"
-   OpMemberName %gl_PerVertex 0 "gl_Position"
-   OpMemberName %gl_PerVertex 1 "gl_PointSize"
-   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
-   OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %_ ""
-   OpName %piglit_vertex "piglit_vertex"
-   OpName %gl_VertexID "gl_VertexID"
-   OpName %gl_InstanceID "gl_InstanceID"
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
@@ -75,7 +66,7 @@ void main() {
 ; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
 ; SPIR-V
 ; Version: 1.0
-; Generator: Khronos Glslang Reference Front End; 4
+; Generator: Khronos Glslang Reference Front End; 7
 ; Bound: 13
 ; Schema: 0
OpCapability Shader
@@ -84,8 +75,6 @@ void main() {
OpEntryPoint Fragment %main "main" %outcolor
OpExecutionMode %main OriginLowerLeft
OpSource GLSL 450
-   OpName %main "main"
-   OpName %outcolor "outcolor"
OpDecorate %outcolor Location 0
%void = OpTypeVoid
   %3 = OpTypeFunction %void
@@ -93,9 +82,9 @@ void main() {
 %v4float = OpTypeVector %float 4
 %_ptr_Output_v4float = OpTypePointer Output %v4float
%outcolor = OpVariable %_ptr_Output_v4float Output
-%float_1 = OpConstant %float 1
 %float_0 = OpConstant %float 0
- %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_0
+%float_1 = OpConstant %float 1
+ %12 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
%main = OpFunction %void None %3
   %5 = OpLabel
OpStore %outcolor %12
@@ -108,7 +97,7 @@ void main() {
 layout(location = 0) out vec4 outcolor;
 
 void main() {
-outcolor = vec4(1.0, 0.0, 0.0, 0.0);
+outcolor = vec4(0.0, 1.0, 0.0, 1.0);
 }
 
 [test]
@@ -116,4 +105,4 @@ clear color 1.0 0.0 0.0 0.0
 clear
 
 draw rect -1 -1 2 2
-probe all rgba 1.0 0.0 0.0 0.0
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.19.1

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


Re: [Piglit] [PATCH] vulkan: Add tests for block layout location calculations

2018-11-08 Thread Alejandro Piñeiro
On 08/11/18 13:24, Neil Roberts wrote:
> All but one of these are currently broken on anv.
>
> See: https://patchwork.freedesktop.org/series/40797/

FWIW, the first patch of that series is outdated, due all the changes on
master since then. A updated version was included on the ubo/ssbo
support series for ARB_gl_spirv:
https://github.com/Igalia/mesa/commit/0e933ed9848c6eea7ad1d664ec3aacbdba111b41

Don't  know about the status of the other two.
> ---
>  .../block-layout-location.vk_shader_test  | 117 +
>  ...lock-member-layout-location.vk_shader_test |  68 ++
>  ...block-mixed-layout-location.vk_shader_test | 120 ++
>  .../double-vertex-input-block.vk_shader_test  |  98 ++
>  4 files changed, 403 insertions(+)
>  create mode 100644 tests/vulkan/shaders/block-layout-location.vk_shader_test
>  create mode 100644 
> tests/vulkan/shaders/block-member-layout-location.vk_shader_test
>  create mode 100644 
> tests/vulkan/shaders/block-mixed-layout-location.vk_shader_test
>  create mode 100644 
> tests/vulkan/shaders/double-vertex-input-block.vk_shader_test
>
> diff --git a/tests/vulkan/shaders/block-layout-location.vk_shader_test 
> b/tests/vulkan/shaders/block-layout-location.vk_shader_test
> new file mode 100644
> index 0..2c81375d8
> --- /dev/null
> +++ b/tests/vulkan/shaders/block-layout-location.vk_shader_test
> @@ -0,0 +1,117 @@
> +# Test that interface block members are correctly matched by explicit
> +# location.
> +
> +[vertex shader spirv]
> +   OpCapability Shader
> +  %1 = OpExtInstImport "GLSL.std.450"
> +   OpMemoryModel Logical GLSL450
> +   OpEntryPoint Vertex %main "main" %name %_ %piglit_vertex
> +   OpSource GLSL 440
> +   OpName %main "main"
> +   OpName %block "block"
> +   OpMemberName %block 0 "a"
> +   OpMemberName %block 1 "b"
> +   OpMemberName %block 2 "c"
> +   OpMemberName %block 3 "d"
> +   OpName %name "name"
> +   OpName %gl_PerVertex "gl_PerVertex"
> +   OpMemberName %gl_PerVertex 0 "gl_Position"
> +   OpMemberName %gl_PerVertex 1 "gl_PointSize"
> +   OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
> +   OpName %_ ""
> +   OpName %piglit_vertex "piglit_vertex"
> +   OpDecorate %block Block
> +; Only the main name variable has a location. The locations of the members
> +; should be derived from this.
> +   OpDecorate %name Location 0
> +   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
> +   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
> +   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
> +   OpDecorate %gl_PerVertex Block
> +   OpDecorate %piglit_vertex Location 0
> +   %void = OpTypeVoid
> +  %3 = OpTypeFunction %void
> +  %float = OpTypeFloat 32
> +%v4float = OpTypeVector %float 4
> +  %block = OpTypeStruct %v4float %v4float %v4float %v4float
> +%_ptr_Output_block = OpTypePointer Output %block
> +   %name = OpVariable %_ptr_Output_block Output
> +%int = OpTypeInt 32 1
> +  %int_0 = OpConstant %int 0
> +%float_1 = OpConstant %float 1
> +%float_0 = OpConstant %float 0
> + %15 = OpConstantComposite %v4float %float_1 %float_0 %float_0 
> %float_1
> +%_ptr_Output_v4float = OpTypePointer Output %v4float
> +  %int_1 = OpConstant %int 1
> + %19 = OpConstantComposite %v4float %float_0 %float_1 %float_0 
> %float_1
> +  %int_2 = OpConstant %int 2
> + %22 = OpConstantComposite %v4float %float_0 %float_0 %float_1 
> %float_1
> +  %int_3 = OpConstant %int 3
> + %25 = OpConstantComposite %v4float %float_1 %float_1 %float_1 
> %float_1
> +   %uint = OpTypeInt 32 0
> + %uint_1 = OpConstant %uint 1
> +%_arr_float_uint_1 = OpTypeArray %float %uint_1
> +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1
> +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
> +  %_ = OpVariable %_ptr_Output_gl_PerVertex Output
> +%_ptr_Input_v4float = OpTypePointer Input %v4float
> +%piglit_vertex = OpVariable %_ptr_Input_v4float Input
> +   %main = OpFunction %void None %3
> +  %5 = OpLabel
> + %17 = OpAccessChain %_ptr_Output_v4float %name %int_0
> +   OpStore %17 %15
> + %20 = OpAccessChain %_ptr_Output_v4float %name %int_1
> +   OpStore %20 %19
> + %23 = OpAccessChain %_ptr_Output_v4float %name %int_2
> +   OpStore %23 %22
> + %26 = OpAccessChain %_ptr_Output_v4float %name %int_3
> +   OpStore %26 %25
> + %35 = OpLoad %v4float %piglit_vertex
> + %36 = OpAccessChain %_ptr_Output_v4float %_ %int_0
> +   OpStore %36 %35
> +   OpReturn
> +   OpFunctionEnd
> +
> +[fragment 

[Piglit] [PATCH] vulkan: test cases for large local arrays

2018-11-08 Thread Alejandro Piñeiro
Equivalent to the GLSL tests added with the series "Test cases for
large GLSL local arrays". Quoting from the cover-letter of that
series:

   "Drivers typically need special handling for local array storage
when arrays exceed a certain size, this adds a few test cases for
exercising some corner cases that were useful when implementing
support for this in the r600g driver."

Right now only two of the tests included on this series is passing
(local-array and multiple). But all of them were working until the the
following commit:
   * b3c6146925595ec3a7eece3afb9ccaad32906d4c ("nir: Copy propagation between 
blocks")

So it is fact, a regression. More info on
  https://bugs.freedesktop.org/show_bug.cgi?id=108624

Original GLSL series:
  https://lists.freedesktop.org/archives/piglit/2017-March/021867.html
---
 .../fs-large-local-array-vec2.vk_shader_test   | 38 +
 .../fs-large-local-array-vec3.vk_shader_test   | 38 +
 .../fs-large-local-array-vec4.vk_shader_test   | 38 +
 .../shaders/fs-large-local-array.vk_shader_test| 47 ++
 .../fs-multiple-large-local-array.vk_shader_test   | 40 ++
 5 files changed, 201 insertions(+)
 create mode 100644 
tests/vulkan/shaders/fs-large-local-array-vec2.vk_shader_test
 create mode 100644 
tests/vulkan/shaders/fs-large-local-array-vec3.vk_shader_test
 create mode 100644 
tests/vulkan/shaders/fs-large-local-array-vec4.vk_shader_test
 create mode 100644 tests/vulkan/shaders/fs-large-local-array.vk_shader_test
 create mode 100644 
tests/vulkan/shaders/fs-multiple-large-local-array.vk_shader_test

diff --git a/tests/vulkan/shaders/fs-large-local-array-vec2.vk_shader_test 
b/tests/vulkan/shaders/fs-large-local-array-vec2.vk_shader_test
new file mode 100644
index 0..6fbf71d50
--- /dev/null
+++ b/tests/vulkan/shaders/fs-large-local-array-vec2.vk_shader_test
@@ -0,0 +1,38 @@
+# Tests a large vec2 local array.
+# Vulkan equivalent to 
tests/spec/glsl-1.30/execution/fs-large-local-array-vec2.shader_test
+
+[require]
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 450
+
+layout (binding = 5) uniform block {
+   uint i;
+};
+
+layout (location = 0) out vec4 out_color;
+
+void main()
+{
+   vec2 A[130];
+   A[20].g = 0;
+   A[i].g = 37;
+   A[i].r = 1;
+out_color.rba = vec3(0.0, 0.0, 1.0);
+   out_color.g = float(A[20].g == 37);
+}
+
+[test]
+clear color 1.0 0.0 0.0 1.0
+clear
+
+uniform ubo 5 uint 0 19
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.0 0.0 1.0
+
+clear
+uniform ubo 5 uint 0 20
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/vulkan/shaders/fs-large-local-array-vec3.vk_shader_test 
b/tests/vulkan/shaders/fs-large-local-array-vec3.vk_shader_test
new file mode 100644
index 0..8c00bc720
--- /dev/null
+++ b/tests/vulkan/shaders/fs-large-local-array-vec3.vk_shader_test
@@ -0,0 +1,38 @@
+# Tests a large vec3 local array.
+# Vulkan equivalent to 
tests/spec/glsl-1.30/execution/fs-large-local-array-vec3.shader_test
+
+[require]
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 450
+
+layout (binding = 5) uniform block {
+   uint i;
+};
+
+layout (location = 0) out vec4 out_color;
+
+void main()
+{
+   vec3 A[130];
+   A[20].g = 0;
+   A[i].g = 37;
+   A[i].r = 1;
+out_color.rba = vec3(0.0, 0.0, 1.0);
+   out_color.g = float(A[20].g == 37);
+}
+
+[test]
+clear color 1.0 0.0 0.0 1.0
+clear
+
+uniform ubo 5 uint 0 19
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.0 0.0 1.0
+
+clear
+uniform ubo 5 uint 0 20
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/vulkan/shaders/fs-large-local-array-vec4.vk_shader_test 
b/tests/vulkan/shaders/fs-large-local-array-vec4.vk_shader_test
new file mode 100644
index 0..6239bfee6
--- /dev/null
+++ b/tests/vulkan/shaders/fs-large-local-array-vec4.vk_shader_test
@@ -0,0 +1,38 @@
+# Tests a large vec4 local array.
+# Vulkan equivalent to 
tests/spec/glsl-1.30/execution/fs-large-local-array-vec4.shader_test
+
+[require]
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 450
+
+layout (binding = 5) uniform block {
+   uint i;
+};
+
+layout (location = 0) out vec4 out_color;
+
+void main()
+{
+   vec4 A[130];
+   A[20].g = 0;
+   A[i].g = 37;
+   A[i].r = 1;
+out_color.rba = vec3(0.0, 0.0, 1.0);
+   out_color.g = float(A[20].g == 37);
+}
+
+[test]
+clear color 1.0 0.0 0.0 1.0
+clear
+
+uniform ubo 5 uint 0 19
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.0 0.0 1.0
+
+clear
+uniform ubo 5 uint 0 20
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/vulkan/shaders/fs-large-local-array.vk_shader_test 
b/tests/vulkan/shaders/fs-large-local-array.vk_shader_test
new file mode 100644
index 0..c62109ee1
--- /dev/null
+++ b/tests/vulkan/shaders/fs-large-local-array.vk_shader_test
@@ -0,0 +1,47 @@
+# Tests a large uint local array.
+# Vulkan 

Re: [Piglit] [PATCH v2 00/17] ARB_gl_spirv: v2 ubo/ssbo tests

2018-10-22 Thread Alejandro Piñeiro
I have just resend the mesa series for ubo/ssbo support. I will not do
the same for the piglit series, as there are no changes even after
rebasing against master. If the mesa series gets reviewed, I plan to
push this piglit series. A review/ack would be welcome though.


BR


On 27/09/18 11:54, Alejandro Piñeiro wrote:
> Hi,
>
> this is the second version of the ubo/ssbo tests for
> ARB_gl_spirv. Differences compared with v1:
>
>   * Rebased against today master.
>
>   * Updated the pass checks on several tests. Instead of a silly
> addition/substraction of the ubo/ssbo content, and check a
> specific value, the value of the individual ubo/ssbo members are
> checked.
>
>   * array-complex became even more complex. Specifically thinking on
> testing some cases mentioned by Timothy feedback on the mesa-dev
> series.
>
> v1 announcement:
>https://lists.freedesktop.org/archives/piglit/2018-September/025065.html
>
> The series can be found on this branch:
>https://github.com/Igalia/piglit/tree/arb_gl_spirv-series5-ubo-ssbo-v2
>
>
> Alejandro Piñeiro (15):
>   shader_runner/spirv: log skip reason on ARB_gl_spirv extension check
>   shader_runner/spirv: check if test really includes spirv
>   shader_runner: add force_no_names mode
>   shader_runner: add support for glGetProgram queries
>   arb_gl_spirv: add GL_ACTIVE_UNIFORMS checks
>   arb_gl_spirv: add some simple ubo tests
>   arb_gl_spirv: add simple ubo tests with matrices
>   arb_gl_spirv: add complex ubo test with matrices
>   arb_gl_spirv: add a array of ubo test, with complex ubo content
>   arb_gl_spirv: add ubo matrix test with different matrix_stride
>   arb_gl_spirv: add ubo array test with different array_stride
>   arb_gl_spirv: add some simple ssbo tests
>   arb_gl_spirv: add simple ssbo tests with matrices
>   arb_gl_spirv: adding complex ssbo matrix test
>   arb_gl_spirv: add ssbo test using std140 and std430
>
> Neil Roberts (2):
>   arb_gl_spirv: Add tests for UBOs with explicit offsets
>   arb_gl_spirv: Add a test for SSBOs with an unsized array
>
>  tests/shaders/shader_runner.c  | 485 +++---
>  .../execution/ssbo/array-indirect.shader_test  | 121 
>  .../execution/ssbo/array-inside-ssbo.shader_test   | 189 ++
>  .../ssbo/array-of-arrays-inside-ssbo.shader_test   | 203 ++
>  .../arb_gl_spirv/execution/ssbo/array.shader_test  | 173 +
>  .../execution/ssbo/matrix/column-major.shader_test | 188 ++
>  .../ssbo/matrix/column-vs-row.shader_test  | 291 +
>  .../execution/ssbo/matrix/complex.shader_test  | 702 
> +
>  .../ssbo/matrix/indirect-column-major.shader_test  | 132 
>  .../ssbo/matrix/indirect-row-major.shader_test | 132 
>  .../execution/ssbo/matrix/row-major.shader_test| 194 ++
>  .../arb_gl_spirv/execution/ssbo/simple.shader_test | 138 
>  .../ssbo/two-ssbo-different-layouts.shader_test| 372 +++
>  .../execution/ssbo/two-ssbo.shader_test| 151 +
>  .../execution/ssbo/two-stages.shader_test  | 279 
>  .../execution/ssbo/unsized-array.shader_test   | 119 
>  .../execution/ubo/array-complex.shader_test| 360 +++
>  .../array-different-array-stride-ubo.shader_test   | 271 
>  .../execution/ubo/array-indirect.shader_test   | 108 
>  .../execution/ubo/array-inside-ubo.shader_test | 154 +
>  .../ubo/array-of-arrays-inside-ubo.shader_test | 184 ++
>  .../arb_gl_spirv/execution/ubo/array.shader_test   | 140 
>  .../ubo/explicit-offset-nested-struct.shader_test  |  81 +++
>  .../execution/ubo/explicit-offset.shader_test  |  80 +++
>  .../execution/ubo/location-0-crash.shader_test |  93 +++
>  .../execution/ubo/matrix/column-major.shader_test  | 176 ++
>  .../execution/ubo/matrix/column-vs-row.shader_test | 303 +
>  .../execution/ubo/matrix/complex.shader_test   | 624 ++
>  .../ubo/matrix/different-matrix-stride.shader_test | 260 
>  .../ubo/matrix/indirect-column-major.shader_test   | 120 
>  .../ubo/matrix/indirect-row-major.shader_test  | 120 
>  .../execution/ubo/matrix/row-major.shader_test | 175 +
>  .../arb_gl_spirv/execution/ubo/simple.shader_test  | 131 
>  .../execution/ubo/two-stages.shader_test   | 276 
>  .../execution/ubo/two-ubos.shader_test | 141 +
>  .../execution/uniform/array.shader_test|   2 +
>  .../execution/uniform/arrays-of-arrays.shader_test |   2 +
>  .../uniform/atomic-uint-aoa-cs.shader_test |   2 +
>  .../uniform/atomic-uint-aoa-fs.shader_test |   2 +
>  .../uniform/atomic-uint-array-cs.shader_tes

[Piglit] [PATCH] arb_gl_spirv: add array test with copy between arrays

2018-10-01 Thread Alejandro Piñeiro
For tests that triggered nir_split_vars to split arrays, we found some
crashes on ARB_gl_spirv if we didn't take into account the explicit
array stride on the splitted type. This is basically a regression
catching test.

This test is based on spec/glsl-1.40/uniform_buffer/fs-array-copy test
that was crashing on ARB_gl_spirv with the first mesa series of
ubo/ssbo support for ARB_gl_spirv.
---

While doing a run with borrowed tests from other specs, I found some
tests that were crashing, when they shouldn't. I have just sent a v2
patch to the mesa-dev.

 .../ubo/array-inside-ubo-copy.shader_test  | 137 +
 1 file changed, 137 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test 
b/tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test
new file mode 100644
index 0..f8ed845eb
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo-copy.shader_test
@@ -0,0 +1,137 @@
+# UBO test using an array inside an ubos, and an temporal array that
+# copy from it.
+
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 45
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpDecorate %_arr_v4float_uint_4_0 ArrayStride 16
+   OpMemberDecorate %Block 0 Offset 0
+   OpDecorate %Block Block
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 6
+   OpDecorate %color Location 0
+   OpDecorate %index Location 4
+   OpDecorate %index DescriptorSet 0
+   OpDecorate %index Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+   %uint = OpTypeInt 32 0
+ %uint_4 = OpConstant %uint 4
+%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4
+%_ptr_Function__arr_v4float_uint_4 = OpTypePointer Function 
%_arr_v4float_uint_4
+%_arr_v4float_uint_4_0 = OpTypeArray %v4float %uint_4
+  %Block = OpTypeStruct %_arr_v4float_uint_4_0
+%_ptr_Uniform_Block = OpTypePointer Uniform %Block
+  %_ = OpVariable %_ptr_Uniform_Block Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform__arr_v4float_uint_4_0 = OpTypePointer Uniform 
%_arr_v4float_uint_4_0
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+  %int_1 = OpConstant %int 1
+  %int_2 = OpConstant %int 2
+  %int_3 = OpConstant %int 3
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %36 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_0
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+%_ptr_UniformConstant_int = OpTypePointer UniformConstant %int
+  %index = OpVariable %_ptr_UniformConstant_int UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+   %temp = OpVariable %_ptr_Function__arr_v4float_uint_4 Function
+ %20 = OpAccessChain %_ptr_Uniform__arr_v4float_uint_4_0 %_ %int_0
+ %21 = OpLoad %_arr_v4float_uint_4_0 %20
+ %22 = OpCompositeExtract %v4float %21 0
+ %24 = OpAccessChain %_ptr_Function_v4float %temp %int_0
+   OpStore %24 %22
+ %25 = OpCompositeExtract %v4float %21 1
+ %27 = OpAccessChain %_ptr_Function_v4float %temp %int_1
+   OpStore %27 %25
+ %28 = OpCompositeExtract %v4float %21 2
+ %30 = OpAccessChain %_ptr_Function_v4float %temp %int_2
+   OpStore %30 %28
+ %31 = OpCompositeExtract %v4float %21 3
+ %33 = OpAccessChain %_ptr_Function_v4float %temp %int_3
+   OpStore %33 %31
+ %37 = OpAccessChain %_ptr_Function_v4float %temp %int_0
+   OpStore %37 %36
+ %42 = OpLoad %int %index
+ %43 = OpAccessChain %_ptr_Function_v4float %temp %42
+ %44 = OpLoad %v4float %43
+   OpStore %color %44
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 4) uniform int index;
+
+layout (location = 0) out vec4 color;
+
+layout (std140, binding = 6) uniform Block {
+   vec4 colors[4];
+};
+
+void main()
+{
+   vec4 temp[4] = colors;
+   temp[0] = vec4(1.0, 0.0, 0.0, 0.0);
+   color = temp[index];
+}
+
+[test]
+
+block binding 6
+block 

[Piglit] [PATCH v2 13/17] arb_gl_spirv: add some simple ssbo tests

2018-09-27 Thread Alejandro Piñeiro
Equivalent to the ubo tests added with the commit "arb_gl_spirv: add
some simple ubo tests", but without the linker tests and the
regression-check test.

v2: no expected final substractions/additions value of content, but
check for real values (Timothy)
---
 .../execution/ssbo/array-indirect.shader_test  | 121 +
 .../execution/ssbo/array-inside-ssbo.shader_test   | 189 ++
 .../ssbo/array-of-arrays-inside-ssbo.shader_test   | 203 +++
 .../arb_gl_spirv/execution/ssbo/array.shader_test  | 173 +
 .../arb_gl_spirv/execution/ssbo/simple.shader_test | 138 ++
 .../execution/ssbo/two-ssbo.shader_test| 151 +++
 .../execution/ssbo/two-stages.shader_test  | 279 +
 7 files changed, 1254 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/array-indirect.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/array-inside-ssbo.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/array-of-arrays-inside-ssbo.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ssbo/array.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ssbo/simple.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/two-stages.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/ssbo/array-indirect.shader_test 
b/tests/spec/arb_gl_spirv/execution/ssbo/array-indirect.shader_test
new file mode 100644
index 0..45d6ce480
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ssbo/array-indirect.shader_test
@@ -0,0 +1,121 @@
+# SSBO test using an array of ssbo and indirect(dynamically uniform)
+# indexing. Just uses one stage.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 24
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpMemberDecorate %ssbo 0 Offset 0
+   OpDecorate %ssbo BufferBlock
+   OpDecorate %components DescriptorSet 0
+   OpDecorate %components Binding 5
+   OpDecorate %u_idx Location 10
+   OpDecorate %u_idx DescriptorSet 0
+   OpDecorate %u_idx Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+   %ssbo = OpTypeStruct %v4float
+   %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_arr_ssbo_uint_3 = OpTypeArray %ssbo %uint_3
+%_ptr_Uniform__arr_ssbo_uint_3 = OpTypePointer Uniform %_arr_ssbo_uint_3
+ %components = OpVariable %_ptr_Uniform__arr_ssbo_uint_3 Uniform
+%int = OpTypeInt 32 1
+%_ptr_UniformConstant_int = OpTypePointer UniformConstant %int
+  %u_idx = OpVariable %_ptr_UniformConstant_int UniformConstant
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %19 = OpLoad %int %u_idx
+ %22 = OpAccessChain %_ptr_Uniform_v4float %components %19 %int_0
+ %23 = OpLoad %v4float %22
+   OpStore %color %23
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+
+#version 450
+
+layout (location = 0) out vec4 color;
+layout (location = 10) uniform int u_idx;
+
+layout (std430, binding = 5) buffer ssbo
+ {
+vec4 c1;
+ } components[3];
+
+void main()
+{
+   color = components[u_idx].c1;
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+ssbo 5 32 # size, aligned to 16
+#c1
+ssbo 5 subdata float 0  0.11
+ssbo 5 subdata float 4  0.12
+ssbo 5 subdata float 8  0.13
+ssbo 5 subdata float 12 0.14
+
+ssbo 6 32
+#c1
+ssbo 6 subdata float 0  0.21
+ssbo 6 subdata float 4  0.22
+ssbo 6 subdata float 8  0.23
+ssbo 6 subdata float 12 0.24
+
+ssbo 7 32
+#c1
+ssbo 7 subdata float 0  0.31
+ssbo 7 subdata float 4  0.32
+ssbo 7 subdata float 8  0.33
+ssbo 7 subdata float 12 0.34
+
+uniform int 10 0 # location 10, uniform u_idx
+draw rect -1 -1 2 2
+probe all rgba 0.11 0.12 0.13 0.14
+
+uniform int 10 1 # location 10, uniform u_idx
+draw rect -1 -1 2 2
+probe all rgba 0.21 0.22 0.23 0.24
+
+uniform int 10 2 # location 10, uniform u_idx
+draw rect -1 -1 2 2
+probe all rgba 0.31 0.32 0.33 0.34
+
+block binding 5
+verify program_interface_query GL_SHADER_STORAGE_BLOCK 

[Piglit] [PATCH v2 11/17] arb_gl_spirv: add ubo matrix test with different matrix_stride

2018-09-27 Thread Alejandro Piñeiro
ARB_gl_spirv requires that the SPIR-V includes the explicit matrix
stride. In general layouts are mapping with explicit offset, matrix
stride and array stride. As far as it respect alignments and minimum
offsets, matrix_stride doesn't need to be exactly what OpenGL GLSL
computes, and in fact, the rules are more similar to SPIR-V under
Vulkan.

This tests defines two UBOs, with the same content (on type and data)
but that each one uses a different matrix stride. As they contains the
same content, you should be able to compare one and the other on the
code.

As you can't define different matrix_stride on GLSL, this is a "SPIRV
ONLY" test. GLSL is there as a reference, as it was used to create the
SPIR-V shader, but then tweaked manually.

v2: no expected final substractions/additions value of content, but
check for real values (Timothy)
---
 .../ubo/matrix/different-matrix-stride.shader_test | 260 +
 1 file changed, 260 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/matrix/different-matrix-stride.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ubo/matrix/different-matrix-stride.shader_test
 
b/tests/spec/arb_gl_spirv/execution/ubo/matrix/different-matrix-stride.shader_test
new file mode 100644
index 0..078b5ad76
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/ubo/matrix/different-matrix-stride.shader_test
@@ -0,0 +1,260 @@
+# UBO test using two mat3x2. The content is the same, but the matrix
+# stride is different. Used to test that the size is properly
+# computed, and the content properly accessed in both cases.
+
+[require]
+SPIRV ONLY
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py, and then 
edited by hand to set the proper matrix stride
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 115
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpName %__0 ""
+   OpDecorate %color Location 0
+   OpMemberDecorate %Block16 0 ColMajor
+   OpMemberDecorate %Block16 0 Offset 0
+   OpMemberDecorate %Block16 0 MatrixStride 16
+   OpDecorate %Block16 Block
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 5
+   OpMemberDecorate %Block32 0 ColMajor
+   OpMemberDecorate %Block32 0 Offset 0
+   OpMemberDecorate %Block32 0 MatrixStride 32
+   OpDecorate %Block32 Block
+   OpDecorate %__0 DescriptorSet 0
+   OpDecorate %__0 Binding 6
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+   %bool = OpTypeBool
+%v2float = OpTypeVector %float 2
+%mat3v2float = OpTypeMatrix %v2float 3
+%Block16 = OpTypeStruct %mat3v2float
+%_ptr_Uniform_Block16 = OpTypePointer Uniform %Block16
+  %_ = OpVariable %_ptr_Uniform_Block16 Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+%float_31933_2734 = OpConstant %float 31933.2734
+%float_n11642_8975 = OpConstant %float -11642.8975
+ %29 = OpConstantComposite %v2float %float_31933_2734 
%float_n11642_8975
+ %v2bool = OpTypeVector %bool 2
+  %int_1 = OpConstant %int 1
+%float_9012_23633 = OpConstant %float 9012.23633
+%float_n6150_84961 = OpConstant %float -6150.84961
+ %41 = OpConstantComposite %v2float %float_9012_23633 
%float_n6150_84961
+  %int_2 = OpConstant %int 2
+%float_n10267_4893 = OpConstant %float -10267.4893
+%float_26495_5859 = OpConstant %float 26495.5859
+ %53 = OpConstantComposite %v2float %float_n10267_4893 
%float_26495_5859
+%Block32 = OpTypeStruct %mat3v2float
+%_ptr_Uniform_Block32 = OpTypePointer Uniform %Block32
+%__0 = OpVariable %_ptr_Uniform_Block32 Uniform
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %fail_color = OpVariable %_ptr_Function_v4float Function
+   OpStore %fail_color %12
+   OpStore %color %15
+ %25 = OpAccessChain %_ptr_Uniform_v2float %_ %int_0 %int_0
+ %26 = OpLoad %v2float %25
+ %31 = 

[Piglit] [PATCH v2 16/17] arb_gl_spirv: Add a test for SSBOs with an unsized array

2018-09-27 Thread Alejandro Piñeiro
From: Neil Roberts 

This tests handling of the OpTypeRuntimeArray opcode.
---
 .../execution/ssbo/unsized-array.shader_test   | 119 +
 1 file changed, 119 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/unsized-array.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/ssbo/unsized-array.shader_test 
b/tests/spec/arb_gl_spirv/execution/ssbo/unsized-array.shader_test
new file mode 100644
index 0..67d93f0ef
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ssbo/unsized-array.shader_test
@@ -0,0 +1,119 @@
+# As SSBO with the last member being an unsized array.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.30
+GL_ARB_gl_spirv
+GL_ARB_shader_storage_buffer_object
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 27
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color_out
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpDecorate %color_out Location 0
+   OpDecorate %_runtimearr_v4float ArrayStride 16
+   OpMemberDecorate %ssbo 0 Offset 0
+   OpMemberDecorate %ssbo 1 Offset 16
+   OpDecorate %ssbo BufferBlock
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 0
+   OpDecorate %color_num Location 0
+   OpDecorate %color_num DescriptorSet 0
+   OpDecorate %color_num Binding 1
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color_out = OpVariable %_ptr_Output_v4float Output
+%_runtimearr_v4float = OpTypeRuntimeArray %v4float
+   %ssbo = OpTypeStruct %v4float %_runtimearr_v4float
+%_ptr_Uniform_ssbo = OpTypePointer Uniform %ssbo
+  %_ = OpVariable %_ptr_Uniform_ssbo Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+  %int_1 = OpConstant %int 1
+   %uint = OpTypeInt 32 0
+%_ptr_UniformConstant_uint = OpTypePointer UniformConstant %uint
+  %color_num = OpVariable %_ptr_UniformConstant_uint UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %17 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0
+ %18 = OpLoad %v4float %17
+ %23 = OpLoad %uint %color_num
+ %24 = OpAccessChain %_ptr_Uniform_v4float %_ %int_1 %23
+ %25 = OpLoad %v4float %24
+ %26 = OpFAdd %v4float %18 %25
+   OpStore %color_out %26
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+
+#version 430
+
+layout(location = 0) out vec4 color_out;
+
+layout(std430, binding = 0) buffer ssbo
+{
+vec4 base_color;
+vec4 other_colors[];
+};
+
+layout(location = 0) uniform uint color_num;
+
+void main()
+{
+color_out = base_color + other_colors[color_num];
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+ssbo 0 128 # size, 8 vec4s
+
+ssbo 0 subdata float 0 -8
+ssbo 0 subdata float 4 6
+ssbo 0 subdata float 8 3
+ssbo 0 subdata float 12 1
+ssbo 0 subdata float 32 8
+ssbo 0 subdata float 36 -5.2
+ssbo 0 subdata float 40 -3
+ssbo 0 subdata float 44 0
+
+uniform uint 0 1
+draw rect -1 -1 1 2
+
+ssbo 0 subdata float 0 8
+ssbo 0 subdata float 4 42
+ssbo 0 subdata float 8 5
+ssbo 0 subdata float 12 9
+ssbo 0 subdata float 96 -8
+ssbo 0 subdata float 100 -41.2
+ssbo 0 subdata float 104 -5
+ssbo 0 subdata float 108 -8
+
+uniform uint 0 5
+draw rect 0 -1 1 2
+
+block binding 0
+verify program_interface_query GL_SHADER_STORAGE_BLOCK ssbo 
GL_NUM_ACTIVE_VARIABLES 2
+
+verify program_query GL_ACTIVE_UNIFORMS 1
+
+probe all rgba 0.0 0.8 0.0 1.0
-- 
2.14.1

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


[Piglit] [PATCH v2 15/17] arb_gl_spirv: adding complex ssbo matrix test

2018-09-27 Thread Alejandro Piñeiro
v2: no expected final substractions/additions value of content, but
check for real values (Timothy)
---
 .../execution/ssbo/matrix/complex.shader_test  | 702 +
 1 file changed, 702 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/matrix/complex.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/ssbo/matrix/complex.shader_test 
b/tests/spec/arb_gl_spirv/execution/ssbo/matrix/complex.shader_test
new file mode 100644
index 0..dc20866a2
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ssbo/matrix/complex.shader_test
@@ -0,0 +1,702 @@
+# SSBO test using several matrices on one block. All possible size
+# combination, mixing row and column major.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 362
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpDecorate %color Location 0
+   OpMemberDecorate %ssbo 0 RowMajor
+   OpMemberDecorate %ssbo 0 Offset 0
+   OpMemberDecorate %ssbo 0 MatrixStride 8
+   OpMemberDecorate %ssbo 1 ColMajor
+   OpMemberDecorate %ssbo 1 Offset 16
+   OpMemberDecorate %ssbo 1 MatrixStride 16
+   OpMemberDecorate %ssbo 2 ColMajor
+   OpMemberDecorate %ssbo 2 Offset 48
+   OpMemberDecorate %ssbo 2 MatrixStride 16
+   OpMemberDecorate %ssbo 3 ColMajor
+   OpMemberDecorate %ssbo 3 Offset 80
+   OpMemberDecorate %ssbo 3 MatrixStride 8
+   OpMemberDecorate %ssbo 4 RowMajor
+   OpMemberDecorate %ssbo 4 Offset 112
+   OpMemberDecorate %ssbo 4 MatrixStride 16
+   OpMemberDecorate %ssbo 5 ColMajor
+   OpMemberDecorate %ssbo 5 Offset 160
+   OpMemberDecorate %ssbo 5 MatrixStride 16
+   OpMemberDecorate %ssbo 6 ColMajor
+   OpMemberDecorate %ssbo 6 Offset 208
+   OpMemberDecorate %ssbo 6 MatrixStride 8
+   OpMemberDecorate %ssbo 7 ColMajor
+   OpMemberDecorate %ssbo 7 Offset 240
+   OpMemberDecorate %ssbo 7 MatrixStride 16
+   OpMemberDecorate %ssbo 8 ColMajor
+   OpMemberDecorate %ssbo 8 Offset 304
+   OpMemberDecorate %ssbo 8 MatrixStride 16
+   OpDecorate %ssbo BufferBlock
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 5
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+   %bool = OpTypeBool
+%v2float = OpTypeVector %float 2
+%mat2v2float = OpTypeMatrix %v2float 2
+%v3float = OpTypeVector %float 3
+%mat2v3float = OpTypeMatrix %v3float 2
+%mat2v4float = OpTypeMatrix %v4float 2
+%mat3v2float = OpTypeMatrix %v2float 3
+%mat3v3float = OpTypeMatrix %v3float 3
+%mat3v4float = OpTypeMatrix %v4float 3
+%mat4v2float = OpTypeMatrix %v2float 4
+%mat4v3float = OpTypeMatrix %v3float 4
+%mat4v4float = OpTypeMatrix %v4float 4
+   %ssbo = OpTypeStruct %mat2v2float %mat2v3float %mat2v4float 
%mat3v2float %mat3v3float %mat3v4float %mat4v2float %mat4v3float %mat4v4float
+%_ptr_Uniform_ssbo = OpTypePointer Uniform %ssbo
+  %_ = OpVariable %_ptr_Uniform_ssbo Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+%float_n29816_0098 = OpConstant %float -29816.0098
+%float_4996_51611 = OpConstant %float 4996.51611
+ %38 = OpConstantComposite %v2float %float_n29816_0098 
%float_4996_51611
+ %v2bool = OpTypeVector %bool 2
+  %int_1 = OpConstant %int 1
+%float_22829_4688 = OpConstant %float 22829.4688
+%float_n30383_2031 = OpConstant %float -30383.2031
+ %50 = OpConstantComposite %v2float %float_22829_4688 
%float_n30383_2031
+%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
+%float_5720_54443 = OpConstant %float 5720.54443
+%float_n21857_1582 = OpConstant %float -21857.1582
+%float_n711_078674 = OpConstant %float -711.078674
+ %63 = OpConstantComposite 

[Piglit] [PATCH v2 17/17] arb_gl_spirv: add ssbo test using std140 and std430

2018-09-27 Thread Alejandro Piñeiro
The test includes two ssbos, with the same content but different
layouts, in order to ensure that works in both cases.

Note that std140 and std430 layouts are used on the base GLSL shader
used to generate the SPIR-V shaders. SPIR-V shaders doesn't include
info about the layout. From ARB_gl_spirv spec:

"Mapping of layouts

  std140/std430 -> explicit *Offset*, *ArrayStride*, and
 *MatrixStride* Decoration on struct members"

So the SPIR-V generated may have different explicit
offset/strides. For this test we include types on the ssbo that gets
different offsets/strides based on the layouts.

v2: minor changes while I was updating the other patches (Alejandro)
---
 .../ssbo/two-ssbo-different-layouts.shader_test| 372 +
 1 file changed, 372 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo-different-layouts.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo-different-layouts.shader_test 
b/tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo-different-layouts.shader_test
new file mode 100644
index 0..7e3c5d06c
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo-different-layouts.shader_test
@@ -0,0 +1,372 @@
+# SSBO test with two ssbos, using different layouts (std140 and
+# std430) on the base GLSL shader. Just one stage.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 159
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpDecorate %_arr_v2float_uint_3 ArrayStride 16
+   OpMemberDecorate %ssbo1 0 Offset 0
+   OpMemberDecorate %ssbo1 1 ColMajor
+   OpMemberDecorate %ssbo1 1 Offset 48
+   OpMemberDecorate %ssbo1 1 MatrixStride 16
+   OpMemberDecorate %ssbo1 2 Offset 80
+   OpDecorate %ssbo1 BufferBlock
+   OpDecorate %ssbo140 DescriptorSet 0
+   OpDecorate %ssbo140 Binding 5
+   OpDecorate %_arr_v2float_uint_3_0 ArrayStride 8
+   OpMemberDecorate %ssbo2 0 Offset 0
+   OpMemberDecorate %ssbo2 1 ColMajor
+   OpMemberDecorate %ssbo2 1 Offset 24
+   OpMemberDecorate %ssbo2 1 MatrixStride 8
+   OpMemberDecorate %ssbo2 2 Offset 48
+   OpDecorate %ssbo2 BufferBlock
+   OpDecorate %ssbo430 DescriptorSet 0
+   OpDecorate %ssbo430 Binding 8
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+   %bool = OpTypeBool
+%v2float = OpTypeVector %float 2
+   %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_arr_v2float_uint_3 = OpTypeArray %v2float %uint_3
+%mat2v2float = OpTypeMatrix %v2float 2
+  %ssbo1 = OpTypeStruct %_arr_v2float_uint_3 %mat2v2float %v4float
+%_ptr_Uniform_ssbo1 = OpTypePointer Uniform %ssbo1
+%ssbo140 = OpVariable %_ptr_Uniform_ssbo1 Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+%float_5720_54443 = OpConstant %float 5720.54443
+%float_n21857_1582 = OpConstant %float -21857.1582
+ %32 = OpConstantComposite %v2float %float_5720_54443 
%float_n21857_1582
+ %v2bool = OpTypeVector %bool 2
+%_arr_v2float_uint_3_0 = OpTypeArray %v2float %uint_3
+  %ssbo2 = OpTypeStruct %_arr_v2float_uint_3_0 %mat2v2float %v4float
+%_ptr_Uniform_ssbo2 = OpTypePointer Uniform %ssbo2
+%ssbo430 = OpVariable %_ptr_Uniform_ssbo2 Uniform
+  %int_1 = OpConstant %int 1
+%float_n711_078674 = OpConstant %float -711.078674
+%float_8904_7334 = OpConstant %float 8904.7334
+ %58 = OpConstantComposite %v2float %float_n711_078674 %float_8904_7334
+  %int_2 = OpConstant %int 2
+%float_3164_0835 = OpConstant %float 3164.0835
+%float_20808_1934 = OpConstant %float 20808.1934
+ %79 = OpConstantComposite %v2float %float_3164_0835 %float_20808_1934
+%float_16690_9727 = OpConstant %float 16690.9727
+%float_9081_78711 = OpConstant %float 9081.78711
+ 

[Piglit] [PATCH v2 14/17] arb_gl_spirv: add simple ssbo tests with matrices

2018-09-27 Thread Alejandro Piñeiro
v2: no expected final substractions/additions value of content, but
check for real values (Timothy)
---
 .../execution/ssbo/matrix/column-major.shader_test | 188 +
 .../ssbo/matrix/column-vs-row.shader_test  | 291 +
 .../ssbo/matrix/indirect-column-major.shader_test  | 132 ++
 .../ssbo/matrix/indirect-row-major.shader_test | 132 ++
 .../execution/ssbo/matrix/row-major.shader_test| 194 ++
 5 files changed, 937 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/matrix/column-major.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/matrix/column-vs-row.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/matrix/indirect-column-major.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/matrix/indirect-row-major.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ssbo/matrix/row-major.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ssbo/matrix/column-major.shader_test 
b/tests/spec/arb_gl_spirv/execution/ssbo/matrix/column-major.shader_test
new file mode 100644
index 0..f67caf78d
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ssbo/matrix/column-major.shader_test
@@ -0,0 +1,188 @@
+# UBO test using a matrix. One stage
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 76
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpDecorate %color Location 0
+   OpMemberDecorate %ssbo 0 ColMajor
+   OpMemberDecorate %ssbo 0 Offset 0
+   OpMemberDecorate %ssbo 0 MatrixStride 16
+   OpDecorate %ssbo BufferBlock
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 5
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+%mat4v4float = OpTypeMatrix %v4float 4
+   %ssbo = OpTypeStruct %mat4v4float
+%_ptr_Uniform_ssbo = OpTypePointer Uniform %ssbo
+  %_ = OpVariable %_ptr_Uniform_ssbo Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+%float_4575_7998 = OpConstant %float 4575.7998
+%float_14191_6123 = OpConstant %float 14191.6123
+%float_n30199_3086 = OpConstant %float -30199.3086
+%float_n31303_4219 = OpConstant %float -31303.4219
+ %29 = OpConstantComposite %v4float %float_4575_7998 %float_14191_6123 
%float_n30199_3086 %float_n31303_4219
+   %bool = OpTypeBool
+ %v4bool = OpTypeVector %bool 4
+  %int_1 = OpConstant %int 1
+%float_16690_9727 = OpConstant %float 16690.9727
+%float_n30557_1582 = OpConstant %float -30557.1582
+%float_n16199_5928 = OpConstant %float -16199.5928
+%float_2088_69482 = OpConstant %float 2088.69482
+ %44 = OpConstantComposite %v4float %float_16690_9727 
%float_n30557_1582 %float_n16199_5928 %float_2088_69482
+  %int_2 = OpConstant %int 2
+%float_n2747_33765 = OpConstant %float -2747.33765
+%float_n30325_041 = OpConstant %float -30325.041
+%float_19382_7812 = OpConstant %float 19382.7812
+%float_28998_5918 = OpConstant %float 28998.5918
+ %57 = OpConstantComposite %v4float %float_n2747_33765 
%float_n30325_041 %float_19382_7812 %float_28998_5918
+  %int_3 = OpConstant %int 3
+%float_n5854_81055 = OpConstant %float -5854.81055
+%float_5217_75732 = OpConstant %float 5217.75732
+%float_26363_8359 = OpConstant %float 26363.8359
+%float_n29557_3516 = OpConstant %float -29557.3516
+ %70 = OpConstantComposite %v4float %float_n5854_81055 
%float_5217_75732 %float_26363_8359 %float_n29557_3516
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %fail_color = OpVariable %_ptr_Function_v4float Function
+   OpStore %fail_color %12
+   OpStore %color %15
+ %23 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_0
+ %24 = OpLoad %v4float %23
+ %32 = OpFOrdNotEqual %v4bool %24 %29
+ %33 = OpAny %bool %32
+   OpSelectionMerge %35 

[Piglit] [PATCH v2 04/17] shader_runner: add support for glGetProgram queries

2018-09-27 Thread Alejandro Piñeiro
Similar to the already existing verify program_interface_query, but
with the glGetProgramiv queries.

Useful, for example, to verify the current number of active (via
GL_ACTIVE_UNIFORMS).

Note that now there are two ways to verify link success. With the
already existing "link succes" shader runner query, or using this one:

   vefiry program_query GL_LINK_STATUS GL_TRUE

Although internally they are checked in a different way. It is pending
to check if there are corner cases where they return a different
value.
---
 tests/shaders/shader_runner.c | 78 +++
 1 file changed, 78 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index e359f97ad..4ba1d326d 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -2783,6 +2783,82 @@ set_subroutine_uniform(const char *line)
return;
 }
 
+/**
+ * Query values from current program using glGetProgram.
+ *
+ * Format of the command:
+ *   verify program_query GL_PNAME_ENUM integer
+ *
+ * or
+ *
+ *   verify program_query GL_PNAME_ENUM 
+ *
+ * Note: GL_COMPUTE_WORK_GROUP_SIZE is not supported, as is the only
+ * query that requires a params with more than one component, and we
+ * want to keep things simple.
+ *
+ */
+static void
+verify_program_query(const char *line)
+{
+   static const struct string_to_enum all_pnames[] = {
+   ENUM_STRING(GL_DELETE_STATUS),
+   ENUM_STRING(GL_LINK_STATUS),
+   ENUM_STRING(GL_VALIDATE_STATUS),
+   ENUM_STRING(GL_INFO_LOG_LENGTH),
+   ENUM_STRING(GL_ATTACHED_SHADERS),
+   ENUM_STRING(GL_ACTIVE_ATOMIC_COUNTER_BUFFERS),
+   ENUM_STRING(GL_ACTIVE_ATTRIBUTES),
+   ENUM_STRING(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH),
+   ENUM_STRING(GL_ACTIVE_UNIFORMS),
+   ENUM_STRING(GL_ACTIVE_UNIFORM_BLOCKS),
+   ENUM_STRING(GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH),
+   ENUM_STRING(GL_ACTIVE_UNIFORM_MAX_LENGTH),
+   ENUM_STRING(GL_COMPUTE_WORK_GROUP_SIZE),
+   ENUM_STRING(GL_PROGRAM_BINARY_LENGTH),
+   ENUM_STRING(GL_TRANSFORM_FEEDBACK_BUFFER_MODE),
+   ENUM_STRING(GL_TRANSFORM_FEEDBACK_VARYINGS),
+   ENUM_STRING(GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH),
+   ENUM_STRING(GL_GEOMETRY_VERTICES_OUT),
+   ENUM_STRING(GL_GEOMETRY_INPUT_TYPE),
+   ENUM_STRING(GL_GEOMETRY_OUTPUT_TYPE),
+   { NULL, 0 }
+   };
+
+   static const struct string_to_enum all_possible_param_enums[] = {
+   ENUM_STRING(GL_TRUE),
+   ENUM_STRING(GL_FALSE),
+   ENUM_STRING(GL_SEPARATE_ATTRIBS),
+   ENUM_STRING(GL_INTERLEAVED_ATTRIBS),
+   ENUM_STRING(GL_POINTS),
+   ENUM_STRING(GL_LINES),
+   ENUM_STRING(GL_LINES_ADJACENCY),
+   ENUM_STRING(GL_TRIANGLES),
+   ENUM_STRING(GL_TRIANGLES_ADJACENCY),
+   { NULL, 0 }
+   };
+
+   unsigned pname;
+   int expected;
+   int value;
+
+   REQUIRE(parse_enum_tab(all_pnames, line,
+  , ),
+   "Bad glGetProgram pname at: %s\n", line);
+
+   REQUIRE(parse_enum_tab(all_possible_param_enums, line, (unsigned 
*), ) ||
+   parse_int(line, , ),
+   "Bad expected value at: %s\n", line);
+
+   glGetProgramiv(prog, pname, );
+
+   if (expected != value) {
+   fprintf(stderr, "glGetProgram(%s): expected %d, got %d\n",
+   piglit_get_gl_enum_name(pname), expected, value);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+}
+
 /**
  * Query a uniform using glGetActiveUniformsiv
  *
@@ -4607,6 +4683,8 @@ piglit_display(void)
parse_ints(rest, _data.row_major, 1, NULL);
} else if (parse_str(line, "active uniform ", )) {
active_uniform(rest);
+   } else if (parse_str(line, "verify program_query", )) {
+verify_program_query(rest);
} else if (parse_str(line, "verify program_interface_query ", 
)) {
active_program_interface(rest, block_data);
} else if (parse_str(line, "vertex attrib ", )) {
-- 
2.14.1

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


[Piglit] [PATCH v2 05/17] arb_gl_spirv: add GL_ACTIVE_UNIFORMS checks

2018-09-27 Thread Alejandro Piñeiro
Right now the main reason is to check that we are expanding uniforms
for arrays and array of arrays of structs properly. This would be even
more important with UBO/SSBO tests.

The other reason is to check that hidden uniforms are really
hidden. As far as we know, current arb_gl_spirv tests doesn't use
internally any hidden uniform, at least on the i965 driver. But we
know of cases that will be send as tests in the future.
---
 tests/spec/arb_gl_spirv/execution/uniform/array.shader_test   | 2 ++
 .../spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test  | 2 ++
 .../arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test | 2 ++
 .../arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test | 2 ++
 .../arb_gl_spirv/execution/uniform/atomic-uint-array-cs.shader_test   | 2 ++
 .../arb_gl_spirv/execution/uniform/atomic-uint-array-fs.shader_test   | 2 ++
 tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-cs.shader_test  | 2 ++
 .../spec/arb_gl_spirv/execution/uniform/atomic-uint-fs.shader_runner  | 1 +
 .../uniform/atomic-uint-mixing-with-normal-uniforms.shader_test   | 2 ++
 .../execution/uniform/atomic-uint-several-slots.shader_test   | 2 ++
 .../spec/arb_gl_spirv/execution/uniform/embedded-structs.shader_test  | 2 ++
 .../arb_gl_spirv/execution/uniform/index-matches-location.shader_test | 2 ++
 .../arb_gl_spirv/execution/uniform/initializer-complex.shader_test| 2 ++
 .../spec/arb_gl_spirv/execution/uniform/initializer-dvec4.shader_test | 3 +++
 .../arb_gl_spirv/execution/uniform/initializer-mat4x3.shader_test | 4 
 tests/spec/arb_gl_spirv/execution/uniform/initializer.shader_test | 2 ++
 .../execution/uniform/nonsequential-locations.shader_test | 2 ++
 .../execution/uniform/sampler2d-binding-array.shader_test | 2 ++
 .../spec/arb_gl_spirv/execution/uniform/sampler2d-binding.shader_test | 2 ++
 .../execution/uniform/sampler2d-nonconst-nested-array.shader_test | 2 ++
 .../spec/arb_gl_spirv/execution/uniform/sampler2d-struct.shader_test  | 2 ++
 tests/spec/arb_gl_spirv/execution/uniform/sampler2d.shader_test   | 2 ++
 .../arb_gl_spirv/execution/uniform/simple-without-names.shader_test   | 2 ++
 tests/spec/arb_gl_spirv/execution/uniform/simple.shader_test  | 2 ++
 tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test| 2 ++
 tests/spec/arb_gl_spirv/execution/uniform/struct.shader_test  | 2 ++
 tests/spec/arb_gl_spirv/execution/uniform/two-uniforms.shader_test| 2 ++
 27 files changed, 56 insertions(+)

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
index 54ac66b42..18ae3ca09 100644
--- a/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
+++ b/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
@@ -133,5 +133,7 @@ clear
 uniform vec4 0 0.2 0.1 0.1 1.6
 uniform vec4 1 0.5 2.0 3.0 0.25
 
+verify program_query GL_ACTIVE_UNIFORMS 1
+
 draw rect -1 -1 2 2
 probe all rgba 0.1 0.2 0.3 0.4
diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test
index 07e32560b..5c9b97fed 100644
--- a/tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test
+++ b/tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test
@@ -73,5 +73,7 @@ uniform vec4 11 0.4 0.5 0.6 0.7
 uniform vec4 12 0.8 0.9 1.0 1.1
 uniform vec4 13 0.1 0.2 0.3 0.4
 
+verify program_query GL_ACTIVE_UNIFORMS 2
+
 draw rect -1 -1 1 1
 relative probe rect rgb (0.0, 0.0, 0.5, 0.5) (0.1, 0.3, 0.5)
diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
index 5bc3850bf..eafc6e2e2 100644
--- a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
+++ b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
@@ -216,6 +216,8 @@ uniform uint 11 14  # a01_expected[5]
 
 uniform uint 12 30  # a12_expected
 
+verify program_query GL_ACTIVE_UNIFORMS 8
+
 # Check original values for the atomic counters
 
 probe atomic counter buffer 0 0 == 0
diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
index f259d3c0f..f24dd8659 100644
--- a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
+++ b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
@@ -197,6 +197,8 @@ uniform uint 0 3
 uniform uint 1 15
 uniform uint 2 17
 
+verify program_query GL_ACTIVE_UNIFORMS 5
+
 # Check original values for the atomic counters
 
 probe atomic counter buffer 0 0 == 0   # outside array (offset qualifier was 4)
diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-array-cs.shader_test 

[Piglit] [PATCH v2 12/17] arb_gl_spirv: add ubo array test with different array_stride

2018-09-27 Thread Alejandro Piñeiro
For more info, see the long explanation at the commit "arb_gl_spirv:
add ubo matrix test with different matrix_stride"

v2: no expected final substractions/additions value of content, but
check for real values (Timothy)
---
 .../array-different-array-stride-ubo.shader_test   | 271 +
 1 file changed, 271 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
 
b/tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
new file mode 100644
index 0..cdab51c24
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
@@ -0,0 +1,271 @@
+# UBO test using two ubos, with an array with the same size and type,
+# but setting a different array stride for each one. Used to test that
+# the size is properly computed, and the content properly accessed in
+# both cases.
+
+[require]
+SPIRV ONLY
+GL >= 3.3
+GLSL >= 3.30
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py, and then 
edited by hand to set the proper array stride
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 123
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpName %__0 ""
+   OpDecorate %color Location 0
+   OpDecorate %_arr_v4float_uint_3 ArrayStride 16
+   OpMemberDecorate %block16 0 Offset 0
+   OpDecorate %block16 Block
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 5
+   OpDecorate %_arr_v4float_uint_3_0 ArrayStride 32
+   OpMemberDecorate %block32 0 Offset 0
+   OpDecorate %block32 Block
+   OpDecorate %__0 DescriptorSet 0
+   OpDecorate %__0 Binding 6
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+   %bool = OpTypeBool
+   %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_arr_v4float_uint_3 = OpTypeArray %v4float %uint_3
+%block16 = OpTypeStruct %_arr_v4float_uint_3
+%_ptr_Uniform_block16 = OpTypePointer Uniform %block16
+  %_ = OpVariable %_ptr_Uniform_block16 Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+%float_20530_7109 = OpConstant %float 20530.7109
+%float_n10508_5107 = OpConstant %float -10508.5107
+%float_n23051_9961 = OpConstant %float -23051.9961
+%float_n23564_0664 = OpConstant %float -23564.0664
+ %32 = OpConstantComposite %v4float %float_20530_7109 
%float_n10508_5107 %float_n23051_9961 %float_n23564_0664
+ %v4bool = OpTypeVector %bool 4
+  %int_1 = OpConstant %int 1
+%float_n27681_2891 = OpConstant %float -27681.2891
+%float_9081_78711 = OpConstant %float 9081.78711
+%float_n12496_1973 = OpConstant %float -12496.1973
+%float_n5854_81055 = OpConstant %float -5854.81055
+ %46 = OpConstantComposite %v4float %float_n27681_2891 
%float_9081_78711 %float_n12496_1973 %float_n5854_81055
+  %int_2 = OpConstant %int 2
+%float_5217_75732 = OpConstant %float 5217.75732
+%float_26363_8359 = OpConstant %float 26363.8359
+%float_n29557_3516 = OpConstant %float -29557.3516
+%float_30238_998 = OpConstant %float 30238.998
+ %60 = OpConstantComposite %v4float %float_5217_75732 
%float_26363_8359 %float_n29557_3516 %float_30238_998
+%_arr_v4float_uint_3_0 = OpTypeArray %v4float %uint_3
+%block32 = OpTypeStruct %_arr_v4float_uint_3_0
+%_ptr_Uniform_block32 = OpTypePointer Uniform %block32
+%__0 = OpVariable %_ptr_Uniform_block32 Uniform
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %fail_color = OpVariable %_ptr_Function_v4float Function
+   OpStore %fail_color %12
+   OpStore %color %15
+ %26 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_0
+ %27 = OpLoad %v4float %26
+ %34 = OpFOrdNotEqual %v4bool %27 %32
+ %35 = OpAny %bool %34
+ %36 = OpLogicalNot %bool %35
+   OpSelectionMerge %38 None
+   

[Piglit] [PATCH v2 00/17] ARB_gl_spirv: v2 ubo/ssbo tests

2018-09-27 Thread Alejandro Piñeiro

Hi,

this is the second version of the ubo/ssbo tests for
ARB_gl_spirv. Differences compared with v1:

  * Rebased against today master.

  * Updated the pass checks on several tests. Instead of a silly
addition/substraction of the ubo/ssbo content, and check a
specific value, the value of the individual ubo/ssbo members are
checked.

  * array-complex became even more complex. Specifically thinking on
testing some cases mentioned by Timothy feedback on the mesa-dev
series.

v1 announcement:
   https://lists.freedesktop.org/archives/piglit/2018-September/025065.html

The series can be found on this branch:
   https://github.com/Igalia/piglit/tree/arb_gl_spirv-series5-ubo-ssbo-v2


Alejandro Piñeiro (15):
  shader_runner/spirv: log skip reason on ARB_gl_spirv extension check
  shader_runner/spirv: check if test really includes spirv
  shader_runner: add force_no_names mode
  shader_runner: add support for glGetProgram queries
  arb_gl_spirv: add GL_ACTIVE_UNIFORMS checks
  arb_gl_spirv: add some simple ubo tests
  arb_gl_spirv: add simple ubo tests with matrices
  arb_gl_spirv: add complex ubo test with matrices
  arb_gl_spirv: add a array of ubo test, with complex ubo content
  arb_gl_spirv: add ubo matrix test with different matrix_stride
  arb_gl_spirv: add ubo array test with different array_stride
  arb_gl_spirv: add some simple ssbo tests
  arb_gl_spirv: add simple ssbo tests with matrices
  arb_gl_spirv: adding complex ssbo matrix test
  arb_gl_spirv: add ssbo test using std140 and std430

Neil Roberts (2):
  arb_gl_spirv: Add tests for UBOs with explicit offsets
  arb_gl_spirv: Add a test for SSBOs with an unsized array

 tests/shaders/shader_runner.c  | 485 +++---
 .../execution/ssbo/array-indirect.shader_test  | 121 
 .../execution/ssbo/array-inside-ssbo.shader_test   | 189 ++
 .../ssbo/array-of-arrays-inside-ssbo.shader_test   | 203 ++
 .../arb_gl_spirv/execution/ssbo/array.shader_test  | 173 +
 .../execution/ssbo/matrix/column-major.shader_test | 188 ++
 .../ssbo/matrix/column-vs-row.shader_test  | 291 +
 .../execution/ssbo/matrix/complex.shader_test  | 702 +
 .../ssbo/matrix/indirect-column-major.shader_test  | 132 
 .../ssbo/matrix/indirect-row-major.shader_test | 132 
 .../execution/ssbo/matrix/row-major.shader_test| 194 ++
 .../arb_gl_spirv/execution/ssbo/simple.shader_test | 138 
 .../ssbo/two-ssbo-different-layouts.shader_test| 372 +++
 .../execution/ssbo/two-ssbo.shader_test| 151 +
 .../execution/ssbo/two-stages.shader_test  | 279 
 .../execution/ssbo/unsized-array.shader_test   | 119 
 .../execution/ubo/array-complex.shader_test| 360 +++
 .../array-different-array-stride-ubo.shader_test   | 271 
 .../execution/ubo/array-indirect.shader_test   | 108 
 .../execution/ubo/array-inside-ubo.shader_test | 154 +
 .../ubo/array-of-arrays-inside-ubo.shader_test | 184 ++
 .../arb_gl_spirv/execution/ubo/array.shader_test   | 140 
 .../ubo/explicit-offset-nested-struct.shader_test  |  81 +++
 .../execution/ubo/explicit-offset.shader_test  |  80 +++
 .../execution/ubo/location-0-crash.shader_test |  93 +++
 .../execution/ubo/matrix/column-major.shader_test  | 176 ++
 .../execution/ubo/matrix/column-vs-row.shader_test | 303 +
 .../execution/ubo/matrix/complex.shader_test   | 624 ++
 .../ubo/matrix/different-matrix-stride.shader_test | 260 
 .../ubo/matrix/indirect-column-major.shader_test   | 120 
 .../ubo/matrix/indirect-row-major.shader_test  | 120 
 .../execution/ubo/matrix/row-major.shader_test | 175 +
 .../arb_gl_spirv/execution/ubo/simple.shader_test  | 131 
 .../execution/ubo/two-stages.shader_test   | 276 
 .../execution/ubo/two-ubos.shader_test | 141 +
 .../execution/uniform/array.shader_test|   2 +
 .../execution/uniform/arrays-of-arrays.shader_test |   2 +
 .../uniform/atomic-uint-aoa-cs.shader_test |   2 +
 .../uniform/atomic-uint-aoa-fs.shader_test |   2 +
 .../uniform/atomic-uint-array-cs.shader_test   |   2 +
 .../uniform/atomic-uint-array-fs.shader_test   |   2 +
 .../execution/uniform/atomic-uint-cs.shader_test   |   2 +
 .../execution/uniform/atomic-uint-fs.shader_runner |   1 +
 ...ic-uint-mixing-with-normal-uniforms.shader_test |   2 +
 .../uniform/atomic-uint-several-slots.shader_test  |   2 +
 .../execution/uniform/embedded-structs.shader_test |   2 +
 .../uniform/index-matches-location.shader_test |   2 +
 .../uniform/initializer-complex.shader_test|   2 +
 .../uniform/initializer-dvec4.shader_test  |   3 +
 .../uniform/initializer-mat4x3.shader_test |   4 +
 .../execution/uniform/initializer.shader_test  |   2 +
 .../uniform/nonsequential-locations.shader_test|   2

[Piglit] [PATCH v2 02/17] shader_runner/spirv: check if test really includes spirv

2018-09-27 Thread Alejandro Piñeiro
SPIRV YES/ONLY assumes that the test includes the SPIR-V shader, and
that you should use it. This commit checks that this really happens,
and prints a proper error message.

Without this commit, a SPIRV YES/ONLY test that by mistake didn't
include the [spirv xx] sections would be just skipped with the
following non-intuitive message:

   "Function "glDeleteProgramsARB" not supported on this implementation"
---
 tests/shaders/shader_runner.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index e5566ee7d..b19ac2f6d 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1622,6 +1622,7 @@ process_test_script(const char *script_name)
enum states state = none;
const char *line = text;
enum piglit_result result;
+   bool test_really_contains_spirv = false;
 
if (line == NULL) {
printf("could not read file \"%s\"\n", script_name);
@@ -1651,6 +1652,7 @@ process_test_script(const char *script_name)
shader_string_size = strlen(shader_string);
} else if (parse_str(line, "[vertex shader spirv]", 
NULL)) {
state = vertex_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[vertex shader 
specializations]", NULL)) {
state = vertex_shader_specializations;
@@ -1659,6 +1661,7 @@ process_test_script(const char *script_name)
shader_string = NULL;
} else if (parse_str(line, "[tessellation control 
shader spirv]", NULL)) {
state = tess_ctrl_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[tessellation control 
shader specializations]", NULL)) {
state = tess_ctrl_shader_specializations;
@@ -1667,6 +1670,7 @@ process_test_script(const char *script_name)
shader_string = NULL;
} else if (parse_str(line, "[tessellation evaluation 
shader spirv]", NULL)) {
state = tess_eval_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[tessellation evaluation 
shader specializations]", NULL)) {
state = tess_eval_shader_specializations;
@@ -1677,6 +1681,7 @@ process_test_script(const char *script_name)
state = geometry_shader_specializations;
} else if (parse_str(line, "[geometry shader spirv]", 
NULL)) {
state = geometry_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[geometry shader 
specializations]", NULL)) {
state = geometry_shader_specializations;
@@ -1693,6 +1698,7 @@ process_test_script(const char *script_name)
state = fragment_shader_specializations;
} else if (parse_str(line, "[fragment shader spirv]", 
NULL)) {
state = fragment_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[fragment shader 
specializations]", NULL)) {
state = fragment_shader_specializations;
@@ -1701,6 +1707,7 @@ process_test_script(const char *script_name)
shader_string = NULL;
} else if (parse_str(line, "[compute shader spirv]", 
NULL)) {
state = compute_shader_spirv;
+test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[compute shader 
specializations]", NULL)) {
state = compute_shader_specializations;
@@ -1712,6 +1719,15 @@ process_test_script(const char *script_name)
test_start_line_num = line_num + 1;
if (test_start[0] != '\0')
test_start++;
+
+   if (!test_really_contains_spirv &&
+   spirv_replaces_glsl) {
+   fprintf(stderr, "SPIRV YES/ONLY test, 
but"
+ 

[Piglit] [PATCH v2 03/17] shader_runner: add force_no_names mode

2018-09-27 Thread Alejandro Piñeiro
Right now UBO data filling is based on using the name of the ubo and
their components, in order to get the block and uniform index. It also
uses it to set the binding (so it forces block_index and block_binding
to be equal).

Since ARB_shading_language_420pack it is possible to set a explicit
ubo binding, so it would be interesting to try to use it directly
without such re-binding, and gather the info without using the names
at all.

We extend this idea to the already existing program interface query
support, so we can do a subset of the queries using only the explicit
binding.

This will be specially interesting for ARB_gl_spirv testing, where
SPIR-V shaders should work without names, and explicit binding is not
just optional but mandatory. For that reason, if running using SPIR-V
instead of GLSL, we use this mode automatically, as it would fail
otherwise. Another alternative is not set a different mode, but
working this way when we are using SPIR-V shaders. But as mentioned,
there would be GLSL cases where this would be interesting, and we are
also interested on a sanity check when writing a SPIR-V test.

In order this to work on all cases, we need to also explicitly set
other info when filling the data:
  * offsets for each individual component
  * matrix stride
  * row major

Using the same approach used to fill the array index info. Note that
for arrays we are not adding array stride, as this can be done by
using the explicit offset. This allow us to not add another variable.

We extended this idea for SSBO, so we gather the info in a generic
"block_info" struct. Although this is not needed for ssbo data
filling, as it already uses the explicit binding, it became useful to
keep using program interface queries.

It is worth to note that some of the queries already supported by
shader_runner will not be supported on this mode, as they are based on
the names.

v2: improve legibility by avoiding so many indentation changes (Ian)
---
 tests/shaders/shader_runner.c | 381 --
 1 file changed, 289 insertions(+), 92 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index b19ac2f6d..e359f97ad 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -93,6 +93,14 @@ struct component_version {
char _string[100];
 };
 
+struct block_info {
+   int array_index;
+   int binding;
+   int offset;
+   int matrix_stride;
+   int row_major; /* int as we don't have a parse_bool */
+};
+
 #define ENUM_STRING(e) { #e, e }
 
 extern float piglit_tolerance[4];
@@ -126,6 +134,7 @@ static GLuint compute_shaders[256];
 static unsigned num_compute_shaders = 0;
 static int num_uniform_blocks;
 static GLuint *uniform_block_bos;
+static int *uniform_block_indexes; /* ubo block index, indexed by ubo binding 
*/
 static GLenum geometry_layout_input_type = GL_TRIANGLES;
 static GLenum geometry_layout_output_type = GL_TRIANGLE_STRIP;
 static GLint geometry_layout_vertices_out = 0;
@@ -155,6 +164,7 @@ static bool sso_in_use = false;
 static bool glsl_in_use = false;
 static bool force_glsl = false;
 static bool spirv_in_use = false;
+static bool force_no_names = false;
 static GLchar *prog_err_info = NULL;
 static GLuint vao = 0;
 static GLuint draw_fbo, read_fbo;
@@ -1204,6 +1214,9 @@ process_requirement(const char *line)
printf("Unknown SPIRV line in [require]\n");
return PIGLIT_FAIL;
}
+
+   if (spirv_replaces_glsl)
+   force_no_names = true;
}
return PIGLIT_PASS;
 }
@@ -1245,6 +1258,10 @@ leave_state(enum states state, const char *line, const 
char *script_name)
if (spirv_replaces_glsl) {
printf("Running on SPIR-V mode\n");
}
+   if (force_no_names && !spirv_replaces_glsl) {
+   printf("Running on GLSL mode, forcing not using "
+   "uniform/uniform block names\n");
+   }
break;
 
case vertex_shader:
@@ -2036,17 +2053,28 @@ check_texture_handle_support(void)
piglit_report_result(PIGLIT_SKIP);
 }
 
+static bool
+get_indexes_and_offset_from_ubo(char *name, struct block_info block_data,
+   GLuint *uniform_index_out,
+   GLint *block_index_out,
+   GLint *offset_out);
+
 /**
  * Handles uploads of UBO uniforms by mapping the buffer and storing
  * the data.  If the uniform is not in a uniform block, returns false.
  */
 static bool
-set_ubo_uniform(char *name, const char *type, const char *line, int 
ubo_array_index)
+set_ubo_uniform(char *name, const char *type,
+   const char *line,
+   struct block_info block_data)
 {
+   /* Note: on SPIR-V we can't access to uniform_index as we
+* could lack the name. We force 

[Piglit] [PATCH v2 09/17] arb_gl_spirv: add a array of ubo test, with complex ubo content

2018-09-27 Thread Alejandro Piñeiro
Specifically the ubo contains some basic types, a struct type, with
array and matrices members.

v2:

  * Add some layer of complexity (to include some cases mentioned by
Timothy on the mesa-dev review)
  * No expected final substractions/additions value of content, but
check for real values (Timothy)
---
 .../execution/ubo/array-complex.shader_test| 360 +
 1 file changed, 360 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-complex.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/ubo/array-complex.shader_test 
b/tests/spec/arb_gl_spirv/execution/ubo/array-complex.shader_test
new file mode 100644
index 0..2a2ffad54
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/array-complex.shader_test
@@ -0,0 +1,360 @@
+# UBO test using an array of ubos, with complex content.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 159
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpDecorate %_arr_v3float_uint_3 ArrayStride 16
+   OpDecorate %_arr_mat2v2float_uint_3 ArrayStride 32
+   OpMemberDecorate %S 0 Offset 0
+   OpMemberDecorate %S 1 Offset 48
+   OpMemberDecorate %S 2 RowMajor
+   OpMemberDecorate %S 2 Offset 64
+   OpMemberDecorate %S 2 MatrixStride 16
+   OpDecorate %_arr_S_uint_3 ArrayStride 160
+   OpMemberDecorate %ComponentsBlock 0 Offset 0
+   OpMemberDecorate %ComponentsBlock 1 Offset 8
+   OpMemberDecorate %ComponentsBlock 2 Offset 16
+   OpDecorate %ComponentsBlock Block
+   OpDecorate %components DescriptorSet 0
+   OpDecorate %components Binding 5
+   OpDecorate %struct_array Location 6
+   OpDecorate %struct_array DescriptorSet 0
+   OpDecorate %struct_array Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+%v2float = OpTypeVector %float 2
+%v3float = OpTypeVector %float 3
+   %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_arr_v3float_uint_3 = OpTypeArray %v3float %uint_3
+%mat2v2float = OpTypeMatrix %v2float 2
+%_arr_mat2v2float_uint_3 = OpTypeArray %mat2v2float %uint_3
+  %S = OpTypeStruct %_arr_v3float_uint_3 %v4float 
%_arr_mat2v2float_uint_3
+%_arr_S_uint_3 = OpTypeArray %S %uint_3
+%ComponentsBlock = OpTypeStruct %float %v2float %_arr_S_uint_3
+ %uint_2 = OpConstant %uint 2
+%_arr_ComponentsBlock_uint_2 = OpTypeArray %ComponentsBlock %uint_2
+%_ptr_Uniform__arr_ComponentsBlock_uint_2 = OpTypePointer Uniform 
%_arr_ComponentsBlock_uint_2
+ %components = OpVariable %_ptr_Uniform__arr_ComponentsBlock_uint_2 Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_float = OpTypePointer Uniform %float
+%float_5720_54443 = OpConstant %float 5720.54443
+   %bool = OpTypeBool
+  %int_1 = OpConstant %int 1
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+%float_n21857_1582 = OpConstant %float -21857.1582
+%float_n711_078674 = OpConstant %float -711.078674
+ %47 = OpConstantComposite %v2float %float_n21857_1582 
%float_n711_078674
+ %v2bool = OpTypeVector %bool 2
+  %int_2 = OpConstant %int 2
+%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
+%float_8904_7334 = OpConstant %float 8904.7334
+%float_3164_0835 = OpConstant %float 3164.0835
+%float_20808_1934 = OpConstant %float 20808.1934
+ %61 = OpConstantComposite %v3float %float_8904_7334 %float_3164_0835 
%float_20808_1934
+ %v3bool = OpTypeVector %bool 3
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+%float_n6150_84961 = OpConstant %float -6150.84961
+%float_n10267_4893 = OpConstant %float -10267.4893
+%float_26495_5859 = OpConstant %float 26495.5859
+%float_n12496_1973 = OpConstant %float -12496.1973
+ %75 = OpConstantComposite %v4float %float_n6150_84961 
%float_n10267_4893 %float_26495_5859 %float_n12496_1973
+ 

[Piglit] [PATCH v2 07/17] arb_gl_spirv: add simple ubo tests with matrices

2018-09-27 Thread Alejandro Piñeiro
v2: no expected final substractions/additions value of content, but
check for real values (Timothy)
---
 .../execution/ubo/matrix/column-major.shader_test  | 176 
 .../execution/ubo/matrix/column-vs-row.shader_test | 303 +
 .../ubo/matrix/indirect-column-major.shader_test   | 120 
 .../ubo/matrix/indirect-row-major.shader_test  | 120 
 .../execution/ubo/matrix/row-major.shader_test | 175 
 5 files changed, 894 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/matrix/column-major.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/matrix/column-vs-row.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/matrix/indirect-column-major.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/matrix/indirect-row-major.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/matrix/row-major.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ubo/matrix/column-major.shader_test 
b/tests/spec/arb_gl_spirv/execution/ubo/matrix/column-major.shader_test
new file mode 100644
index 0..78a2d6fda
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/matrix/column-major.shader_test
@@ -0,0 +1,176 @@
+# UBO test using a matrix. One stage
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 76
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpDecorate %color Location 0
+   OpMemberDecorate %ComponentsBlock 0 ColMajor
+   OpMemberDecorate %ComponentsBlock 0 Offset 0
+   OpMemberDecorate %ComponentsBlock 0 MatrixStride 16
+   OpDecorate %ComponentsBlock Block
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 5
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+%mat4v4float = OpTypeMatrix %v4float 4
+%ComponentsBlock = OpTypeStruct %mat4v4float
+%_ptr_Uniform_ComponentsBlock = OpTypePointer Uniform %ComponentsBlock
+  %_ = OpVariable %_ptr_Uniform_ComponentsBlock Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+%float_4575_7998 = OpConstant %float 4575.7998
+%float_14191_6123 = OpConstant %float 14191.6123
+%float_n30199_3086 = OpConstant %float -30199.3086
+%float_n31303_4219 = OpConstant %float -31303.4219
+ %29 = OpConstantComposite %v4float %float_4575_7998 %float_14191_6123 
%float_n30199_3086 %float_n31303_4219
+   %bool = OpTypeBool
+ %v4bool = OpTypeVector %bool 4
+  %int_1 = OpConstant %int 1
+%float_16690_9727 = OpConstant %float 16690.9727
+%float_n30557_1582 = OpConstant %float -30557.1582
+%float_n16199_5928 = OpConstant %float -16199.5928
+%float_2088_69482 = OpConstant %float 2088.69482
+ %44 = OpConstantComposite %v4float %float_16690_9727 
%float_n30557_1582 %float_n16199_5928 %float_2088_69482
+  %int_2 = OpConstant %int 2
+%float_n2747_33765 = OpConstant %float -2747.33765
+%float_n30325_041 = OpConstant %float -30325.041
+%float_19382_7812 = OpConstant %float 19382.7812
+%float_28998_5918 = OpConstant %float 28998.5918
+ %57 = OpConstantComposite %v4float %float_n2747_33765 
%float_n30325_041 %float_19382_7812 %float_28998_5918
+  %int_3 = OpConstant %int 3
+%float_n5854_81055 = OpConstant %float -5854.81055
+%float_5217_75732 = OpConstant %float 5217.75732
+%float_26363_8359 = OpConstant %float 26363.8359
+%float_n29557_3516 = OpConstant %float -29557.3516
+ %70 = OpConstantComposite %v4float %float_n5854_81055 
%float_5217_75732 %float_26363_8359 %float_n29557_3516
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %fail_color = OpVariable %_ptr_Function_v4float Function
+   OpStore %fail_color %12
+   OpStore %color %15
+ %23 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_0
+ %24 = OpLoad %v4float %23
+ %32 = OpFOrdNotEqual %v4bool %24 %29
+ 

[Piglit] [PATCH v2 10/17] arb_gl_spirv: Add tests for UBOs with explicit offsets

2018-09-27 Thread Alejandro Piñeiro
From: Neil Roberts 

Adds two tests, one which has an explicit offset in GLSL using the
layout(offset) decoration on an interface member, and another which
has a struct embedded in an interface. On SPIR-V it is possible to set
an explicit offset even within this embedded struct.
---
 .../ubo/explicit-offset-nested-struct.shader_test  | 81 ++
 .../execution/ubo/explicit-offset.shader_test  | 80 +
 2 files changed, 161 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test
 
b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test
new file mode 100644
index 0..7c3514e45
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset-nested-struct.shader_test
@@ -0,0 +1,81 @@
+# Test a UBO with a member at an explicit offset. The member is itself
+# a struct with its own explicit offset.
+
+[require]
+SPIRV ONLY
+GLSL >= 4.50
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 20
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %outcolor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %outcolor "outcolor"
+   OpName %InnerThing "InnerThing"
+   OpMemberName %InnerThing 0 "ignored"
+   OpMemberName %InnerThing 1 "a"
+   OpName %Block "Block"
+   OpMemberName %Block 0 "thing"
+   OpName %_ ""
+   OpDecorate %outcolor Location 0
+   OpMemberDecorate %InnerThing 0 Offset 0
+   OpMemberDecorate %InnerThing 1 Offset 64
+   OpMemberDecorate %Block 0 Offset 64
+   OpDecorate %Block Block
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outcolor = OpVariable %_ptr_Output_v4float Output
+ %InnerThing = OpTypeStruct %float %v4float
+  %Block = OpTypeStruct %InnerThing
+%_ptr_Uniform_Block = OpTypePointer Uniform %Block
+  %_ = OpVariable %_ptr_Uniform_Block Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+  %int_1 = OpConstant %int 1
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_1
+ %19 = OpLoad %v4float %18
+   OpStore %outcolor %19
+   OpReturn
+   OpFunctionEnd
+
+[test]
+clear color 0.8 0.0 0.0 1.0
+
+# Set the value at a few locations. This shouldn’t affect the result
+# unless the shader is ignoring the offset.
+block binding 0
+block offset 0
+uniform vec4 a 0.9 0.0 0.0 1.0
+block offset 64
+uniform vec4 a 0.9 0.0 0.0 1.0
+block offset 80
+uniform vec4 a 0.9 0.0 0.0 1.0
+
+block offset 128
+uniform vec4 a 0.0 1.0 0.0 1.0
+
+verify program_interface_query GL_UNIFORM_BLOCK Block GL_BUFFER_DATA_SIZE 144
+verify program_query GL_ACTIVE_UNIFORMS 2
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
diff --git a/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test 
b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test
new file mode 100644
index 0..38c58fff1
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/explicit-offset.shader_test
@@ -0,0 +1,80 @@
+# Test a UBO with a member at an explicit offset
+
+[require]
+SPIRV YES
+GLSL >= 4.50
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 18
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %outcolor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpDecorate %outcolor Location 0
+   OpMemberDecorate %Block 0 Offset 16
+   OpDecorate %Block Block
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+

[Piglit] [PATCH v2 06/17] arb_gl_spirv: add some simple ubo tests

2018-09-27 Thread Alejandro Piñeiro
Add two linker tests and several simple execution tests for
ubo. Linker tests just checks for some basic linker errors (like
mistmatched ubo on different stages).

The execution tests include:
 * Simple one with just one ubo
 * Two different ubo on the same stage
 * Same ubo used on two different stages
 * Array and array using indirect index of ubos

Finally this also includes a test for a shader that was crashing on a
early version of the SPIR-V support. Included here just in case the
codebase regresses.

v2: don't check if the block content is correct with additions and
substractions of the ubo content (Timothy)
---
 .../execution/ubo/array-indirect.shader_test   | 108 
 .../execution/ubo/array-inside-ubo.shader_test | 154 
 .../ubo/array-of-arrays-inside-ubo.shader_test | 184 ++
 .../arb_gl_spirv/execution/ubo/array.shader_test   | 140 +++
 .../execution/ubo/location-0-crash.shader_test |  93 +++
 .../arb_gl_spirv/execution/ubo/simple.shader_test  | 131 ++
 .../execution/ubo/two-stages.shader_test   | 276 +
 .../execution/ubo/two-ubos.shader_test | 141 +++
 .../linker/ubo/two-stages-wrong1.shader_test   | 190 ++
 .../linker/ubo/two-stages-wrong2.shader_test   | 185 ++
 10 files changed, 1602 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-indirect.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-inside-ubo.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/array-of-arrays-inside-ubo.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/array.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/location-0-crash.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/simple.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/two-stages.shader_test
 create mode 100644 tests/spec/arb_gl_spirv/execution/ubo/two-ubos.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/linker/ubo/two-stages-wrong1.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/linker/ubo/two-stages-wrong2.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/ubo/array-indirect.shader_test 
b/tests/spec/arb_gl_spirv/execution/ubo/array-indirect.shader_test
new file mode 100644
index 0..87e741159
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/array-indirect.shader_test
@@ -0,0 +1,108 @@
+# UBO test using an array of ubo and indirect(dynamically uniform)
+# indexing. Just uses one stage.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 24
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %outColor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %outColor Location 0
+   OpMemberDecorate %ComponentsBlock 0 Offset 0
+   OpDecorate %ComponentsBlock Block
+   OpDecorate %components DescriptorSet 0
+   OpDecorate %components Binding 5
+   OpDecorate %u_idx Location 10
+   OpDecorate %u_idx DescriptorSet 0
+   OpDecorate %u_idx Binding 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outColor = OpVariable %_ptr_Output_v4float Output
+%ComponentsBlock = OpTypeStruct %v4float
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr_ComponentsBlock_uint_2 = OpTypeArray %ComponentsBlock %uint_2
+%_ptr_Uniform__arr_ComponentsBlock_uint_2 = OpTypePointer Uniform 
%_arr_ComponentsBlock_uint_2
+ %components = OpVariable %_ptr_Uniform__arr_ComponentsBlock_uint_2 Uniform
+%int = OpTypeInt 32 1
+%_ptr_UniformConstant_int = OpTypePointer UniformConstant %int
+  %u_idx = OpVariable %_ptr_UniformConstant_int UniformConstant
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %19 = OpLoad %int %u_idx
+ %22 = OpAccessChain %_ptr_Uniform_v4float %components %19 %int_0
+ %23 = OpLoad %v4float %22
+   OpStore %outColor %23
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+
+#version 450
+
+layout (location = 0) out vec4 outColor;
+layout (location = 10) uniform int u_idx;
+
+layout (std140, binding = 5) uniform ComponentsBlock
+ {
+vec4 c1;
+ } components[2];

[Piglit] [PATCH v2 08/17] arb_gl_spirv: add complex ubo test with matrices

2018-09-27 Thread Alejandro Piñeiro
UBO test using several matrices on one block. All possible size
combination, mixing row and column major.
---
 .../execution/ubo/matrix/complex.shader_test   | 624 +
 1 file changed, 624 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/ubo/matrix/complex.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/ubo/matrix/complex.shader_test 
b/tests/spec/arb_gl_spirv/execution/ubo/matrix/complex.shader_test
new file mode 100644
index 0..2692bf080
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/matrix/complex.shader_test
@@ -0,0 +1,624 @@
+# UBO test using several matrices on one block. All possible size
+# combination, mixing row and column major.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_gl_spirv
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 359
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %outColor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpMemberDecorate %ComponentsBlock 0 RowMajor
+   OpMemberDecorate %ComponentsBlock 0 Offset 0
+   OpMemberDecorate %ComponentsBlock 0 MatrixStride 16
+   OpMemberDecorate %ComponentsBlock 1 ColMajor
+   OpMemberDecorate %ComponentsBlock 1 Offset 32
+   OpMemberDecorate %ComponentsBlock 1 MatrixStride 16
+   OpMemberDecorate %ComponentsBlock 2 ColMajor
+   OpMemberDecorate %ComponentsBlock 2 Offset 64
+   OpMemberDecorate %ComponentsBlock 2 MatrixStride 16
+   OpMemberDecorate %ComponentsBlock 3 ColMajor
+   OpMemberDecorate %ComponentsBlock 3 Offset 96
+   OpMemberDecorate %ComponentsBlock 3 MatrixStride 16
+   OpMemberDecorate %ComponentsBlock 4 RowMajor
+   OpMemberDecorate %ComponentsBlock 4 Offset 144
+   OpMemberDecorate %ComponentsBlock 4 MatrixStride 16
+   OpMemberDecorate %ComponentsBlock 5 ColMajor
+   OpMemberDecorate %ComponentsBlock 5 Offset 192
+   OpMemberDecorate %ComponentsBlock 5 MatrixStride 16
+   OpMemberDecorate %ComponentsBlock 6 ColMajor
+   OpMemberDecorate %ComponentsBlock 6 Offset 240
+   OpMemberDecorate %ComponentsBlock 6 MatrixStride 16
+   OpMemberDecorate %ComponentsBlock 7 ColMajor
+   OpMemberDecorate %ComponentsBlock 7 Offset 304
+   OpMemberDecorate %ComponentsBlock 7 MatrixStride 16
+   OpMemberDecorate %ComponentsBlock 8 ColMajor
+   OpMemberDecorate %ComponentsBlock 8 Offset 368
+   OpMemberDecorate %ComponentsBlock 8 MatrixStride 16
+   OpDecorate %ComponentsBlock Block
+   OpDecorate %_ DescriptorSet 0
+   OpDecorate %_ Binding 5
+   OpDecorate %outColor Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+   %bool = OpTypeBool
+%_ptr_Function_bool = OpTypePointer Function %bool
+   %true = OpConstantTrue %bool
+  %float = OpTypeFloat 32
+%v2float = OpTypeVector %float 2
+%mat2v2float = OpTypeMatrix %v2float 2
+%v3float = OpTypeVector %float 3
+%mat2v3float = OpTypeMatrix %v3float 2
+%v4float = OpTypeVector %float 4
+%mat2v4float = OpTypeMatrix %v4float 2
+%mat3v2float = OpTypeMatrix %v2float 3
+%mat3v3float = OpTypeMatrix %v3float 3
+%mat3v4float = OpTypeMatrix %v4float 3
+%mat4v2float = OpTypeMatrix %v2float 4
+%mat4v3float = OpTypeMatrix %v3float 4
+%mat4v4float = OpTypeMatrix %v4float 4
+%ComponentsBlock = OpTypeStruct %mat2v2float %mat2v3float %mat2v4float 
%mat3v2float %mat3v3float %mat3v4float %mat4v2float %mat4v3float %mat4v4float
+%_ptr_Uniform_ComponentsBlock = OpTypePointer Uniform %ComponentsBlock
+  %_ = OpVariable %_ptr_Uniform_ComponentsBlock Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+%float_n29816_0098 = OpConstant %float -29816.0098
+%float_4996_51611 = OpConstant %float 4996.51611
+ %33 = OpConstantComposite %v2float %float_n29816_0098 
%float_4996_51611
+ %v2bool = OpTypeVector %bool 2
+  %int_1 = OpConstant %int 1
+%float_22829_4688 = OpConstant %float 22829.4688
+%float_n30383_2031 = OpConstant %float -30383.2031
+ %45 = OpConstantComposite %v2float %float_22829_4688 
%float_n30383_2031
+  %false = OpConstantFalse %bool
+%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
+%float_5720_54443 = OpConstant %float 5720.54443
+%float_n21857_1582 = OpConstant %float -21857.1582
+%float_n711_078674 = 

[Piglit] [PATCH v2 01/17] shader_runner/spirv: log skip reason on ARB_gl_spirv extension check

2018-09-27 Thread Alejandro Piñeiro
---
 tests/shaders/shader_runner.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 6df8bd860..e5566ee7d 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -814,6 +814,8 @@ static enum piglit_result
 assemble_spirv(GLenum target)
 {
if (!piglit_is_extension_supported("GL_ARB_gl_spirv")) {
+   printf("GL_ARB_gl_spirv not supported, but required "
+   "to run SPIR-V shaders\n");
return PIGLIT_SKIP;
}
 
-- 
2.14.1

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


[Piglit] [PATCH v2] shader_runner: add force_no_names mode

2018-09-21 Thread Alejandro Piñeiro
Right now UBO data filling is based on using the name of the ubo and
their components, in order to get the block and uniform index. It also
uses it to set the binding (so it forces block_index and block_binding
to be equal).

Since ARB_shading_language_420pack it is possible to set a explicit
ubo binding, so it would be interesting to try to use it directly
without such re-binding, and gather the info without using the names
at all.

We extend this idea to the already existing program interface query
support, so we can do a subset of the queries using only the explicit
binding.

This will be specially interesting for ARB_gl_spirv testing, where
SPIR-V shaders should work without names, and explicit binding is not
just optional but mandatory. For that reason, if running using SPIR-V
instead of GLSL, we use this mode automatically, as it would fail
otherwise. Another alternative is not set a different mode, but
working this way when we are using SPIR-V shaders. But as mentioned,
there would be GLSL cases where this would be interesting.

In order this to work on all cases, we need to also explicitly set
other info when filling the data:
  * offsets for each individual component
  * matrix stride
  * row major

Using the same approach used to fill the array index info. Note that
for arrays we are not adding array stride, as this can be done by
using the explicit offset. This allow us to not add another variable.

We extended this idea for SSBO, so we gather the info in a generic
"block_info" struct. Although this is not needed for ssbo data
filling, as it already uses the explicit binding, it became useful to
keep using program interface queries.

It is worth to note that some of the queries already supported by
shader_runner will not be supported on this mode, as they are based on
the names.

v2: improve legibility by avoiding so many indentation changes (Ian)
---

In order to avoid the indentation changes, I removed the previous
code, and moved to a new two functions. Those two functions are the
ones that checks if we are running in normal or force_no_names
mode. This also helps with avoid a too big indentation. I hope this
helps the legibility of the patch.


 tests/shaders/shader_runner.c | 381 --
 1 file changed, 289 insertions(+), 92 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index b19ac2f6d..e359f97ad 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -93,6 +93,14 @@ struct component_version {
char _string[100];
 };
 
+struct block_info {
+   int array_index;
+   int binding;
+   int offset;
+   int matrix_stride;
+   int row_major; /* int as we don't have a parse_bool */
+};
+
 #define ENUM_STRING(e) { #e, e }
 
 extern float piglit_tolerance[4];
@@ -126,6 +134,7 @@ static GLuint compute_shaders[256];
 static unsigned num_compute_shaders = 0;
 static int num_uniform_blocks;
 static GLuint *uniform_block_bos;
+static int *uniform_block_indexes; /* ubo block index, indexed by ubo binding 
*/
 static GLenum geometry_layout_input_type = GL_TRIANGLES;
 static GLenum geometry_layout_output_type = GL_TRIANGLE_STRIP;
 static GLint geometry_layout_vertices_out = 0;
@@ -155,6 +164,7 @@ static bool sso_in_use = false;
 static bool glsl_in_use = false;
 static bool force_glsl = false;
 static bool spirv_in_use = false;
+static bool force_no_names = false;
 static GLchar *prog_err_info = NULL;
 static GLuint vao = 0;
 static GLuint draw_fbo, read_fbo;
@@ -1204,6 +1214,9 @@ process_requirement(const char *line)
printf("Unknown SPIRV line in [require]\n");
return PIGLIT_FAIL;
}
+
+   if (spirv_replaces_glsl)
+   force_no_names = true;
}
return PIGLIT_PASS;
 }
@@ -1245,6 +1258,10 @@ leave_state(enum states state, const char *line, const 
char *script_name)
if (spirv_replaces_glsl) {
printf("Running on SPIR-V mode\n");
}
+   if (force_no_names && !spirv_replaces_glsl) {
+   printf("Running on GLSL mode, forcing not using "
+   "uniform/uniform block names\n");
+   }
break;
 
case vertex_shader:
@@ -2036,17 +2053,28 @@ check_texture_handle_support(void)
piglit_report_result(PIGLIT_SKIP);
 }
 
+static bool
+get_indexes_and_offset_from_ubo(char *name, struct block_info block_data,
+   GLuint *uniform_index_out,
+   GLint *block_index_out,
+   GLint *offset_out);
+
 /**
  * Handles uploads of UBO uniforms by mapping the buffer and storing
  * the data.  If the uniform is not in a uniform block, returns false.
  */
 static bool
-set_ubo_uniform(char *name, const char *type, const char *line, int 
ubo_array_index)

Re: [Piglit] [PATCH 12/17] arb_gl_spirv: add ubo array test with different array_stride

2018-09-21 Thread Alejandro Piñeiro
On 21/09/18 00:13, Timothy Arceri wrote:
> On 16/9/18 2:22 am, Alejandro Piñeiro wrote:
>> For more info, see the long explanation at the commit "arb_gl_spirv:
>> add ubo matrix test with different matrix_stride"
>> ---
>>   .../array-different-array-stride-ubo.shader_test   | 147
>> +
>>   1 file changed, 147 insertions(+)
>>   create mode 100644
>> tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
>>
>> diff --git
>> a/tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
>> b/tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
>>
>> new file mode 100644
>> index 0..0638864b2
>> --- /dev/null
>> +++
>> b/tests/spec/arb_gl_spirv/execution/ubo/array-different-array-stride-ubo.shader_test
>> @@ -0,0 +1,147 @@
>> +# UBO test using two ubos, with an array with the same size and type,
>> +# but setting a different array stride for each one. Used to test that
>> +# the size is properly computed, and the content properly accessed in
>> +# both cases.
>> +
>> +[require]
>> +SPIRV ONLY
>> +GL >= 3.3
>> +GLSL >= 3.30
>> +
>> +[vertex shader passthrough]
>> +
>> +[fragment shader spirv]
>> +; Automatically generated from the GLSL by shader_test_spirv.py, and
>> then edited by hand to set the proper array stride
>> +; SPIR-V
>> +; Version: 1.0
>> +; Generator: Khronos Glslang Reference Front End; 7
>> +; Bound: 47
>> +; Schema: 0
>> +   OpCapability Shader
>> +  %1 = OpExtInstImport "GLSL.std.450"
>> +   OpMemoryModel Logical GLSL450
>> +   OpEntryPoint Fragment %main "main" %color
>> +   OpExecutionMode %main OriginLowerLeft
>> +   OpSource GLSL 450
>> +   OpName %_ ""
>> +   OpName %__0 ""
>> +   OpDecorate %color Location 0
>> +   OpDecorate %_arr_v4float_uint_3 ArrayStride 16
>> +   OpMemberDecorate %block16 0 Offset 0
>> +   OpDecorate %block16 Block
>> +   OpDecorate %_ DescriptorSet 0
>> +   OpDecorate %_ Binding 5
>> +   OpDecorate %_arr_v4float_uint_3_0 ArrayStride 32
>> +   OpMemberDecorate %block32 0 Offset 0
>> +   OpDecorate %block32 Block
>> +   OpDecorate %__0 DescriptorSet 0
>> +   OpDecorate %__0 Binding 6
>> +   %void = OpTypeVoid
>> +  %3 = OpTypeFunction %void
>> +  %float = OpTypeFloat 32
>> +    %v4float = OpTypeVector %float 4
>> +%_ptr_Output_v4float = OpTypePointer Output %v4float
>> +  %color = OpVariable %_ptr_Output_v4float Output
>> +   %uint = OpTypeInt 32 0
>> + %uint_3 = OpConstant %uint 3
>> +%_arr_v4float_uint_3 = OpTypeArray %v4float %uint_3
>> +    %block16 = OpTypeStruct %_arr_v4float_uint_3
>> +%_ptr_Uniform_block16 = OpTypePointer Uniform %block16
>> +  %_ = OpVariable %_ptr_Uniform_block16 Uniform
>> +    %int = OpTypeInt 32 1
>> +  %int_0 = OpConstant %int 0
>> +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
>> +  %int_1 = OpConstant %int 1
>> +  %int_2 = OpConstant %int 2
>> +%_arr_v4float_uint_3_0 = OpTypeArray %v4float %uint_3
>> +    %block32 = OpTypeStruct %_arr_v4float_uint_3_0
>> +%_ptr_Uniform_block32 = OpTypePointer Uniform %block32
>> +    %__0 = OpVariable %_ptr_Uniform_block32 Uniform
>> +    %float_0 = OpConstant %float 0
>> +    %float_1 = OpConstant %float 1
>> + %44 = OpConstantComposite %v4float %float_0 %float_1
>> %float_0 %float_0
>> +   %main = OpFunction %void None %3
>> +  %5 = OpLabel
>> + %19 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_0
>> + %20 = OpLoad %v4float %19
>> + %22 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_1
>> + %23 = OpLoad %v4float %22
>> + %24 = OpFAdd %v4float %20 %23
>> + %26 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %int_2
>> + %27 = OpLoad %v4float %26
>> + %28 = OpFAdd %v4float %24 %27
>> + %33 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %int_0
>> + %34 = OpLoad %v4float %33
>> + %35 = OpFSub %v4float %28 %34
>> + %36 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %int_1
>> + %37 = OpLoad %v4float %36
>> + %38 = OpFSub

Re: [Piglit] [PATCH 03/17] shader_runner: add forcing_no_names mode

2018-09-20 Thread Alejandro Piñeiro
On 20/09/18 17:02, Ian Romanick wrote:
> On 09/15/2018 09:22 AM, Alejandro Piñeiro wrote:
>> Right now UBO data filling is based on using the name of the ubo and
>> their components, in order to get the block and uniform index. It also
>> uses it to set the binding (so it forces block_index and block_binding
>> to be equal).
>>
>> Since ARB_shading_language_420pack it is possible to set a explicit
>> ubo binding, so it would be interesting to try to use it directly
>> without such re-binding, and gather the info without using the names
>> at all.
>>
>> We extend this idea to the already existing program interface query
>> support, so we can do a subset of the queries using only the explicit
>> binding.
>>
>> This will be specially interesting for ARB_gl_spirv testing, where
>> SPIR-V shaders should work without names, and explicit binding is not
>> just optional but mandatory. For that reason, if running using SPIR-V
>> instead of GLSL, we use this mode automatically, as it would fail
>> otherwise. Another alternative is not set a different mode, but
>> working this way when we are using SPIR-V shaders. But as mentioned,
>> there would be GLSL cases where this would be interesting.
>>
>> In order this to work on all cases, we need to also explicitly set
>> other info when filling the data:
>>   * offsets for each individual component
>>   * matrix stride
>>   * row major
> These values can vary on each matrix in the block.  

Yes, it is expected to specify a matrix stride for each one (although
technically, taking how shader runner works when parsing the file, after
setting one, it is only needed to re-specify it if the matrix stride
changes).

Having said so, the script we use to process the shader_test before
calling glslangValidator already parses the SPIR-V shader, so those
offsets, matrix stride and row major are added on the shader_test
automatically when the SPIR-V shader is integrated on the test. I guess
that we could try to get this done is a somewhat more transparent way,
like moving that parsing from the script to shader_runner, but
shader_runner is already doing a look of work right now.

> It's not clear to me
> why this is necessary.  The idea is an application SPIR-V shader will
> "know" where various values are located in the UBOs and SSBOs used by
> the shader, and that data will be filled by poking values into the right
> locations.  Why wouldn't we set the values in the buffers bound to the
> UBO or SSBO based on the offset?

FWIW, that is basically why we don't require an array_stride.

>   Or am I not really understanding
> what's happening here?  

As far as I remember the reason we still ask the test to include the
matrix stride/row major is how we are filling the matrix data at
set_ubo_uniform (shader_runner.c, line 2134 at current master). That
code gets the data included on the shader_test and reorganize it to be
passed to the ubo/ssbo bound. Right now shader_runner is asking OpenGL
for the matrix_stride/row_major on GLSL, and this patch or using the
explicit values for SPIR-V. Right now I don't see how that data filling
would be done with just the offset. Yes, we would be able to poke the
values into the right position, but we would only have where the matrix
should start, but not if there is any padding on the data for using a
specific matrix_stride (unless I'm the one not understanding something).

> Due to all the indentation changes, this patch
> is really hard to read. :(

Sorry for that. shader_runner is already mixing tabs and spaces, so
getting a coherent patch is complex. Will do a new run, trying to make
it more legible.

>
>> Using the same approach used to fill the array index info. Note that
>> for arrays we are not adding array stride, as this can be done by
>> using the explicit offset. This allow us to not add another variable.
>>
>> We extended this idea for SSBO, so we gather the info in a generic
>> "block_info" struct. Although this is not needed for ssbo data
>> filling, as it already uses the explicit binding, it became useful to
>> keep using program interface queries.
>>
>> It is worth to note that some of the queries already supported by
>> shader_runner will not be supported on this mode, as they are based on
>> the names.
>> ---
>>  tests/shaders/shader_runner.c | 244 
>> --
>>  1 file changed, 188 insertions(+), 56 deletions(-)
>>
>> diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
>> index 8acb76317..6d53414d0 100644
>> --- a/tests/shaders/shader_runner.c
>> +++ b/tests/shaders/shader_runner.c
>> @@ -92,6 +92,14 @@ struct component_vers

  1   2   3   4   5   >