[Piglit] [PATCH] arb_shader_storage_buffer_object: don't do out-of-bounds writes

Arthur Huillet arthur.huillet at free.fr
Fri Aug 25 08:43:03 UTC 2017


Reviewed-by: Arthur Huillet <ahuillet at nvidia.com>

The test now passes with our change of behavior to out-of-bounds writes 
(redirected to 0 instead of ignored). That change isn't present in any 
currently available NVIDIA driver release.

Thanks!

On 25.08.2017 08:13, Samuel Iglesias Gonsálvez wrote:
> From GLGL 4.5 spec, 5.11 "Out-of-Bounds Accesses":
> 
> "In the subsections described above for array, vector, matrix and
>  structure accesses, any out-of-bounds access produced undefined
>  behavior. However, if robust buffer access is enabled via the
>  OpenGL API, such accesses will be bound within the memory extent
>  of the active program."
> 
> These tests perform writes to an unsized array, however some of
> these writes can be out-of-bounds and the result is undefined. As
> the tests are focused on in-bound access and they don't enable
> robust buffer access, then this patch removes the out-of-bounds writes
> because we cannot assume they will be ignored.
> 
> Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
> Cc: ahuillet at nvidia.com
> ---
>  .../arb_shader_storage_buffer_object/layout-std140-write-shader.c   | 
> 6 ++++--
>  .../arb_shader_storage_buffer_object/layout-std430-write-shader.c   | 
> 6 ++++--
>  2 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git
> a/tests/spec/arb_shader_storage_buffer_object/layout-std140-write-shader.c
> b/tests/spec/arb_shader_storage_buffer_object/layout-std140-write-shader.c
> index c67248e7a..914fc000f 100644
> --- 
> a/tests/spec/arb_shader_storage_buffer_object/layout-std140-write-shader.c
> +++ 
> b/tests/spec/arb_shader_storage_buffer_object/layout-std140-write-shader.c
> @@ -63,7 +63,8 @@ static const char vs_pass_thru_text[] =
>  	"       f = 4.0;\n"
>  	"       s.a2[0] = vec2(6.0, 7.0); \n"
>  	"       int index = int(v.x); // index should be zero\n"
> -	"       unsized_array[index + gl_VertexID] = 
> unsized_array.length();\n"
> +	"       if ((index + gl_VertexID) < 4)\n"
> +	"              unsized_array[index + gl_VertexID] = 
> unsized_array.length();\n"
>          "}\n";
> 
>  static const char fs_source[] =
> @@ -91,7 +92,8 @@ static const char fs_source[] =
>  	"       s.a2[1] = vec2(8.0, 9.0);\n"
>  	"       s.a4 = mat2(10.0, 11.0, 12.0, 13.0);\n"
>  	"       int index = int(v.z + gl_FragCoord.x);\n"
> -	"       unsized_array[index] = unsized_array.length() * 2.0;\n"
> +	"       if (index >= 0 && index < 4)\n"
> +	"              unsized_array[index] = unsized_array.length() * 
> 2.0;\n"
>  	"}\n";
> 
>  GLuint prog;
> diff --git
> a/tests/spec/arb_shader_storage_buffer_object/layout-std430-write-shader.c
> b/tests/spec/arb_shader_storage_buffer_object/layout-std430-write-shader.c
> index 70c87a164..3d5dcdc47 100644
> --- 
> a/tests/spec/arb_shader_storage_buffer_object/layout-std430-write-shader.c
> +++ 
> b/tests/spec/arb_shader_storage_buffer_object/layout-std430-write-shader.c
> @@ -86,7 +86,8 @@ static const char vs_pass_thru_text[] =
>  	"       v3a[0].xz = vec2(39.0, 41.0);\n"
>  	"       v3a[1].y = 43.0;\n"
>  	"       int index = int(v.x); // index should be zero\n"
> -	"       unsized_array[index + gl_VertexID] = 
> unsized_array.length();\n"
> +	"       if ((index + gl_VertexID) < 4)\n"
> +	"              unsized_array[index + gl_VertexID] = 
> unsized_array.length();\n"
>  	"}\n";
> 
>  static const char fs_source[] =
> @@ -126,7 +127,8 @@ static const char fs_source[] =
>  	"       v3a[0].y = 40.0;\n"
>  	"       v3a[1].xz = vec2(42.0, 44.0);\n"
>  	"       int index = int(v.z + gl_FragCoord.x);\n"
> -	"       unsized_array[index] = unsized_array.length() * 2.0;\n"
> +	"       if (index >= 0 && index < 4)\n"
> +	"              unsized_array[index] = unsized_array.length() * 
> 2.0;\n"
>  	"}\n";
> 
>  GLuint prog;

-- 
A. Huillet


More information about the Piglit mailing list