[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)
+set_ubo_u

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 %v4f

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 +

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

2018-09-15 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.
---
 .../ssbo/two-ssbo-different-layouts.shader_test| 374 +
 1 file changed, 374 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..2c06d0f1c
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/ssbo/two-ssbo-different-layouts.shader_test
@@ -0,0 +1,374 @@
+# 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" %outColor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   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
+   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
+   %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_arr_v2float_uint_3 = OpTypeArray %v2float %uint_3
+%mat2v2float = OpTypeMatrix %v2float 2
+%v4float = OpTypeVector %float 4
+  %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
+ %27 = 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
+  %false = OpConstantFalse %bool
+  %int_1 = OpConstant %int 1
+%float_n711_078674 = OpConstant %float -711.078674
+%float_8904_7334 = OpConstant %float 8904.7334
+ %53 = 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
+ %73 = OpConstantComposite %v2float %float_3164_0835 %float_20808_1934
+%float_16690_9727 = OpConstant %float 16690.9727
+%float_9081_78711 = OpConstant %float 9081.78711
+ %92 = OpConstantComposite %v2float %float_16690_9727 %float_9081_78711
+%float_n12496_1973 = OpConstant %float -12496.1973
+%float_n5854_81055 = OpConstant %float -5854.81055
+%111 = OpConstantComposite %v2float %float_n12496_1973 
%float_n5854_81055
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+%float_n30557_1582 = 

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

2018-09-15 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 15/17] arb_gl_spirv: adding complex ssbo matrix test

2018-09-15 Thread Alejandro Piñeiro
---
 .../execution/ssbo/matrix/complex.shader_test  | 699 +
 1 file changed, 699 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..95b6d6eb8
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ssbo/matrix/complex.shader_test
@@ -0,0 +1,699 @@
+# 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: 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 %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
+   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
+   %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
+ %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 = OpConstant %float -711.078674
+ %58 = OpConstantComposite %v3float %float_5720_54443 
%float_n21857_1582 %float_n711_078674
+ %v3bool = OpTypeVector %bool 3
+%float_8904_7334 = OpConstant %float 8904.7334
+%float_3164_0835 = OpConstant %float 3164.0835
+%float_20808_1934 = OpConstant %float 20808.1934
+ %70 = OpConstantComposite %v3float %float_8904_7334 %float_3164_0835 
%float_20808_1934
+  %int_2 = OpConstant %int 2

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

2018-09-15 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"
---
 .../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 %v4float %35 %37
+ %39 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %int_2
+ %40 = OpLoad %v4float %39
+ %41 = OpFSub %v4float %38 %40
+   OpStore %color %41
+ %45 = OpLoad %v4float %color
+ %46 = OpFAdd %v4float %45 %44
+   OpStore %color %46
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 0) out vec4 color;
+
+layout (std140, binding = 5) uniform block16 {
+   vec4 arr16[3];
+};
+
+/*
+ * This array will have a array_stride of 32.
+ *
+ * Note that there is no way to set a explicit array_stride on GLSL. This GLSL
+ * was used initially to generate the SPIRV-V, and then array stride was 
tweaked.
+ * That's the reason this is a SPIRV ONLY test. GLSL here is just as reference.
+ */
+layout (std140, binding = 6) uniform block32 {
+   vec4 arr32[3];
+};
+
+
+void main()
+{
+   color = arr16[0] + arr16[1] + arr16[2] - arr32[0] - arr32[1] - arr32[2];
+   color += vec4(0.0, 1.0, 0.0, 

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

2018-09-15 Thread Alejandro Piñeiro
---
 .../execution/ssbo/matrix/column-major.shader_test | 109 
 .../ssbo/matrix/column-vs-row.shader_test  | 196 +
 .../ssbo/matrix/indirect-column-major.shader_test  | 131 ++
 .../ssbo/matrix/indirect-row-major.shader_test | 131 ++
 .../execution/ssbo/matrix/row-major.shader_test| 109 
 5 files changed, 676 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..737c8ab05
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ssbo/matrix/column-major.shader_test
@@ -0,0 +1,109 @@
+# 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: 32
+; 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 %ssbo 0 ColMajor
+   OpMemberDecorate %ssbo 0 Offset 0
+   OpMemberDecorate %ssbo 0 MatrixStride 16
+   OpDecorate %ssbo BufferBlock
+   OpDecorate %components DescriptorSet 0
+   OpDecorate %components Binding 5
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outColor = OpVariable %_ptr_Output_v4float Output
+%mat4v4float = OpTypeMatrix %v4float 4
+   %ssbo = OpTypeStruct %mat4v4float
+%_ptr_Uniform_ssbo = OpTypePointer Uniform %ssbo
+ %components = OpVariable %_ptr_Uniform_ssbo Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+  %int_3 = OpConstant %int 3
+   %uint = OpTypeInt 32 0
+ %uint_0 = OpConstant %uint 0
+%_ptr_Uniform_float = OpTypePointer Uniform %float
+ %uint_1 = OpConstant %uint 1
+ %uint_2 = OpConstant %uint 2
+ %uint_3 = OpConstant %uint 3
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %20 = OpAccessChain %_ptr_Uniform_float %components %int_0 %int_3 
%uint_0
+ %21 = OpLoad %float %20
+ %23 = OpAccessChain %_ptr_Uniform_float %components %int_0 %int_3 
%uint_1
+ %24 = OpLoad %float %23
+ %26 = OpAccessChain %_ptr_Uniform_float %components %int_0 %int_3 
%uint_2
+ %27 = OpLoad %float %26
+ %29 = OpAccessChain %_ptr_Uniform_float %components %int_0 %int_3 
%uint_3
+ %30 = OpLoad %float %29
+ %31 = OpCompositeConstruct %v4float %21 %24 %27 %30
+   OpStore %outColor %31
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+
+#version 450
+
+layout (location = 0) out vec4 outColor;
+layout (std430, binding = 5, column_major) buffer ssbo
+ {
+mat4 matrix;
+ } components;
+
+void main()
+{
+   outColor = vec4(components.matrix[3][0], components.matrix[3][1], 
components.matrix[3][2], components.matrix[3][3]);
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+ssbo 5 64
+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 5 subdata float 16 0.21
+ssbo 5 subdata float 20 0.22
+ssbo 5 subdata float 24 0.23
+ssbo 5 subdata float 28 0.24
+ssbo 5 subdata float 32 0.31
+ssbo 5 subdata float 36 0.32
+ssbo 5 subdata float 40 0.33
+ssbo 5 subdata float 44 0.34
+ssbo 5 subdata float 48 0.41
+ssbo 5 subdata float 52 0.42
+ssbo 5 subdata float 56 0.43
+ssbo 5 subdata float 60 0.44
+
+block binding 5
+verify program_interface_query GL_SHADER_STORAGE_BLOCK ssbo 
GL_NUM_ACTIVE_VARIABLES 1
+verify program_interface_query GL_SHADER_STORAGE_BLOCK ssbo 
GL_BUFFER_DATA_SIZE 64
+
+verify program_query GL_ACTIVE_UNIFORMS 0
+
+draw rect -1 -1 2 2
+probe all rgba 0.41 0.42 0.43 0.44
diff --git 
a/tests/spec/arb_gl_spirv/execution/ssbo/matrix/column-vs-row.shader_test 
b/tests/spec/arb_gl_spirv/execution/ssbo/matrix/column-vs-row.shader_test
new file mode 100644
index 0..3a391d860
--- /dev/nul

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

2018-09-15 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.
---
 .../ubo/matrix/different-matrix-stride.shader_test | 155 +
 1 file changed, 155 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..6bc08c519
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/ubo/matrix/different-matrix-stride.shader_test
@@ -0,0 +1,155 @@
+# 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: 57
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %outColor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %_ ""
+   OpName %__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
+   OpDecorate %outColor Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v2float = OpTypeVector %float 2
+%mat3v2float = OpTypeMatrix %v2float 3
+%_ptr_Function_mat3v2float = OpTypePointer Function %mat3v2float
+%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_mat3v2float = OpTypePointer Uniform %mat3v2float
+%Block32 = OpTypeStruct %mat3v2float
+%_ptr_Uniform_Block32 = OpTypePointer Uniform %Block32
+%__0 = OpVariable %_ptr_Uniform_Block32 Uniform
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outColor = OpVariable %_ptr_Output_v4float Output
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+  %int_1 = OpConstant %int 1
+  %int_2 = OpConstant %int 2
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %54 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_0
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %difference = OpVariable %_ptr_Function_mat3v2float Function
+ %17 = OpAccessChain %_ptr_Uniform_mat3v2float %_ %int_0
+ %18 = OpLoad %mat3v2float %17
+ %22 = OpAccessChain %_ptr_Uniform_mat3v2float %__0 %int_0
+ %23 = OpLoad %mat3v2float %22
+ %24 = OpCompositeExtract %v2float %18 0
+ %25 = OpCompositeExtract %v2float %23 0
+ %26 = OpFSub %v2float %24 %25
+ %27 = OpCompositeExtract %v2float %18 1
+ %28 = OpCompositeExtract %v2float %23 1
+ %29 = OpFSub %v2float %27 %28
+ %30 = OpCompositeExtract %v2float %18 2
+ %31 = OpCompositeExtract %v2float %23 2
+ %32 = OpFSub %v2float %30 %31
+ %33 = OpCompositeConstruct %mat3v2float %26 %29 %32
+   OpStore %difference %33
+ %38 = OpAccessChain %_ptr_Function_v2float %difference %int_0
+ %39 = OpLoad %v2float %38
+ %41 = OpAccessChain %_ptr_Function_v2float %difference %int_1
+

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

2018-09-15 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 13/17] arb_gl_spirv: add some simple ssbo tests

2018-09-15 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.
---
 .../execution/ssbo/array-indirect.shader_test  | 121 
 .../execution/ssbo/array-inside-ssbo.shader_test   | 104 ++
 .../ssbo/array-of-arrays-inside-ssbo.shader_test   | 210 +
 .../arb_gl_spirv/execution/ssbo/array.shader_test  | 111 +++
 .../arb_gl_spirv/execution/ssbo/simple.shader_test |  97 ++
 .../execution/ssbo/two-ssbo.shader_test| 106 +++
 .../execution/ssbo/two-stages.shader_test  | 196 +++
 7 files changed, 945 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..616f1a2ac
--- /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" %outColor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %outColor 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
+   %outColor = 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 %outColor %23
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+
+#version 450
+
+layout (location = 0) out vec4 outColor;
+layout (location = 10) uniform int u_idx;
+
+layout (std430, binding = 5) buffer ssbo
+ {
+vec4 c1;
+ } components[3];
+
+void main()
+{
+   outColor = 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 ssbo[0] 
GL_NUM_ACTIVE_VARIABLES 1
+verify program_interface_query GL_SHADER_STORAGE_BLOCK ssb

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

2018-09-15 Thread Alejandro Piñeiro
Specifically the ubo contains some basic types and a struct type.
---
 .../execution/ubo/array-complex.shader_test| 183 +
 1 file changed, 183 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..be76f8722
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/array-complex.shader_test
@@ -0,0 +1,183 @@
+# UBO test using an array of ubos, with a 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: 77
+; 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 %S 0 Offset 0
+   OpMemberDecorate %S 1 Offset 16
+   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 %normal_array Location 3
+   OpDecorate %normal_array DescriptorSet 0
+   OpDecorate %normal_array 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
+%v2float = OpTypeVector %float 2
+%v3float = OpTypeVector %float 3
+  %S = OpTypeStruct %v3float %v4float
+%ComponentsBlock = OpTypeStruct %float %v2float %S
+   %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
+  %int_0 = OpConstant %int 0
+%_ptr_Uniform_float = OpTypePointer Uniform %float
+  %int_1 = OpConstant %int 1
+%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
+%float_0 = OpConstant %float 0
+  %int_2 = OpConstant %int 2
+%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
+%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
+ %uint_5 = OpConstant %uint 5
+%_arr_v4float_uint_5 = OpTypeArray %v4float %uint_5
+%_ptr_UniformConstant__arr_v4float_uint_5 = OpTypePointer UniformConstant 
%_arr_v4float_uint_5
+%normal_array = OpVariable %_ptr_UniformConstant__arr_v4float_uint_5 
UniformConstant
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %22 = OpAccessChain %_ptr_Uniform_float %components %int_0 %int_0
+ %23 = OpLoad %float %22
+ %24 = OpCompositeConstruct %v4float %23 %23 %23 %23
+ %27 = OpAccessChain %_ptr_Uniform_v2float %components %int_0 %int_1
+ %28 = OpLoad %v2float %27
+ %30 = OpCompositeExtract %float %28 0
+ %31 = OpCompositeExtract %float %28 1
+ %32 = OpCompositeConstruct %v4float %30 %31 %float_0 %float_0
+ %33 = OpFAdd %v4float %24 %32
+ %36 = OpAccessChain %_ptr_Uniform_v3float %components %int_0 %int_2 
%int_0
+ %37 = OpLoad %v3float %36
+ %38 = OpCompositeExtract %float %37 0
+ %39 = OpCompositeExtract %float %37 1
+ %40 = OpCompositeExtract %float %37 2
+ %41 = OpCompositeConstruct %v4float %38 %39 %40 %float_0
+ %42 = OpFAdd %v4float %33 %41
+ %44 = OpAccessChain %_ptr_Uniform_v4float %components %int_0 %int_2 
%int_1
+ %45 = OpLoad %v4float %44
+ %46 = OpFAdd %v4float %42 %45
+   OpStore %outColor %46
+ %47 = OpAccessChain %_ptr_Uniform_float %components %int_1 %int_0
+ %48 = OpLoad %float %47
+ %49 = OpCompositeConstruct %v4float %48 %48 %48 %48
+ %50 = OpAccessChain %_ptr_Uniform_v2float %components %int_1 %int_1
+ %51 = OpLoad %v2float %50
+ %52 = OpCompositeExtract %float %51 0
+ %53 = OpCompositeExtract %float %51 1
+ %54 = OpCompositeConstruct %v4float %52 %53 %float_0 %float_0
+ %55 = OpFAdd %v4float %49 %54
+ %56 = OpAccessChain %_ptr_Uniform_v3float %components

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

2018-09-15 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 = OpC

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

2018-09-15 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 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-

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

2018-09-15 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.
---
 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_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];
@@ -125,6 +133,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 glsl_in_use = false;
 static bool force_glsl = false;
 static bool spirv_in_use = false;
 static bool spirv_replaces_glsl = 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:
@@ -2041,8 +2058,14 @@ check_texture_handle_support(void)
  * 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 that with force_no_names on
+* GLSL
+*/
GLuint uniform_index;
GLint block_index;
GLint offset;
@@ -2080,34 +2103,69 @@ set_ubo_uniform(char *name, const char *type, const 
char *line, int ubo_array_in
 
}
 
+   if (!force_no_names) {
+   glGetUniformIndices(prog, 1, (const char **)&name, 
&uniform_index);
+   if (uniform_index == GL_INVALID_INDEX) {
+   printf("cannot get index of uniform \"%s\"\n", name);
+  

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

2018-09-15 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 6d53414d0..8b833eb17 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -2757,6 +2757,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,
+  &pname, &line),
+   "Bad glGetProgram pname at: %s\n", line);
+
+   REQUIRE(parse_enum_tab(all_possible_param_enums, line, (unsigned 
*)&expected, &line) ||
+   parse_int(line, &expected, &line),
+   "Bad expected value at: %s\n", line);
+
+   glGetProgramiv(prog, pname, &value);
+
+   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
  *
@@ -4542,6 +4618,8 @@ piglit_display(void)
parse_ints(rest, &block_data.row_major, 1, NULL);
} else if (parse_str(line, "active uniform ", &rest)) {
active_uniform(rest);
+   } else if (parse_str(line, "verify program_query", &rest)) {
+verify_program_query(rest);
} else if (parse_str(line, "verify program_interface_query ", 
&rest)) {
active_program_interface(rest, block_data);
} else if (parse_str(line, "vertex attrib ", &rest)) {
-- 
2.14.1

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


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

2018-09-15 Thread Alejandro Piñeiro
---
 .../execution/ubo/matrix/column-major.shader_test  |  96 +++
 .../execution/ubo/matrix/column-vs-row.shader_test | 176 +
 .../ubo/matrix/indirect-column-major.shader_test   | 119 ++
 .../ubo/matrix/indirect-row-major.shader_test  | 119 ++
 .../execution/ubo/matrix/row-major.shader_test |  96 +++
 5 files changed, 606 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..5928bd2ec
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/matrix/column-major.shader_test
@@ -0,0 +1,96 @@
+# 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: 32
+; 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 ColMajor
+   OpMemberDecorate %ComponentsBlock 0 Offset 0
+   OpMemberDecorate %ComponentsBlock 0 MatrixStride 16
+   OpDecorate %ComponentsBlock Block
+   OpDecorate %components DescriptorSet 0
+   OpDecorate %components Binding 5
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outColor = OpVariable %_ptr_Output_v4float Output
+%mat4v4float = OpTypeMatrix %v4float 4
+%ComponentsBlock = OpTypeStruct %mat4v4float
+%_ptr_Uniform_ComponentsBlock = OpTypePointer Uniform %ComponentsBlock
+ %components = OpVariable %_ptr_Uniform_ComponentsBlock Uniform
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+  %int_3 = OpConstant %int 3
+   %uint = OpTypeInt 32 0
+ %uint_0 = OpConstant %uint 0
+%_ptr_Uniform_float = OpTypePointer Uniform %float
+ %uint_1 = OpConstant %uint 1
+ %uint_2 = OpConstant %uint 2
+ %uint_3 = OpConstant %uint 3
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %20 = OpAccessChain %_ptr_Uniform_float %components %int_0 %int_3 
%uint_0
+ %21 = OpLoad %float %20
+ %23 = OpAccessChain %_ptr_Uniform_float %components %int_0 %int_3 
%uint_1
+ %24 = OpLoad %float %23
+ %26 = OpAccessChain %_ptr_Uniform_float %components %int_0 %int_3 
%uint_2
+ %27 = OpLoad %float %26
+ %29 = OpAccessChain %_ptr_Uniform_float %components %int_0 %int_3 
%uint_3
+ %30 = OpLoad %float %29
+ %31 = OpCompositeConstruct %v4float %21 %24 %27 %30
+   OpStore %outColor %31
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+
+#version 450
+
+layout (location = 0) out vec4 outColor;
+layout (std140, binding = 5, column_major) uniform ComponentsBlock
+ {
+mat4 matrix;
+ } components;
+
+void main()
+{
+   outColor = vec4(components.matrix[3][0], components.matrix[3][1], 
components.matrix[3][2], components.matrix[3][3]);
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+block binding 5
+block offset 0
+block matrix stride 16
+block row major 0
+uniform mat4 ComponentsBlock.matrix 0.11 0.12 0.13 0.14 0.21 0.22 0.23 0.24 
0.31 0.32 0.33 0.34 0.41 0.42 0.43 0.44
+
+verify program_interface_query GL_UNIFORM_BLOCK ComponentsBlock 
GL_NUM_ACTIVE_VARIABLES 1
+verify program_interface_query GL_UNIFORM_BLOCK ComponentsBlock 
GL_BUFFER_DATA_SIZE 64
+
+verify program_query GL_ACTIVE_UNIFORMS 1
+
+draw rect -1 -1 2 2
+probe all rgba 0.41 0.42 0.43 0.44
diff --git 
a/tests/spec/arb_gl_spirv/execution/ubo/matrix/column-vs-row.shader_test 
b/tests/spec/arb_gl_spirv/execution/ubo/matrix/column-vs-row.shader_test
new file mode 100644
index 0..338221b48
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/ubo/matrix/column-vs-row.shader_test
@@ -0,0 +1,176 @@
+# UBO test comparing a matrix using row_major layout and another using
+# column_major layout, when the data used for both is the same

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

2018-09-15 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.
---
 .../execution/ubo/array-indirect.shader_test   | 108 
 .../execution/ubo/array-inside-ubo.shader_test |  94 ++
 .../ubo/array-of-arrays-inside-ubo.shader_test | 184 
 .../arb_gl_spirv/execution/ubo/array.shader_test   |  96 +++
 .../execution/ubo/location-0-crash.shader_test |  93 ++
 .../arb_gl_spirv/execution/ubo/simple.shader_test  |  92 ++
 .../execution/ubo/two-stages.shader_test   | 191 +
 .../execution/ubo/two-ubos.shader_test |  98 +++
 .../linker/ubo/two-stages-wrong1.shader_test   | 190 
 .../linker/ubo/two-stages-wrong2.shader_test   | 185 
 10 files changed, 1331 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];
+
+void main()
+{
+   outColor = components[u_idx].c1;
+}
+
+[test]
+clear color 1.0 0.0 

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

2018-09-15 Thread Alejandro Piñeiro
Hi,

a new series with ARB_gl_spirv tests, ubo/ssbo tests this time.

To test them we needed to extend shader runner in order to allow
dealing with ubos and ssbos without using the name of the ubo/ssbo or
their variables. This is needed because ARB_gl_spirv should work
without names available (on SPIR-V names are considered optional debug
info).

Instead of making that just inherent to SPIR-V tests, we added a mode
called force-no-names. This is because testing ubo/ssbos without names
could be interesting on GLSL too, since ARB_shading_language_420pack
added the support to set a explicit binding on the shader itself. In
that sense, without this commit, it is not possible to query that the
explicit binding is the one set when executing the test, as
shader_runner was resetting it.

The tests include some basic smoke-testing ubo/ssbo tests. Tests that
cover several common cases, that should work on any ARB_gl_spirv
implementation. For more detailed testing, it would be needed to use
borrowed testing, or even the random ubo generator script at
generated_tests (that it is not used by default).

The tests also includes some tests that only applies to ARB_gl_spirv
(so marked as SPIRV ONLY). Those tests the ability of setting the
explicit offsets/matrix stride/array stride of values that would not
be the ones that GLSL would provide, but are allowed on the SPIR-V
case.

In total, we are adding 36 new tests with this series.

Finally the first two patches are somewhat unrelated, as they are
patches that just improve the log when a test fail/skips on two
specific cases.

The tree for this series can be found on the following repository:
   https://github.com/Igalia/piglit/tree/arb_gl_spirv-series5-ubo-ssbo-v1

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 forcing_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  | 348 --
 .../execution/ssbo/array-indirect.shader_test  | 121 
 .../execution/ssbo/array-inside-ssbo.shader_test   | 104 +++
 .../ssbo/array-of-arrays-inside-ssbo.shader_test   | 210 +++
 .../arb_gl_spirv/execution/ssbo/array.shader_test  | 111 
 .../execution/ssbo/matrix/column-major.shader_test | 109 
 .../ssbo/matrix/column-vs-row.shader_test  | 196 ++
 .../execution/ssbo/matrix/complex.shader_test  | 699 +
 .../ssbo/matrix/indirect-column-major.shader_test  | 131 
 .../ssbo/matrix/indirect-row-major.shader_test | 131 
 .../execution/ssbo/matrix/row-major.shader_test| 109 
 .../arb_gl_spirv/execution/ssbo/simple.shader_test |  97 +++
 .../ssbo/two-ssbo-different-layouts.shader_test| 374 +++
 .../execution/ssbo/two-ssbo.shader_test| 106 
 .../execution/ssbo/two-stages.shader_test  | 196 ++
 .../execution/ssbo/unsized-array.shader_test   | 119 
 .../execution/ubo/array-complex.shader_test| 183 ++
 .../array-different-array-stride-ubo.shader_test   | 147 +
 .../execution/ubo/array-indirect.shader_test   | 108 
 .../execution/ubo/array-inside-ubo.shader_test |  94 +++
 .../ubo/array-of-arrays-inside-ubo.shader_test | 184 ++
 .../arb_gl_spirv/execution/ubo/array.shader_test   |  96 +++
 .../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  |  96 +++
 .../execution/ubo/matrix/column-vs-row.shader_test | 176 ++
 .../execution/ubo/matrix/complex.shader_test   | 624 ++
 .../ubo/matrix/different-matrix-stride.shader_test | 155 +
 .../ubo/matrix/indirect-column-major.shader_test   | 119 
 .../ubo/matrix/indirect-row-major.shader_test  | 119 
 .../execution/ubo/matrix/row-major.shader_test |  96 +++
 .../arb_gl_spirv/execution/ubo/simple.shader_test  |  92 +++
 .../execution/ubo/two-stages.shader_test   | 191 ++
 .../execution/ubo/two-ubos.shader_test |  98 +++
 .../execution/uniform/array.shader_test

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

2018-09-15 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.
---
 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_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];
@@ -125,6 +133,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 glsl_in_use = false;
 static bool force_glsl = false;
 static bool spirv_in_use = false;
 static bool spirv_replaces_glsl = 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:
@@ -2041,8 +2058,14 @@ check_texture_handle_support(void)
  * 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 that with force_no_names on
+* GLSL
+*/
GLuint uniform_index;
GLint block_index;
GLint offset;
@@ -2080,34 +2103,69 @@ set_ubo_uniform(char *name, const char *type, const 
char *line, int ubo_array_in
 
}
 
+   if (!force_no_names) {
+   glGetUniformIndices(prog, 1, (const char **)&name, 
&uniform_index);
+   if (uniform_index == GL_INVALID_INDEX) {
+   printf("cannot get index of uniform \"%s\"\n", name);
+  

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

2018-09-15 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 1795d66ce..8acb76317 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 01/17] shader_runner/spirv: log skip reason on ARB_gl_spirv extension check

2018-09-15 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 cc377cb5e..1795d66ce 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


Re: [Piglit] [PATCH] shader_runner: Take spirv_replaces_glsl into account for current_config

2018-09-05 Thread Alejandro Piñeiro
On 05/09/18 18:44, Michel Dänzer wrote:
> On 2018-09-05 6:29 p.m., Alejandro Piñeiro wrote:
>> On 04/09/18 17:24, Michel Dänzer wrote:
>>> From: Michel Dänzer 
>>>
>>> Without this, validate_current_gl_context never returns true if
>>> spirv_replaces_glsl == true, resulting in repeatedly calling
>>> recreate_gl_context indefinitely after the first subtest.
>> Hi, could you provide some extra details? From "indefinitely" I'm
>> understanding that shader_runs hangs.
> Right (and after some time crashes on my development machine).
>
>
>> How I can reproduce this bug?
> Either something like
>
>  ./piglit run --process-isolation false gpu
>
> or just manually running multiple SPIR-V tests in a single shader_runner
> invocation, e.g.
>
>  .../piglit/bin/shader_runner 
> .../piglit/tests/spec/arb_gl_spirv/execution/vs-ps-simple.shader_test 
> .../piglit/tests/spec/arb_gl_spirv/execution/vs-ps-specializations.shader_test
>  -auto -report-subtests
>
>
Thanks for the explanation. I was able to test it, and look a little on
it. The patch lgtm:

Reviewed-by: Alejandro Piñeiro 
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] shader_runner: Take spirv_replaces_glsl into account for current_config

2018-09-05 Thread Alejandro Piñeiro
On 04/09/18 17:24, Michel Dänzer wrote:
> From: Michel Dänzer 
>
> Without this, validate_current_gl_context never returns true if
> spirv_replaces_glsl == true, resulting in repeatedly calling
> recreate_gl_context indefinitely after the first subtest.

Hi, could you provide some extra details? From "indefinitely" I'm
understanding that shader_runs hangs. How I can reproduce this bug?
Calling shader_runner for individual tests, or piglit run to run several
tests works for me. Unless you mean that recreate_gl_context is called
too many times, and that this commit just prevents that.

>
> Fixes: 0baf4e2708c "shader_runner/spirv: support loading SPIR-V shaders"
> Signed-off-by: Michel Dänzer 
> ---
>  tests/shaders/shader_runner.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
> index cc377cb5e..6df8bd860 100644
> --- a/tests/shaders/shader_runner.c
> +++ b/tests/shaders/shader_runner.c
> @@ -39,6 +39,7 @@
>  #define DEFAULT_WINDOW_WIDTH 250
>  #define DEFAULT_WINDOW_HEIGHT 250
>  
> +static bool spirv_replaces_glsl = false;
>  static struct piglit_gl_test_config current_config;
>  
>  static void
> @@ -61,7 +62,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
>* [require] section, so it will be handled later.
>*/
>   if (argc > 1) {
> - get_required_config(argv[1], false, &config);
> + get_required_config(argv[1], spirv_replaces_glsl, &config);
>   } else {
>   config.supports_gl_compat_version = 10;
>   }
> @@ -154,7 +155,6 @@ 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 spirv_replaces_glsl = false;
>  static GLchar *prog_err_info = NULL;
>  static GLuint vao = 0;
>  static GLuint draw_fbo, read_fbo;

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


[Piglit] [PATCH] arb_tessellation_shader: add GL_EXT_shader_integer_mix on [require]

2018-08-24 Thread Alejandro Piñeiro
Needed by the tessellation evaluation shader.
---
 .../tes-patch-input-array-vec2-index-invalid-rd.shader_test  | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/tests/spec/arb_tessellation_shader/execution/variable-indexing/tes-patch-input-array-vec2-index-invalid-rd.shader_test
 
b/tests/spec/arb_tessellation_shader/execution/variable-indexing/tes-patch-input-array-vec2-index-invalid-rd.shader_test
index 06c375d40..7bfd87b9b 100644
--- 
a/tests/spec/arb_tessellation_shader/execution/variable-indexing/tes-patch-input-array-vec2-index-invalid-rd.shader_test
+++ 
b/tests/spec/arb_tessellation_shader/execution/variable-indexing/tes-patch-input-array-vec2-index-invalid-rd.shader_test
@@ -1,6 +1,7 @@
 [require]
 GLSL >= 1.50
 GL_ARB_tessellation_shader
+GL_EXT_shader_integer_mix
 
 [vertex shader]
 #version 150
-- 
2.14.1

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


Re: [Piglit] [PATCH piglit] util: stop overallocating shader memory

2018-08-24 Thread Alejandro Piñeiro
Reviewed-by: Alejandro Piñeiro 


On 23/08/18 18:50, Eric Engestrom wrote:
> Fixes: 606e40b2659ad7fc4ae8e "util: Add utilities to handle shader_test files"
> Cc: Alejandro Piñeiro 
> Signed-off-by: Eric Engestrom 
> ---
>  tests/util/piglit-shader-test.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/util/piglit-shader-test.c b/tests/util/piglit-shader-test.c
> index f11ee8ab5383080ae090..1db6aa2eb203a50ca93e 100644
> --- a/tests/util/piglit-shader-test.c
> +++ b/tests/util/piglit-shader-test.c
> @@ -143,7 +143,7 @@ piglit_load_source_from_shader_test(const char *filename,
>   text_size = line - first_line + 1;
>  
>   if (output_source) {
> - *output_source = malloc(sizeof(char*) * text_size);
> + *output_source = malloc(sizeof(char) * text_size);
>   snprintf(*output_source, line - first_line + 1, "%s", 
> first_line);
>   }
>  

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


Re: [Piglit] [PATCH 31/35] arb_gpu_shader5: Add support for testing spirv with XFB streams

2018-08-20 Thread Alejandro Piñeiro
On 20/08/18 04:11, Timothy Arceri wrote:
> On 18/08/18 19:30, Alejandro Piñeiro wrote:
>> On 18/08/18 06:36, Timothy Arceri wrote:
>>> On 18/08/18 14:32, Timothy Arceri wrote:
>>>> Won't this cause shader runner to needlessly parse the .shader_test
>>>> file?
>>
>> True, good point. In any case, as the test lacks a [test] section, full
>> shader.py runs would just check if the test links (assuming that
>> ARB_gl_spirv are available). Having said so ...
>>
>>>
>>> The file extension is also confusing. Maybe we should name these type
>>> of files .shader_source or something similar rather than
>>> .shader_test ???
>>
>> ... this makes sense. That name fits better, and would avoid the
>> previous issue. As that would be a small change, I will make the change
>> locally, while I wait for the review of the other patches.
>
> I've skimmed over most of the series and I didn't see anything other
> than this that I had issue with. It's not very common to get a full
> review for a piglit series. The general rule is once its been on the
> list for a few weeks it's usually ok to push. After all it's better to
> have wrong tests that can be fixed later than to have no tests at all.
>
> I understand the external dependency might have stopped you from just
> pushing but since its an optional dependency it's fine IMO.

Yes, exactly, that was the only reason I didn't push it yet. FWIW, I was
expecting it to be somewhat controversial. But I always tend to be on
the pessimistic/conservative side of things.

>
> Anyway for the series feel free to add:
>
> Acked-by: Timothy Arceri 

Ok, thank you very much.

As the series was around several weeks, I think that I will push it as
it is. If the optional dependency causes some issues, at least pushing
it would get the attention of people.

BR




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


Re: [Piglit] [PATCH 31/35] arb_gpu_shader5: Add support for testing spirv with XFB streams

2018-08-18 Thread Alejandro Piñeiro
On 18/08/18 06:36, Timothy Arceri wrote:
> On 18/08/18 14:32, Timothy Arceri wrote:
>> Won't this cause shader runner to needlessly parse the .shader_test
>> file?

True, good point. In any case, as the test lacks a [test] section, full
shader.py runs would just check if the test links (assuming that
ARB_gl_spirv are available). Having said so ...

>
> The file extension is also confusing. Maybe we should name these type
> of files .shader_source or something similar rather than .shader_test ???

... this makes sense. That name fits better, and would avoid the
previous issue. As that would be a small change, I will make the change
locally, while I wait for the review of the other patches.

Thanks pointing that out

>
>>
>> On 09/08/18 21:36, Alejandro Piñeiro wrote:
>>> From: Neil Roberts 
>>>
>>> v2: use shader_test file with the spirv assembly, instead of include
>>>  two SPIRV binaries (Alejandro Piñeiro)
>>>
>>> Signed-off-by: Neil Roberts 
>>> Signed-off-by: Alejandro Piñeiro 
>>> ---
>>>   tests/opengl.py    |   1 +
>>>   .../xfb_streams_without_invocations.shader_test    | 197
>>> +
>>>   .../execution/xfb-streams-without-invocations.c    | 135
>>> ++
>>>   3 files changed, 300 insertions(+), 33 deletions(-)
>>>   create mode 100644
>>> tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
>>>
>>>
>>> diff --git a/tests/opengl.py b/tests/opengl.py
>>> index 064c43e08..9b1e09564 100644
>>> --- a/tests/opengl.py
>>> +++ b/tests/opengl.py
>>> @@ -1969,6 +1969,7 @@ with profile.test_list.group_manager(
>>>   g(['arb_gpu_shader5-emitstreamvertex_stream_too_large'])
>>>   g(['arb_gpu_shader5-tf-wrong-stream-value'])
>>>   g(['arb_gpu_shader5-xfb-streams-without-invocations'])
>>> +    g(['arb_gpu_shader5-xfb-streams-without-invocations', 'spirv'])
>>>   g(['arb_gpu_shader5-emitstreamvertex_nodraw'])
>>>   g(['arb_gpu_shader5-interpolateAtCentroid'])
>>>   g(['arb_gpu_shader5-interpolateAtCentroid-packing'])
>>> diff --git
>>> a/tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
>>> b/tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
>>>
>>> new file mode 100644
>>> index 0..6611e0bf8
>>> --- /dev/null
>>> +++
>>> b/tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
>>>
>>> @@ -0,0 +1,197 @@
>>> +[require]
>>> +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: 23
>>> +; Schema: 0
>>> +   OpCapability Shader
>>> +  %1 = OpExtInstImport "GLSL.std.450"
>>> +   OpMemoryModel Logical GLSL450
>>> +   OpEntryPoint Vertex %main "main" %_ %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 %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
>>&g

Re: [Piglit] [PATCH] glsl-1.10: add a 'invalid-array-as-function-param' glslparsertest

2018-08-14 Thread Alejandro Piñeiro
Reviewed-by: Alejandro Piñeiro 


On 14/08/18 09:41, Tapani Pälli wrote:
> Signed-off-by: Tapani Pälli 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107550
> ---
>  .../spec/glsl-1.10/compiler/invalid-array-as-function-param.vert | 9 
> +
>  1 file changed, 9 insertions(+)
>  create mode 100644 
> tests/spec/glsl-1.10/compiler/invalid-array-as-function-param.vert
>
> diff --git 
> a/tests/spec/glsl-1.10/compiler/invalid-array-as-function-param.vert 
> b/tests/spec/glsl-1.10/compiler/invalid-array-as-function-param.vert
> new file mode 100644
> index 0..d285680de
> --- /dev/null
> +++ b/tests/spec/glsl-1.10/compiler/invalid-array-as-function-param.vert
> @@ -0,0 +1,9 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.10
> +// [end config]
> +
> +void main()
> +{
> + func(0[2]);
> +}

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


[Piglit] [PATCH 26/35] arb_gl_spirv: add tests for atomic counter operations in FS

2018-08-09 Thread Alejandro Piñeiro
From: Antia Puentes 

Tests the atomic counter operations and layout qualifiers offset and binding
described in the ARB_shader_atomic_counters specification.

They check the final values for the atomic counters and that the values returned
by the atomic counter operations are the expected ones.

Includes 3 tests: atomic_uint, arrays of atomic_uint and AOA of atomic_uints.
---
 .../uniform/atomic-uint-aoa-fs.shader_test | 222 +
 .../uniform/atomic-uint-array-fs.shader_test   | 211 
 .../execution/uniform/atomic-uint-fs.shader_runner | 219 
 3 files changed, 652 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-array-fs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-fs.shader_runner

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
new file mode 100644
index 0..f259d3c0f
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
@@ -0,0 +1,222 @@
+# Tests the atomic counter operations described in the
+# ARB_shader_atomic_counters spec for an array of arrays of
+# atomic counters in a fragment shader.
+#
+# Checks the final value of the atomic counters and the values
+# returned by the operations.
+#
+# The declaration of the atomic counter AOA uses the atomic counter
+# layout qualifiers binding and offset.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 6
+; Bound: 76
+; Schema: 0
+   OpCapability Shader
+   OpCapability AtomicStorage
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %a0_out "a0_out"
+   OpName %a "a"
+   OpName %a0_expected "a0_expected"
+   OpName %color "color"
+   OpName %a1_out "a1_out"
+   OpName %a1_expected "a1_expected"
+   OpName %a2_out "a2_out"
+   OpName %a2_expected "a2_expected"
+   OpDecorate %a Offset 4
+   OpDecorate %a DescriptorSet 0
+   OpDecorate %a Binding 0
+   OpDecorate %a0_expected Location 0
+   OpDecorate %a0_expected DescriptorSet 0
+   OpDecorate %a0_expected Binding 1
+   OpDecorate %color Location 0
+   OpDecorate %a1_expected Location 1
+   OpDecorate %a1_expected DescriptorSet 0
+   OpDecorate %a1_expected Binding 2
+   OpDecorate %a2_expected Location 2
+   OpDecorate %a2_expected DescriptorSet 0
+   OpDecorate %a2_expected Binding 3
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+   %uint = OpTypeInt 32 0
+%_ptr_Function_uint = OpTypePointer Function %uint
+ %uint_3 = OpConstant %uint 3
+%_arr_uint_uint_3 = OpTypeArray %uint %uint_3
+ %uint_2 = OpConstant %uint 2
+%_arr__arr_uint_uint_3_uint_2 = OpTypeArray %_arr_uint_uint_3 %uint_2
+%_ptr_AtomicCounter__arr__arr_uint_uint_3_uint_2 = OpTypePointer AtomicCounter 
%_arr__arr_uint_uint_3_uint_2
+  %a = OpVariable %_ptr_AtomicCounter__arr__arr_uint_uint_3_uint_2 
AtomicCounter
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_AtomicCounter_uint = OpTypePointer AtomicCounter %uint
+ %uint_1 = OpConstant %uint 1
+ %uint_0 = OpConstant %uint 0
+%_ptr_UniformConstant_uint = OpTypePointer UniformConstant %uint
+%a0_expected = OpVariable %_ptr_UniformConstant_uint UniformConstant
+   %bool = OpTypeBool
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+  %float_255 = OpConstant %float 255
+  %int_1 = OpConstant %int 1
+%a1_expected = OpVariable %_ptr_UniformConstant_uint UniformConstant
+%float_0_10001 = OpConstant %float 0.10001
+  %int_2 = OpConstant %int 2
+%a2_expected = OpVariable %_ptr_UniformConstant_uint UniformConstant
+%float_0_20003 = OpConstant %float 0.20003
+ %75 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %a0_out = OpVariable %_ptr_Function_uint Function
+ %a1_out = OpVariable %_ptr_Function_uint Fun

[Piglit] [PATCH 22/35] arb_gl_spirv: Add a test for a uniform struct with struct members

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

---
 .../execution/uniform/embedded-structs.shader_test | 151 +
 1 file changed, 151 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/embedded-structs.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/embedded-structs.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/embedded-structs.shader_test
new file mode 100644
index 0..0dd7ba486
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/embedded-structs.shader_test
@@ -0,0 +1,151 @@
+# Tests an array of arrays with an explicit uniform location
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 55
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %pair "pair"
+   OpMemberName %pair 0 "a"
+   OpMemberName %pair 1 "b"
+   OpName %quadruple "quadruple"
+   OpMemberName %quadruple 0 "a"
+   OpMemberName %quadruple 1 "b"
+   OpName %_ ""
+   OpMemberName %_ 0 "r"
+   OpMemberName %_ 1 "g"
+   OpMemberName %_ 2 "b"
+   OpName %parts "parts"
+   OpDecorate %color Location 0
+   OpDecorate %parts Location 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
+   %pair = OpTypeStruct %float %float
+  %quadruple = OpTypeStruct %pair %pair
+  %_ = OpTypeStruct %quadruple %quadruple %quadruple
+%_ptr_UniformConstant__ = OpTypePointer UniformConstant %_
+  %parts = OpVariable %_ptr_UniformConstant__ UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+  %int_1 = OpConstant %int 1
+  %int_2 = OpConstant %int 2
+%float_1 = OpConstant %float 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpAccessChain %_ptr_UniformConstant_float %parts %int_0 %int_0 
%int_0
+ %19 = OpLoad %float %18
+ %21 = OpAccessChain %_ptr_UniformConstant_float %parts %int_0 %int_0 
%int_1
+ %22 = OpLoad %float %21
+ %23 = OpFAdd %float %19 %22
+ %24 = OpAccessChain %_ptr_UniformConstant_float %parts %int_0 %int_1 
%int_0
+ %25 = OpLoad %float %24
+ %26 = OpFAdd %float %23 %25
+ %27 = OpAccessChain %_ptr_UniformConstant_float %parts %int_0 %int_1 
%int_1
+ %28 = OpLoad %float %27
+ %29 = OpFAdd %float %26 %28
+ %30 = OpAccessChain %_ptr_UniformConstant_float %parts %int_1 %int_0 
%int_0
+ %31 = OpLoad %float %30
+ %32 = OpAccessChain %_ptr_UniformConstant_float %parts %int_1 %int_0 
%int_1
+ %33 = OpLoad %float %32
+ %34 = OpFAdd %float %31 %33
+ %35 = OpAccessChain %_ptr_UniformConstant_float %parts %int_1 %int_1 
%int_0
+ %36 = OpLoad %float %35
+ %37 = OpFAdd %float %34 %36
+ %38 = OpAccessChain %_ptr_UniformConstant_float %parts %int_1 %int_1 
%int_1
+ %39 = OpLoad %float %38
+ %40 = OpFAdd %float %37 %39
+ %42 = OpAccessChain %_ptr_UniformConstant_float %parts %int_2 %int_0 
%int_0
+ %43 = OpLoad %float %42
+ %44 = OpAccessChain %_ptr_UniformConstant_float %parts %int_2 %int_0 
%int_1
+ %45 = OpLoad %float %44
+ %46 = OpFAdd %float %43 %45
+ %47 = OpAccessChain %_ptr_UniformConstant_float %parts %int_2 %int_1 
%int_0
+ %48 = OpLoad %float %47
+ %49 = OpFAdd %float %46 %48
+ %50 = OpAccessChain %_ptr_UniformConstant_float %parts %int_2 %int_1 
%int_1
+ %51 = OpLoad %float %50
+ %52 = OpFAdd %float %49 %51
+ %54 = OpCompositeConstruct %v4float %29 %40 %52 %float_1
+   OpStore %color %54
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+struct pair {
+float a;
+float b;
+};
+
+struct quadruple {
+pair a;
+pair b;
+};
+
+layout(location = 0) uniform struct {
+   quadruple r;
+   quadruple g;
+   quadruple b;
+} parts;
+
+out vec4 color;
+
+void main()
+{
+   color = vec4(parts.r.a.a +
+ parts.r.a.b +
+ parts.r.b.a +
+ parts.r.b.b,
+

[Piglit] [PATCH 35/35] arb_gl_spirv: adding basic va64 test

2018-08-09 Thread Alejandro Piñeiro
---
 .../arb_gl_spirv/execution/va64-simple.shader_test | 136 +
 1 file changed, 136 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/va64-simple.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/va64-simple.shader_test 
b/tests/spec/arb_gl_spirv/execution/va64-simple.shader_test
new file mode 100644
index 0..bcd87081e
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/va64-simple.shader_test
@@ -0,0 +1,136 @@
+# Very basic 64bit vertex attribute test.
+
+[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: 31
+; Schema: 0
+   OpCapability Shader
+   OpCapability Float64
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %_ %piglit_vertex %fs_color 
%value0 %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 1
+   OpDecorate %fs_color Location 0
+   OpDecorate %value0 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
+   %fs_color = OpVariable %_ptr_Output_v4float Output
+ %double = OpTypeFloat 64
+   %v4double = OpTypeVector %double 4
+%_ptr_Input_v4double = OpTypePointer Input %v4double
+ %value0 = OpVariable %_ptr_Input_v4double 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
+ %18 = OpLoad %v4float %piglit_vertex
+ %20 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %20 %18
+ %26 = OpLoad %v4double %value0
+ %27 = OpFConvert %v4float %26
+   OpStore %fs_color %27
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+layout(location = 0) in dvec4 value0;
+layout(location = 1) in vec4 piglit_vertex;
+
+layout(location = 0) out vec4 fs_color;
+
+void main()
+{
+gl_Position = piglit_vertex;
+
+fs_color = vec4(value0);
+}
+
+[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: 13
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color %fs_color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpDecorate %fs_color Location 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
+%_ptr_Input_v4float = OpTypePointer Input %v4float
+   %fs_color = OpVariable %_ptr_Input_v4float Input
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %12 = OpLoad %v4float %fs_color
+   OpStore %color %12
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) in vec4 fs_color;
+layout(location = 0) out vec4 color;
+
+void main()
+{
+  color = fs_color;
+}
+
+[vertex data]
+0/double/dvec4   1/float/vec4
+0.20.30.40.5 
-1.0 -1.0 0.0 1.0
+0.20.30.40.5 
1.0 -1.0  0.0 1.0
+0.20.30.4   

[Piglit] [PATCH 28/35] arb_gl_spirv: add test that mixes atomic counters with a normal uniform

2018-08-09 Thread Alejandro Piñeiro
Under ARB_gl_spirv, most uniforms require a explicit location. There
are some exceptions like atomic counters. In that case, some drivers
like mesa, still sets internally a location for those. This test
purpose is checking that mixing "normal" uniforms with uniforms
without location works properly, or at least in a basic case.
---
 ...ic-uint-mixing-with-normal-uniforms.shader_test | 197 +
 .../uniform/atomic-uint-several-slots.shader_test  | 197 +
 2 files changed, 394 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-mixing-with-normal-uniforms.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-several-slots.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-mixing-with-normal-uniforms.shader_test
 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-mixing-with-normal-uniforms.shader_test
new file mode 100644
index 0..5029dd561
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-mixing-with-normal-uniforms.shader_test
@@ -0,0 +1,197 @@
+# Test that have several "normal" uniforms with explicit location, and
+# several uniform atomic counter, that has not explicit location. For
+# the latter mesa assigns a internal location. Development test, to
+# ensure that they are properly assigned.
+
+[require]
+SPIRV YES
+GL >= 4.5
+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: 59
+; Schema: 0
+   OpCapability Shader
+   OpCapability AtomicStorage
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpDecorate %a0 Offset 0
+   OpDecorate %a0 DescriptorSet 0
+   OpDecorate %a0 Binding 0
+   OpDecorate %u0 Location 2
+   OpDecorate %u0 DescriptorSet 0
+   OpDecorate %u0 Binding 1
+   OpDecorate %a1 Offset 4
+   OpDecorate %a1 DescriptorSet 0
+   OpDecorate %a1 Binding 0
+   OpDecorate %u1 Location 4
+   OpDecorate %u1 DescriptorSet 0
+   OpDecorate %u1 Binding 2
+   OpDecorate %a2 Offset 8
+   OpDecorate %a2 DescriptorSet 0
+   OpDecorate %a2 Binding 0
+   OpDecorate %u2 Location 7
+   OpDecorate %u2 DescriptorSet 0
+   OpDecorate %u2 Binding 3
+   OpDecorate %a3 Offset 12
+   OpDecorate %a3 DescriptorSet 0
+   OpDecorate %a3 Binding 0
+   OpDecorate %u3 Location 10
+   OpDecorate %u3 DescriptorSet 0
+   OpDecorate %u3 Binding 4
+   %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
+%_ptr_Function_uint = OpTypePointer Function %uint
+%_ptr_AtomicCounter_uint = OpTypePointer AtomicCounter %uint
+ %a0 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_1 = OpConstant %uint 1
+ %uint_0 = OpConstant %uint 0
+   %bool = OpTypeBool
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+ %u0 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+ %a1 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_3 = OpConstant %uint 3
+ %u1 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+ %a2 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_5 = OpConstant %uint 5
+ %u2 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+ %a3 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_7 = OpConstant %uint 7
+ %u3 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %uival0 = OpVariable %_ptr_Function_uint Function
+ %uival1 = OpVariable %_ptr_Function_uint Function
+ %uival2 = OpVariable %_ptr_Function_uint Function
+ %uival3 = OpVariable %_ptr_Function_uint Function
+   OpStore %color %12
+ %20 = OpAtomicLoad %uint %a0 %uint_1 %uint_0
+   OpStore %uival0 %20
+ %21 = OpLoad %uint %uival0
+ %23 = OpINotEqual %bool %21 %uint_1
+   OpSelectionMerge %25 No

[Piglit] [PATCH 20/35] arb_gl_spirv: Add a test for non-sequential explicit uniform locations

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

Tests using two uniforms that have explicit uniform locations with a
gap between them.
---
 .../uniform/nonsequential-locations.shader_test| 69 ++
 1 file changed, 69 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/nonsequential-locations.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/nonsequential-locations.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/nonsequential-locations.shader_test
new file mode 100644
index 0..a5be8e621
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/uniform/nonsequential-locations.shader_test
@@ -0,0 +1,69 @@
+# Test using explicit uniform locations that aren’t sequential. Ie,
+# there is a gap between them.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 16
+; 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 %part1 "part1"
+   OpName %part2 "part2"
+   OpDecorate %outcolor Location 0
+   OpDecorate %part1 Location 3
+   OpDecorate %part2 Location 5
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outcolor = OpVariable %_ptr_Output_v4float Output
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %part1 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+  %part2 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %12 = OpLoad %v4float %part1
+ %14 = OpLoad %v4float %part2
+ %15 = OpFAdd %v4float %12 %14
+   OpStore %outcolor %15
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 3) uniform vec4 part1;
+layout(location = 5) uniform vec4 part2;
+
+layout(location = 0) out vec4 outcolor;
+
+void main() {
+outcolor = part1 + part2;
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+uniform vec4 3 0.1 0.15 0.2 0.25
+uniform vec4 5 0.3 0.35 0.4 0.45
+
+draw rect -1 -1 2 2
+probe all rgba 0.4 0.5 0.6 0.7
-- 
2.14.1

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


[Piglit] [PATCH 27/35] arb_gl_spirv: add tests for atomic counter operations in CS

2018-08-09 Thread Alejandro Piñeiro
From: Antia Puentes 

Tests the atomic counter operations and layout qualifiers offset and binding
described in the ARB_shader_atomic_counters specification in a CS with
local_size_x, y, z equal to 3, 2 and 1 respectively.

Includes 3 tests: atomic_uint, arrays of atomic_uint and AOA of atomic_uints.
---
 .../uniform/atomic-uint-aoa-cs.shader_test | 249 +
 .../uniform/atomic-uint-array-cs.shader_test   | 239 
 .../execution/uniform/atomic-uint-cs.shader_test   | 244 
 3 files changed, 732 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-array-cs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-cs.shader_test

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
new file mode 100644
index 0..5bc3850bf
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
@@ -0,0 +1,249 @@
+# Tests the atomic counter operations described in the
+# ARB_shader_atomic_counters specification using AOAs
+# of atomic counters in a CS with  local_sizes_x, y, z
+# equal to 3, 2 and 1 respectively.
+#
+# Checks the final value of the atomic counter and the values
+# returned by the operations.
+#
+# The declaration of the atomic counters array uses the atomic
+# counter layout qualifiers binding and offset.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+
+[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: 68
+; Schema: 0
+   OpCapability Shader
+   OpCapability AtomicStorage
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint GLCompute %main "main" %gl_LocalInvocationIndex
+   OpExecutionMode %main LocalSize 3 2 1
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %a00_out "a00_out"
+   OpName %a "a"
+   OpName %a00_expected "a00_expected"
+   OpName %gl_LocalInvocationIndex "gl_LocalInvocationIndex"
+   OpName %ok_a00 "ok_a00"
+   OpName %a01_out "a01_out"
+   OpName %a01_expected "a01_expected"
+   OpName %ok_a01 "ok_a01"
+   OpName %a12_out "a12_out"
+   OpName %a12_expected "a12_expected"
+   OpName %ok_a12 "ok_a12"
+   OpDecorate %a Offset 4
+   OpDecorate %a DescriptorSet 0
+   OpDecorate %a Binding 0
+   OpDecorate %a00_expected Location 0
+   OpDecorate %a00_expected DescriptorSet 0
+   OpDecorate %a00_expected Binding 4
+   OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex
+   OpDecorate %ok_a00 Offset 0
+   OpDecorate %ok_a00 DescriptorSet 0
+   OpDecorate %ok_a00 Binding 1
+   OpDecorate %a01_expected Location 6
+   OpDecorate %a01_expected DescriptorSet 0
+   OpDecorate %a01_expected Binding 5
+   OpDecorate %ok_a01 Offset 0
+   OpDecorate %ok_a01 DescriptorSet 0
+   OpDecorate %ok_a01 Binding 2
+   OpDecorate %a12_expected Location 12
+   OpDecorate %a12_expected DescriptorSet 0
+   OpDecorate %a12_expected Binding 6
+   OpDecorate %ok_a12 Offset 0
+   OpDecorate %ok_a12 DescriptorSet 0
+   OpDecorate %ok_a12 Binding 3
+   OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+   %uint = OpTypeInt 32 0
+%_ptr_Function_uint = OpTypePointer Function %uint
+ %uint_3 = OpConstant %uint 3
+%_arr_uint_uint_3 = OpTypeArray %uint %uint_3
+ %uint_2 = OpConstant %uint 2
+%_arr__arr_uint_uint_3_uint_2 = OpTypeArray %_arr_uint_uint_3 %uint_2
+%_ptr_AtomicCounter__arr__arr_uint_uint_3_uint_2 = OpTypePointer AtomicCounter 
%_arr__arr_uint_uint_3_uint_2
+  %a = OpVariable %_ptr_AtomicCounter__arr__arr_uint_uint_3_uint_2 
AtomicCounter
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_AtomicCounter_uint = OpTypePointer AtomicCounter %uint
+ %uint_1 = OpConstant %uint 1
+ %uint_0 = OpConstant %uint 0
+ %uint_6 = OpConstant %uint 6
+%_arr_uint_uint_6 = OpTypeArray %uint %uint_6
+%_ptr_UniformConstant__arr_uint_uint_6 = OpTypePointer UniformConstant 
%_arr_uint_uint_6
+%a00_expected = OpVariable %_ptr_UniformConstant__arr_uint_uint_6 
UniformConstant
+%_ptr_Input_uint = OpTypePointer Input %uint
+%gl_LocalInvocationIndex = OpVariable %_ptr_Input_

[Piglit] [PATCH 31/35] arb_gpu_shader5: Add support for testing spirv with XFB streams

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

v2: use shader_test file with the spirv assembly, instead of include
two SPIRV binaries (Alejandro Piñeiro)

Signed-off-by: Neil Roberts 
Signed-off-by: Alejandro Piñeiro 
---
 tests/opengl.py|   1 +
 .../xfb_streams_without_invocations.shader_test| 197 +
 .../execution/xfb-streams-without-invocations.c| 135 ++
 3 files changed, 300 insertions(+), 33 deletions(-)
 create mode 100644 
tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test

diff --git a/tests/opengl.py b/tests/opengl.py
index 064c43e08..9b1e09564 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -1969,6 +1969,7 @@ with profile.test_list.group_manager(
 g(['arb_gpu_shader5-emitstreamvertex_stream_too_large'])
 g(['arb_gpu_shader5-tf-wrong-stream-value'])
 g(['arb_gpu_shader5-xfb-streams-without-invocations'])
+g(['arb_gpu_shader5-xfb-streams-without-invocations', 'spirv'])
 g(['arb_gpu_shader5-emitstreamvertex_nodraw'])
 g(['arb_gpu_shader5-interpolateAtCentroid'])
 g(['arb_gpu_shader5-interpolateAtCentroid-packing'])
diff --git 
a/tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
 
b/tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
new file mode 100644
index 0..6611e0bf8
--- /dev/null
+++ 
b/tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
@@ -0,0 +1,197 @@
+[require]
+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: 23
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %_ %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 %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
+%float_0 = OpConstant %float 0
+ %17 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
+%_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
+ %19 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %19 %17
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+void main() {
+ gl_Position = vec4(0.0);
+}
+
+
+[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
+   OpCapability TransformFeedback
+   OpCapability GeometryStreams
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Geometry %main "main" %_ %gl_in %stream0_0_out 
%stream2_0_out %stream2_1_out %stream1_0_out
+   OpExecutionMode %main Xfb
+   OpExecutionMode %main InputPoints
+   OpExecutionMode %main Invocations 1
+   OpExecutionMode %main OutputPoints
+   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
+   OpDecorate %g

[Piglit] [PATCH 30/35] util: Add utilities to handle shader_test files

2018-08-09 Thread Alejandro Piñeiro
v2: fix memory leak (Antia Puentes)
---
 tests/util/CMakeLists.txt   |   1 +
 tests/util/piglit-shader-test.c | 156 
 tests/util/piglit-shader-test.h |  43 +++
 3 files changed, 200 insertions(+)
 create mode 100644 tests/util/piglit-shader-test.c
 create mode 100644 tests/util/piglit-shader-test.h

diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index e083761d1..a5f080156 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -59,6 +59,7 @@ set(UTIL_GL_SOURCES
piglit-framework-gl.c
piglit-framework-gl/piglit_gl_framework.c
piglit-shader.c
+   piglit-shader-test.c
piglit_ktx.c
rgb9e5.c
r11g11b10f.c
diff --git a/tests/util/piglit-shader-test.c b/tests/util/piglit-shader-test.c
new file mode 100644
index 0..6aeb5a521
--- /dev/null
+++ b/tests/util/piglit-shader-test.c
@@ -0,0 +1,156 @@
+/*
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "piglit-shader-test.h"
+
+#include 
+
+/* FIXME: C&P from parse_utils, that is local to shader_runner. At
+ * this point it is not worth to move all parse_utils to a common
+ * library. Perhaps in the future if we start to use all the utils
+ */
+bool
+parse_whitespace(const char *s, const char **rest)
+{
+   const char *end = s;
+   for (; *end && *end != '\n' && isspace(*end); end++);
+
+   if (rest)
+   *rest = end;
+
+   return end != s;
+}
+
+/* FIXME: C&P from parse_utils, that is local to shader_runner. At
+ * this point it is not worth to move all parse_utils to a common
+ * library. Perhaps in the future if we start to use all the utils
+ */
+bool
+parse_str(const char *s, const char *lit, const char **rest)
+{
+   const char *t;
+   parse_whitespace(s, &t);
+   const bool ret = strncmp(t, lit, strlen(lit)) == 0;
+
+   if (rest)
+   *rest = (ret ? t + strlen(lit) : s);
+
+   return ret;
+}
+
+static void
+group_name_for_stage(GLenum shader_type,
+bool spirv,
+char *group_name)
+{
+   char *stage_name;
+
+   switch(shader_type) {
+   case GL_VERTEX_SHADER:
+   stage_name = "vertex";
+   break;
+   case GL_FRAGMENT_SHADER:
+   stage_name = "fragment";
+   break;
+   case GL_TESS_CONTROL_SHADER:
+   stage_name = "tessellation control";
+   break;
+   case GL_TESS_EVALUATION_SHADER:
+   stage_name = "tessellation evaluation";
+   break;
+   case GL_GEOMETRY_SHADER:
+   stage_name = "geometry";
+   break;
+   case GL_COMPUTE_SHADER:
+   stage_name = "compute";
+   break;
+   default: stage_name = "error";
+   }
+
+   if (!spirv)
+   sprintf(group_name, "[%s shader]", stage_name);
+   else
+   sprintf(group_name, "[%s shader spirv]", stage_name);
+}
+
+bool
+piglit_load_source_from_shader_test(const char *filename,
+   GLenum shader_type,
+   bool spirv,
+   char **output_source,
+   unsigned *output_source_size)
+{
+   char group_name[4096];
+   char *source = NULL;
+   unsigned text_size;
+   char *line = NULL;
+   char *first_line = NULL;
+
+   group_name_for_stage(shader_type, spirv, group_name);
+
+   char *text = piglit_load_text_file(filename, &text_size);
+   line = text;
+
+   if (line == NULL) {
+   fprintf(stderr, "Could not read file \"%s\"\n", filename);
+   return false;
+   }
+
+   while (line[0] != '\0') {
+   if (line[0] == '[' && first_line != NULL) {
+   

[Piglit] [PATCH 29/35] util: Add a utility to assemble SPIR-V sources

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

Adds piglit_assemble_spirv which invokes spirv-as to assemble a SPIR-V
source. The function is based on a static helper function that was in
shader_runner.
---
 tests/shaders/shader_runner.c | 45 ++-
 tests/util/piglit-shader.c| 37 +++
 tests/util/piglit-shader.h|  3 +++
 3 files changed, 46 insertions(+), 39 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index d96049687..cc377cb5e 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -720,8 +720,8 @@ program_binary_save_restore(bool script_command)
 }
 
 static enum piglit_result
-load_and_specialize_spirv(GLenum target,
- const char *binary, unsigned size)
+specialize_spirv(GLenum target,
+GLuint shader)
 {
if (glsl_in_use) {
printf("Cannot mix SPIR-V and non-SPIR-V shaders\n");
@@ -730,11 +730,6 @@ load_and_specialize_spirv(GLenum target,
 
spirv_in_use = true;
 
-   GLuint shader = glCreateShader(target);
-
-   glShaderBinary(1, &shader, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB,
-  binary, size);
-
const struct specialization_list *specs;
 
switch (target) {
@@ -822,15 +817,6 @@ assemble_spirv(GLenum target)
return PIGLIT_SKIP;
}
 
-   char *arguments[] = {
-   getenv("PIGLIT_SPIRV_AS_BINARY"),
-   "-o", "-",
-   NULL
-   };
-
-   if (arguments[0] == NULL)
-   arguments[0] = "spirv-as";
-
/* Strip comments from the source */
char *stripped_source = malloc(shader_string_size);
char *p = stripped_source;
@@ -853,32 +839,13 @@ assemble_spirv(GLenum target)
}
}
 
-   uint8_t *binary_source;
-   size_t binary_source_length;
-   bool res = piglit_subprocess(arguments,
-p - stripped_source,
-(const uint8_t *)
-stripped_source,
-&binary_source_length,
-&binary_source);
+   GLuint shader = piglit_assemble_spirv(target,
+ p - stripped_source,
+ stripped_source);
 
free(stripped_source);
 
-   if (!res) {
-   fprintf(stderr, "spirv-as failed\n");
-   return PIGLIT_FAIL;
-   }
-
-   enum piglit_result ret;
-
-   ret = load_and_specialize_spirv(target,
-   (const char *)
-   binary_source,
-   binary_source_length);
-
-   free(binary_source);
-
-   return ret;
+   return specialize_spirv(target, shader);
 }
 
 static enum piglit_result
diff --git a/tests/util/piglit-shader.c b/tests/util/piglit-shader.c
index 7ac5df14d..1938b1576 100644
--- a/tests/util/piglit-shader.c
+++ b/tests/util/piglit-shader.c
@@ -24,6 +24,7 @@
 #include 
 
 #include "piglit-util-gl.h"
+#include "piglit-subprocess.h"
 
 void piglit_get_glsl_version(bool *es, int* major, int* minor)
 {
@@ -464,6 +465,42 @@ piglit_build_simple_program_multiple_shaders(GLenum 
target1,
return prog;
 }
 
+GLuint
+piglit_assemble_spirv(GLenum target,
+ size_t source_length,
+ const char *source)
+{
+   char *arguments[] = {
+   getenv("PIGLIT_SPIRV_AS_BINARY"),
+   "-o", "-",
+   NULL
+   };
+
+   if (arguments[0] == NULL)
+   arguments[0] = "spirv-as";
+
+   uint8_t *binary_source;
+   size_t binary_source_length;
+   bool res = piglit_subprocess(arguments,
+source_length,
+(const uint8_t *) source,
+&binary_source_length,
+&binary_source);
+
+   if (!res) {
+   fprintf(stderr, "spirv-as failed\n");
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   GLuint shader = glCreateShader(target);
+   glShaderBinary(1, &shader, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB,
+  binary_source, binary_source_length);
+
+   free(binary_source);
+
+   return shader;
+}
+
 void
 piglit_require_GLSL(void)
 {
diff --git a/tests/util/piglit-shader.h b/tests/util/piglit-shader.h
index 9208451a8..aa29d0994 100644
--- a/tests/util/piglit-shader.h
+++ b/tests/util/piglit-shader.h
@@ -49,6 +49,9 @@ GLint 
piglit_build_simple_program_unlinked_multiple_shaders(GLenum target1,
 GLint piglit_build_simple_program_multiple_shaders(GLenum target1,
  const char *source1,
  ...);
+GLui

[Piglit] [PATCH 33/35] arb_enhanced_layouts: Test doubles

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

v2: use shader_test file with the spirv assembly, instead of include a
SPIR-V binary binaries (Alejandro Piñeiro)

Signed-off-by: Neil Roberts 
Signed-off-by: Alejandro Piñeiro 
---
 tests/opengl.py|   2 +-
 .../shader_test/vs_double.shader_test  | 102 +
 .../transform-feedback-layout-qualifiers.c |  99 
 3 files changed, 184 insertions(+), 19 deletions(-)
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_double.shader_test

diff --git a/tests/opengl.py b/tests/opengl.py
index 0b06d9505..b021b2a9e 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -2308,7 +2308,7 @@ with profile.test_list.group_manager(
'explicit-offset-bufferstorage')
 g(['arb_enhanced_layouts-gs-stream-location-aliasing'],
'gs-stream-location-aliasing')
-for test in ['vs', 'vs_ifc', 'vs_named_ifc', 'vs_struct']:
+for test in ['vs', 'vs_ifc', 'vs_named_ifc', 'vs_struct', 'vs_double']:
 g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', test],
   'arb_enhanced_layouts-transform-feedback-layout-qualifiers_' + test,
   run_concurrent=False)
diff --git a/tests/spec/arb_enhanced_layouts/shader_test/vs_double.shader_test 
b/tests/spec/arb_enhanced_layouts/shader_test/vs_double.shader_test
new file mode 100644
index 0..6f19d0d13
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/shader_test/vs_double.shader_test
@@ -0,0 +1,102 @@
+[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: 41
+; Schema: 0
+   OpCapability Shader
+   OpCapability Float64
+   OpCapability TransformFeedback
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %_ %x1_out %x2_out %x3_out 
%gl_VertexID %gl_InstanceID
+   OpExecutionMode %main Xfb
+   OpSource GLSL 450
+   OpSourceExtension "GL_ARB_enhanced_layouts"
+   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 %_ XfbBuffer 0
+   OpDecorate %_ XfbStride 56
+   OpDecorate %x1_out Location 0
+   OpDecorate %x1_out XfbBuffer 0
+   OpDecorate %x1_out XfbStride 56
+   OpDecorate %x1_out Offset 0
+   OpDecorate %x2_out Location 1
+   OpDecorate %x2_out XfbBuffer 0
+   OpDecorate %x2_out XfbStride 56
+   OpDecorate %x2_out Offset 8
+   OpDecorate %x3_out Location 2
+   OpDecorate %x3_out XfbBuffer 0
+   OpDecorate %x3_out XfbStride 56
+   OpDecorate %x3_out Offset 24
+   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
+%float_0 = OpConstant %float 0
+ %17 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %double = OpTypeFloat 64
+%_ptr_Output_double = OpTypePointer Output %double
+ %x1_out = OpVariable %_ptr_Output_double Output
+   %double_1 = OpConstant %double 1
+   %v2double = OpTypeVector %double 2
+%_ptr_Output_v2double = OpTypePointer Output %v2double
+ %x2_out = OpVariable %_ptr_Output_v2double Output
+   %double_2 = OpConstant %double 2
+   %double_3 = OpConstant %double 3
+ %29 = OpConstantComposite %v2double %double_2 %double_3
+   %v4double = OpTypeVector %double 4
+%_ptr_Output_v4double = OpTypePointer Output %v4double
+ %x3_out = OpVariable %_ptr_Output_v4double Output
+   %double_4 = OpConstant %double 4
+   %double_5 = OpConstant %double 5
+   %double_6 = OpConstant %double 6
+   %double_7 = OpConstant %double 7
+ %3

[Piglit] [PATCH 34/35] util/vbo: Accept integer attribute names

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

---
 tests/util/piglit-vbo.cpp | 28 +---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/tests/util/piglit-vbo.cpp b/tests/util/piglit-vbo.cpp
index 86d5081de..3ef6b1107 100644
--- a/tests/util/piglit-vbo.cpp
+++ b/tests/util/piglit-vbo.cpp
@@ -131,6 +131,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "piglit-util.h"
 #include "piglit-util-gl.h"
@@ -312,6 +313,29 @@ public:
GLuint index;
 };
 
+static bool
+get_attrib_location(GLuint prog,
+   const std::string &name,
+   GLuint *index)
+{
+   errno = 0;
+
+   char *end;
+   unsigned long ul = strtoul(name.c_str(), &end, 10);
+
+   if (errno == 0 && *end == '\0' && ul <= UINT_MAX) {
+   *index = ul;
+   return true;
+   }
+
+   GLint attrib_location = glGetAttribLocation(prog, name.c_str());
+   if (attrib_location == -1)
+   return false;
+
+   *index = attrib_location;
+
+   return true;
+}
 
 /**
  * Build a vertex_attrib_description from a column header, by looking
@@ -408,12 +432,10 @@ 
vertex_attrib_description::vertex_attrib_description(GLuint prog,
this->matrix_index = 0;
}
 
-   GLint attrib_location = glGetAttribLocation(prog, name.c_str());
-   if (attrib_location == -1) {
+   if (!get_attrib_location(prog, name, &this->index)) {
printf("Unexpected vbo column name.  Got: %s\n", name.c_str());
piglit_report_result(PIGLIT_FAIL);
}
-   this->index = attrib_location;
/* If the type is integral, verify that integer vertex
 * attribute support is present.  Note: we treat it as a FAIL
 * if support is not present, because it's up to the test to
-- 
2.14.1

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


[Piglit] [PATCH 32/35] arb_enhanced_layouts: Test XFB layout qualifiers via SPIR-V

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

v2: use shader_test file with the spirv assembly, instead of include
two SPIRV binaries (Alejandro Piñeiro)

Signed-off-by: Neil Roberts 
Signed-off-by: Alejandro Piñeiro 
---
 tests/opengl.py|  22 +-
 .../shader_test/gs_text_two_sets_tmpl.shader_test  |  35 +++
 .../shader_test/vs_passthru.shader_test|  53 
 .../shader_test/vs_two_sets.shader_test| 125 
 .../shader_test/vs_two_sets_ifc.shader_test| 128 
 .../shader_test/vs_two_sets_named_ifc.shader_test  | 125 
 .../shader_test/vs_two_sets_struct.shader_test | 134 +
 .../transform-feedback-layout-qualifiers.c | 322 +++--
 8 files changed, 784 insertions(+), 160 deletions(-)
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/gs_text_two_sets_tmpl.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_passthru.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets_ifc.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets_named_ifc.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets_struct.shader_test

diff --git a/tests/opengl.py b/tests/opengl.py
index 9b1e09564..0b06d9505 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -2308,18 +2308,16 @@ with profile.test_list.group_manager(
'explicit-offset-bufferstorage')
 g(['arb_enhanced_layouts-gs-stream-location-aliasing'],
'gs-stream-location-aliasing')
-g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', 'vs'],
-  'arb_enhanced_layouts-transform-feedback-layout-qualifiers_vs',
-  run_concurrent=False)
-g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', 'vs_ifc'],
-  'arb_enhanced_layouts-transform-feedback-layout-qualifiers_vs_interface',
-  run_concurrent=False)
-g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', 
'vs_named_ifc'],
-  
'arb_enhanced_layouts-transform-feedback-layout-qualifiers_vs_named_interface',
-  run_concurrent=False)
-g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', 
'vs_struct'],
-  'arb_enhanced_layouts-transform-feedback-layout-qualifiers_vs_struct',
-  run_concurrent=False)
+for test in ['vs', 'vs_ifc', 'vs_named_ifc', 'vs_struct']:
+g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', test],
+  'arb_enhanced_layouts-transform-feedback-layout-qualifiers_' + test,
+  run_concurrent=False)
+g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers',
+   test,
+   'spirv'],
+  'arb_enhanced_layouts-transform-feedback-layout-qualifiers_' +
+  test + '_spirv',
+  run_concurrent=False)
 g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', 'gs'],
   'arb_enhanced_layouts-transform-feedback-layout-qualifiers_gs',
   run_concurrent=False)
diff --git 
a/tests/spec/arb_enhanced_layouts/shader_test/gs_text_two_sets_tmpl.shader_test 
b/tests/spec/arb_enhanced_layouts/shader_test/gs_text_two_sets_tmpl.shader_test
new file mode 100644
index 0..b58468b53
--- /dev/null
+++ 
b/tests/spec/arb_enhanced_layouts/shader_test/gs_text_two_sets_tmpl.shader_test
@@ -0,0 +1,35 @@
+[require]
+GLSL >= 4.50
+
+[geometry shader]
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_gpu_shader5 : enable
+#define INVOCATION_MAX_N %u
+
+layout(points, invocations = INVOCATION_MAX_N) in;
+layout(points, max_vertices = 1) out;
+
+layout(xfb_offset = 0) out float x1_out;
+layout(xfb_offset = 4) out vec2 x2_out;
+layout(xfb_offset = 12) out vec3 x3_out;
+out vec3 not_captured1;
+layout(xfb_buffer = 2) out;
+layout(xfb_offset = 0) out float y1_out;
+layout(xfb_offset = 4) out vec4 y2_out;
+layout(xfb_buffer = 2) out vec3 not_captured2;
+
+void main() {
+   gl_Position = gl_in[0].gl_Position;
+   x1_out = 1.0 + gl_InvocationID;
+   x2_out = vec2(2.0 + gl_InvocationID, 3.0 + gl_InvocationID);
+   x3_out = vec3(4.0 + gl_InvocationID, 5.0 + gl_InvocationID,
+ 6.0 + gl_InvocationID);
+   y1_out = 7.0 + gl_InvocationID;
+   y2_out = vec4(8.0 + gl_InvocationID, 9.0 + gl_InvocationID,
+ 10.0 + gl_InvocationID, 11.0 + gl_InvocationID);
+   not_captured1 = vec3(1.0);
+   not_captured2 = vec3(1.0);
+   EmitVertex();
+   EndPrimitive();
+}
diff --git 
a/tests/spec/arb_enhanced_layouts/shader_test/vs_passthru.shader_test 
b/tests/spec/arb_enhanced_layouts/shader_test/vs_passt

[Piglit] [PATCH 24/35] arb_gl_spirv: Add a fiddly test for uniform index calculation

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

This is a somewhat convoluted test to catch a particular problem
with the code we were using to assign a uniform index to a variable.
A uniform’s location starts off being the explicit location.
Previously while recursing through the uniform’s type, whenever the
location matches the current calculated location we were setting it
to the index. However, if the calculated index happens to match a
calculated location then it would set the index a second time and
get it wrong.

Note: This probably shouldn’t be merged into Piglit master because
it’s a bit too specific to a temporary problem we had in Mesa.
---
 .../uniform/index-matches-location.shader_test | 100 +
 1 file changed, 100 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test
new file mode 100644
index 0..3b2e894cf
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test
@@ -0,0 +1,100 @@
+# This is a somewhat convoluted test to catch a particular problem
+# with the code we were using to assign a uniform index to a variable.
+# A uniform’s location starts off being the explicit location.
+# Previously while recursing through the uniform’s type, whenever the
+# location matches the current calculated location we were setting it
+# to the index. However, if the calculated index happens to match a
+# calculated location then it would set the index a second time and
+# get it wrong.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 28
+; 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 %a "a"
+   OpName %_ ""
+   OpMemberName %_ 0 "b"
+   OpMemberName %_ 1 "c"
+   OpName %s "s"
+   OpDecorate %outcolor Location 0
+   OpDecorate %a Location 2
+   OpDecorate %s Location 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
+%float_0 = OpConstant %float 0
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+  %a = OpVariable %_ptr_UniformConstant_float UniformConstant
+  %_ = OpTypeStruct %float %float
+%_ptr_UniformConstant__ = OpTypePointer UniformConstant %_
+  %s = OpVariable %_ptr_UniformConstant__ UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+  %int_1 = OpConstant %int 1
+%float_1 = OpConstant %float 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %13 = OpLoad %float %a
+ %19 = OpAccessChain %_ptr_UniformConstant_float %s %int_0
+ %20 = OpLoad %float %19
+ %21 = OpFAdd %float %13 %20
+ %23 = OpAccessChain %_ptr_UniformConstant_float %s %int_1
+ %24 = OpLoad %float %23
+ %25 = OpFAdd %float %21 %24
+ %27 = OpCompositeConstruct %v4float %float_0 %25 %float_0 %float_1
+   OpStore %outcolor %27
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+// This ends up with index 0
+layout (location = 2) uniform float a;
+
+// This ends up with index 1
+layout (location = 0) uniform struct {
+// index 1, location 0
+float b;
+// index 2, location 1
+//   -> this matches previous index, location gets set again
+float c;
+} s;
+
+layout(location = 0) out vec4 outcolor;
+
+void main() {
+outcolor = vec4(0.0, a + s.b + s.c, 0.0, 1.0);
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+uniform float 0 0.1
+uniform float 1 0.6
+uniform float 2 0.25
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.95 0.0 1.0
-- 
2.14.1

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


[Piglit] [PATCH 21/35] arb_gl_spirv: Add a test for a struct uniform

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

---
 .../execution/uniform/struct.shader_test   | 79 ++
 1 file changed, 79 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/uniform/struct.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/struct.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/struct.shader_test
new file mode 100644
index 0..f68120512
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/struct.shader_test
@@ -0,0 +1,79 @@
+# Test using a simple struct uniform with a non-zero explicit location
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 22
+; 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 %parts "parts"
+   OpMemberName %parts 0 "part1"
+   OpMemberName %parts 1 "part2"
+   OpName %fsin "fsin"
+   OpDecorate %outcolor Location 0
+   OpDecorate %fsin Location 4
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outcolor = OpVariable %_ptr_Output_v4float Output
+  %parts = OpTypeStruct %v4float %v4float
+%_ptr_UniformConstant_parts = OpTypePointer UniformConstant %parts
+   %fsin = OpVariable %_ptr_UniformConstant_parts UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %int_1 = OpConstant %int 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %16 = OpAccessChain %_ptr_UniformConstant_v4float %fsin %int_0
+ %17 = OpLoad %v4float %16
+ %19 = OpAccessChain %_ptr_UniformConstant_v4float %fsin %int_1
+ %20 = OpLoad %v4float %19
+ %21 = OpFAdd %v4float %17 %20
+   OpStore %outcolor %21
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+struct parts {
+vec4 part1;
+vec4 part2;
+};
+
+layout(location = 4) uniform parts fsin;
+
+layout(location = 0) out vec4 outcolor;
+
+void main() {
+outcolor = fsin.part1 + fsin.part2;
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+uniform vec4 4 0.1 0.15 0.2 0.25
+uniform vec4 5 0.3 0.35 0.4 0.45
+
+draw rect -1 -1 2 2
+probe all rgba 0.4 0.5 0.6 0.7
-- 
2.14.1

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


[Piglit] [PATCH 23/35] arb_gl_spirv: Add a test for an array of structs uniform

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

---
 .../execution/uniform/struct-array.shader_test | 140 +
 1 file changed, 140 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test
new file mode 100644
index 0..b237c1c77
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test
@@ -0,0 +1,140 @@
+# Tests an array of structs with an explicit uniform location
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 60
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %i "i"
+   OpName %_ ""
+   OpMemberName %_ 0 "r"
+   OpMemberName %_ 1 "g"
+   OpMemberName %_ 2 "b"
+   OpName %parts "parts"
+   OpDecorate %color Location 0
+   OpDecorate %parts Location 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
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %12 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_1
+%int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+  %int_0 = OpConstant %int 0
+  %int_2 = OpConstant %int 2
+   %bool = OpTypeBool
+  %_ = OpTypeStruct %float %float %float
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr___uint_2 = OpTypeArray %_ %uint_2
+%_ptr_UniformConstant__arr___uint_2 = OpTypePointer UniformConstant 
%_arr___uint_2
+  %parts = OpVariable %_ptr_UniformConstant__arr___uint_2 UniformConstant
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+ %uint_0 = OpConstant %uint 0
+%_ptr_Output_float = OpTypePointer Output %float
+  %int_1 = OpConstant %int 1
+ %uint_1 = OpConstant %uint 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+  %i = OpVariable %_ptr_Function_int Function
+   OpStore %color %12
+   OpStore %i %int_0
+   OpBranch %17
+ %17 = OpLabel
+   OpLoopMerge %19 %20 None
+   OpBranch %21
+ %21 = OpLabel
+ %22 = OpLoad %int %i
+ %25 = OpSLessThan %bool %22 %int_2
+   OpBranchConditional %25 %18 %19
+ %18 = OpLabel
+ %32 = OpLoad %int %i
+ %34 = OpAccessChain %_ptr_UniformConstant_float %parts %32 %int_0
+ %35 = OpLoad %float %34
+ %38 = OpAccessChain %_ptr_Output_float %color %uint_0
+ %39 = OpLoad %float %38
+ %40 = OpFAdd %float %39 %35
+ %41 = OpAccessChain %_ptr_Output_float %color %uint_0
+   OpStore %41 %40
+ %42 = OpLoad %int %i
+ %44 = OpAccessChain %_ptr_UniformConstant_float %parts %42 %int_1
+ %45 = OpLoad %float %44
+ %47 = OpAccessChain %_ptr_Output_float %color %uint_1
+ %48 = OpLoad %float %47
+ %49 = OpFAdd %float %48 %45
+ %50 = OpAccessChain %_ptr_Output_float %color %uint_1
+   OpStore %50 %49
+ %51 = OpLoad %int %i
+ %52 = OpAccessChain %_ptr_UniformConstant_float %parts %51 %int_2
+ %53 = OpLoad %float %52
+ %54 = OpAccessChain %_ptr_Output_float %color %uint_2
+ %55 = OpLoad %float %54
+ %56 = OpFAdd %float %55 %53
+ %57 = OpAccessChain %_ptr_Output_float %color %uint_2
+   OpStore %57 %56
+   OpBranch %20
+ %20 = OpLabel
+ %58 = OpLoad %int %i
+ %59 = OpIAdd %int %58 %int_1
+   OpStore %i %59
+   OpBranch %17
+ %19 = OpLabel
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) uniform struct {
+   float r;
+   float g;
+   float b;
+} parts[2];
+
+out vec4 color;
+
+void main()
+{
+   color = vec4(0.0, 0.0, 0.0, 1.0);
+
+   for (int i = 0; i < 2; i++) {
+   color.r += parts[i].r;
+   color.g += parts[i].g;
+   color.b += parts[i].b;
+   }
+}
+
+[test]
+clear color 0.2 0.2 0.2 0.2
+clear
+
+uniform float 0 0.1
+uniform float 1 0.2
+uniform float 2 0

[Piglit] [PATCH 25/35] shader_runner: add command 'probe atomic counter buffer'

2018-08-09 Thread Alejandro Piñeiro
From: Antia Puentes 

Extends the already existing 'probe atomic counter' command to allow comparing
the value of an atomic counter stored in an ATOMIC_COUNTER_BUFFER with a binding
different from zero, and at a chosen offset. In other words, adds support to
test the atomic counter layout qualifiers: binding and offset.

Usage: 'probe atomic counter buffer'

   *  and  are the atomic counter layout qualifiers.
   *  is the comparison operator.
   *  is the number to be compared with the atomic counter.
---
 tests/shaders/shader_runner.c | 25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 2ff6f9af8..d96049687 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -3419,7 +3419,8 @@ draw_arrays_common(int first, size_t count)
 }
 
 static bool
-probe_atomic_counter(unsigned buffer_num, GLint counter_num, const char *op, 
uint32_t value)
+probe_atomic_counter(unsigned buffer_num, GLint counter_num, const char *op,
+uint32_t value, bool uses_layout_qualifiers)
 {
 uint32_t *p;
uint32_t observed;
@@ -3430,7 +3431,8 @@ probe_atomic_counter(unsigned buffer_num, GLint 
counter_num, const char *op, uin
"Invalid comparison operation at: %s\n", op);
 
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomics_bos[buffer_num]);
-   p = glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER, counter_num * 
sizeof(uint32_t),
+   p = glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER,
+uses_layout_qualifiers ? counter_num : counter_num 
* sizeof(uint32_t),
 sizeof(uint32_t), GL_MAP_READ_BIT);
 
 if (!p) {
@@ -3442,8 +3444,13 @@ probe_atomic_counter(unsigned buffer_num, GLint 
counter_num, const char *op, uin
result = compare_uint(value, observed, cmp);
 
if (!result) {
-   printf("Atomic counter %d test failed: Reference %s Observed\n",
-  counter_num, comparison_string(cmp));
+   if (uses_layout_qualifiers)
+   printf("Atomic counter (binding = %d, offset = %d) test 
failed: "
+  "Reference %s Observed\n",
+  buffer_num, counter_num, comparison_string(cmp));
+   else
+   printf("Atomic counter %d test failed: Reference %s 
Observed\n",
+  counter_num, comparison_string(cmp));
printf("  Reference: %u\n", value);
printf("  Observed:  %u\n", observed);
glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
@@ -3510,7 +3517,7 @@ piglit_display(void)
float c[32];
double d[4];
int x, y, z, w, h, l, tex, level;
-   unsigned ux, uy;
+   unsigned ux, uy, uz;
char s[300]; // 300 for safety
enum piglit_result result = PIGLIT_PASS;
 
@@ -3960,10 +3967,16 @@ piglit_display(void)
  c[2])) {
result = PIGLIT_FAIL;
}
+   } else if (sscanf(line,
+ "probe atomic counter buffer %u %u %s %u",
+ &ux, &uy, s, &uz) == 4) {
+   if (!probe_atomic_counter(ux, uy, s, uz, true)) {
+   piglit_report_result(PIGLIT_FAIL);
+   }
} else if (sscanf(line,
  "probe atomic counter %u %s %u",
  &ux, s, &uy) == 3) {
-   if (!probe_atomic_counter(0, ux, s, uy)) {
+   if (!probe_atomic_counter(0, ux, s, uy, false)) {
piglit_report_result(PIGLIT_FAIL);
}
} else if (sscanf(line, "probe ssbo uint %d %d %s 0x%x",
-- 
2.14.1

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


[Piglit] [PATCH 19/35] arb_gl_spirv: Add 4 tests for uniform initializers

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

This includes a basic test with uniform initializers, one using a
mat4x3 type, one using a dvec4 and finally a complex one using a
combination of types (arrays, structs and mats).  # This is the commit
message #2:
---
 .../uniform/initializer-complex.shader_test| 180 +
 .../uniform/initializer-dvec4.shader_test  |  68 
 .../uniform/initializer-mat4x3.shader_test |  83 ++
 .../execution/uniform/initializer.shader_test  |  66 
 4 files changed, 397 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/initializer-complex.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/initializer-dvec4.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/initializer-mat4x3.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/initializer.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/initializer-complex.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/initializer-complex.shader_test
new file mode 100644
index 0..5db111b25
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/initializer-complex.shader_test
@@ -0,0 +1,180 @@
+# Test a uniform with an initializer that has a type containing
+# structs, arrays and matrices.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+
+; This is manually edited by hand to add the uniform constant
+; initialiser because glslang seems to silently drop it.
+
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 4
+; Bound: 59
+; 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 %out_color "out_color"
+   OpName %i "i"
+   OpName %color "color"
+   OpMemberName %color 0 "r"
+   OpMemberName %color 1 "g"
+   OpMemberName %color 2 "b"
+   OpMemberName %color 3 "a"
+   OpName %base "base"
+   OpMemberName %base 0 "colors"
+   OpMemberName %base 1 "transform"
+   OpName %value "value"
+   OpDecorate %out_color Location 0
+   OpDecorate %value Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %out_color = OpVariable %_ptr_Output_v4float Output
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %11 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
+%int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+  %int_0 = OpConstant %int 0
+  %int_4 = OpConstant %int 4
+   %bool = OpTypeBool
+  %color = OpTypeStruct %float %float %float %float
+   %uint = OpTypeInt 32 0
+ %uint_4 = OpConstant %uint 4
+%_arr_color_uint_4 = OpTypeArray %color %uint_4
+%mat4v4float = OpTypeMatrix %v4float 4
+   %base = OpTypeStruct %_arr_color_uint_4 %mat4v4float
+%_ptr_UniformConstant_base = OpTypePointer UniformConstant %base
+%f01 = OpConstant %float 0.01
+%f02 = OpConstant %float 0.02
+%f03 = OpConstant %float 0.03
+%f04 = OpConstant %float 0.04
+%f05 = OpConstant %float 0.05
+%f06 = OpConstant %float 0.06
+%f07 = OpConstant %float 0.07
+%f08 = OpConstant %float 0.08
+%f09 = OpConstant %float 0.09
+%f11 = OpConstant %float 0.11
+%f12 = OpConstant %float 0.12
+%f25 = OpConstant %float 0.25
+%f85 = OpConstant %float 0.85
+%c0 = OpConstantComposite %color %f01 %f02 %f03 %f25
+%c1 = OpConstantComposite %color %f04 %f05 %f06 %f25
+%c2 = OpConstantComposite %color %f07 %f08 %f09 %f25
+%c3 = OpConstantComposite %color %f85 %f11 %f12 %f25
+ %colors = OpConstantComposite %_arr_color_uint_4 %c0 %c1 %c2 %c3
+ %t0 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_0
+ %t1 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_0
+ %t2 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_0
+ %t3 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_1
+  %transform = OpConstantComposite %mat4v4float %t0 %t1 %t2 %t3
+%initializer = OpConstantComposite %base %colors %transform
+  %value = OpVariable %_ptr_UniformConstant_base UniformConstant 
%initializer
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+  %int_1 = OpConstant %int 1
+  %int_2 = OpConstant %int 2
+  %int_3 = OpConstant %int 3
+%_ptr_Unif

[Piglit] [PATCH 18/35] arb_gl_spirv: add two linking tests for uniform multisample images

2018-08-09 Thread Alejandro Piñeiro
Use a uniform image2DMS and image2DMSArray. The latter related with
SpvCapabilityImageMSArray.

Note that those are linking tests, because although the specific
extensions are supported, in the practice multisampling is not allowed
as GL_MAX_IMAGE_SAMPLES is zero for most mesa drivers.

Signed-off-by: Alejandro Piñeiro 
Signed-off-by: Antia Puentes 
---
 .../linker/uniform/multisampler-array.shader_test  | 68 ++
 .../linker/uniform/multisampler.shader_test| 67 +
 2 files changed, 135 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/linker/uniform/multisampler-array.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/linker/uniform/multisampler.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/linker/uniform/multisampler-array.shader_test 
b/tests/spec/arb_gl_spirv/linker/uniform/multisampler-array.shader_test
new file mode 100644
index 0..8d79aca43
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/linker/uniform/multisampler-array.shader_test
@@ -0,0 +1,68 @@
+# Test for SpvCapabilityImageMSArray
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+
+[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; 4
+; Bound: 23
+; Schema: 0
+   OpCapability Shader
+   OpCapability StorageImageMultisample
+   OpCapability ImageMSArray
+   OpCapability ImageQuery
+  %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 %samp "samp"
+   OpName %rimg2DMSArray "rimg2DMSArray"
+   OpDecorate %rimg2DMSArray Location 2
+   OpDecorate %rimg2DMSArray DescriptorSet 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+   %uint = OpTypeInt 32 0
+ %10 = OpTypeImage %uint 2D 0 1 1 2 Rgba8ui
+%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10
+%rimg2DMSArray = OpVariable %_ptr_UniformConstant_10 UniformConstant
+  %v3int = OpTypeVector %int 3
+  %int_0 = OpConstant %int 0
+ %18 = OpConstantComposite %v3int %int_0 %int_0 %int_0
+  %int_2 = OpConstant %int 2
+ %v4uint = OpTypeVector %uint 4
+   %uint_255 = OpConstant %uint 255
+ %22 = OpConstantComposite %v4uint %uint_255 %uint_255 %uint_255 
%uint_255
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+   %samp = OpVariable %_ptr_Function_int Function
+ %13 = OpLoad %10 %rimg2DMSArray
+ %14 = OpImageQuerySamples %int %13
+   OpStore %samp %14
+ %15 = OpLoad %10 %rimg2DMSArray
+   OpImageWrite %15 %18 %22 Sample %int_2
+   OpReturn
+   OpFunctionEnd
+
+[compute shader]
+#version 450
+
+layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+
+layout (location = 2, rgba8ui) uniform uimage2DMSArray rimg2DMSArray;
+
+void main()
+{
+int samp = imageSamples(rimg2DMSArray);
+imageStore(rimg2DMSArray, ivec3(0), 2, uvec4(255));
+}
+
+[test]
+link success
diff --git a/tests/spec/arb_gl_spirv/linker/uniform/multisampler.shader_test 
b/tests/spec/arb_gl_spirv/linker/uniform/multisampler.shader_test
new file mode 100644
index 0..5cf00192f
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/linker/uniform/multisampler.shader_test
@@ -0,0 +1,67 @@
+#Test using an uniform of type uimage2DMS
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+
+[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; 4
+; Bound: 23
+; Schema: 0
+   OpCapability Shader
+   OpCapability StorageImageMultisample
+   OpCapability ImageQuery
+  %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 %samp "samp"
+   OpName %rimg2DMS "rimg2DMS"
+   OpDecorate %rimg2DMS Location 2
+   OpDecorate %rimg2DMS DescriptorSet 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+   %uint = OpTypeInt 32 0
+ %10 = OpTypeImage %uint 2D 0 0 1 2 Rgba8ui
+%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10
+   %rimg2DMS = OpVariable %_ptr_Unifor

[Piglit] [PATCH 16/35] arb_gl_spirv: Add a test for a sampler within a struct

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

---
 .../execution/uniform/sampler2d-struct.shader_test | 98 ++
 1 file changed, 98 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/sampler2d-struct.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-struct.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-struct.shader_test
new file mode 100644
index 0..8e440543e
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-struct.shader_test
@@ -0,0 +1,98 @@
+# Test a texture sampler array within a struct. This is not allowed by
+# Vulkan so it needs special handling for GL_ARB_gl_spirv.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 35
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %Samp "Samp"
+   OpMemberName %Samp 0 "tex"
+   OpMemberName %Samp 1 "green_offset"
+   OpName %s "s"
+   OpDecorate %color Location 0
+   OpDecorate %s Location 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
+ %10 = OpTypeImage %float 2D 0 0 0 1 Unknown
+ %11 = OpTypeSampledImage %10
+   %Samp = OpTypeStruct %11 %float
+%_ptr_UniformConstant_Samp = OpTypePointer UniformConstant %Samp
+  %s = OpVariable %_ptr_UniformConstant_Samp UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
+%v2float = OpTypeVector %float 2
+ %float_0_25 = OpConstant %float 0.25
+ %22 = OpConstantComposite %v2float %float_0_25 %float_0_25
+  %int_1 = OpConstant %int 1
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_ptr_Output_float = OpTypePointer Output %float
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpAccessChain %_ptr_UniformConstant_11 %s %int_0
+ %19 = OpLoad %11 %18
+ %23 = OpImageSampleImplicitLod %v4float %19 %22
+   OpStore %color %23
+ %26 = OpAccessChain %_ptr_UniformConstant_float %s %int_1
+ %27 = OpLoad %float %26
+ %31 = OpAccessChain %_ptr_Output_float %color %uint_1
+ %32 = OpLoad %float %31
+ %33 = OpFAdd %float %32 %27
+ %34 = OpAccessChain %_ptr_Output_float %color %uint_1
+   OpStore %34 %33
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 0) out vec4 color;
+
+struct Samp {
+sampler2D tex;
+   float green_offset;
+};
+
+layout (location = 0) uniform Samp s;
+
+void main()
+{
+   color = texture(s.tex, vec2(0.25));
+   color.g += s.green_offset;
+}
+
+[test]
+clear color 1.0 0.0 0.0 1.0
+clear
+
+uniform int 0 3
+uniform float 1 0.45
+
+texture checkerboard 3 0 (32, 32) (0.0, 0.5, 0.0, 0.0) (0.8, 0.0, 0.0, 1.0)
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.95 0.0 0.0
-- 
2.14.1

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


[Piglit] [PATCH 17/35] arb_gl_spirv: Add a test for nonconst array of sampler structs

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

This is a simple port of arb_arrays_of_arrays/execution/sampler/
fs-nested-struct-arrays-nonconst-nested-array.shader_test
---
 .../sampler2d-nonconst-nested-array.shader_test| 225 +
 1 file changed, 225 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/sampler2d-nonconst-nested-array.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-nonconst-nested-array.shader_test
 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-nonconst-nested-array.shader_test
new file mode 100644
index 0..cf1fed17e
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-nonconst-nested-array.shader_test
@@ -0,0 +1,225 @@
+# This test verifies that dynamic uniform indexing of samplers within
+# a nested struct array for the fragment shader behaves correctly.
+#
+# It is a direct copy of arb_arrays_of_arrays/execution/sampler/
+# fs-nested-struct-arrays-nonconst-nested-array.shader_test
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 71
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpSourceExtension "GL_ARB_gpu_shader5"
+   OpName %main "main"
+   OpName %select "select"
+   OpName %color "color"
+   OpName %S_inner "S_inner"
+   OpMemberName %S_inner 0 "tex"
+   OpMemberName %S_inner 1 "tex2"
+   OpName %S "S"
+   OpMemberName %S 0 "si"
+   OpMemberName %S 1 "tex"
+   OpMemberName %S 2 "final_member"
+   OpName %s "s"
+   OpName %n "n"
+   OpDecorate %select Location 1
+   OpDecorate %color Location 0
+   OpDecorate %s Location 2
+   OpDecorate %n Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%_ptr_UniformConstant_int = OpTypePointer UniformConstant %int
+ %select = OpVariable %_ptr_UniformConstant_int UniformConstant
+  %int_0 = OpConstant %int 0
+   %bool = OpTypeBool
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %19 = OpTypeImage %float 2D 0 0 0 1 Unknown
+ %20 = OpTypeSampledImage %19
+%S_inner = OpTypeStruct %20 %20
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr_S_inner_uint_2 = OpTypeArray %S_inner %uint_2
+%_arr__arr_S_inner_uint_2_uint_2 = OpTypeArray %_arr_S_inner_uint_2 %uint_2
+ %uint_3 = OpConstant %uint 3
+%_arr_20_uint_3 = OpTypeArray %20 %uint_3
+%_arr__arr_20_uint_3_uint_2 = OpTypeArray %_arr_20_uint_3 %uint_2
+%_arr_20_uint_2 = OpTypeArray %20 %uint_2
+  %S = OpTypeStruct %_arr__arr_S_inner_uint_2_uint_2 
%_arr__arr_20_uint_3_uint_2 %_arr_20_uint_2
+%_ptr_UniformConstant_S = OpTypePointer UniformConstant %S
+  %s = OpVariable %_ptr_UniformConstant_S UniformConstant
+  %int_1 = OpConstant %int 1
+  %n = OpVariable %_ptr_UniformConstant_int UniformConstant
+%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20
+%v2float = OpTypeVector %float 2
+ %float_0_75 = OpConstant %float 0.75
+ %float_0_25 = OpConstant %float 0.25
+ %43 = OpConstantComposite %v2float %float_0_75 %float_0_25
+  %int_2 = OpConstant %int 2
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+  %9 = OpLoad %int %select
+ %12 = OpIEqual %bool %9 %int_0
+   OpSelectionMerge %14 None
+   OpBranchConditional %12 %13 %45
+ %13 = OpLabel
+ %35 = OpLoad %int %n
+ %36 = OpLoad %int %n
+ %38 = OpAccessChain %_ptr_UniformConstant_20 %s %int_1 %35 %36
+ %39 = OpLoad %20 %38
+ %44 = OpImageSampleImplicitLod %v4float %39 %43
+   OpStore %color %44
+   OpBranch %14
+ %45 = OpLabel
+ %46 = OpLoad %int %select
+ %47 = OpIEqual %bool %46 %int_1
+   OpSelectionMerge %49 None
+   OpBranchConditional %47 %48 %61
+ %48 = OpLabel
+ %50 = OpLoad %int %n
+ %51 = OpLoad %int %n
+ %52 = OpAccessChain %_ptr_UniformConstant_20 %s %int_0 %50 %51 %int_0
+ %53 = OpLoad %20 %52
+ %54 = OpImageSampleImplicitLod %v4float %53 %43
+ %55 = OpLoad %int %n
+ %56 = OpLoad %int %n
+ %57 = OpAccessChain %_ptr_UniformConstant_20 %s %int_0 %55 %56 %int_1
+   

[Piglit] [PATCH 15/35] arb_gl_spirv: Add tests for sampler2D uniform binding initialisers

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

---
 .../uniform/sampler2d-binding-array.shader_test| 85 ++
 .../uniform/sampler2d-binding.shader_test  | 70 ++
 2 files changed, 155 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding-array.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding-array.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding-array.shader_test
new file mode 100644
index 0..527f1624e
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding-array.shader_test
@@ -0,0 +1,85 @@
+# Test a texture sampler array with a binding initialiser. The
+# initialiser should set the first element and the subsequent ones
+# should increment from there.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 31
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %tex "tex"
+   OpDecorate %color Location 0
+   OpDecorate %tex Location 0
+   OpDecorate %tex DescriptorSet 0
+   OpDecorate %tex Binding 3
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %10 = OpTypeImage %float 2D 0 0 0 1 Unknown
+ %11 = OpTypeSampledImage %10
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr_11_uint_2 = OpTypeArray %11 %uint_2
+%_ptr_UniformConstant__arr_11_uint_2 = OpTypePointer UniformConstant 
%_arr_11_uint_2
+%tex = OpVariable %_ptr_UniformConstant__arr_11_uint_2 UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
+%v2float = OpTypeVector %float 2
+ %float_0_25 = OpConstant %float 0.25
+ %24 = OpConstantComposite %v2float %float_0_25 %float_0_25
+  %int_1 = OpConstant %int 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %20 = OpAccessChain %_ptr_UniformConstant_11 %tex %int_0
+ %21 = OpLoad %11 %20
+ %25 = OpImageSampleImplicitLod %v4float %21 %24
+ %27 = OpAccessChain %_ptr_UniformConstant_11 %tex %int_1
+ %28 = OpLoad %11 %27
+ %29 = OpImageSampleImplicitLod %v4float %28 %24
+ %30 = OpFAdd %v4float %25 %29
+   OpStore %color %30
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 0) out vec4 color;
+
+layout (location = 0, binding = 3) uniform sampler2D tex[2];
+
+void main()
+{
+   color = texture(tex[0], vec2(0.25)) + texture(tex[1], vec2(0.25));
+}
+
+[test]
+clear color 1.0 0.0 0.0 1.0
+clear
+
+texture checkerboard 3 0 (32, 32) (0.02, 0.04, 0.06, 0.08) (0.8, 0.0, 0.0, 1.0)
+texture checkerboard 4 0 (32, 32) (0.10, 0.92, 0.14, 0.16) (0.2, 0.0, 0.0, 1.0)
+
+draw rect -1 -1 2 2
+probe all rgba 0.12 0.96 0.20 0.24
diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding.shader_test
new file mode 100644
index 0..e99aaebbd
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding.shader_test
@@ -0,0 +1,70 @@
+# Test a texture sampler with a binding initialiser
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 19
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %tex "tex"
+   OpDecorate %color Location 0
+   OpDecorate %tex Location 0
+   OpDecorate %tex DescriptorSet 0
+   OpDecorate %tex Binding 3
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTyp

[Piglit] [PATCH 07/35] arb_gl_spirv: add really simple execution test

2018-08-09 Thread Alejandro Piñeiro
Really basic VS-PS pipeline, without uniforms.
---
 .../execution/vs-ps-simple.shader_test | 119 +
 1 file changed, 119 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/vs-ps-simple.shader_test

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
new file mode 100644
index 0..88e38540f
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/vs-ps-simple.shader_test
@@ -0,0 +1,119 @@
+# Test a very simple VS-PS shader pipeline. It doesn't even have
+# uniforms.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 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 450
+
+layout(location = 0) 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; 4
+; Bound: 13
+; 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"
+   OpDecorate %outcolor Location 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
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+ %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_0
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+   OpStore %outcolor %12
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 430
+
+layout(location = 0) out vec4 outcolor;
+
+void main() {
+outcolor = vec4(1.0, 0.0, 0.0, 0.0);
+}
+
+[test]
+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
-- 
2.14.1

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


[Piglit] [PATCH 08/35] arb_gl_spirv: Add a test using specializations

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

---
 .../execution/vs-ps-specializations.shader_test| 181 +
 1 file changed, 181 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/vs-ps-specializations.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/vs-ps-specializations.shader_test 
b/tests/spec/arb_gl_spirv/execution/vs-ps-specializations.shader_test
new file mode 100644
index 0..7b3e7ee81
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/vs-ps-specializations.shader_test
@@ -0,0 +1,181 @@
+# Simple shader test using specialization constants
+
+[require]
+GL >= 3.3
+GLSL >= 4.50
+SPIRV ONLY
+
+[vertex shader specializations]
+uint 0 42
+float 1 0.42
+
+[fragment shader specializations]
+float 5 0.0
+float 6 1.0
+float 7 0.0
+
+[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: 44
+; 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 %magic_number "magic_number"
+   OpName %magic_float "magic_float"
+   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"
+   OpDecorate %magic_number SpecId 0
+   OpDecorate %magic_float SpecId 1
+   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
+   %bool = OpTypeBool
+   %uint = OpTypeInt 32 0
+%magic_number = OpSpecConstant %uint 0
+%uint_42 = OpConstant %uint 42
+ %10 = OpSpecConstantOp %bool INotEqual %magic_number %uint_42
+  %float = OpTypeFloat 32
+%magic_float = OpSpecConstant %float 0
+ %float_0_42 = OpConstant %float 0.42
+ %float_0_01 = OpConstant %float 0.01
+%v4float = OpTypeVector %float 4
+ %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
+%float_0 = OpConstant %float 0
+ %33 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%_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
+ %11 = OpLogicalNot %bool %10
+   OpSelectionMerge %13 None
+   OpBranchConditional %11 %12 %13
+ %12 = OpLabel
+ %17 = OpFSub %float %magic_float %float_0_42
+ %18 = OpExtInst %float %1 FAbs %17
+ %20 = OpFOrdGreaterThan %bool %18 %float_0_01
+   OpBranch %13
+ %13 = OpLabel
+ %21 = OpPhi %bool %10 %5 %20 %12
+   OpSelectionMerge %23 None
+   OpBranchConditional %21 %22 %36
+ %22 = OpLabel
+ %35 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %35 %33
+   OpBranch %23
+ %36 = OpLabel
+ %39 = OpLoad %v4float %piglit_vertex
+ %40 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %40 %39
+   OpBranch %23
+ %23 = OpLabel
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+layout(location = 0) in vec4 piglit_vertex;
+
+layout(constant_id = 0) const uint magic_number = 0;
+layout(constant_id = 1) const float magic_float = 0;
+
+void main()
+{
+if (magic_number != 42 ||
+abs(magic_float - 0.42) > 0.01) {
+gl_Position = vec4(0.0

[Piglit] [PATCH 13/35] arb_gl_spirv: add execution test for multi-dimensional (aoa) uniform

2018-08-09 Thread Alejandro Piñeiro
---
 .../execution/uniform/arrays-of-arrays.shader_test | 77 ++
 1 file changed, 77 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test

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
new file mode 100644
index 0..07e32560b
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test
@@ -0,0 +1,77 @@
+# Array of arrays of uniforms test
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 25
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %u_color "u_color"
+   OpDecorate %color Location 0
+   OpDecorate %u_color Location 10
+   %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_2 = OpConstant %uint 2
+%_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2
+%_arr__arr_v4float_uint_2_uint_2 = OpTypeArray %_arr_v4float_uint_2 %uint_2
+%_ptr_UniformConstant__arr__arr_v4float_uint_2_uint_2 = OpTypePointer 
UniformConstant %_arr__arr_v4float_uint_2_uint_2
+%u_color = OpVariable 
%_ptr_UniformConstant__arr__arr_v4float_uint_2_uint_2 UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %int_1 = OpConstant %int 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %19 = OpAccessChain %_ptr_UniformConstant_v4float %u_color %int_0 
%int_0
+ %20 = OpLoad %v4float %19
+ %22 = OpAccessChain %_ptr_UniformConstant_v4float %u_color %int_1 
%int_1
+ %23 = OpLoad %v4float %22
+ %24 = OpFAdd %v4float %20 %23
+   OpStore %color %24
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 0) out vec4 color;
+
+layout (location = 10) uniform vec4 u_color[2][2];
+
+void main()
+{
+   color = u_color[0][0] + u_color[1][1];
+}
+
+[test]
+clear color 0.2 0.2 0.2 0.2
+clear
+
+uniform vec4 10 0.0 0.1 0.2 0.3
+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
+
+draw rect -1 -1 1 1
+relative probe rect rgb (0.0, 0.0, 0.5, 0.5) (0.1, 0.3, 0.5)
-- 
2.14.1

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


[Piglit] [PATCH 14/35] arb_gl_spirv: uniform sampler2D

2018-08-09 Thread Alejandro Piñeiro
---
 .../execution/uniform/sampler2d.shader_test| 70 ++
 1 file changed, 70 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/sampler2d.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/sampler2d.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d.shader_test
new file mode 100644
index 0..cb0fa50cc
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d.shader_test
@@ -0,0 +1,70 @@
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 19
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %fragColor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %fragColor "fragColor"
+   OpName %tex2D "tex2D"
+   OpDecorate %fragColor Location 0
+   OpDecorate %tex2D Location 0
+   OpDecorate %tex2D DescriptorSet 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %fragColor = OpVariable %_ptr_Output_v4float Output
+ %10 = OpTypeImage %float 2D 0 0 0 1 Unknown
+ %11 = OpTypeSampledImage %10
+%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
+  %tex2D = OpVariable %_ptr_UniformConstant_11 UniformConstant
+%v2float = OpTypeVector %float 2
+ %float_0_25 = OpConstant %float 0.25
+ %17 = OpConstantComposite %v2float %float_0_25 %float_0_25
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %14 = OpLoad %11 %tex2D
+ %18 = OpImageSampleImplicitLod %v4float %14 %17
+   OpStore %fragColor %18
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 0) out vec4 fragColor;
+
+layout (location = 0) uniform sampler2D tex2D;
+
+void main()
+{
+fragColor = texture(tex2D, vec2(0.25));
+}
+
+[test]
+uniform int 0 0
+texture checkerboard 0 0 (32, 32) (0.0, 1.0, 0.0, 1.0) (1.0, 0.0, 0.0, 1.0)
+texparameter 2D min nearest
+texparameter 2D mag nearest
+
+clear
+clear color 0.0 0.0 1.0 0.0
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.14.1

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


[Piglit] [PATCH 02/35] shader_runner/spirv: support loading SPIR-V shaders

2018-08-09 Thread Alejandro Piñeiro
From: Nicolai Hähnle 

This commit add support to load a SPIR-V shader, possible since
ARB_gl_spirv.

The SPIR-V shader is included on the shader_test script on new shader
stage versions ([vertex shader spirv], [fragment shader spirv],
etc). It is not in direct binary format, but in assembly format that
it is assembled using spirv-tools. This is done by calling spirv-as,
that is provided by setting the envvar PIGLIT_SPIRV_AS_BINARY. In this
way we are adding an optional runtime dependency, instead of a build
time one.

Those sections are ignored unless [require] section includes "SPIRV
YES" or "SPIRV ONLY". The only difference between the two is that
"SPIRV ONLY" marks tests that can only be run on SPIR-V mode, as they
are testing specific SPIR-V/ARB_gl_spirv features, like
specializations.

By default if those sections are present, shader_runner will try to
load the SPIR-V shader (run in SPIR-V mode). This commit also adds a
command line option "-glsl", that would try to force run the shader in
GLSL mode even if the SPIR-V shader are available. If "SPIRV ONLY" is
present, and force GLSL is attempted, the test will be skipped.

Note that in GLSL mode, ARB_gl_spirv is not required. For that reason,
we will not add ARB_gl_spirv on the [require] section of the tests. We
check for this extension when assembling the SPIR-V shader.

Signed-off-by: Nicolai Hähnle 
Signed-off-by: Alejandro Piñeiro 
Signed-off-by: Neil Roberts 
---
 tests/shaders/shader_runner.c | 272 --
 1 file changed, 261 insertions(+), 11 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 5b35f6b45..baca0a95c 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -29,6 +29,7 @@
 #include "piglit-util-gl.h"
 #include "piglit-vbo.h"
 #include "piglit-framework-gl/piglit_gl_framework.h"
+#include "piglit-subprocess.h"
 
 #include "shader_runner_gles_workarounds.h"
 #include "parser_utils.h"
@@ -39,7 +40,7 @@
 static struct piglit_gl_test_config current_config;
 
 static void
-get_required_config(const char *script_name,
+get_required_config(const char *script_name, bool spirv,
struct piglit_gl_test_config *config);
 static GLenum
 decode_drawing_mode(const char *mode_str);
@@ -53,10 +54,15 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
config.khr_no_error_support = PIGLIT_NO_ERRORS;
 
-   if (argc > 1)
-   get_required_config(argv[1], &config);
-   else
+   /* 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], false, &config);
+   } else {
config.supports_gl_compat_version = 10;
+   }
 
current_config = config;
 
@@ -143,6 +149,10 @@ static bool vbo_present = false;
 static bool link_ok = false;
 static bool prog_in_use = false;
 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 spirv_replaces_glsl = false;
 static GLchar *prog_err_info = NULL;
 static GLuint vao = 0;
 static GLuint draw_fbo, read_fbo;
@@ -245,14 +255,20 @@ enum states {
requirements,
vertex_shader,
vertex_shader_passthrough,
+   vertex_shader_spirv,
vertex_program,
tess_ctrl_shader,
+   tess_ctrl_shader_spirv,
tess_eval_shader,
+   tess_eval_shader_spirv,
geometry_shader,
+   geometry_shader_spirv,
geometry_layout,
fragment_shader,
+   fragment_shader_spirv,
fragment_program,
compute_shader,
+   compute_shader_spirv,
vertex_data,
test,
 };
@@ -436,6 +452,13 @@ compile_glsl(GLenum target)
GLuint shader = glCreateShader(target);
GLint ok;
 
+   if (spirv_in_use) {
+   printf("Cannot mix SPIRV and non-SPIRV shaders\n");
+   return PIGLIT_FAIL;
+   }
+
+   glsl_in_use = true;
+
switch (target) {
case GL_VERTEX_SHADER:
if (piglit_get_gl_version() < 20 &&
@@ -552,6 +575,7 @@ compile_glsl(GLenum target)
return PIGLIT_PASS;
 }
 
+
 static enum piglit_result
 compile_and_bind_program(GLenum target, const char *start, int len)
 {
@@ -677,6 +701,139 @@ program_binary_save_restore(bool script_command)
return true;
 }
 
+static enum piglit_result
+load_and_specialize_spirv(GLenum target,
+ const char *binary, unsigned size)
+{
+   if (glsl_in_use) {
+   printf("Cannot mix SPIR-V and non-SPIR-V shaders\n");
+  

[Piglit] [PATCH 06/35] shader_runner: debug prints if running on SPIR-V mode.

2018-08-09 Thread Alejandro Piñeiro
Fancy to be sure that shader_runner is trying to run in SPIR-V
mode. Didn't print if it is running on GLSL mode as that is the
default. Initially only some small amount of tests will run on SPIR-V
mode.
---
 tests/shaders/shader_runner.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 570ec2f22..2ff6f9af8 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1273,6 +1273,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
break;
 
case requirements:
+   if (spirv_replaces_glsl) {
+   printf("Running on SPIR-V mode\n");
+   }
break;
 
case vertex_shader:
-- 
2.14.1

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


[Piglit] [PATCH 05/35] shader_runner/spirv: Add support for SPIR-V specializations

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

There can now be extra sections such as the following in the
shader_test file:

[vertex shader specializations]
uint 0 3

These will get passed to glSpecializeShader when compiling the
corresponding shader.
---
 tests/shaders/shader_runner.c | 181 +-
 1 file changed, 180 insertions(+), 1 deletion(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 7ed4958fb..570ec2f22 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -165,6 +165,16 @@ static bool use_get_program_binary = false;
 
 static bool report_subtests = false;
 
+struct specialization_list {
+   size_t buffer_size;
+   size_t n_entries;
+   GLuint *indices;
+   union { GLuint u; GLfloat f; } *values;
+};
+
+static struct specialization_list
+specializations[SHADER_TYPES];
+
 static struct texture_binding {
GLuint obj;
unsigned width;
@@ -258,19 +268,25 @@ enum states {
vertex_shader,
vertex_shader_passthrough,
vertex_shader_spirv,
+   vertex_shader_specializations,
vertex_program,
tess_ctrl_shader,
tess_ctrl_shader_spirv,
+   tess_ctrl_shader_specializations,
tess_eval_shader,
tess_eval_shader_spirv,
+   tess_eval_shader_specializations,
geometry_shader,
geometry_shader_spirv,
+   geometry_shader_specializations,
geometry_layout,
fragment_shader,
fragment_shader_spirv,
+   fragment_shader_specializations,
fragment_program,
compute_shader,
compute_shader_spirv,
+   compute_shader_specializations,
vertex_data,
test,
 };
@@ -719,7 +735,36 @@ load_and_specialize_spirv(GLenum target,
glShaderBinary(1, &shader, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB,
   binary, size);
 
-   glSpecializeShaderARB(shader, "main", 0, NULL, NULL);
+   const struct specialization_list *specs;
+
+   switch (target) {
+   case GL_VERTEX_SHADER:
+   specs = specializations + 0;
+   break;
+   case GL_TESS_CONTROL_SHADER:
+   specs = specializations + 1;
+   break;
+   case GL_TESS_EVALUATION_SHADER:
+   specs = specializations + 2;
+   break;
+   case GL_GEOMETRY_SHADER:
+   specs = specializations + 3;
+   break;
+   case GL_FRAGMENT_SHADER:
+   specs = specializations + 4;
+   break;
+   case GL_COMPUTE_SHADER:
+   specs = specializations + 5;
+   break;
+   default:
+   assert(!"Should not get here.");
+   }
+
+   glSpecializeShaderARB(shader,
+ "main",
+ specs->n_entries,
+ specs->indices,
+ &specs->values[0].u);
 
GLint ok;
glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
@@ -1256,6 +1301,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
shader_string_size = line - shader_string;
return assemble_spirv(GL_VERTEX_SHADER);
 
+   case vertex_shader_specializations:
+   break;
+
case tess_ctrl_shader:
if (spirv_replaces_glsl)
break;
@@ -1268,6 +1316,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
shader_string_size = line - shader_string;
return assemble_spirv(GL_TESS_CONTROL_SHADER);
 
+   case tess_ctrl_shader_specializations:
+   break;
+
case tess_eval_shader:
if (spirv_replaces_glsl)
break;
@@ -1280,6 +1331,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
shader_string_size = line - shader_string;
return assemble_spirv(GL_TESS_EVALUATION_SHADER);
 
+   case tess_eval_shader_specializations:
+   break;
+
case geometry_shader:
if (spirv_replaces_glsl)
break;
@@ -1292,6 +1346,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
shader_string_size = line - shader_string;
return assemble_spirv(GL_GEOMETRY_SHADER);
 
+   case geometry_shader_specializations:
+   break;
+
case geometry_layout:
break;
 
@@ -1313,6 +1370,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
shader_string_size = line - shader_string;
return assemble_spirv(GL_FRAGMENT_SHADER);
 
+   case fragment_shader_specializations:
+   break;
+
case compute_shader:
if (spirv_replaces_glsl)
break;
@@ -1325,6 +1385,9 @@ leave_state(enum states state, const ch

[Piglit] [PATCH 12/35] arb_gl_spirv: add a small test with an array of uniforms

2018-08-09 Thread Alejandro Piñeiro
---
 .../execution/uniform/array.shader_test| 137 +
 1 file changed, 137 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/uniform/array.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
new file mode 100644
index 0..54ac66b42
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
@@ -0,0 +1,137 @@
+# Test a very simple VS-PS shader pipeline with an array of two
+# uniforms with explicit location.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 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 450
+
+layout(location = 0) 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; 4
+; 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
+   OpName %main "main"
+   OpName %outcolor "outcolor"
+   OpName %uniforms "uniforms"
+   OpDecorate %outcolor Location 0
+   OpDecorate %uniforms Location 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
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2
+%_ptr_UniformConstant__arr_v4float_uint_2 = OpTypePointer UniformConstant 
%_arr_v4float_uint_2
+   %uniforms = OpVariable %_ptr_UniformConstant__arr_v4float_uint_2 
UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %int_1 = OpConstant %int 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpAccessChain %_ptr_UniformConstant_v4float %uniforms %int_0
+ %19 = OpLoad %v4float %18
+ %21 = OpAccessChain %_ptr_UniformConstant_v4float %uniform

[Piglit] [PATCH 04/35] shader_runner/spirv: add vertex shader passthrough support on SPIR-V

2018-08-09 Thread Alejandro Piñeiro
Adds a equivalent to the existing GLSL
passthrough_vertex_shader_source, but with an SPIR-V assembly one. As
it is somewhat big, moved to a different header.

An alternative would be kept the assembly on a file, and open it when
required.
---
 tests/shaders/shader_runner.c|  8 +
 tests/shaders/shader_runner_vs_passthrough_spv.h | 45 
 2 files changed, 53 insertions(+)
 create mode 100644 tests/shaders/shader_runner_vs_passthrough_spv.h

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index baca0a95c..7ed4958fb 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -34,6 +34,8 @@
 #include "shader_runner_gles_workarounds.h"
 #include "parser_utils.h"
 
+#include "shader_runner_vs_passthrough_spv.h"
+
 #define DEFAULT_WINDOW_WIDTH 250
 #define DEFAULT_WINDOW_HEIGHT 250
 
@@ -1235,6 +1237,12 @@ leave_state(enum states state, const char *line, const 
char *script_name)
return compile_glsl(GL_VERTEX_SHADER);
 
case vertex_shader_passthrough:
+   if (spirv_replaces_glsl) {
+   shader_string = (char *) 
passthrough_vertex_shader_source_spv;
+   shader_string_size = 
strlen(passthrough_vertex_shader_source_spv);
+
+   return assemble_spirv(GL_VERTEX_SHADER);
+   }
return compile_glsl(GL_VERTEX_SHADER);
 
case vertex_program:
diff --git a/tests/shaders/shader_runner_vs_passthrough_spv.h 
b/tests/shaders/shader_runner_vs_passthrough_spv.h
new file mode 100644
index 0..07bdbfabe
--- /dev/null
+++ b/tests/shaders/shader_runner_vs_passthrough_spv.h
@@ -0,0 +1,45 @@
+static const char passthrough_vertex_shader_source_spv[] =
+   "; SPIR-V\n"
+   "; Version: 1.0\n"
+   "; Generator: Khronos Glslang Reference Front End; 6\n"
+   "; Bound: 24\n"
+   "; Schema: 0\n"
+   "   OpCapability Shader\n"
+   "  %1 = OpExtInstImport \"GLSL.std.450\"\n"
+   "   OpMemoryModel Logical GLSL450\n"
+   "   OpEntryPoint Vertex %main \"main\" %_ %piglit_vertex 
%gl_VertexID %gl_InstanceID\n"
+   "   OpSource GLSL 450\n"
+   "   OpMemberDecorate %gl_PerVertex 0 BuiltIn Position\n"
+   "   OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize\n"
+   "   OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance\n"
+   "   OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance\n"
+   "   OpDecorate %gl_PerVertex Block\n"
+   "   OpDecorate %piglit_vertex Location 0\n"
+   "   OpDecorate %gl_VertexID BuiltIn VertexId\n"
+   "   OpDecorate %gl_InstanceID BuiltIn InstanceId\n"
+   "   %void = OpTypeVoid\n"
+   "  %3 = OpTypeFunction %void\n"
+   "  %float = OpTypeFloat 32\n"
+   "%v4float = OpTypeVector %float 4\n"
+   "   %uint = OpTypeInt 32 0\n"
+   " %uint_1 = OpConstant %uint 1\n"
+   "%_arr_float_uint_1 = OpTypeArray %float %uint_1\n"
+   "%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 
%_arr_float_uint_1\n"
+   "%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex\n"
+   "  %_ = OpVariable %_ptr_Output_gl_PerVertex Output\n"
+   "%int = OpTypeInt 32 1\n"
+   "  %int_0 = OpConstant %int 0\n"
+   "%_ptr_Input_v4float = OpTypePointer Input %v4float\n"
+   "%piglit_vertex = OpVariable %_ptr_Input_v4float Input\n"
+   "%_ptr_Output_v4float = OpTypePointer Output %v4float\n"
+   "%_ptr_Input_int = OpTypePointer Input %int\n"
+   "%gl_VertexID = OpVariable %_ptr_Input_int Input\n"
+   "%gl_InstanceID = OpVariable %_ptr_Input_int Input\n"
+   "   %main = OpFunction %void None %3\n"
+   "  %5 = OpLabel\n"
+   " %18 = OpLoad %v4float %piglit_vertex\n"
+   " %20 = OpAccessChain %_ptr_Output_v4float %_ %int_0\n"
+   "   OpStore %20 %18\n"
+   "   OpReturn\n"
+   "   OpFunctionEnd\n"
+   ;
-- 
2.14.1

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


[Piglit] [PATCH 11/35] arb_gl_spirv: add basic test with two uniforms

2018-08-09 Thread Alejandro Piñeiro
---
 .../execution/uniform/two-uniforms.shader_test | 132 +
 1 file changed, 132 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/two-uniforms.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/two-uniforms.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/two-uniforms.shader_test
new file mode 100644
index 0..5a6b6e7c4
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/two-uniforms.shader_test
@@ -0,0 +1,132 @@
+# Test a very simple VS-PS shader pipeline with two uniforms with
+# explicit location, using glsl as base.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 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 450
+
+layout(location = 0) 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; 4
+; Bound: 16
+; 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 %base "base"
+   OpName %multiplier "multiplier"
+   OpDecorate %outcolor Location 0
+   OpDecorate %base Location 0
+   OpDecorate %multiplier Location 1
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outcolor = OpVariable %_ptr_Output_v4float Output
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+   %base = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+ %multiplier = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %12 = OpLoad %v4float %base
+ %14 = OpLoad %v4float %multiplier
+ %15 = OpFMul %v4float %12 %14
+   OpStore %outcolor %15
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) uniform vec4 base;
+layout(location = 1

[Piglit] [PATCH 09/35] arb_gl_spirv: basic uniform test with names still present

2018-08-09 Thread Alejandro Piñeiro
From: Nicolai Hähnle 

Signed-off-by: Nicolai Hähnle 
Signed-off-by: Neil Roberts 
---
 .../execution/uniform/simple.shader_test   | 124 +
 1 file changed, 124 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/uniform/simple.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/simple.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/simple.shader_test
new file mode 100644
index 0..5f2fdf293
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/simple.shader_test
@@ -0,0 +1,124 @@
+# Test a very simple VS-PS shader pipeline with one uniform
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 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 450
+
+layout(location = 0) 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; 4
+; Bound: 13
+; 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 %color "color"
+   OpDecorate %outcolor Location 0
+   OpDecorate %color Location 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
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %color = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %12 = OpLoad %v4float %color
+   OpStore %outcolor %12
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) uniform vec4 color;
+
+layout(location = 0) out vec4 outcolor;
+
+void main() {
+outcolor = color;
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+uniform vec4 0 0.0 1.0 0.0 1.0
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.14.1

___

[Piglit] [PATCH 10/35] arb_gl_spirv: add basic uniform test without names

2018-08-09 Thread Alejandro Piñeiro
From: Nicolai Hähnle 

The names were removed from the text-format SPIR-V by hand.

Signed-off-by: Alejandro Piñeiro 
Signed-off-by: Nicolai Hähnle 
---
 .../uniform/simple-without-names.shader_test   | 111 +
 1 file changed, 111 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/simple-without-names.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/simple-without-names.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/simple-without-names.shader_test
new file mode 100644
index 0..b9ccd1a40
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/simple-without-names.shader_test
@@ -0,0 +1,111 @@
+# Test a very simple VS-PS shader pipeline with all names removed.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+
+[vertex shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. Then manually 
edited to remove all names.
+; 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
+   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
+
+layout(location = 0) in vec4 piglit_vertex;
+
+void main() {
+   gl_Position = piglit_vertex;
+}
+
+[fragment shader spirv]
+; Automatically generated from the GLSL by shader_test_spirv.py. Then manually 
edited to remove all names.
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 4
+; Bound: 13
+; 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 %color Location 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
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %color = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %12 = OpLoad %v4float %color
+   OpStore %outcolor %12
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) uniform vec4 color;
+
+layout(location = 0) out vec4 outcolor;
+
+void main() {
+outcolor = color;
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+uniform vec4 0 0.0 1.0 0.0 1.0
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.14.1

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


[Piglit] [PATCH 03/35] framework: add --glsl option

2018-08-09 Thread Alejandro Piñeiro
So when executing shader tests, they will be executed with -glsl. This
is the force GLSL mode, that is only relevant if the shader test
includes SPIR-V shaders.

So for example:
./piglit run tests/shader.py -t ARB_gl_spirv --glsl results/results

Will try to run all the shader tests for ARB_gl_spirv using GLSL
instead of the default (for that extension) SPIR-V.
---
 framework/options.py  |  1 +
 framework/programs/run.py |  6 ++
 framework/test/shader_test.py | 10 --
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/framework/options.py b/framework/options.py
index f5f32af78..0500640b2 100644
--- a/framework/options.py
+++ b/framework/options.py
@@ -59,6 +59,7 @@ class _Options(object):  # pylint: 
disable=too-many-instance-attributes
 self.deqp_mustpass = False
 self.process_isolation = True
 self.jobs = None
+self.force_glsl = 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 8011a2966..23cb5e188 100644
--- a/framework/programs/run.py
+++ b/framework/programs/run.py
@@ -238,6 +238,10 @@ 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")
+
 return parser.parse_args(unparsed)
 
 
@@ -316,6 +320,7 @@ def run(input_):
 options.OPTIONS.deqp_mustpass = args.deqp_mustpass
 options.OPTIONS.process_isolation = args.process_isolation
 options.OPTIONS.jobs = args.jobs
+options.OPTIONS.force_glsl = args.glsl
 
 # Set the platform to pass to waffle
 options.OPTIONS.env['PIGLIT_PLATFORM'] = args.platform
@@ -430,6 +435,7 @@ def resume(input_):
 options.OPTIONS.process_isolation = results.options['process_isolation']
 options.OPTIONS.jobs = args.jobs
 options.OPTIONS.no_retry = args.no_retry
+options.OPTIONS.force_glsl = results.options['glsl']
 
 core.get_config(args.config_file)
 
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index de3e92f4b..40fdc3c09 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -32,6 +32,7 @@ import re
 
 from framework import exceptions
 from framework import status
+from framework import options
 from .base import ReducedProcessMixin, TestIsSkip
 from .opengl import FastSkipMixin, FastSkip
 from .piglit_test import PiglitBaseTest, ROOT_DIR
@@ -188,10 +189,15 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
 
 @PiglitBaseTest.command.getter
 def command(self):
-""" Add -auto and -fbo to the test command """
+""" Add -auto, -fbo and -glsl (if needed) to the test command """
+
 command = super(ShaderTest, self).command
 shaderfile = os.path.join(ROOT_DIR, command[1])
-return [command[0]] + [shaderfile, '-auto', '-fbo']
+
+if options.OPTIONS.force_glsl:
+return [command[0]] + [shaderfile, '-auto', '-fbo', '-glsl']
+else:
+return [command[0]] + [shaderfile, '-auto', '-fbo']
 
 @command.setter
 def command(self, new):
-- 
2.14.1

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


[Piglit] [PATCH 01/35] util: Add a utility to stream data through an external process

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

The data is given as a buffer which is streamed through the standard
in of the child process. The standard output is captured into a
buffer.
---
 tests/util/CMakeLists.txt  |   1 +
 tests/util/piglit-subprocess.c | 207 +
 tests/util/piglit-subprocess.h |  44 +
 3 files changed, 252 insertions(+)
 create mode 100644 tests/util/piglit-subprocess.c
 create mode 100644 tests/util/piglit-subprocess.h

diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index 3fa67d7f6..e083761d1 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -35,6 +35,7 @@ set(UTIL_INCLUDES
 set(UTIL_SOURCES
piglit-log.c
piglit-util.c
+   piglit-subprocess.c
)
 
 set(UTIL_GL_INCLUDES
diff --git a/tests/util/piglit-subprocess.c b/tests/util/piglit-subprocess.c
new file mode 100644
index 0..4e9ee1a14
--- /dev/null
+++ b/tests/util/piglit-subprocess.c
@@ -0,0 +1,207 @@
+/*
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "piglit-subprocess.h"
+
+#include 
+
+#ifndef _WIN32
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static bool
+stream_data(pid_t pid,
+   int to_child,
+   int from_child,
+   size_t input_size,
+   const uint8_t *input,
+   size_t *output_size,
+   uint8_t **output)
+{
+   bool ret = true;
+   size_t buf_size = 128;
+
+   *output = malloc(buf_size);
+   *output_size = 0;
+
+   while (true) {
+   int n_pollfds = 0;
+   struct pollfd pollfds[2];
+
+   if (to_child != -1) {
+   pollfds[n_pollfds].fd = to_child;
+   pollfds[n_pollfds].events = POLLOUT;
+   pollfds[n_pollfds].revents = 0;
+   n_pollfds++;
+   }
+
+   pollfds[n_pollfds].fd = from_child;
+   pollfds[n_pollfds].events = POLLIN;
+   pollfds[n_pollfds].revents = 0;
+   n_pollfds++;
+
+   int res = poll(pollfds, n_pollfds, INT_MAX);
+
+   if (res < 0) {
+   if (errno == EINTR)
+   continue;
+   fprintf(stderr, "poll: %s\n", strerror(errno));
+   ret = false;
+   goto done;
+   }
+
+   for (int i = 0; i < n_pollfds; i++) {
+   if (pollfds[i].revents &
+   ~(POLLIN | POLLOUT | POLLHUP)) {
+   ret = false;
+   goto done;
+   }
+
+   if (pollfds[i].fd == from_child &&
+   pollfds[i].revents) {
+   if (buf_size - *output_size < 128) {
+   buf_size *=2;
+   *output = realloc(*output, buf_size);
+   }
+   res = read(from_child,
+  *output + *output_size,
+  buf_size - *output_size);
+   if (res < 0) {
+   if (errno != EINTR) {
+   ret = false;
+   goto done;
+   }
+   } else if (res == 0) {
+   if (to_child != -1)
+   ret = false;
+   goto done;
+   } else {
+   *output_size += res;
+  

[Piglit] [PATCH 00/35] ARB_gl_spirv: all tests so far

2018-08-09 Thread Alejandro Piñeiro
Hi,

due the series on Mesa that I send today, we are adding some
ARB_gl_spirv tests (doubles). As the previous series were not
reviewed, Im sending all the patches. So this series is the merge of
all the pending ARB_gl_spirv series already sent, updates on the xfb
tests, some new double tests, and rebased against a recent master.

As mentioned previously, most of the patches are "vanilla", and the
one that could lead to some debate, as it adds a new runtime
dependency, is the following one:
  [PATCH 02/35] shader_runner/spirv: support loading SPIR-V shaders

The full series can be found here:
https://github.com/Igalia/piglit/tree/arb_gl_spirv-series4-misc-v1


Alejandro Piñeiro (12):
  framework: add --glsl option
  shader_runner/spirv: add vertex shader passthrough support on SPIR-V
  shader_runner: debug prints if running on SPIR-V mode.
  arb_gl_spirv: add really simple execution test
  arb_gl_spirv: add basic test with two uniforms
  arb_gl_spirv: add a small test with an array of uniforms
  arb_gl_spirv: add execution test for multi-dimensional (aoa) uniform
  arb_gl_spirv: uniform sampler2D
  arb_gl_spirv: add two linking tests for uniform multisample images
  arb_gl_spirv: add test that mixes atomic counters with a normal
uniform
  util: Add utilities to handle shader_test files
  arb_gl_spirv: adding basic va64 test

Antia Puentes (3):
  shader_runner: add command 'probe atomic counter buffer'
  arb_gl_spirv: add tests for atomic counter operations in FS
  arb_gl_spirv: add tests for atomic counter operations in CS

Neil Roberts (17):
  util: Add a utility to stream data through an external process
  shader_runner/spirv: Add support for SPIR-V specializations
  arb_gl_spirv: Add a test using specializations
  arb_gl_spirv: Add tests for sampler2D uniform binding initialisers
  arb_gl_spirv: Add a test for a sampler within a struct
  arb_gl_spirv: Add a test for nonconst array of sampler structs
  arb_gl_spirv: Add 4 tests for uniform initializers
  arb_gl_spirv: Add a test for non-sequential explicit uniform locations
  arb_gl_spirv: Add a test for a struct uniform
  arb_gl_spirv: Add a test for a uniform struct with struct members
  arb_gl_spirv: Add a test for an array of structs uniform
  arb_gl_spirv: Add a fiddly test for uniform index calculation
  util: Add a utility to assemble SPIR-V sources
  arb_gpu_shader5: Add support for testing spirv with XFB streams
  arb_enhanced_layouts: Test XFB layout qualifiers via SPIR-V
  arb_enhanced_layouts: Test doubles
  util/vbo: Accept integer attribute names

Nicolai Hähnle (3):
  shader_runner/spirv: support loading SPIR-V shaders
  arb_gl_spirv: basic uniform test with names still present
  arb_gl_spirv: add basic uniform test without names

 framework/options.py   |   1 +
 framework/programs/run.py  |   6 +
 framework/test/shader_test.py  |  10 +-
 tests/opengl.py|  23 +-
 tests/shaders/shader_runner.c  | 452 -
 tests/shaders/shader_runner_vs_passthrough_spv.h   |  45 ++
 .../shader_test/gs_text_two_sets_tmpl.shader_test  |  35 ++
 .../shader_test/vs_double.shader_test  | 102 +
 .../shader_test/vs_passthru.shader_test|  53 +++
 .../shader_test/vs_two_sets.shader_test| 125 ++
 .../shader_test/vs_two_sets_ifc.shader_test| 128 ++
 .../shader_test/vs_two_sets_named_ifc.shader_test  | 125 ++
 .../shader_test/vs_two_sets_struct.shader_test | 134 ++
 .../transform-feedback-layout-qualifiers.c | 395 +++---
 .../execution/uniform/array.shader_test| 137 +++
 .../execution/uniform/arrays-of-arrays.shader_test |  77 
 .../uniform/atomic-uint-aoa-cs.shader_test | 249 
 .../uniform/atomic-uint-aoa-fs.shader_test | 222 ++
 .../uniform/atomic-uint-array-cs.shader_test   | 239 +++
 .../uniform/atomic-uint-array-fs.shader_test   | 211 ++
 .../execution/uniform/atomic-uint-cs.shader_test   | 244 +++
 .../execution/uniform/atomic-uint-fs.shader_runner | 219 ++
 ...ic-uint-mixing-with-normal-uniforms.shader_test | 197 +
 .../uniform/atomic-uint-several-slots.shader_test  | 197 +
 .../execution/uniform/embedded-structs.shader_test | 151 +++
 .../uniform/index-matches-location.shader_test | 100 +
 .../uniform/initializer-complex.shader_test| 180 
 .../uniform/initializer-dvec4.shader_test  |  68 
 .../uniform/initializer-mat4x3.shader_test |  83 
 .../execution/uniform/initializer.shader_test  |  66 +++
 .../uniform/nonsequential-locations.shader_test|  69 
 .../uniform/sampler2d-binding-array.shader_test|  85 
 .../uniform/sampler2d-binding.shader_test  |  70 
 .../sampler2d-nonconst-nested-array.

Re: [Piglit] [PATCH 2/4] util: Add utilities to handle shader_test files

2018-08-09 Thread Alejandro Piñeiro


On 09/08/18 13:19, Antia Puentes wrote:
> Hi Alejandro,
>
>
> On 20/07/18 17:16, Alejandro Piñeiro wrote:
>> +
>> +bool
>> +piglit_load_source_from_shader_test(const char *filename,
>> +    GLenum shader_type,
>> +    bool spirv,
>> +    char **output_source,
>> +    unsigned *output_source_size)
>> +{
>> +    char group_name[4096];
>> +    char *source = NULL;
>> +    unsigned text_size;
>> +    char *line = NULL;
>> +    char *first_line = NULL;
>> +
>> +    group_name_for_stage(shader_type, spirv, group_name);
>> +
>> +    char *text = piglit_load_text_file(filename, &text_size);
> There is a memory leak, you forgot to free "text" before returning.

Thanks. I plan to send a new version of the pending ARB_gl_spirv series
today. I will include a new version of this patch with that leak fixed.

>
>> +    line = text;
>> +
>> +    if (line == NULL) {
>> +    fprintf(stderr, "Could not read file \"%s\"\n", filename);
>> +    return false;
>> +    }
>> +
>> +    while (line[0] != '\0') {
>> +    if (line[0] == '[' && first_line != NULL) {
>> +    break;
>> +    }
>> +
>> +    if (line[0] == '[' && first_line == NULL) {
>> +    if (parse_str(line, group_name, NULL)) {
>> +    first_line = strchrnul(line, '\n');
>> +    if (first_line[0] != '\0')
>> +    first_line++;
>> +    }
>> +    }
>> +
>> +    line = strchrnul(line, '\n');
>> +    if (line[0] != '\0')
>> +    line++;
>> +    }
>> +
>> +    if (first_line == NULL) {
>> +    fprintf(stderr, "Could not find groupname \"%s\" on file
>> \"%s\"\n",
>> +    group_name, filename);
>> +    return false;
>> +    }
>> +
>> +    text_size = line - first_line + 1;
>> +    source = malloc(sizeof(char*) * text_size);
>> +    snprintf(source, line - first_line + 1, "%s", first_line);
>> +
>> +    if (output_source)
>> +    *output_source = source;
>> +
>> +    if (output_source_size)
>> +    *output_source_size = text_size;
>> +
>> +    return true;
>> +}
>>
> Regards.
>
>
>

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


Re: [Piglit] [PATCH] ext_texture_norm16-render: add more API coverage

2018-07-24 Thread Alejandro Piñeiro
Reviewed-by: Alejandro Piñeiro 


On 23/07/18 14:16, Tapani Pälli wrote:
> Add tests for glRenderbufferStorage and glCopyTexImage2D.
>
> Signed-off-by: Tapani Pälli 
> ---
>  tests/spec/ext_texture_norm16/render.c | 53 
> --
>  1 file changed, 50 insertions(+), 3 deletions(-)
>
> diff --git a/tests/spec/ext_texture_norm16/render.c 
> b/tests/spec/ext_texture_norm16/render.c
> index a6011e3f7..46cc7c91b 100644
> --- a/tests/spec/ext_texture_norm16/render.c
> +++ b/tests/spec/ext_texture_norm16/render.c
> @@ -173,14 +173,12 @@ generate_data(const struct fmt_test *test)
>  }
>  
>  static GLuint
> -create_texture(const struct fmt_test *test)
> +create_empty_texture()
>  {
>   GLuint tex;
>   glGenTextures(1, &tex);
>   glBindTexture(GL_TEXTURE_2D, tex);
>  
> - generate_data(test);
> -
>   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
>   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
>   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
> @@ -189,6 +187,25 @@ create_texture(const struct fmt_test *test)
>   return tex;
>  }
>  
> +static GLuint
> +create_texture(const struct fmt_test *test)
> +{
> + GLuint tex = create_empty_texture();
> + generate_data(test);
> + return tex;
> +}
> +
> +static GLuint
> +create_rbo(const struct fmt_test *test)
> +{
> + GLuint rbo;
> + glGenRenderbuffers(1, &rbo);
> + glBindRenderbuffer(GL_RENDERBUFFER, rbo);
> + glRenderbufferStorage(GL_RENDERBUFFER, test->iformat, piglit_width,
> +   piglit_height);
> + return rbo;
> +}
> +
>  static GLuint
>  create_fbo(const struct fmt_test *test, GLuint *tex)
>  {
> @@ -362,6 +379,21 @@ test_format(const struct fmt_test *test)
>   return pass;
>   }
>  
> + /* Test glRenderbufferStorage. */
> + GLuint rbo = create_rbo(test);
> + if (!rbo || !piglit_check_gl_error(GL_NO_ERROR)) {
> + piglit_report_subtest_result(PIGLIT_FAIL,
> +  "format 0x%x RBO test",
> +  test->iformat);
> + pass &= false;
> + } else {
> + piglit_report_subtest_result(PIGLIT_PASS,
> +  "format 0x%x RBO test",
> +  test->iformat);
> + }
> + glDeleteRenderbuffers(1, &rbo);
> +
> + /* Create framebuffer object. */
>   GLuint fbo_tex;
>   const GLuint fbo = create_fbo(test, &fbo_tex);
>  
> @@ -375,6 +407,21 @@ test_format(const struct fmt_test *test)
>  
>   render_texture(texture, GL_TEXTURE_2D, fbo);
>  
> + /* Test glCopyTexImage2D by copying current fbo content to
> +  * a texture, rendering copy back to fbo and verifying fbo contents.
> +  */
> + GLuint tmp_tex = create_empty_texture();
> + glCopyTexImage2D(GL_TEXTURE_2D, 0, test->iformat, 0, 0, piglit_width,
> +  piglit_height, 0);
> +
> + render_texture(tmp_tex, GL_TEXTURE_2D, fbo);
> +
> + /* If format can be read, verify contents. */
> + if (test->can_read)
> + pass &= verify_contents(test);
> +
> + glDeleteTextures(1, &tmp_tex);
> +
>   /* If GL_EXT_copy_image is supported then create another
>* texture, copy contents and render result to fbo.
>*/

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


[Piglit] [PATCH 4/4] arb_enhanced_layouts: Test XFB layout qualifiers via SPIR-V

2018-07-20 Thread Alejandro Piñeiro
From: Neil Roberts 

v2: use shader_test file with the spirv assembly, instead of include
two SPIRV binaries (Alejandro Piñeiro)

Signed-off-by: Neil Roberts 
Signed-off-by: Alejandro Piñeiro 
---
 tests/opengl.py|  22 +-
 .../shader_test/gs_text_two_sets_tmpl.shader_test  |  32 ++
 .../shader_test/vs_passthru.shader_test|  50 
 .../shader_test/vs_two_sets.shader_test| 122 
 .../shader_test/vs_two_sets_ifc.shader_test| 125 
 .../shader_test/vs_two_sets_named_ifc.shader_test  | 122 
 .../shader_test/vs_two_sets_struct.shader_test | 131 +
 .../transform-feedback-layout-qualifiers.c | 322 +++--
 8 files changed, 766 insertions(+), 160 deletions(-)
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/gs_text_two_sets_tmpl.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_passthru.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets_ifc.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets_named_ifc.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets_struct.shader_test

diff --git a/tests/opengl.py b/tests/opengl.py
index e4c49e72a..99d17037f 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -2288,18 +2288,16 @@ with profile.test_list.group_manager(
'explicit-offset-bufferstorage')
 g(['arb_enhanced_layouts-gs-stream-location-aliasing'],
'gs-stream-location-aliasing')
-g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', 'vs'],
-  'arb_enhanced_layouts-transform-feedback-layout-qualifiers_vs',
-  run_concurrent=False)
-g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', 'vs_ifc'],
-  'arb_enhanced_layouts-transform-feedback-layout-qualifiers_vs_interface',
-  run_concurrent=False)
-g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', 
'vs_named_ifc'],
-  
'arb_enhanced_layouts-transform-feedback-layout-qualifiers_vs_named_interface',
-  run_concurrent=False)
-g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', 
'vs_struct'],
-  'arb_enhanced_layouts-transform-feedback-layout-qualifiers_vs_struct',
-  run_concurrent=False)
+for test in ['vs', 'vs_ifc', 'vs_named_ifc', 'vs_struct']:
+g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', test],
+  'arb_enhanced_layouts-transform-feedback-layout-qualifiers_' + test,
+  run_concurrent=False)
+g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers',
+   test,
+   'spirv'],
+  'arb_enhanced_layouts-transform-feedback-layout-qualifiers_' +
+  test + '_spirv',
+  run_concurrent=False)
 g(['arb_enhanced_layouts-transform-feedback-layout-qualifiers', 'gs'],
   'arb_enhanced_layouts-transform-feedback-layout-qualifiers_gs',
   run_concurrent=False)
diff --git 
a/tests/spec/arb_enhanced_layouts/shader_test/gs_text_two_sets_tmpl.shader_test 
b/tests/spec/arb_enhanced_layouts/shader_test/gs_text_two_sets_tmpl.shader_test
new file mode 100644
index 0..48e079efe
--- /dev/null
+++ 
b/tests/spec/arb_enhanced_layouts/shader_test/gs_text_two_sets_tmpl.shader_test
@@ -0,0 +1,32 @@
+[geometry shader]
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_gpu_shader5 : enable
+#define INVOCATION_MAX_N %u
+
+layout(points, invocations = INVOCATION_MAX_N) in;
+layout(points, max_vertices = 1) out;
+
+layout(xfb_offset = 0) out float x1_out;
+layout(xfb_offset = 4) out vec2 x2_out;
+layout(xfb_offset = 12) out vec3 x3_out;
+out vec3 not_captured1;
+layout(xfb_buffer = 2) out;
+layout(xfb_offset = 0) out float y1_out;
+layout(xfb_offset = 4) out vec4 y2_out;
+layout(xfb_buffer = 2) out vec3 not_captured2;
+
+void main() {
+   gl_Position = gl_in[0].gl_Position;
+   x1_out = 1.0 + gl_InvocationID;
+   x2_out = vec2(2.0 + gl_InvocationID, 3.0 + gl_InvocationID);
+   x3_out = vec3(4.0 + gl_InvocationID, 5.0 + gl_InvocationID,
+ 6.0 + gl_InvocationID);
+   y1_out = 7.0 + gl_InvocationID;
+   y2_out = vec4(8.0 + gl_InvocationID, 9.0 + gl_InvocationID,
+ 10.0 + gl_InvocationID, 11.0 + gl_InvocationID);
+   not_captured1 = vec3(1.0);
+   not_captured2 = vec3(1.0);
+   EmitVertex();
+   EndPrimitive();
+}
diff --git 
a/tests/spec/arb_enhanced_layouts/shader_test/vs_passthru.shader_test 
b/tests/spec/arb_enhanced_layouts/shader_test/vs_passthru.shader_test
new file mod

[Piglit] [PATCH 3/4] arb_gpu_shader5: Add support for testing spirv with XFB streams

2018-07-20 Thread Alejandro Piñeiro
From: Neil Roberts 

v2: use shader_test file with the spirv assembly, instead of include
two SPIRV binaries (Alejandro Piñeiro)

Signed-off-by: Neil Roberts 
Signed-off-by: Alejandro Piñeiro 
---
 tests/opengl.py|   1 +
 .../xfb_streams_without_invocations.shader_test| 194 +
 .../execution/xfb-streams-without-invocations.c| 135 ++
 3 files changed, 297 insertions(+), 33 deletions(-)
 create mode 100644 
tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test

diff --git a/tests/opengl.py b/tests/opengl.py
index 3109a5e34..e4c49e72a 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -1951,6 +1951,7 @@ with profile.test_list.group_manager(
 g(['arb_gpu_shader5-emitstreamvertex_stream_too_large'])
 g(['arb_gpu_shader5-tf-wrong-stream-value'])
 g(['arb_gpu_shader5-xfb-streams-without-invocations'])
+g(['arb_gpu_shader5-xfb-streams-without-invocations', 'spirv'])
 g(['arb_gpu_shader5-emitstreamvertex_nodraw'])
 g(['arb_gpu_shader5-interpolateAtCentroid'])
 g(['arb_gpu_shader5-interpolateAtCentroid-packing'])
diff --git 
a/tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
 
b/tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
new file mode 100644
index 0..ab798c022
--- /dev/null
+++ 
b/tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
@@ -0,0 +1,194 @@
+[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: 23
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Vertex %main "main" %_ %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 %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
+%float_0 = OpConstant %float 0
+ %17 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
+%_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
+ %19 = OpAccessChain %_ptr_Output_v4float %_ %int_0
+   OpStore %19 %17
+   OpReturn
+   OpFunctionEnd
+
+[vertex shader]
+#version 450
+
+void main() {
+ gl_Position = vec4(0.0);
+}
+
+
+[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
+   OpCapability TransformFeedback
+   OpCapability GeometryStreams
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Geometry %main "main" %_ %gl_in %stream0_0_out 
%stream2_0_out %stream2_1_out %stream1_0_out
+   OpExecutionMode %main Xfb
+   OpExecutionMode %main InputPoints
+   OpExecutionMode %main Invocations 1
+   OpExecutionMode %main OutputPoints
+   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
+   OpDecorate %gl_PerVertex Stream 0
+  

[Piglit] [PATCH 2/4] util: Add utilities to handle shader_test files

2018-07-20 Thread Alejandro Piñeiro
---
 tests/util/CMakeLists.txt   |   1 +
 tests/util/piglit-shader-test.c | 154 
 tests/util/piglit-shader-test.h |  43 +++
 3 files changed, 198 insertions(+)
 create mode 100644 tests/util/piglit-shader-test.c
 create mode 100644 tests/util/piglit-shader-test.h

diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index e083761d1..a5f080156 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -59,6 +59,7 @@ set(UTIL_GL_SOURCES
piglit-framework-gl.c
piglit-framework-gl/piglit_gl_framework.c
piglit-shader.c
+   piglit-shader-test.c
piglit_ktx.c
rgb9e5.c
r11g11b10f.c
diff --git a/tests/util/piglit-shader-test.c b/tests/util/piglit-shader-test.c
new file mode 100644
index 0..ba76113b1
--- /dev/null
+++ b/tests/util/piglit-shader-test.c
@@ -0,0 +1,154 @@
+/*
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "piglit-shader-test.h"
+
+#include 
+
+/* FIXME: C&P from parse_utils, that is local to shader_runner. At
+ * this point it is not worth to move all parse_utils to a common
+ * library. Perhaps in the future if we start to use all the utils
+ */
+bool
+parse_whitespace(const char *s, const char **rest)
+{
+   const char *end = s;
+   for (; *end && *end != '\n' && isspace(*end); end++);
+
+   if (rest)
+   *rest = end;
+
+   return end != s;
+}
+
+/* FIXME: C&P from parse_utils, that is local to shader_runner. At
+ * this point it is not worth to move all parse_utils to a common
+ * library. Perhaps in the future if we start to use all the utils
+ */
+bool
+parse_str(const char *s, const char *lit, const char **rest)
+{
+   const char *t;
+   parse_whitespace(s, &t);
+   const bool ret = strncmp(t, lit, strlen(lit)) == 0;
+
+   if (rest)
+   *rest = (ret ? t + strlen(lit) : s);
+
+   return ret;
+}
+
+static void
+group_name_for_stage(GLenum shader_type,
+bool spirv,
+char *group_name)
+{
+   char *stage_name;
+
+   switch(shader_type) {
+   case GL_VERTEX_SHADER:
+   stage_name = "vertex";
+   break;
+   case GL_FRAGMENT_SHADER:
+   stage_name = "fragment";
+   break;
+   case GL_TESS_CONTROL_SHADER:
+   stage_name = "tessellation control";
+   break;
+   case GL_TESS_EVALUATION_SHADER:
+   stage_name = "tessellation evaluation";
+   break;
+   case GL_GEOMETRY_SHADER:
+   stage_name = "geometry";
+   break;
+   case GL_COMPUTE_SHADER:
+   stage_name = "compute";
+   break;
+   default: stage_name = "error";
+   }
+
+   if (!spirv)
+   sprintf(group_name, "[%s shader]", stage_name);
+   else
+   sprintf(group_name, "[%s shader spirv]", stage_name);
+}
+
+bool
+piglit_load_source_from_shader_test(const char *filename,
+   GLenum shader_type,
+   bool spirv,
+   char **output_source,
+   unsigned *output_source_size)
+{
+   char group_name[4096];
+   char *source = NULL;
+   unsigned text_size;
+   char *line = NULL;
+   char *first_line = NULL;
+
+   group_name_for_stage(shader_type, spirv, group_name);
+
+   char *text = piglit_load_text_file(filename, &text_size);
+   line = text;
+
+   if (line == NULL) {
+   fprintf(stderr, "Could not read file \"%s\"\n", filename);
+   return false;
+   }
+
+   while (line[0] != '\0') {
+   if (line[0] == '[' && first_line != NULL) {
+   break;
+   }

[Piglit] [PATCH 1/4] util: Add a utility to assemble SPIR-V sources

2018-07-20 Thread Alejandro Piñeiro
From: Neil Roberts 

Adds piglit_assemble_spirv which invokes spirv-as to assemble a SPIR-V
source. The function is based on a static helper function that was in
shader_runner.
---
 tests/shaders/shader_runner.c | 45 ++-
 tests/util/piglit-shader.c| 37 +++
 tests/util/piglit-shader.h|  3 +++
 3 files changed, 46 insertions(+), 39 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 63cffdc19..00f13ec70 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -720,8 +720,8 @@ program_binary_save_restore(bool script_command)
 }
 
 static enum piglit_result
-load_and_specialize_spirv(GLenum target,
- const char *binary, unsigned size)
+specialize_spirv(GLenum target,
+GLuint shader)
 {
if (glsl_in_use) {
printf("Cannot mix SPIR-V and non-SPIR-V shaders\n");
@@ -730,11 +730,6 @@ load_and_specialize_spirv(GLenum target,
 
spirv_in_use = true;
 
-   GLuint shader = glCreateShader(target);
-
-   glShaderBinary(1, &shader, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB,
-  binary, size);
-
const struct specialization_list *specs;
 
switch (target) {
@@ -822,15 +817,6 @@ assemble_spirv(GLenum target)
return PIGLIT_SKIP;
}
 
-   char *arguments[] = {
-   getenv("PIGLIT_SPIRV_AS_BINARY"),
-   "-o", "-",
-   NULL
-   };
-
-   if (arguments[0] == NULL)
-   arguments[0] = "spirv-as";
-
/* Strip comments from the source */
char *stripped_source = malloc(shader_string_size);
char *p = stripped_source;
@@ -853,32 +839,13 @@ assemble_spirv(GLenum target)
}
}
 
-   uint8_t *binary_source;
-   size_t binary_source_length;
-   bool res = piglit_subprocess(arguments,
-p - stripped_source,
-(const uint8_t *)
-stripped_source,
-&binary_source_length,
-&binary_source);
+   GLuint shader = piglit_assemble_spirv(target,
+ p - stripped_source,
+ stripped_source);
 
free(stripped_source);
 
-   if (!res) {
-   fprintf(stderr, "spirv-as failed\n");
-   return PIGLIT_FAIL;
-   }
-
-   enum piglit_result ret;
-
-   ret = load_and_specialize_spirv(target,
-   (const char *)
-   binary_source,
-   binary_source_length);
-
-   free(binary_source);
-
-   return ret;
+   return specialize_spirv(target, shader);
 }
 
 static enum piglit_result
diff --git a/tests/util/piglit-shader.c b/tests/util/piglit-shader.c
index 7ac5df14d..1938b1576 100644
--- a/tests/util/piglit-shader.c
+++ b/tests/util/piglit-shader.c
@@ -24,6 +24,7 @@
 #include 
 
 #include "piglit-util-gl.h"
+#include "piglit-subprocess.h"
 
 void piglit_get_glsl_version(bool *es, int* major, int* minor)
 {
@@ -464,6 +465,42 @@ piglit_build_simple_program_multiple_shaders(GLenum 
target1,
return prog;
 }
 
+GLuint
+piglit_assemble_spirv(GLenum target,
+ size_t source_length,
+ const char *source)
+{
+   char *arguments[] = {
+   getenv("PIGLIT_SPIRV_AS_BINARY"),
+   "-o", "-",
+   NULL
+   };
+
+   if (arguments[0] == NULL)
+   arguments[0] = "spirv-as";
+
+   uint8_t *binary_source;
+   size_t binary_source_length;
+   bool res = piglit_subprocess(arguments,
+source_length,
+(const uint8_t *) source,
+&binary_source_length,
+&binary_source);
+
+   if (!res) {
+   fprintf(stderr, "spirv-as failed\n");
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   GLuint shader = glCreateShader(target);
+   glShaderBinary(1, &shader, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB,
+  binary_source, binary_source_length);
+
+   free(binary_source);
+
+   return shader;
+}
+
 void
 piglit_require_GLSL(void)
 {
diff --git a/tests/util/piglit-shader.h b/tests/util/piglit-shader.h
index 9208451a8..aa29d0994 100644
--- a/tests/util/piglit-shader.h
+++ b/tests/util/piglit-shader.h
@@ -49,6 +49,9 @@ GLint 
piglit_build_simple_program_unlinked_multiple_shaders(GLenum target1,
 GLint piglit_build_simple_program_multiple_shaders(GLenum target1,
  const char *source1,
  ...);
+GLui

[Piglit] [PATCH 0/4] ARB_gl_spirv: xfb tests

2018-07-20 Thread Alejandro Piñeiro
Hi,

this is the third series that includes tests for the ARB_gl_spirv
extension. Note that this depends on the pending-to-review first
series (basics+uniforms) and second (atomic counters). The three
series are included on the following branch:

https://github.com/Igalia/piglit/tree/arb_gl_spirv-series3-xfb-v1

It is worth to note that this series introduces a change on the tests
we are including. Until now all the tests were tests in shader_test
format run by shader_runner. But right now shader_runner doesn't have
too much support for transform feedback/geometry streams testing, and
adding support on a generic way would be far from trivial.

For that reason we preferred to modify existing XFB/Geometry Stream
tests, but adding the capability to load GLSL and SPIR-V shaders. In
order to do that, we moved the GLSL code they were using to a
shader_test, that also includes now the SPIR-V, and added utilities to
load shaders from a shader_test, and to assemble the SPIR-V from the
assembler format. The latter is refactored from shader_runner.

So from now we would have more that one consumer of the shader_test
format: the generic shader_runner, and some custom one used for really
specific features.


Alejandro Piñeiro (1):
  util: Add utilities to handle shader_test files

Neil Roberts (3):
  util: Add a utility to assemble SPIR-V sources
  arb_gpu_shader5: Add support for testing spirv with XFB streams
  arb_enhanced_layouts: Test XFB layout qualifiers via SPIR-V

 tests/opengl.py|  23 +-
 tests/shaders/shader_runner.c  |  45 +--
 .../shader_test/gs_text_two_sets_tmpl.shader_test  |  32 ++
 .../shader_test/vs_passthru.shader_test|  50 
 .../shader_test/vs_two_sets.shader_test| 122 
 .../shader_test/vs_two_sets_ifc.shader_test| 125 
 .../shader_test/vs_two_sets_named_ifc.shader_test  | 122 
 .../shader_test/vs_two_sets_struct.shader_test | 131 +
 .../transform-feedback-layout-qualifiers.c | 322 +++--
 .../xfb_streams_without_invocations.shader_test| 194 +
 .../execution/xfb-streams-without-invocations.c| 135 ++---
 tests/util/CMakeLists.txt  |   1 +
 tests/util/piglit-shader-test.c| 154 ++
 tests/util/piglit-shader-test.h|  43 +++
 tests/util/piglit-shader.c |  37 +++
 tests/util/piglit-shader.h |   3 +
 16 files changed, 1307 insertions(+), 232 deletions(-)
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/gs_text_two_sets_tmpl.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_passthru.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets_ifc.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets_named_ifc.shader_test
 create mode 100644 
tests/spec/arb_enhanced_layouts/shader_test/vs_two_sets_struct.shader_test
 create mode 100644 
tests/spec/arb_gpu_shader5/execution/shader_test/xfb_streams_without_invocations.shader_test
 create mode 100644 tests/util/piglit-shader-test.c
 create mode 100644 tests/util/piglit-shader-test.h

-- 
2.14.1

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


Re: [Piglit] [PATCH 02/24] shader_runner/spirv: support loading SPIR-V shaders

2018-07-12 Thread Alejandro Piñeiro
Hi list,

this thread didn't get too much attention. We would like to push them on
master, as we plan to keep adding tests for this extension.

In general, all the thread is non-problematic, and really isolated for
this extension. The only debatable patch is this one. For two reasons:

* It adds a runtime dependency with spirv tools: it tries to use
PIGLIT_SPIRV_AS_BINARY to find spirv-as, or execute it as the system.
This is a really soft/non-problematic runtime dependency, as if the
binary is not present the tests would just FAIL. In any case, we would
like to know if adding such runtime dependency is ok.

* The other thing to debate is what should be the test outcome if
spirv-as is not present: as mentioned, right now if spirv-as fails the
test return PIGLIT_FAIL. But that is debatable, as technically in that
case the test was not properly run, and it is just that a needed tool
needed to run it is missing. So perhaps PIGLIT_SKIP makes more sense. I
don't have a strong opinion though.

So I would appreciate some feedback about those two items, specially the
first one. Once that get settled, we would like to integrate the tests
on master.

Thanks in advance.


On 20/06/18 14:40, Alejandro Piñeiro wrote:
> From: Nicolai Hähnle 
>
> This commit add support to load a SPIR-V shader, possible since
> ARB_gl_spirv.
>
> The SPIR-V shader is included on the shader_test script on new shader
> stage versions ([vertex shader spirv], [fragment shader spirv],
> etc). It is not in direct binary format, but in assembly format that
> it is assembled using spirv-tools. This is done by calling spirv-as,
> that is provided by setting the envvar PIGLIT_SPIRV_AS_BINARY. In this
> way we are adding an optional runtime dependency, instead of a build
> time one.
>
> Those sections are ignored unless [require] section includes "SPIRV
> YES" or "SPIRV ONLY". The only difference between the two is that
> "SPIRV ONLY" marks tests that can only be run on SPIR-V mode, as they
> are testing specific SPIR-V/ARB_gl_spirv features, like
> specializations.
>
> By default if those sections are present, shader_runner will try to
> load the SPIR-V shader (run in SPIR-V mode). This commit also adds a
> command line option "-glsl", that would try to force run the shader in
> GLSL mode even if the SPIR-V shader are available. If "SPIRV ONLY" is
> present, and force GLSL is attempted, the test will be skipped.
>
> Note that in GLSL mode, ARB_gl_spirv is not required. For that reason,
> we will not add ARB_gl_spirv on the [require] section of the tests. We
> check for this extension when assembling the SPIR-V shader.
>
> Signed-off-by: Nicolai Hähnle 
> Signed-off-by: Alejandro Piñeiro 
> Signed-off-by: Neil Roberts 
> ---
>  tests/shaders/shader_runner.c | 272 
> --
>  1 file changed, 261 insertions(+), 11 deletions(-)
>
> diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
> index a6dbdedeb..b1bad8d9b 100644
> --- a/tests/shaders/shader_runner.c
> +++ b/tests/shaders/shader_runner.c
> @@ -29,6 +29,7 @@
>  #include "piglit-util-gl.h"
>  #include "piglit-vbo.h"
>  #include "piglit-framework-gl/piglit_gl_framework.h"
> +#include "piglit-subprocess.h"
>  
>  #include "shader_runner_gles_workarounds.h"
>  #include "parser_utils.h"
> @@ -39,7 +40,7 @@
>  static struct piglit_gl_test_config current_config;
>  
>  static void
> -get_required_config(const char *script_name,
> +get_required_config(const char *script_name, bool spirv,
>   struct piglit_gl_test_config *config);
>  static GLenum
>  decode_drawing_mode(const char *mode_str);
> @@ -53,10 +54,15 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
>   config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
>   config.khr_no_error_support = PIGLIT_NO_ERRORS;
>  
> - if (argc > 1)
> - get_required_config(argv[1], &config);
> - else
> + /* 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], false, &config);
> + } else {
>   config.supports_gl_compat_version = 10;
> + }
>  
>   current_config = config;
>  
> @@ -143,6 +149,10 @@ static bool vbo_present = false;
>  static bool link_ok = false;
>  static bool prog_in_use = false;
>  static bool sso_in_use = false;
> +static bool glsl_in_use = false;
> +static bool force_glsl = false;
> +static bool spirv_in_u

[Piglit] [PATCH 4/4] arb_gl_spirv: add test that mixes atomic counters with a normal uniform

2018-06-29 Thread Alejandro Piñeiro
Under ARB_gl_spirv, most uniforms require a explicit location. There
are some exceptions like atomic counters. In that case, some drivers
like mesa, still sets internally a location for those. This test
purpose is checking that mixing "normal" uniforms with uniforms
without location works properly, or at least in a basic case.
---
 ...ic-uint-mixing-with-normal-uniforms.shader_test | 197 +
 .../uniform/atomic-uint-several-slots.shader_test  | 197 +
 2 files changed, 394 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-mixing-with-normal-uniforms.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-several-slots.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-mixing-with-normal-uniforms.shader_test
 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-mixing-with-normal-uniforms.shader_test
new file mode 100644
index 0..5029dd561
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-mixing-with-normal-uniforms.shader_test
@@ -0,0 +1,197 @@
+# Test that have several "normal" uniforms with explicit location, and
+# several uniform atomic counter, that has not explicit location. For
+# the latter mesa assigns a internal location. Development test, to
+# ensure that they are properly assigned.
+
+[require]
+SPIRV YES
+GL >= 4.5
+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: 59
+; Schema: 0
+   OpCapability Shader
+   OpCapability AtomicStorage
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpDecorate %color Location 0
+   OpDecorate %a0 Offset 0
+   OpDecorate %a0 DescriptorSet 0
+   OpDecorate %a0 Binding 0
+   OpDecorate %u0 Location 2
+   OpDecorate %u0 DescriptorSet 0
+   OpDecorate %u0 Binding 1
+   OpDecorate %a1 Offset 4
+   OpDecorate %a1 DescriptorSet 0
+   OpDecorate %a1 Binding 0
+   OpDecorate %u1 Location 4
+   OpDecorate %u1 DescriptorSet 0
+   OpDecorate %u1 Binding 2
+   OpDecorate %a2 Offset 8
+   OpDecorate %a2 DescriptorSet 0
+   OpDecorate %a2 Binding 0
+   OpDecorate %u2 Location 7
+   OpDecorate %u2 DescriptorSet 0
+   OpDecorate %u2 Binding 3
+   OpDecorate %a3 Offset 12
+   OpDecorate %a3 DescriptorSet 0
+   OpDecorate %a3 Binding 0
+   OpDecorate %u3 Location 10
+   OpDecorate %u3 DescriptorSet 0
+   OpDecorate %u3 Binding 4
+   %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
+%_ptr_Function_uint = OpTypePointer Function %uint
+%_ptr_AtomicCounter_uint = OpTypePointer AtomicCounter %uint
+ %a0 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_1 = OpConstant %uint 1
+ %uint_0 = OpConstant %uint 0
+   %bool = OpTypeBool
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+ %u0 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+ %a1 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_3 = OpConstant %uint 3
+ %u1 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+ %a2 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_5 = OpConstant %uint 5
+ %u2 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+ %a3 = OpVariable %_ptr_AtomicCounter_uint AtomicCounter
+ %uint_7 = OpConstant %uint 7
+ %u3 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %uival0 = OpVariable %_ptr_Function_uint Function
+ %uival1 = OpVariable %_ptr_Function_uint Function
+ %uival2 = OpVariable %_ptr_Function_uint Function
+ %uival3 = OpVariable %_ptr_Function_uint Function
+   OpStore %color %12
+ %20 = OpAtomicLoad %uint %a0 %uint_1 %uint_0
+   OpStore %uival0 %20
+ %21 = OpLoad %uint %uival0
+ %23 = OpINotEqual %bool %21 %uint_1
+   OpSelectionMerge %25 No

[Piglit] [PATCH 2/4] arb_gl_spirv: add tests for atomic counter operations in FS

2018-06-29 Thread Alejandro Piñeiro
From: Antia Puentes 

Tests the atomic counter operations and layout qualifiers offset and binding
described in the ARB_shader_atomic_counters specification.

They check the final values for the atomic counters and that the values returned
by the atomic counter operations are the expected ones.

Includes 3 tests: atomic_uint, arrays of atomic_uint and AOA of atomic_uints.
---
 .../uniform/atomic-uint-aoa-fs.shader_test | 222 +
 .../uniform/atomic-uint-array-fs.shader_test   | 211 
 .../execution/uniform/atomic-uint-fs.shader_runner | 219 
 3 files changed, 652 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-array-fs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-fs.shader_runner

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
new file mode 100644
index 0..f259d3c0f
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
@@ -0,0 +1,222 @@
+# Tests the atomic counter operations described in the
+# ARB_shader_atomic_counters spec for an array of arrays of
+# atomic counters in a fragment shader.
+#
+# Checks the final value of the atomic counters and the values
+# returned by the operations.
+#
+# The declaration of the atomic counter AOA uses the atomic counter
+# layout qualifiers binding and offset.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 6
+; Bound: 76
+; Schema: 0
+   OpCapability Shader
+   OpCapability AtomicStorage
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %a0_out "a0_out"
+   OpName %a "a"
+   OpName %a0_expected "a0_expected"
+   OpName %color "color"
+   OpName %a1_out "a1_out"
+   OpName %a1_expected "a1_expected"
+   OpName %a2_out "a2_out"
+   OpName %a2_expected "a2_expected"
+   OpDecorate %a Offset 4
+   OpDecorate %a DescriptorSet 0
+   OpDecorate %a Binding 0
+   OpDecorate %a0_expected Location 0
+   OpDecorate %a0_expected DescriptorSet 0
+   OpDecorate %a0_expected Binding 1
+   OpDecorate %color Location 0
+   OpDecorate %a1_expected Location 1
+   OpDecorate %a1_expected DescriptorSet 0
+   OpDecorate %a1_expected Binding 2
+   OpDecorate %a2_expected Location 2
+   OpDecorate %a2_expected DescriptorSet 0
+   OpDecorate %a2_expected Binding 3
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+   %uint = OpTypeInt 32 0
+%_ptr_Function_uint = OpTypePointer Function %uint
+ %uint_3 = OpConstant %uint 3
+%_arr_uint_uint_3 = OpTypeArray %uint %uint_3
+ %uint_2 = OpConstant %uint 2
+%_arr__arr_uint_uint_3_uint_2 = OpTypeArray %_arr_uint_uint_3 %uint_2
+%_ptr_AtomicCounter__arr__arr_uint_uint_3_uint_2 = OpTypePointer AtomicCounter 
%_arr__arr_uint_uint_3_uint_2
+  %a = OpVariable %_ptr_AtomicCounter__arr__arr_uint_uint_3_uint_2 
AtomicCounter
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_AtomicCounter_uint = OpTypePointer AtomicCounter %uint
+ %uint_1 = OpConstant %uint 1
+ %uint_0 = OpConstant %uint 0
+%_ptr_UniformConstant_uint = OpTypePointer UniformConstant %uint
+%a0_expected = OpVariable %_ptr_UniformConstant_uint UniformConstant
+   %bool = OpTypeBool
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+%float_1 = OpConstant %float 1
+%float_0 = OpConstant %float 0
+  %float_255 = OpConstant %float 255
+  %int_1 = OpConstant %int 1
+%a1_expected = OpVariable %_ptr_UniformConstant_uint UniformConstant
+%float_0_10001 = OpConstant %float 0.10001
+  %int_2 = OpConstant %int 2
+%a2_expected = OpVariable %_ptr_UniformConstant_uint UniformConstant
+%float_0_20003 = OpConstant %float 0.20003
+ %75 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %a0_out = OpVariable %_ptr_Function_uint Function
+ %a1_out = OpVariable %_ptr_Function_uint Fun

[Piglit] [PATCH 3/4] arb_gl_spirv: add tests for atomic counter operations in CS

2018-06-29 Thread Alejandro Piñeiro
From: Antia Puentes 

Tests the atomic counter operations and layout qualifiers offset and binding
described in the ARB_shader_atomic_counters specification in a CS with
local_size_x, y, z equal to 3, 2 and 1 respectively.

Includes 3 tests: atomic_uint, arrays of atomic_uint and AOA of atomic_uints.
---
 .../uniform/atomic-uint-aoa-cs.shader_test | 249 +
 .../uniform/atomic-uint-array-cs.shader_test   | 239 
 .../execution/uniform/atomic-uint-cs.shader_test   | 244 
 3 files changed, 732 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-array-cs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-cs.shader_test

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
new file mode 100644
index 0..5bc3850bf
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
@@ -0,0 +1,249 @@
+# Tests the atomic counter operations described in the
+# ARB_shader_atomic_counters specification using AOAs
+# of atomic counters in a CS with  local_sizes_x, y, z
+# equal to 3, 2 and 1 respectively.
+#
+# Checks the final value of the atomic counter and the values
+# returned by the operations.
+#
+# The declaration of the atomic counters array uses the atomic
+# counter layout qualifiers binding and offset.
+
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+
+[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: 68
+; Schema: 0
+   OpCapability Shader
+   OpCapability AtomicStorage
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint GLCompute %main "main" %gl_LocalInvocationIndex
+   OpExecutionMode %main LocalSize 3 2 1
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %a00_out "a00_out"
+   OpName %a "a"
+   OpName %a00_expected "a00_expected"
+   OpName %gl_LocalInvocationIndex "gl_LocalInvocationIndex"
+   OpName %ok_a00 "ok_a00"
+   OpName %a01_out "a01_out"
+   OpName %a01_expected "a01_expected"
+   OpName %ok_a01 "ok_a01"
+   OpName %a12_out "a12_out"
+   OpName %a12_expected "a12_expected"
+   OpName %ok_a12 "ok_a12"
+   OpDecorate %a Offset 4
+   OpDecorate %a DescriptorSet 0
+   OpDecorate %a Binding 0
+   OpDecorate %a00_expected Location 0
+   OpDecorate %a00_expected DescriptorSet 0
+   OpDecorate %a00_expected Binding 4
+   OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex
+   OpDecorate %ok_a00 Offset 0
+   OpDecorate %ok_a00 DescriptorSet 0
+   OpDecorate %ok_a00 Binding 1
+   OpDecorate %a01_expected Location 6
+   OpDecorate %a01_expected DescriptorSet 0
+   OpDecorate %a01_expected Binding 5
+   OpDecorate %ok_a01 Offset 0
+   OpDecorate %ok_a01 DescriptorSet 0
+   OpDecorate %ok_a01 Binding 2
+   OpDecorate %a12_expected Location 12
+   OpDecorate %a12_expected DescriptorSet 0
+   OpDecorate %a12_expected Binding 6
+   OpDecorate %ok_a12 Offset 0
+   OpDecorate %ok_a12 DescriptorSet 0
+   OpDecorate %ok_a12 Binding 3
+   OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+   %uint = OpTypeInt 32 0
+%_ptr_Function_uint = OpTypePointer Function %uint
+ %uint_3 = OpConstant %uint 3
+%_arr_uint_uint_3 = OpTypeArray %uint %uint_3
+ %uint_2 = OpConstant %uint 2
+%_arr__arr_uint_uint_3_uint_2 = OpTypeArray %_arr_uint_uint_3 %uint_2
+%_ptr_AtomicCounter__arr__arr_uint_uint_3_uint_2 = OpTypePointer AtomicCounter 
%_arr__arr_uint_uint_3_uint_2
+  %a = OpVariable %_ptr_AtomicCounter__arr__arr_uint_uint_3_uint_2 
AtomicCounter
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_AtomicCounter_uint = OpTypePointer AtomicCounter %uint
+ %uint_1 = OpConstant %uint 1
+ %uint_0 = OpConstant %uint 0
+ %uint_6 = OpConstant %uint 6
+%_arr_uint_uint_6 = OpTypeArray %uint %uint_6
+%_ptr_UniformConstant__arr_uint_uint_6 = OpTypePointer UniformConstant 
%_arr_uint_uint_6
+%a00_expected = OpVariable %_ptr_UniformConstant__arr_uint_uint_6 
UniformConstant
+%_ptr_Input_uint = OpTypePointer Input %uint
+%gl_LocalInvocationIndex = OpVariable %_ptr_Input_

[Piglit] [PATCH 1/4] shader_runner: add command 'probe atomic counter buffer'

2018-06-29 Thread Alejandro Piñeiro
From: Antia Puentes 

Extends the already existing 'probe atomic counter' command to allow comparing
the value of an atomic counter stored in an ATOMIC_COUNTER_BUFFER with a binding
different from zero, and at a chosen offset. In other words, adds support to
test the atomic counter layout qualifiers: binding and offset.

Usage: 'probe atomic counter buffer'

   *  and  are the atomic counter layout qualifiers.
   *  is the comparison operator.
   *  is the number to be compared with the atomic counter.
---
 tests/shaders/shader_runner.c | 25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 2c6837fb6..63cffdc19 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -3419,7 +3419,8 @@ draw_arrays_common(int first, size_t count)
 }
 
 static bool
-probe_atomic_counter(unsigned buffer_num, GLint counter_num, const char *op, 
uint32_t value)
+probe_atomic_counter(unsigned buffer_num, GLint counter_num, const char *op,
+uint32_t value, bool uses_layout_qualifiers)
 {
 uint32_t *p;
uint32_t observed;
@@ -3430,7 +3431,8 @@ probe_atomic_counter(unsigned buffer_num, GLint 
counter_num, const char *op, uin
"Invalid comparison operation at: %s\n", op);
 
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomics_bos[buffer_num]);
-   p = glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER, counter_num * 
sizeof(uint32_t),
+   p = glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER,
+uses_layout_qualifiers ? counter_num : counter_num 
* sizeof(uint32_t),
 sizeof(uint32_t), GL_MAP_READ_BIT);
 
 if (!p) {
@@ -3442,8 +3444,13 @@ probe_atomic_counter(unsigned buffer_num, GLint 
counter_num, const char *op, uin
result = compare_uint(value, observed, cmp);
 
if (!result) {
-   printf("Atomic counter %d test failed: Reference %s Observed\n",
-  counter_num, comparison_string(cmp));
+   if (uses_layout_qualifiers)
+   printf("Atomic counter (binding = %d, offset = %d) test 
failed: "
+  "Reference %s Observed\n",
+  buffer_num, counter_num, comparison_string(cmp));
+   else
+   printf("Atomic counter %d test failed: Reference %s 
Observed\n",
+  counter_num, comparison_string(cmp));
printf("  Reference: %u\n", value);
printf("  Observed:  %u\n", observed);
glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
@@ -3510,7 +3517,7 @@ piglit_display(void)
float c[32];
double d[4];
int x, y, z, w, h, l, tex, level;
-   unsigned ux, uy;
+   unsigned ux, uy, uz;
char s[300]; // 300 for safety
enum piglit_result result = PIGLIT_PASS;
 
@@ -3958,10 +3965,16 @@ piglit_display(void)
  c[2])) {
result = PIGLIT_FAIL;
}
+   } else if (sscanf(line,
+ "probe atomic counter buffer %u %u %s %u",
+ &ux, &uy, s, &uz) == 4) {
+   if (!probe_atomic_counter(ux, uy, s, uz, true)) {
+   piglit_report_result(PIGLIT_FAIL);
+   }
} else if (sscanf(line,
  "probe atomic counter %u %s %u",
  &ux, s, &uy) == 3) {
-   if (!probe_atomic_counter(0, ux, s, uy)) {
+   if (!probe_atomic_counter(0, ux, s, uy, false)) {
piglit_report_result(PIGLIT_FAIL);
}
} else if (sscanf(line, "probe ssbo uint %d %d %s 0x%x",
-- 
2.14.1

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


[Piglit] [PATCH 0/4] ARB_gl_spirv: atomic counters tests

2018-06-29 Thread Alejandro Piñeiro
Hi,

this is the second series with patches for the ARB_gl_spirv
extension. This series includes atomic counter tests. The patches
providing support for that feature on mesa has been sent recently to
mesa-dev.

This series depends on the still-to-be-reviewed first series with
tests for ARB_gl_spirv:

https://lists.freedesktop.org/archives/piglit/2018-June/024605.html

You can find both series on the following branch:
https://github.com/Igalia/piglit/tree/arb_gl_spirv-series2-atomic-counters-v1



Alejandro Piñeiro (1):
  arb_gl_spirv: add test that mixes atomic counters with a normal
uniform

Antia Puentes (3):
  shader_runner: add command 'probe atomic counter buffer'
  arb_gl_spirv: add tests for atomic counter operations in FS
  arb_gl_spirv: add tests for atomic counter operations in CS

 tests/shaders/shader_runner.c  |  25 ++-
 .../uniform/atomic-uint-aoa-cs.shader_test | 249 +
 .../uniform/atomic-uint-aoa-fs.shader_test | 222 ++
 .../uniform/atomic-uint-array-cs.shader_test   | 239 
 .../uniform/atomic-uint-array-fs.shader_test   | 211 +
 .../execution/uniform/atomic-uint-cs.shader_test   | 244 
 .../execution/uniform/atomic-uint-fs.shader_runner | 219 ++
 ...ic-uint-mixing-with-normal-uniforms.shader_test | 197 
 .../uniform/atomic-uint-several-slots.shader_test  | 197 
 9 files changed, 1797 insertions(+), 6 deletions(-)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-cs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-aoa-fs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-array-cs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-array-fs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-cs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-fs.shader_runner
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-mixing-with-normal-uniforms.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/atomic-uint-several-slots.shader_test

-- 
2.14.1

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


Re: [Piglit] [PATCH 03/24] framework: add --glsl option

2018-06-27 Thread Alejandro Piñeiro
On 26/06/18 17:35, Dylan Baker wrote:
> Quoting Alejandro Piñeiro (2018-06-26 03:44:53)
>> On 25/06/18 17:59, Dylan Baker wrote:
>>> Quoting Alejandro Piñeiro (2018-06-23 04:26:33)
>>>> On 22/06/18 19:14, Dylan Baker wrote:
>>>>> Quoting Alejandro Piñeiro (2018-06-20 05:40:38)
>>>>>> So when executing shader tests, they will be executed with -glsl. This
>>>>>> is the force GLSL mode, that is only relevant if the shader test
>>>>>> includes SPIR-V shaders.
>>>>> I'm not sure I understand what you're doing. It looks like you're 
>>>>> planning to
>>>>> build tests that can be run in either SPIRV or GLSL mode, that they can be
>>>>> forced into GLSL mode using a switch, or use SPIRV mode if available. Is 
>>>>> that
>>>>> correct?
>>>> Yes. Perhaps the commit message is not really clear, as all the details
>>>> are included on the previous commit "shader_runner/spirv: support
>>>> loading SPIR-V shaders". On that commit we explain that we add a -glsl
>>>> option to shader_runner, that is mostly a debugging option. What this
>>>> commits adds is adding the -glsl option when running the tests in a
>>>> batch. With this series, the -glsl option would only make sense with the
>>>> ARB_gl_spirv tests we are adding.
>>>>
>>>> Do you think that I should update the commit message to be more clear?
>>>>
>>>> BR
>>>>
>>> My concern is that you could end up with two tests with the same name that
>>> aren't the same (I think), since the --glsl option won't change the name of 
>>> the
>>> test.
>> Right now, the idea behind the --glsl option is not getting two tests
>> from the same executable. The tests included with this series are
>> expected to run on SPIR-V mode. So for example, we would not add a new
>> entry on opengl.py/shader.py to run those tests twice. As mentioned it
>> is mostly a debug utility/sanity check, that was useful when we were
>> working on getting them passed, so we understand that will be still
>> useful on the future, for any other driver interested on support the
>> extension, or even for i965 again, if there is  any future regression.
>>
>> Perhaps you are thinking that we plan to use that option, or similar, to
>> reuse tests from other extensions. What I called "borrowed tests" on the
>> RFC I sent some months ago. For that case, our plan would be generate
>> new tests to be placed under generated_tests. So in the case of reusing
>> tests from other extensions, we would still have two different base
>> tests (one for GLSL, other for SPIRV).
>>
>> BR
> That sounds reasonable. My concern was that someone would see tests failing
> because they lacked spirv tools, and run with --glsl, then give that to a 
> second
> person who did have spriv-tools, and see different results.

Well, fwiw, that option is just useful, not totally needed. So if you
are really worried about people not using it properly, we can just drop
this patch. After all, usually when you are debugging, you do it with a
individual test, so it is enough if shader_runner has that option.

So how about that compromise? We keep the -glsl option on shader_runner,
but drop the piglit framework support to run several tests with that option?

BR






signature.asc
Description: OpenPGP digital signature
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 03/24] framework: add --glsl option

2018-06-26 Thread Alejandro Piñeiro
On 25/06/18 17:59, Dylan Baker wrote:
> Quoting Alejandro Piñeiro (2018-06-23 04:26:33)
>> On 22/06/18 19:14, Dylan Baker wrote:
>>> Quoting Alejandro Piñeiro (2018-06-20 05:40:38)
>>>> So when executing shader tests, they will be executed with -glsl. This
>>>> is the force GLSL mode, that is only relevant if the shader test
>>>> includes SPIR-V shaders.
>>> I'm not sure I understand what you're doing. It looks like you're planning 
>>> to
>>> build tests that can be run in either SPIRV or GLSL mode, that they can be
>>> forced into GLSL mode using a switch, or use SPIRV mode if available. Is 
>>> that
>>> correct?
>> Yes. Perhaps the commit message is not really clear, as all the details
>> are included on the previous commit "shader_runner/spirv: support
>> loading SPIR-V shaders". On that commit we explain that we add a -glsl
>> option to shader_runner, that is mostly a debugging option. What this
>> commits adds is adding the -glsl option when running the tests in a
>> batch. With this series, the -glsl option would only make sense with the
>> ARB_gl_spirv tests we are adding.
>>
>> Do you think that I should update the commit message to be more clear?
>>
>> BR
>>
> My concern is that you could end up with two tests with the same name that
> aren't the same (I think), since the --glsl option won't change the name of 
> the
> test.

Right now, the idea behind the --glsl option is not getting two tests
from the same executable. The tests included with this series are
expected to run on SPIR-V mode. So for example, we would not add a new
entry on opengl.py/shader.py to run those tests twice. As mentioned it
is mostly a debug utility/sanity check, that was useful when we were
working on getting them passed, so we understand that will be still
useful on the future, for any other driver interested on support the
extension, or even for i965 again, if there is  any future regression.

Perhaps you are thinking that we plan to use that option, or similar, to
reuse tests from other extensions. What I called "borrowed tests" on the
RFC I sent some months ago. For that case, our plan would be generate
new tests to be placed under generated_tests. So in the case of reusing
tests from other extensions, we would still have two different base
tests (one for GLSL, other for SPIRV).

BR




signature.asc
Description: OpenPGP digital signature
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH v2] ARB_vertex_attrib_64bit: add doubles support to attributes test

2018-06-25 Thread Alejandro Piñeiro
LGTM. Just a nitpick below. But in any case:
Reviewed-by: Alejandro Piñeiro 

On 25/06/18 10:45, Timothy Arceri wrote:
> ---
>
>  V2: Add missing opengl.py entry.
>
>  tests/general/attribs.c | 68 +++--
>  tests/opengl.py |  3 +-
>  2 files changed, 67 insertions(+), 4 deletions(-)
>
> diff --git a/tests/general/attribs.c b/tests/general/attribs.c
> index 05a0d4a1e..bf627dece 100644
> --- a/tests/general/attribs.c
> +++ b/tests/general/attribs.c
> @@ -53,6 +53,7 @@ enum {
>  };
>  
>  enum {
> + DOUBLE_TYPE,
>   FLOAT_TYPE,
>   INT_TYPE,
>   UINT_TYPE
> @@ -120,12 +121,13 @@ static GLboolean test(int x, int y, const char 
> *shaderfunc,
> const char *info)
>  {
>   static const char *templ = {
> + "%s \n"

Is this extra line really needed?

>   "%s \n"
>   "#extension GL_ARB_explicit_attrib_location : require \n"
>   "layout(location = 1) in %s attr; \n"
>   "void main() { \n"
>   "  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n"
> - "  gl_FrontColor = (%s) * vec4(1.0, 1.0, 1.0, 0.5); \n"
> + "  gl_FrontColor = vec4(%s %s) * vec4(1.0, 1.0, 1.0, 0.5); \n"
>   "} \n"
>   };
>   GLuint prog, vs;
> @@ -139,10 +141,56 @@ static GLboolean test(int x, int y, const char 
> *shaderfunc,
>   {0.5, 0.3, 0.9, 0.2}
>   };
>  
> + char *defaults;
> + char *type_string;
> +
> + /* From Section 11.1.1 (Vertex Attributes) of the OpenGL 4.6
> +  * Compatibility Profile spec:
> +  *
> +  *"Scalar and vector vertex attribute types and VertexAttrib*
> +  *commands used to set the values of the corresponding generic
> +  *attribute. values are provided if the values of the vertex
> +  *attribute variable are specified with fewer components than
> +  *required for the attribute variable. For example, the fourth
> +  *component of a variable of type dvec4 will be undefined if
> +  *specified using VertexAttribL3dv, or using a vertex array
> +  *specified with VertexAttribLPointer and a size of three.
> +  *
> +  * TODO: We should probably also be doing this for attribute functions
> +  *   other than doubles.
> +  */
> + if (type == DOUBLE_TYPE) {
> + switch (mask) {
> + case R:
> + type_string = "double";
> + defaults = ", dvec3(0.0, 0.0, 1.0)";
> + break;
> + case RG:
> + type_string = "dvec2";
> + defaults = ", dvec2(0.0, 1.0)";
> + break;
> + case RGB:
> + type_string = "dvec3";
> + defaults = ", 1.0";
> + break;
> + case RGBA:
> + type_string = "dvec4";
> + defaults = "";
> + break;
> + default:
> + assert(0);
> + }
> + } else {
> + defaults = "";
> + type_string =
> + type == INT_TYPE ? "ivec4" : type == UINT_TYPE ? 
> "uvec4" : "vec4";
> + }
> +
>   sprintf(vstext, templ,
>   type != FLOAT_TYPE ? "#version 130" : "",
> - type == INT_TYPE ? "ivec4" : type == UINT_TYPE ? "uvec4" : 
> "vec4",
> - shaderfunc);
> + type == DOUBLE_TYPE ?
> + "#extension GL_ARB_gpu_shader_fp64: enable\n#extension 
> GL_ARB_vertex_attrib_64bit: enable" : "",
> + type_string, shaderfunc, defaults);
>  
>   /* Create the shader. */
>   vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
> @@ -343,6 +391,19 @@ static test_func tests_GL3[] = {
>   test_glVertexAttribI4ui,
>  };
>  
> +/* ARB_vertex_attrib_64bit */
> +DEFINE_TEST(glVertexAttribL1d,,  (1, x), "attr", R, DOUBLE_TYPE, 
> "")
> +DEFINE_TEST(glVertexAttribL2d,,  (1, x, y),  "attr", RG, 
> DOUBLE_TYPE, "")
> +DEFINE_TEST(glVertexAttribL3d,,  (1, x, y, z),   "attr", RGB, 
> DOUBLE_TYPE, "")
> +DEFINE_TEST(glVertexAttribL4d,,  (1, x, y, z, w),"attr", RGBA, 
> DOUBLE_T

Re: [Piglit] [PATCH 03/24] framework: add --glsl option

2018-06-23 Thread Alejandro Piñeiro
On 22/06/18 19:14, Dylan Baker wrote:
> Quoting Alejandro Piñeiro (2018-06-20 05:40:38)
>> So when executing shader tests, they will be executed with -glsl. This
>> is the force GLSL mode, that is only relevant if the shader test
>> includes SPIR-V shaders.
> I'm not sure I understand what you're doing. It looks like you're planning to
> build tests that can be run in either SPIRV or GLSL mode, that they can be
> forced into GLSL mode using a switch, or use SPIRV mode if available. Is that
> correct?

Yes. Perhaps the commit message is not really clear, as all the details
are included on the previous commit "shader_runner/spirv: support
loading SPIR-V shaders". On that commit we explain that we add a -glsl
option to shader_runner, that is mostly a debugging option. What this
commits adds is adding the -glsl option when running the tests in a
batch. With this series, the -glsl option would only make sense with the
ARB_gl_spirv tests we are adding.

Do you think that I should update the commit message to be more clear?

BR



signature.asc
Description: OpenPGP digital signature
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH v2 00/24] ARB_gl_spirv: support for loading SPIR-V binaries, plus first set of tests

2018-06-20 Thread Alejandro Piñeiro
I forgot to mention that you can find this series, rebased against today
master, here:

https://github.com/Igalia/piglit/tree/arb_gl_spirv-series1-uniforms-v2


On 20/06/18 14:40, Alejandro Piñeiro wrote:
> Hi,
>
> this is the second version of the first series of patches to add tests
> for the ARB_gl_spirv spec. This is basically a rebased against master
> version of the original series. You can find the details here:
>
> https://lists.freedesktop.org/archives/piglit/2018-April/024145.html
>
> Sending again as the there are the series on mesa that this piglit
> series provides tests to, is about to get fully reviewed
> ("ARB_gl_spirv: support for uniforms and some extras").
>
> It would be good to at least get some extra feedback on the SPIR-V
> loading, as it is adding a (soft) spirv-tools runtime dependency to
> piglit. Withougo spirv-tools, those tests would just fail, but it
> would be good if people thinks that's ok.
>
>
> Alejandro Piñeiro (9):
>   framework: add --glsl option
>   shader_runner/spirv: add vertex shader passthrough support on SPIR-V
>   shader_runner: debug prints if running on SPIR-V mode.
>   arb_gl_spirv: add really simple execution test
>   arb_gl_spirv: add basic test with two uniforms
>   arb_gl_spirv: add a small test with an array of uniforms
>   arb_gl_spirv: add execution test for multi-dimensional (aoa) uniform
>   arb_gl_spirv: uniform sampler2D
>   arb_gl_spirv: add two linking tests for uniform multisample images
>
> Neil Roberts (12):
>   util: Add a utility to stream data through an external process
>   shader_runner/spirv: Add support for SPIR-V specializations
>   arb_gl_spirv: Add a test using specializations
>   arb_gl_spirv: Add tests for sampler2D uniform binding initialisers
>   arb_gl_spirv: Add a test for a sampler within a struct
>   arb_gl_spirv: Add a test for nonconst array of sampler structs
>   arb_gl_spirv: Add 4 tests for uniform initializers
>   arb_gl_spirv: Add a test for non-sequential explicit uniform locations
>   arb_gl_spirv: Add a test for a struct uniform
>   arb_gl_spirv: Add a test for a uniform struct with struct members
>   arb_gl_spirv: Add a test for an array of structs uniform
>   arb_gl_spirv: Add a fiddly test for uniform index calculation
>
> Nicolai Hähnle (3):
>   shader_runner/spirv: support loading SPIR-V shaders
>   arb_gl_spirv: basic uniform test with names still present
>   arb_gl_spirv: add basic uniform test without names
>
>  framework/options.py   |   1 +
>  framework/programs/run.py  |   6 +
>  framework/test/shader_test.py  |  10 +-
>  tests/shaders/shader_runner.c  | 460 
> -
>  tests/shaders/shader_runner_vs_passthrough_spv.h   |  45 ++
>  .../execution/uniform/array.shader_test| 137 ++
>  .../execution/uniform/arrays-of-arrays.shader_test |  77 
>  .../execution/uniform/embedded-structs.shader_test | 151 +++
>  .../uniform/index-matches-location.shader_test | 100 +
>  .../uniform/initializer-complex.shader_test| 180 
>  .../uniform/initializer-dvec4.shader_test  |  68 +++
>  .../uniform/initializer-mat4x3.shader_test |  83 
>  .../execution/uniform/initializer.shader_test  |  66 +++
>  .../uniform/nonsequential-locations.shader_test|  69 
>  .../uniform/sampler2d-binding-array.shader_test|  85 
>  .../uniform/sampler2d-binding.shader_test  |  70 
>  .../sampler2d-nonconst-nested-array.shader_test| 225 ++
>  .../execution/uniform/sampler2d-struct.shader_test |  98 +
>  .../execution/uniform/sampler2d.shader_test|  70 
>  .../uniform/simple-without-names.shader_test   | 111 +
>  .../execution/uniform/simple.shader_test   | 124 ++
>  .../execution/uniform/struct-array.shader_test | 140 +++
>  .../execution/uniform/struct.shader_test   |  79 
>  .../execution/uniform/two-uniforms.shader_test | 132 ++
>  .../execution/vs-ps-simple.shader_test | 119 ++
>  .../execution/vs-ps-specializations.shader_test| 181 
>  .../linker/uniform/multisampler-array.shader_test  |  68 +++
>  .../linker/uniform/multisampler.shader_test|  67 +++
>  tests/util/CMakeLists.txt  |   1 +
>  tests/util/piglit-subprocess.c | 207 ++
>  tests/util/piglit-subprocess.h |  44 ++
>  31 files changed, 3262 insertions(+), 12 deletions(-)
>  create mode 100644 tests/shaders/shader_runner_vs_passthrough_spv.h
>  create mode 100644 
> tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
> 

[Piglit] [PATCH 16/24] arb_gl_spirv: Add a test for a sampler within a struct

2018-06-20 Thread Alejandro Piñeiro
From: Neil Roberts 

---
 .../execution/uniform/sampler2d-struct.shader_test | 98 ++
 1 file changed, 98 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/sampler2d-struct.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-struct.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-struct.shader_test
new file mode 100644
index 0..8e440543e
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-struct.shader_test
@@ -0,0 +1,98 @@
+# Test a texture sampler array within a struct. This is not allowed by
+# Vulkan so it needs special handling for GL_ARB_gl_spirv.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 35
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %Samp "Samp"
+   OpMemberName %Samp 0 "tex"
+   OpMemberName %Samp 1 "green_offset"
+   OpName %s "s"
+   OpDecorate %color Location 0
+   OpDecorate %s Location 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
+ %10 = OpTypeImage %float 2D 0 0 0 1 Unknown
+ %11 = OpTypeSampledImage %10
+   %Samp = OpTypeStruct %11 %float
+%_ptr_UniformConstant_Samp = OpTypePointer UniformConstant %Samp
+  %s = OpVariable %_ptr_UniformConstant_Samp UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
+%v2float = OpTypeVector %float 2
+ %float_0_25 = OpConstant %float 0.25
+ %22 = OpConstantComposite %v2float %float_0_25 %float_0_25
+  %int_1 = OpConstant %int 1
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+   %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+%_ptr_Output_float = OpTypePointer Output %float
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpAccessChain %_ptr_UniformConstant_11 %s %int_0
+ %19 = OpLoad %11 %18
+ %23 = OpImageSampleImplicitLod %v4float %19 %22
+   OpStore %color %23
+ %26 = OpAccessChain %_ptr_UniformConstant_float %s %int_1
+ %27 = OpLoad %float %26
+ %31 = OpAccessChain %_ptr_Output_float %color %uint_1
+ %32 = OpLoad %float %31
+ %33 = OpFAdd %float %32 %27
+ %34 = OpAccessChain %_ptr_Output_float %color %uint_1
+   OpStore %34 %33
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 0) out vec4 color;
+
+struct Samp {
+sampler2D tex;
+   float green_offset;
+};
+
+layout (location = 0) uniform Samp s;
+
+void main()
+{
+   color = texture(s.tex, vec2(0.25));
+   color.g += s.green_offset;
+}
+
+[test]
+clear color 1.0 0.0 0.0 1.0
+clear
+
+uniform int 0 3
+uniform float 1 0.45
+
+texture checkerboard 3 0 (32, 32) (0.0, 0.5, 0.0, 0.0) (0.8, 0.0, 0.0, 1.0)
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.95 0.0 0.0
-- 
2.14.1

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


[Piglit] [PATCH v2 00/24] ARB_gl_spirv: support for loading SPIR-V binaries, plus first set of tests

2018-06-20 Thread Alejandro Piñeiro
Hi,

this is the second version of the first series of patches to add tests
for the ARB_gl_spirv spec. This is basically a rebased against master
version of the original series. You can find the details here:

https://lists.freedesktop.org/archives/piglit/2018-April/024145.html

Sending again as the there are the series on mesa that this piglit
series provides tests to, is about to get fully reviewed
("ARB_gl_spirv: support for uniforms and some extras").

It would be good to at least get some extra feedback on the SPIR-V
loading, as it is adding a (soft) spirv-tools runtime dependency to
piglit. Withougo spirv-tools, those tests would just fail, but it
would be good if people thinks that's ok.


Alejandro Piñeiro (9):
  framework: add --glsl option
  shader_runner/spirv: add vertex shader passthrough support on SPIR-V
  shader_runner: debug prints if running on SPIR-V mode.
  arb_gl_spirv: add really simple execution test
  arb_gl_spirv: add basic test with two uniforms
  arb_gl_spirv: add a small test with an array of uniforms
  arb_gl_spirv: add execution test for multi-dimensional (aoa) uniform
  arb_gl_spirv: uniform sampler2D
  arb_gl_spirv: add two linking tests for uniform multisample images

Neil Roberts (12):
  util: Add a utility to stream data through an external process
  shader_runner/spirv: Add support for SPIR-V specializations
  arb_gl_spirv: Add a test using specializations
  arb_gl_spirv: Add tests for sampler2D uniform binding initialisers
  arb_gl_spirv: Add a test for a sampler within a struct
  arb_gl_spirv: Add a test for nonconst array of sampler structs
  arb_gl_spirv: Add 4 tests for uniform initializers
  arb_gl_spirv: Add a test for non-sequential explicit uniform locations
  arb_gl_spirv: Add a test for a struct uniform
  arb_gl_spirv: Add a test for a uniform struct with struct members
  arb_gl_spirv: Add a test for an array of structs uniform
  arb_gl_spirv: Add a fiddly test for uniform index calculation

Nicolai Hähnle (3):
  shader_runner/spirv: support loading SPIR-V shaders
  arb_gl_spirv: basic uniform test with names still present
  arb_gl_spirv: add basic uniform test without names

 framework/options.py   |   1 +
 framework/programs/run.py  |   6 +
 framework/test/shader_test.py  |  10 +-
 tests/shaders/shader_runner.c  | 460 -
 tests/shaders/shader_runner_vs_passthrough_spv.h   |  45 ++
 .../execution/uniform/array.shader_test| 137 ++
 .../execution/uniform/arrays-of-arrays.shader_test |  77 
 .../execution/uniform/embedded-structs.shader_test | 151 +++
 .../uniform/index-matches-location.shader_test | 100 +
 .../uniform/initializer-complex.shader_test| 180 
 .../uniform/initializer-dvec4.shader_test  |  68 +++
 .../uniform/initializer-mat4x3.shader_test |  83 
 .../execution/uniform/initializer.shader_test  |  66 +++
 .../uniform/nonsequential-locations.shader_test|  69 
 .../uniform/sampler2d-binding-array.shader_test|  85 
 .../uniform/sampler2d-binding.shader_test  |  70 
 .../sampler2d-nonconst-nested-array.shader_test| 225 ++
 .../execution/uniform/sampler2d-struct.shader_test |  98 +
 .../execution/uniform/sampler2d.shader_test|  70 
 .../uniform/simple-without-names.shader_test   | 111 +
 .../execution/uniform/simple.shader_test   | 124 ++
 .../execution/uniform/struct-array.shader_test | 140 +++
 .../execution/uniform/struct.shader_test   |  79 
 .../execution/uniform/two-uniforms.shader_test | 132 ++
 .../execution/vs-ps-simple.shader_test | 119 ++
 .../execution/vs-ps-specializations.shader_test| 181 
 .../linker/uniform/multisampler-array.shader_test  |  68 +++
 .../linker/uniform/multisampler.shader_test|  67 +++
 tests/util/CMakeLists.txt  |   1 +
 tests/util/piglit-subprocess.c | 207 ++
 tests/util/piglit-subprocess.h |  44 ++
 31 files changed, 3262 insertions(+), 12 deletions(-)
 create mode 100644 tests/shaders/shader_runner_vs_passthrough_spv.h
 create mode 100644 tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/embedded-structs.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/initializer-complex.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/initializer-dvec4.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/initializer-mat4x3.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/ex

[Piglit] [PATCH 20/24] arb_gl_spirv: Add a test for non-sequential explicit uniform locations

2018-06-20 Thread Alejandro Piñeiro
From: Neil Roberts 

Tests using two uniforms that have explicit uniform locations with a
gap between them.
---
 .../uniform/nonsequential-locations.shader_test| 69 ++
 1 file changed, 69 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/nonsequential-locations.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/nonsequential-locations.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/nonsequential-locations.shader_test
new file mode 100644
index 0..a5be8e621
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/uniform/nonsequential-locations.shader_test
@@ -0,0 +1,69 @@
+# Test using explicit uniform locations that aren’t sequential. Ie,
+# there is a gap between them.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 16
+; 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 %part1 "part1"
+   OpName %part2 "part2"
+   OpDecorate %outcolor Location 0
+   OpDecorate %part1 Location 3
+   OpDecorate %part2 Location 5
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outcolor = OpVariable %_ptr_Output_v4float Output
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %part1 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+  %part2 = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %12 = OpLoad %v4float %part1
+ %14 = OpLoad %v4float %part2
+ %15 = OpFAdd %v4float %12 %14
+   OpStore %outcolor %15
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 3) uniform vec4 part1;
+layout(location = 5) uniform vec4 part2;
+
+layout(location = 0) out vec4 outcolor;
+
+void main() {
+outcolor = part1 + part2;
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+uniform vec4 3 0.1 0.15 0.2 0.25
+uniform vec4 5 0.3 0.35 0.4 0.45
+
+draw rect -1 -1 2 2
+probe all rgba 0.4 0.5 0.6 0.7
-- 
2.14.1

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


[Piglit] [PATCH 17/24] arb_gl_spirv: Add a test for nonconst array of sampler structs

2018-06-20 Thread Alejandro Piñeiro
From: Neil Roberts 

This is a simple port of arb_arrays_of_arrays/execution/sampler/
fs-nested-struct-arrays-nonconst-nested-array.shader_test
---
 .../sampler2d-nonconst-nested-array.shader_test| 225 +
 1 file changed, 225 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/sampler2d-nonconst-nested-array.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-nonconst-nested-array.shader_test
 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-nonconst-nested-array.shader_test
new file mode 100644
index 0..cf1fed17e
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-nonconst-nested-array.shader_test
@@ -0,0 +1,225 @@
+# This test verifies that dynamic uniform indexing of samplers within
+# a nested struct array for the fragment shader behaves correctly.
+#
+# It is a direct copy of arb_arrays_of_arrays/execution/sampler/
+# fs-nested-struct-arrays-nonconst-nested-array.shader_test
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 71
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpSourceExtension "GL_ARB_gpu_shader5"
+   OpName %main "main"
+   OpName %select "select"
+   OpName %color "color"
+   OpName %S_inner "S_inner"
+   OpMemberName %S_inner 0 "tex"
+   OpMemberName %S_inner 1 "tex2"
+   OpName %S "S"
+   OpMemberName %S 0 "si"
+   OpMemberName %S 1 "tex"
+   OpMemberName %S 2 "final_member"
+   OpName %s "s"
+   OpName %n "n"
+   OpDecorate %select Location 1
+   OpDecorate %color Location 0
+   OpDecorate %s Location 2
+   OpDecorate %n Location 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%_ptr_UniformConstant_int = OpTypePointer UniformConstant %int
+ %select = OpVariable %_ptr_UniformConstant_int UniformConstant
+  %int_0 = OpConstant %int 0
+   %bool = OpTypeBool
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %19 = OpTypeImage %float 2D 0 0 0 1 Unknown
+ %20 = OpTypeSampledImage %19
+%S_inner = OpTypeStruct %20 %20
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr_S_inner_uint_2 = OpTypeArray %S_inner %uint_2
+%_arr__arr_S_inner_uint_2_uint_2 = OpTypeArray %_arr_S_inner_uint_2 %uint_2
+ %uint_3 = OpConstant %uint 3
+%_arr_20_uint_3 = OpTypeArray %20 %uint_3
+%_arr__arr_20_uint_3_uint_2 = OpTypeArray %_arr_20_uint_3 %uint_2
+%_arr_20_uint_2 = OpTypeArray %20 %uint_2
+  %S = OpTypeStruct %_arr__arr_S_inner_uint_2_uint_2 
%_arr__arr_20_uint_3_uint_2 %_arr_20_uint_2
+%_ptr_UniformConstant_S = OpTypePointer UniformConstant %S
+  %s = OpVariable %_ptr_UniformConstant_S UniformConstant
+  %int_1 = OpConstant %int 1
+  %n = OpVariable %_ptr_UniformConstant_int UniformConstant
+%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20
+%v2float = OpTypeVector %float 2
+ %float_0_75 = OpConstant %float 0.75
+ %float_0_25 = OpConstant %float 0.25
+ %43 = OpConstantComposite %v2float %float_0_75 %float_0_25
+  %int_2 = OpConstant %int 2
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+  %9 = OpLoad %int %select
+ %12 = OpIEqual %bool %9 %int_0
+   OpSelectionMerge %14 None
+   OpBranchConditional %12 %13 %45
+ %13 = OpLabel
+ %35 = OpLoad %int %n
+ %36 = OpLoad %int %n
+ %38 = OpAccessChain %_ptr_UniformConstant_20 %s %int_1 %35 %36
+ %39 = OpLoad %20 %38
+ %44 = OpImageSampleImplicitLod %v4float %39 %43
+   OpStore %color %44
+   OpBranch %14
+ %45 = OpLabel
+ %46 = OpLoad %int %select
+ %47 = OpIEqual %bool %46 %int_1
+   OpSelectionMerge %49 None
+   OpBranchConditional %47 %48 %61
+ %48 = OpLabel
+ %50 = OpLoad %int %n
+ %51 = OpLoad %int %n
+ %52 = OpAccessChain %_ptr_UniformConstant_20 %s %int_0 %50 %51 %int_0
+ %53 = OpLoad %20 %52
+ %54 = OpImageSampleImplicitLod %v4float %53 %43
+ %55 = OpLoad %int %n
+ %56 = OpLoad %int %n
+ %57 = OpAccessChain %_ptr_UniformConstant_20 %s %int_0 %55 %56 %int_1
+   

[Piglit] [PATCH 14/24] arb_gl_spirv: uniform sampler2D

2018-06-20 Thread Alejandro Piñeiro
---
 .../execution/uniform/sampler2d.shader_test| 70 ++
 1 file changed, 70 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/sampler2d.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/sampler2d.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d.shader_test
new file mode 100644
index 0..cb0fa50cc
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d.shader_test
@@ -0,0 +1,70 @@
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 19
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %fragColor
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %fragColor "fragColor"
+   OpName %tex2D "tex2D"
+   OpDecorate %fragColor Location 0
+   OpDecorate %tex2D Location 0
+   OpDecorate %tex2D DescriptorSet 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %fragColor = OpVariable %_ptr_Output_v4float Output
+ %10 = OpTypeImage %float 2D 0 0 0 1 Unknown
+ %11 = OpTypeSampledImage %10
+%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
+  %tex2D = OpVariable %_ptr_UniformConstant_11 UniformConstant
+%v2float = OpTypeVector %float 2
+ %float_0_25 = OpConstant %float 0.25
+ %17 = OpConstantComposite %v2float %float_0_25 %float_0_25
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %14 = OpLoad %11 %tex2D
+ %18 = OpImageSampleImplicitLod %v4float %14 %17
+   OpStore %fragColor %18
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 0) out vec4 fragColor;
+
+layout (location = 0) uniform sampler2D tex2D;
+
+void main()
+{
+fragColor = texture(tex2D, vec2(0.25));
+}
+
+[test]
+uniform int 0 0
+texture checkerboard 0 0 (32, 32) (0.0, 1.0, 0.0, 1.0) (1.0, 0.0, 0.0, 1.0)
+texparameter 2D min nearest
+texparameter 2D mag nearest
+
+clear
+clear color 0.0 0.0 1.0 0.0
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.14.1

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


[Piglit] [PATCH 15/24] arb_gl_spirv: Add tests for sampler2D uniform binding initialisers

2018-06-20 Thread Alejandro Piñeiro
From: Neil Roberts 

---
 .../uniform/sampler2d-binding-array.shader_test| 85 ++
 .../uniform/sampler2d-binding.shader_test  | 70 ++
 2 files changed, 155 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding-array.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding-array.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding-array.shader_test
new file mode 100644
index 0..527f1624e
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding-array.shader_test
@@ -0,0 +1,85 @@
+# Test a texture sampler array with a binding initialiser. The
+# initialiser should set the first element and the subsequent ones
+# should increment from there.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 31
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %tex "tex"
+   OpDecorate %color Location 0
+   OpDecorate %tex Location 0
+   OpDecorate %tex DescriptorSet 0
+   OpDecorate %tex Binding 3
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+  %color = OpVariable %_ptr_Output_v4float Output
+ %10 = OpTypeImage %float 2D 0 0 0 1 Unknown
+ %11 = OpTypeSampledImage %10
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr_11_uint_2 = OpTypeArray %11 %uint_2
+%_ptr_UniformConstant__arr_11_uint_2 = OpTypePointer UniformConstant 
%_arr_11_uint_2
+%tex = OpVariable %_ptr_UniformConstant__arr_11_uint_2 UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
+%v2float = OpTypeVector %float 2
+ %float_0_25 = OpConstant %float 0.25
+ %24 = OpConstantComposite %v2float %float_0_25 %float_0_25
+  %int_1 = OpConstant %int 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %20 = OpAccessChain %_ptr_UniformConstant_11 %tex %int_0
+ %21 = OpLoad %11 %20
+ %25 = OpImageSampleImplicitLod %v4float %21 %24
+ %27 = OpAccessChain %_ptr_UniformConstant_11 %tex %int_1
+ %28 = OpLoad %11 %27
+ %29 = OpImageSampleImplicitLod %v4float %28 %24
+ %30 = OpFAdd %v4float %25 %29
+   OpStore %color %30
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 0) out vec4 color;
+
+layout (location = 0, binding = 3) uniform sampler2D tex[2];
+
+void main()
+{
+   color = texture(tex[0], vec2(0.25)) + texture(tex[1], vec2(0.25));
+}
+
+[test]
+clear color 1.0 0.0 0.0 1.0
+clear
+
+texture checkerboard 3 0 (32, 32) (0.02, 0.04, 0.06, 0.08) (0.8, 0.0, 0.0, 1.0)
+texture checkerboard 4 0 (32, 32) (0.10, 0.92, 0.14, 0.16) (0.2, 0.0, 0.0, 1.0)
+
+draw rect -1 -1 2 2
+probe all rgba 0.12 0.96 0.20 0.24
diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding.shader_test
new file mode 100644
index 0..e99aaebbd
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/sampler2d-binding.shader_test
@@ -0,0 +1,70 @@
+# Test a texture sampler with a binding initialiser
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 19
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %tex "tex"
+   OpDecorate %color Location 0
+   OpDecorate %tex Location 0
+   OpDecorate %tex DescriptorSet 0
+   OpDecorate %tex Binding 3
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTyp

[Piglit] [PATCH 09/24] arb_gl_spirv: basic uniform test with names still present

2018-06-20 Thread Alejandro Piñeiro
From: Nicolai Hähnle 

Signed-off-by: Nicolai Hähnle 
Signed-off-by: Neil Roberts 
---
 .../execution/uniform/simple.shader_test   | 124 +
 1 file changed, 124 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/uniform/simple.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/simple.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/simple.shader_test
new file mode 100644
index 0..5f2fdf293
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/simple.shader_test
@@ -0,0 +1,124 @@
+# Test a very simple VS-PS shader pipeline with one uniform
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 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 450
+
+layout(location = 0) 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; 4
+; Bound: 13
+; 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 %color "color"
+   OpDecorate %outcolor Location 0
+   OpDecorate %color Location 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
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %color = OpVariable %_ptr_UniformConstant_v4float UniformConstant
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %12 = OpLoad %v4float %color
+   OpStore %outcolor %12
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) uniform vec4 color;
+
+layout(location = 0) out vec4 outcolor;
+
+void main() {
+outcolor = color;
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+uniform vec4 0 0.0 1.0 0.0 1.0
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.14.1

___

[Piglit] [PATCH 06/24] shader_runner: debug prints if running on SPIR-V mode.

2018-06-20 Thread Alejandro Piñeiro
Fancy to be sure that shader_runner is trying to run in SPIR-V
mode. Didn't print if it is running on GLSL mode as that is the
default. Initially only some small amount of tests will run on SPIR-V
mode.
---
 tests/shaders/shader_runner.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index bffc444d7..2c6837fb6 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1273,6 +1273,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
break;
 
case requirements:
+   if (spirv_replaces_glsl) {
+   printf("Running on SPIR-V mode\n");
+   }
break;
 
case vertex_shader:
-- 
2.14.1

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


[Piglit] [PATCH 12/24] arb_gl_spirv: add a small test with an array of uniforms

2018-06-20 Thread Alejandro Piñeiro
---
 .../execution/uniform/array.shader_test| 137 +
 1 file changed, 137 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/uniform/array.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
new file mode 100644
index 0..54ac66b42
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/array.shader_test
@@ -0,0 +1,137 @@
+# Test a very simple VS-PS shader pipeline with an array of two
+# uniforms with explicit location.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 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 450
+
+layout(location = 0) 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; 4
+; 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
+   OpName %main "main"
+   OpName %outcolor "outcolor"
+   OpName %uniforms "uniforms"
+   OpDecorate %outcolor Location 0
+   OpDecorate %uniforms Location 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
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2
+%_ptr_UniformConstant__arr_v4float_uint_2 = OpTypePointer UniformConstant 
%_arr_v4float_uint_2
+   %uniforms = OpVariable %_ptr_UniformConstant__arr_v4float_uint_2 
UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %int_1 = OpConstant %int 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpAccessChain %_ptr_UniformConstant_v4float %uniforms %int_0
+ %19 = OpLoad %v4float %18
+ %21 = OpAccessChain %_ptr_UniformConstant_v4float %uniform

[Piglit] [PATCH 23/24] arb_gl_spirv: Add a test for an array of structs uniform

2018-06-20 Thread Alejandro Piñeiro
From: Neil Roberts 

---
 .../execution/uniform/struct-array.shader_test | 140 +
 1 file changed, 140 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test
new file mode 100644
index 0..b237c1c77
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/struct-array.shader_test
@@ -0,0 +1,140 @@
+# Tests an array of structs with an explicit uniform location
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 60
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %i "i"
+   OpName %_ ""
+   OpMemberName %_ 0 "r"
+   OpMemberName %_ 1 "g"
+   OpMemberName %_ 2 "b"
+   OpName %parts "parts"
+   OpDecorate %color Location 0
+   OpDecorate %parts Location 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
+%float_0 = OpConstant %float 0
+%float_1 = OpConstant %float 1
+ %12 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_1
+%int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+  %int_0 = OpConstant %int 0
+  %int_2 = OpConstant %int 2
+   %bool = OpTypeBool
+  %_ = OpTypeStruct %float %float %float
+   %uint = OpTypeInt 32 0
+ %uint_2 = OpConstant %uint 2
+%_arr___uint_2 = OpTypeArray %_ %uint_2
+%_ptr_UniformConstant__arr___uint_2 = OpTypePointer UniformConstant 
%_arr___uint_2
+  %parts = OpVariable %_ptr_UniformConstant__arr___uint_2 UniformConstant
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+ %uint_0 = OpConstant %uint 0
+%_ptr_Output_float = OpTypePointer Output %float
+  %int_1 = OpConstant %int 1
+ %uint_1 = OpConstant %uint 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+  %i = OpVariable %_ptr_Function_int Function
+   OpStore %color %12
+   OpStore %i %int_0
+   OpBranch %17
+ %17 = OpLabel
+   OpLoopMerge %19 %20 None
+   OpBranch %21
+ %21 = OpLabel
+ %22 = OpLoad %int %i
+ %25 = OpSLessThan %bool %22 %int_2
+   OpBranchConditional %25 %18 %19
+ %18 = OpLabel
+ %32 = OpLoad %int %i
+ %34 = OpAccessChain %_ptr_UniformConstant_float %parts %32 %int_0
+ %35 = OpLoad %float %34
+ %38 = OpAccessChain %_ptr_Output_float %color %uint_0
+ %39 = OpLoad %float %38
+ %40 = OpFAdd %float %39 %35
+ %41 = OpAccessChain %_ptr_Output_float %color %uint_0
+   OpStore %41 %40
+ %42 = OpLoad %int %i
+ %44 = OpAccessChain %_ptr_UniformConstant_float %parts %42 %int_1
+ %45 = OpLoad %float %44
+ %47 = OpAccessChain %_ptr_Output_float %color %uint_1
+ %48 = OpLoad %float %47
+ %49 = OpFAdd %float %48 %45
+ %50 = OpAccessChain %_ptr_Output_float %color %uint_1
+   OpStore %50 %49
+ %51 = OpLoad %int %i
+ %52 = OpAccessChain %_ptr_UniformConstant_float %parts %51 %int_2
+ %53 = OpLoad %float %52
+ %54 = OpAccessChain %_ptr_Output_float %color %uint_2
+ %55 = OpLoad %float %54
+ %56 = OpFAdd %float %55 %53
+ %57 = OpAccessChain %_ptr_Output_float %color %uint_2
+   OpStore %57 %56
+   OpBranch %20
+ %20 = OpLabel
+ %58 = OpLoad %int %i
+ %59 = OpIAdd %int %58 %int_1
+   OpStore %i %59
+   OpBranch %17
+ %19 = OpLabel
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout(location = 0) uniform struct {
+   float r;
+   float g;
+   float b;
+} parts[2];
+
+out vec4 color;
+
+void main()
+{
+   color = vec4(0.0, 0.0, 0.0, 1.0);
+
+   for (int i = 0; i < 2; i++) {
+   color.r += parts[i].r;
+   color.g += parts[i].g;
+   color.b += parts[i].b;
+   }
+}
+
+[test]
+clear color 0.2 0.2 0.2 0.2
+clear
+
+uniform float 0 0.1
+uniform float 1 0.2
+uniform float 2 0

[Piglit] [PATCH 24/24] arb_gl_spirv: Add a fiddly test for uniform index calculation

2018-06-20 Thread Alejandro Piñeiro
From: Neil Roberts 

This is a somewhat convoluted test to catch a particular problem
with the code we were using to assign a uniform index to a variable.
A uniform’s location starts off being the explicit location.
Previously while recursing through the uniform’s type, whenever the
location matches the current calculated location we were setting it
to the index. However, if the calculated index happens to match a
calculated location then it would set the index a second time and
get it wrong.

Note: This probably shouldn’t be merged into Piglit master because
it’s a bit too specific to a temporary problem we had in Mesa.
---
 .../uniform/index-matches-location.shader_test | 100 +
 1 file changed, 100 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test
new file mode 100644
index 0..3b2e894cf
--- /dev/null
+++ 
b/tests/spec/arb_gl_spirv/execution/uniform/index-matches-location.shader_test
@@ -0,0 +1,100 @@
+# This is a somewhat convoluted test to catch a particular problem
+# with the code we were using to assign a uniform index to a variable.
+# A uniform’s location starts off being the explicit location.
+# Previously while recursing through the uniform’s type, whenever the
+# location matches the current calculated location we were setting it
+# to the index. However, if the calculated index happens to match a
+# calculated location then it would set the index a second time and
+# get it wrong.
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 28
+; 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 %a "a"
+   OpName %_ ""
+   OpMemberName %_ 0 "b"
+   OpMemberName %_ 1 "c"
+   OpName %s "s"
+   OpDecorate %outcolor Location 0
+   OpDecorate %a Location 2
+   OpDecorate %s Location 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
+%float_0 = OpConstant %float 0
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+  %a = OpVariable %_ptr_UniformConstant_float UniformConstant
+  %_ = OpTypeStruct %float %float
+%_ptr_UniformConstant__ = OpTypePointer UniformConstant %_
+  %s = OpVariable %_ptr_UniformConstant__ UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+  %int_1 = OpConstant %int 1
+%float_1 = OpConstant %float 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %13 = OpLoad %float %a
+ %19 = OpAccessChain %_ptr_UniformConstant_float %s %int_0
+ %20 = OpLoad %float %19
+ %21 = OpFAdd %float %13 %20
+ %23 = OpAccessChain %_ptr_UniformConstant_float %s %int_1
+ %24 = OpLoad %float %23
+ %25 = OpFAdd %float %21 %24
+ %27 = OpCompositeConstruct %v4float %float_0 %25 %float_0 %float_1
+   OpStore %outcolor %27
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+// This ends up with index 0
+layout (location = 2) uniform float a;
+
+// This ends up with index 1
+layout (location = 0) uniform struct {
+// index 1, location 0
+float b;
+// index 2, location 1
+//   -> this matches previous index, location gets set again
+float c;
+} s;
+
+layout(location = 0) out vec4 outcolor;
+
+void main() {
+outcolor = vec4(0.0, a + s.b + s.c, 0.0, 1.0);
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+uniform float 0 0.1
+uniform float 1 0.6
+uniform float 2 0.25
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.95 0.0 1.0
-- 
2.14.1

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


[Piglit] [PATCH 13/24] arb_gl_spirv: add execution test for multi-dimensional (aoa) uniform

2018-06-20 Thread Alejandro Piñeiro
---
 .../execution/uniform/arrays-of-arrays.shader_test | 77 ++
 1 file changed, 77 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test

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
new file mode 100644
index 0..07e32560b
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/arrays-of-arrays.shader_test
@@ -0,0 +1,77 @@
+# Array of arrays of uniforms test
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 25
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %u_color "u_color"
+   OpDecorate %color Location 0
+   OpDecorate %u_color Location 10
+   %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_2 = OpConstant %uint 2
+%_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2
+%_arr__arr_v4float_uint_2_uint_2 = OpTypeArray %_arr_v4float_uint_2 %uint_2
+%_ptr_UniformConstant__arr__arr_v4float_uint_2_uint_2 = OpTypePointer 
UniformConstant %_arr__arr_v4float_uint_2_uint_2
+%u_color = OpVariable 
%_ptr_UniformConstant__arr__arr_v4float_uint_2_uint_2 UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %int_1 = OpConstant %int 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %19 = OpAccessChain %_ptr_UniformConstant_v4float %u_color %int_0 
%int_0
+ %20 = OpLoad %v4float %19
+ %22 = OpAccessChain %_ptr_UniformConstant_v4float %u_color %int_1 
%int_1
+ %23 = OpLoad %v4float %22
+ %24 = OpFAdd %v4float %20 %23
+   OpStore %color %24
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+layout (location = 0) out vec4 color;
+
+layout (location = 10) uniform vec4 u_color[2][2];
+
+void main()
+{
+   color = u_color[0][0] + u_color[1][1];
+}
+
+[test]
+clear color 0.2 0.2 0.2 0.2
+clear
+
+uniform vec4 10 0.0 0.1 0.2 0.3
+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
+
+draw rect -1 -1 1 1
+relative probe rect rgb (0.0, 0.0, 0.5, 0.5) (0.1, 0.3, 0.5)
-- 
2.14.1

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


[Piglit] [PATCH 05/24] shader_runner/spirv: Add support for SPIR-V specializations

2018-06-20 Thread Alejandro Piñeiro
From: Neil Roberts 

There can now be extra sections such as the following in the
shader_test file:

[vertex shader specializations]
uint 0 3

These will get passed to glSpecializeShader when compiling the
corresponding shader.
---
 tests/shaders/shader_runner.c | 181 +-
 1 file changed, 180 insertions(+), 1 deletion(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index abe0df0b0..bffc444d7 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -165,6 +165,16 @@ static bool use_get_program_binary = false;
 
 static bool report_subtests = false;
 
+struct specialization_list {
+   size_t buffer_size;
+   size_t n_entries;
+   GLuint *indices;
+   union { GLuint u; GLfloat f; } *values;
+};
+
+static struct specialization_list
+specializations[SHADER_TYPES];
+
 static struct texture_binding {
GLuint obj;
unsigned width;
@@ -258,19 +268,25 @@ enum states {
vertex_shader,
vertex_shader_passthrough,
vertex_shader_spirv,
+   vertex_shader_specializations,
vertex_program,
tess_ctrl_shader,
tess_ctrl_shader_spirv,
+   tess_ctrl_shader_specializations,
tess_eval_shader,
tess_eval_shader_spirv,
+   tess_eval_shader_specializations,
geometry_shader,
geometry_shader_spirv,
+   geometry_shader_specializations,
geometry_layout,
fragment_shader,
fragment_shader_spirv,
+   fragment_shader_specializations,
fragment_program,
compute_shader,
compute_shader_spirv,
+   compute_shader_specializations,
vertex_data,
test,
 };
@@ -719,7 +735,36 @@ load_and_specialize_spirv(GLenum target,
glShaderBinary(1, &shader, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB,
   binary, size);
 
-   glSpecializeShaderARB(shader, "main", 0, NULL, NULL);
+   const struct specialization_list *specs;
+
+   switch (target) {
+   case GL_VERTEX_SHADER:
+   specs = specializations + 0;
+   break;
+   case GL_TESS_CONTROL_SHADER:
+   specs = specializations + 1;
+   break;
+   case GL_TESS_EVALUATION_SHADER:
+   specs = specializations + 2;
+   break;
+   case GL_GEOMETRY_SHADER:
+   specs = specializations + 3;
+   break;
+   case GL_FRAGMENT_SHADER:
+   specs = specializations + 4;
+   break;
+   case GL_COMPUTE_SHADER:
+   specs = specializations + 5;
+   break;
+   default:
+   assert(!"Should not get here.");
+   }
+
+   glSpecializeShaderARB(shader,
+ "main",
+ specs->n_entries,
+ specs->indices,
+ &specs->values[0].u);
 
GLint ok;
glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
@@ -1256,6 +1301,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
shader_string_size = line - shader_string;
return assemble_spirv(GL_VERTEX_SHADER);
 
+   case vertex_shader_specializations:
+   break;
+
case tess_ctrl_shader:
if (spirv_replaces_glsl)
break;
@@ -1268,6 +1316,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
shader_string_size = line - shader_string;
return assemble_spirv(GL_TESS_CONTROL_SHADER);
 
+   case tess_ctrl_shader_specializations:
+   break;
+
case tess_eval_shader:
if (spirv_replaces_glsl)
break;
@@ -1280,6 +1331,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
shader_string_size = line - shader_string;
return assemble_spirv(GL_TESS_EVALUATION_SHADER);
 
+   case tess_eval_shader_specializations:
+   break;
+
case geometry_shader:
if (spirv_replaces_glsl)
break;
@@ -1292,6 +1346,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
shader_string_size = line - shader_string;
return assemble_spirv(GL_GEOMETRY_SHADER);
 
+   case geometry_shader_specializations:
+   break;
+
case geometry_layout:
break;
 
@@ -1313,6 +1370,9 @@ leave_state(enum states state, const char *line, const 
char *script_name)
shader_string_size = line - shader_string;
return assemble_spirv(GL_FRAGMENT_SHADER);
 
+   case fragment_shader_specializations:
+   break;
+
case compute_shader:
if (spirv_replaces_glsl)
break;
@@ -1325,6 +1385,9 @@ leave_state(enum states state, const ch

[Piglit] [PATCH 21/24] arb_gl_spirv: Add a test for a struct uniform

2018-06-20 Thread Alejandro Piñeiro
From: Neil Roberts 

---
 .../execution/uniform/struct.shader_test   | 79 ++
 1 file changed, 79 insertions(+)
 create mode 100644 tests/spec/arb_gl_spirv/execution/uniform/struct.shader_test

diff --git a/tests/spec/arb_gl_spirv/execution/uniform/struct.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/struct.shader_test
new file mode 100644
index 0..f68120512
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/struct.shader_test
@@ -0,0 +1,79 @@
+# Test using a simple struct uniform with a non-zero explicit location
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 22
+; 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 %parts "parts"
+   OpMemberName %parts 0 "part1"
+   OpMemberName %parts 1 "part2"
+   OpName %fsin "fsin"
+   OpDecorate %outcolor Location 0
+   OpDecorate %fsin Location 4
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+  %float = OpTypeFloat 32
+%v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+   %outcolor = OpVariable %_ptr_Output_v4float Output
+  %parts = OpTypeStruct %v4float %v4float
+%_ptr_UniformConstant_parts = OpTypePointer UniformConstant %parts
+   %fsin = OpVariable %_ptr_UniformConstant_parts UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_v4float = OpTypePointer UniformConstant %v4float
+  %int_1 = OpConstant %int 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %16 = OpAccessChain %_ptr_UniformConstant_v4float %fsin %int_0
+ %17 = OpLoad %v4float %16
+ %19 = OpAccessChain %_ptr_UniformConstant_v4float %fsin %int_1
+ %20 = OpLoad %v4float %19
+ %21 = OpFAdd %v4float %17 %20
+   OpStore %outcolor %21
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+struct parts {
+vec4 part1;
+vec4 part2;
+};
+
+layout(location = 4) uniform parts fsin;
+
+layout(location = 0) out vec4 outcolor;
+
+void main() {
+outcolor = fsin.part1 + fsin.part2;
+}
+
+[test]
+clear color 1.0 0.0 0.0 0.0
+clear
+
+uniform vec4 4 0.1 0.15 0.2 0.25
+uniform vec4 5 0.3 0.35 0.4 0.45
+
+draw rect -1 -1 2 2
+probe all rgba 0.4 0.5 0.6 0.7
-- 
2.14.1

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


[Piglit] [PATCH 22/24] arb_gl_spirv: Add a test for a uniform struct with struct members

2018-06-20 Thread Alejandro Piñeiro
From: Neil Roberts 

---
 .../execution/uniform/embedded-structs.shader_test | 151 +
 1 file changed, 151 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/execution/uniform/embedded-structs.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/execution/uniform/embedded-structs.shader_test 
b/tests/spec/arb_gl_spirv/execution/uniform/embedded-structs.shader_test
new file mode 100644
index 0..0dd7ba486
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/execution/uniform/embedded-structs.shader_test
@@ -0,0 +1,151 @@
+# Tests an array of arrays with an explicit uniform location
+
+[require]
+SPIRV YES
+GL >= 3.3
+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; 4
+; Bound: 55
+; Schema: 0
+   OpCapability Shader
+  %1 = OpExtInstImport "GLSL.std.450"
+   OpMemoryModel Logical GLSL450
+   OpEntryPoint Fragment %main "main" %color
+   OpExecutionMode %main OriginLowerLeft
+   OpSource GLSL 450
+   OpName %main "main"
+   OpName %color "color"
+   OpName %pair "pair"
+   OpMemberName %pair 0 "a"
+   OpMemberName %pair 1 "b"
+   OpName %quadruple "quadruple"
+   OpMemberName %quadruple 0 "a"
+   OpMemberName %quadruple 1 "b"
+   OpName %_ ""
+   OpMemberName %_ 0 "r"
+   OpMemberName %_ 1 "g"
+   OpMemberName %_ 2 "b"
+   OpName %parts "parts"
+   OpDecorate %color Location 0
+   OpDecorate %parts Location 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
+   %pair = OpTypeStruct %float %float
+  %quadruple = OpTypeStruct %pair %pair
+  %_ = OpTypeStruct %quadruple %quadruple %quadruple
+%_ptr_UniformConstant__ = OpTypePointer UniformConstant %_
+  %parts = OpVariable %_ptr_UniformConstant__ UniformConstant
+%int = OpTypeInt 32 1
+  %int_0 = OpConstant %int 0
+%_ptr_UniformConstant_float = OpTypePointer UniformConstant %float
+  %int_1 = OpConstant %int 1
+  %int_2 = OpConstant %int 2
+%float_1 = OpConstant %float 1
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+ %18 = OpAccessChain %_ptr_UniformConstant_float %parts %int_0 %int_0 
%int_0
+ %19 = OpLoad %float %18
+ %21 = OpAccessChain %_ptr_UniformConstant_float %parts %int_0 %int_0 
%int_1
+ %22 = OpLoad %float %21
+ %23 = OpFAdd %float %19 %22
+ %24 = OpAccessChain %_ptr_UniformConstant_float %parts %int_0 %int_1 
%int_0
+ %25 = OpLoad %float %24
+ %26 = OpFAdd %float %23 %25
+ %27 = OpAccessChain %_ptr_UniformConstant_float %parts %int_0 %int_1 
%int_1
+ %28 = OpLoad %float %27
+ %29 = OpFAdd %float %26 %28
+ %30 = OpAccessChain %_ptr_UniformConstant_float %parts %int_1 %int_0 
%int_0
+ %31 = OpLoad %float %30
+ %32 = OpAccessChain %_ptr_UniformConstant_float %parts %int_1 %int_0 
%int_1
+ %33 = OpLoad %float %32
+ %34 = OpFAdd %float %31 %33
+ %35 = OpAccessChain %_ptr_UniformConstant_float %parts %int_1 %int_1 
%int_0
+ %36 = OpLoad %float %35
+ %37 = OpFAdd %float %34 %36
+ %38 = OpAccessChain %_ptr_UniformConstant_float %parts %int_1 %int_1 
%int_1
+ %39 = OpLoad %float %38
+ %40 = OpFAdd %float %37 %39
+ %42 = OpAccessChain %_ptr_UniformConstant_float %parts %int_2 %int_0 
%int_0
+ %43 = OpLoad %float %42
+ %44 = OpAccessChain %_ptr_UniformConstant_float %parts %int_2 %int_0 
%int_1
+ %45 = OpLoad %float %44
+ %46 = OpFAdd %float %43 %45
+ %47 = OpAccessChain %_ptr_UniformConstant_float %parts %int_2 %int_1 
%int_0
+ %48 = OpLoad %float %47
+ %49 = OpFAdd %float %46 %48
+ %50 = OpAccessChain %_ptr_UniformConstant_float %parts %int_2 %int_1 
%int_1
+ %51 = OpLoad %float %50
+ %52 = OpFAdd %float %49 %51
+ %54 = OpCompositeConstruct %v4float %29 %40 %52 %float_1
+   OpStore %color %54
+   OpReturn
+   OpFunctionEnd
+
+[fragment shader]
+#version 450
+
+struct pair {
+float a;
+float b;
+};
+
+struct quadruple {
+pair a;
+pair b;
+};
+
+layout(location = 0) uniform struct {
+   quadruple r;
+   quadruple g;
+   quadruple b;
+} parts;
+
+out vec4 color;
+
+void main()
+{
+   color = vec4(parts.r.a.a +
+ parts.r.a.b +
+ parts.r.b.a +
+ parts.r.b.b,
+

[Piglit] [PATCH 18/24] arb_gl_spirv: add two linking tests for uniform multisample images

2018-06-20 Thread Alejandro Piñeiro
Use a uniform image2DMS and image2DMSArray. The latter related with
SpvCapabilityImageMSArray.

Note that those are linking tests, because although the specific
extensions are supported, in the practice multisampling is not allowed
as GL_MAX_IMAGE_SAMPLES is zero for most mesa drivers.

Signed-off-by: Alejandro Piñeiro 
Signed-off-by: Antia Puentes 
---
 .../linker/uniform/multisampler-array.shader_test  | 68 ++
 .../linker/uniform/multisampler.shader_test| 67 +
 2 files changed, 135 insertions(+)
 create mode 100644 
tests/spec/arb_gl_spirv/linker/uniform/multisampler-array.shader_test
 create mode 100644 
tests/spec/arb_gl_spirv/linker/uniform/multisampler.shader_test

diff --git 
a/tests/spec/arb_gl_spirv/linker/uniform/multisampler-array.shader_test 
b/tests/spec/arb_gl_spirv/linker/uniform/multisampler-array.shader_test
new file mode 100644
index 0..8d79aca43
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/linker/uniform/multisampler-array.shader_test
@@ -0,0 +1,68 @@
+# Test for SpvCapabilityImageMSArray
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+
+[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; 4
+; Bound: 23
+; Schema: 0
+   OpCapability Shader
+   OpCapability StorageImageMultisample
+   OpCapability ImageMSArray
+   OpCapability ImageQuery
+  %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 %samp "samp"
+   OpName %rimg2DMSArray "rimg2DMSArray"
+   OpDecorate %rimg2DMSArray Location 2
+   OpDecorate %rimg2DMSArray DescriptorSet 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+   %uint = OpTypeInt 32 0
+ %10 = OpTypeImage %uint 2D 0 1 1 2 Rgba8ui
+%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10
+%rimg2DMSArray = OpVariable %_ptr_UniformConstant_10 UniformConstant
+  %v3int = OpTypeVector %int 3
+  %int_0 = OpConstant %int 0
+ %18 = OpConstantComposite %v3int %int_0 %int_0 %int_0
+  %int_2 = OpConstant %int 2
+ %v4uint = OpTypeVector %uint 4
+   %uint_255 = OpConstant %uint 255
+ %22 = OpConstantComposite %v4uint %uint_255 %uint_255 %uint_255 
%uint_255
+   %main = OpFunction %void None %3
+  %5 = OpLabel
+   %samp = OpVariable %_ptr_Function_int Function
+ %13 = OpLoad %10 %rimg2DMSArray
+ %14 = OpImageQuerySamples %int %13
+   OpStore %samp %14
+ %15 = OpLoad %10 %rimg2DMSArray
+   OpImageWrite %15 %18 %22 Sample %int_2
+   OpReturn
+   OpFunctionEnd
+
+[compute shader]
+#version 450
+
+layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+
+layout (location = 2, rgba8ui) uniform uimage2DMSArray rimg2DMSArray;
+
+void main()
+{
+int samp = imageSamples(rimg2DMSArray);
+imageStore(rimg2DMSArray, ivec3(0), 2, uvec4(255));
+}
+
+[test]
+link success
diff --git a/tests/spec/arb_gl_spirv/linker/uniform/multisampler.shader_test 
b/tests/spec/arb_gl_spirv/linker/uniform/multisampler.shader_test
new file mode 100644
index 0..5cf00192f
--- /dev/null
+++ b/tests/spec/arb_gl_spirv/linker/uniform/multisampler.shader_test
@@ -0,0 +1,67 @@
+#Test using an uniform of type uimage2DMS
+[require]
+SPIRV YES
+GL >= 3.3
+GLSL >= 4.50
+
+[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; 4
+; Bound: 23
+; Schema: 0
+   OpCapability Shader
+   OpCapability StorageImageMultisample
+   OpCapability ImageQuery
+  %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 %samp "samp"
+   OpName %rimg2DMS "rimg2DMS"
+   OpDecorate %rimg2DMS Location 2
+   OpDecorate %rimg2DMS DescriptorSet 0
+   %void = OpTypeVoid
+  %3 = OpTypeFunction %void
+%int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+   %uint = OpTypeInt 32 0
+ %10 = OpTypeImage %uint 2D 0 0 1 2 Rgba8ui
+%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10
+   %rimg2DMS = OpVariable %_ptr_Unifor

<    1   2   3   4   5   >