[Piglit] [PATCH] gs: Test that input arrays can be accessed dynamically.

Paul Berry stereotype441 at gmail.com
Tue Sep 10 16:52:55 PDT 2013


On 10 September 2013 16:28, Chad Versace <chad.versace at linux.intel.com>wrote:

> On 09/04/2013 02:22 PM, Paul Berry wrote:
>
>> Most geometry shaders access their input arrays using a constant index
>> (or an index that is constant after loop unrolling).  This test checks
>> that we get the right results if we access a geometry shader input
>> array using a non-constant index.
>> ---
>>   .../geometry/dynamic_input_**array_index.shader_test | 67
>> ++++++++++++++++++++++
>>   1 file changed, 67 insertions(+)
>>   create mode 100644 tests/spec/glsl-1.50/**execution/geometry/dynamic_**
>> input_array_index.shader_test
>>
>> diff --git a/tests/spec/glsl-1.50/**execution/geometry/dynamic_**input_array_index.shader_test
>> b/tests/spec/glsl-1.50/**execution/geometry/dynamic_**
>> input_array_index.shader_test
>> new file mode 100644
>> index 0000000..685a66a
>> --- /dev/null
>> +++ b/tests/spec/glsl-1.50/**execution/geometry/dynamic_**
>> input_array_index.shader_test
>> @@ -0,0 +1,67 @@
>> +# Verify that a geometry shader can access an input array using a
>> +# dynamic index rather than a constant index.
>> +
>> +[require]
>> +GL >= 3.2
>> +GLSL >= 1.50
>> +
>> +[vertex shader]
>> +#version 150
>> +
>> +in vec4 vertex;
>> +in vec4 color;
>> +in int index;
>> +out vec4 vertex_to_gs;
>> +out vec4 color_to_gs;
>> +out int index_to_gs;
>> +
>> +void main()
>> +{
>> +  vertex_to_gs = vertex;
>> +  color_to_gs = color;
>> +  index_to_gs = index;
>> +}
>> +
>> +[geometry shader]
>> +#version 150
>> +
>> +layout(triangles) in;
>> +layout(triangle_strip, max_vertices = 3) out;
>> +
>> +in vec4 vertex_to_gs[3];
>> +in vec4 color_to_gs[3];
>> +in int index_to_gs[3];
>> +out vec4 color_to_fs;
>> +
>> +void main()
>> +{
>> +  for (int i = 0; i < 3; i++) {
>> +    gl_Position = vertex_to_gs[i];
>> +    color_to_fs = color_to_gs[index_to_gs[i]];
>> +    EmitVertex();
>> +  }
>> +}
>> +
>> +[fragment shader]
>> +#version 150
>> +
>> +in vec4 color_to_fs;
>> +out vec4 color;
>> +
>> +void main()
>> +{
>> +  color = color_to_fs;
>> +}
>> +
>> +[vertex data]
>> +vertex/float/2  color/float/4    index/int/1
>> +-1.0 -1.0       1.0 0.0 0.0 1.0  1
>> + 1.0 -1.0       0.0 1.0 0.0 1.0  1
>> + 1.0  1.0       0.0 0.0 1.0 1.0  1
>> +-1.0 -1.0       1.0 0.0 0.0 1.0  2
>> + 1.0  1.0       0.0 0.0 1.0 1.0  2
>> +-1.0  1.0       0.0 1.0 0.0 1.0  2
>> +
>> +[test]
>> +draw arrays GL_TRIANGLES 0 6
>> +probe all rgba 0.0 1.0 0.0 1.0
>>
>>
> Seeing that the index attribute has the same value for all vertices
> that belong to the same primitive, I can imagine some simple code
> generation
> bugs under which this test would produce a false positive.
>
> I'd like to see each index attribute have a unique value, and guarantee
> that the test fails if a single wrong index value is chosen.
> Here's a partial example that I think accomplishes that:
>
> [geometry shader]
> #version 150
>
> layout(triangles) in;
> layout(triangle_strip, max_vertices = 3) out;
>
> in vec4 vertex_to_gs[3];
> in ivec4 color_to_gs[3];
> in ivec4 modulus_to_gs[3];
> int index_to_gs[3];
> out vec4 color_to_fs;
>
> void main()
> {
>
>   for (int i = 0; i < 3; i++) {
>     gl_Position = vertex_to_gs[i];
>     color_to_fs = vec4(mod(color_to_gs[i], modulus_to_gs[index_to_gs[i]])*
> *);
>     EmitVertex();
>   }
> }
>
> [vertex data]
> vertex/float/2  color/int/4       modulus/int/4   index/int/1
> -1.0 -1.0       5  7  9 10        4 7 5 2         2
>  1.0 -1.0       2  3  4  3        2 2 2 2         1
>  1.0  1.0       8 15 15 15        5 6 9 9         0
> -1.0 -1.0       ...
>  1.0  1.0       ...
> -1.0  1.0       ...
>

Sure, I can go along with this.  It's definitely a more thorough test, and
it didn't take me too long to think through all the math and convince
myself that it produces the correct results.  v2 on its way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130910/3e666111/attachment.html>


More information about the Piglit mailing list