[Piglit] [PATCH] arb_enhanced_layouts: explicit-offset: add more corner cases

apinheiro apinheiro at igalia.com
Mon Dec 17 13:32:10 UTC 2018


LGTM

Reviewed-by: Alejandro PiƱeiro <apinheiro at igalia.com>

On 16/12/18 6:15, Niklas Haas wrote:
> From: Niklas Haas <git at haasn.xyz>
>
> This adds a few tests:
> - testing offsets that immediately follow a member whose actual size is
>   smaller than its actual alignment
> - testing confusing interactions between explicit alignment and explicit
>   offsets, in particular when the former overrides the latter
> - test that overriding block-level alignments works as expected
>
> Notably, the first of the three test cases triggers a compile-time error
> in current mesa.
>
> Signed-off-by: Niklas Haas <git at haasn.xyz>
> ---
>  ...-explicit-offset-align-mismatch-error.vert | 39 +++++++++++++++++++
>  .../ssbo-explicit-offset-align-mismatch.vert  | 32 +++++++++++++++
>  .../ssbo-explicit-offset-vec3.vert            | 29 ++++++++++++++
>  ...sbo-override-explicit-block-alignment.vert | 31 +++++++++++++++
>  ...-explicit-offset-align-mismatch-error.vert | 38 ++++++++++++++++++
>  .../ubo-explicit-offset-align-mismatch.vert   | 31 +++++++++++++++
>  .../ubo-explicit-offset-vec3.vert             | 28 +++++++++++++
>  ...ubo-override-explicit-block-alignment.vert | 30 ++++++++++++++
>  8 files changed, 258 insertions(+)
>  create mode 100644 tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-align-mismatch-error.vert
>  create mode 100644 tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-align-mismatch.vert
>  create mode 100644 tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-vec3.vert
>  create mode 100644 tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-override-explicit-block-alignment.vert
>  create mode 100644 tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-align-mismatch-error.vert
>  create mode 100644 tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-align-mismatch.vert
>  create mode 100644 tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-vec3.vert
>  create mode 100644 tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-override-explicit-block-alignment.vert
>
> diff --git a/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-align-mismatch-error.vert b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-align-mismatch-error.vert
> new file mode 100644
> index 000000000..00d458b28
> --- /dev/null
> +++ b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-align-mismatch-error.vert
> @@ -0,0 +1,39 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.40
> +// require_extensions: GL_ARB_enhanced_layouts GL_ARB_shader_storage_buffer_object
> +// check_link: false
> +// [end config]
> +//
> +// ARB_enhanced_layouts spec says:
> +//    "The /actual alignment/ of a member will be the greater of the specified
> +//    *align* alignment and the standard (e.g., *std140*) base alignment for the
> +//    member's type.  The /actual offset/ of a member is computed as follows:
> +//    If *offset* was declared, start with that offset, otherwise start with the
> +//    next available offset.  If the resulting offset is not a multiple of the
> +//    /actual alignment/, increase it to the first offset that is a multiple of
> +//    the /actual alignment/.  This results in the /actual offset/ the member
> +//    will have."
> +//
> +//    "It is a compile-time error to
> +//    specify an *offset* that is smaller than the offset of the previous
> +//    member in the block or that lies within the previous member of the
> +//    block."
> +//
> +// Tests whether a block with conflicting offset and alignment requirements
> +// followed by a field with an explicit offset that lies within the actual
> +// position of the previous member fails.
> +//
> +
> +#version 140
> +#extension GL_ARB_enhanced_layouts : enable
> +#extension GL_ARB_shader_storage_buffer_object : enable
> +
> +layout(std430) buffer b {
> +       layout(offset = 8, align = 16) vec2 var1; // starts at actual offset 16
> +       layout(offset = 20) float var2; // error: inside var1
> +};
> +
> +void main()
> +{
> +}
> diff --git a/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-align-mismatch.vert b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-align-mismatch.vert
> new file mode 100644
> index 000000000..79e83ed1c
> --- /dev/null
> +++ b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-align-mismatch.vert
> @@ -0,0 +1,32 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.40
> +// require_extensions: GL_ARB_enhanced_layouts GL_ARB_shader_storage_buffer_object
> +// check_link: false
> +// [end config]
> +//
> +// ARB_enhanced_layouts spec says:
> +//    "The /actual alignment/ of a member will be the greater of the specified
> +//    *align* alignment and the standard (e.g., *std140*) base alignment for the
> +//    member's type.  The /actual offset/ of a member is computed as follows:
> +//    If *offset* was declared, start with that offset, otherwise start with the
> +//    next available offset.  If the resulting offset is not a multiple of the
> +//    /actual alignment/, increase it to the first offset that is a multiple of
> +//    the /actual alignment/.  This results in the /actual offset/ the member
> +//    will have."
> +//
> +// Tests whether a block with conflicting offset and alignment requirements
> +// is accepted.
> +//
> +
> +#version 140
> +#extension GL_ARB_enhanced_layouts : enable
> +#extension GL_ARB_shader_storage_buffer_object : enable
> +
> +layout(std430) buffer b {
> +       layout(offset = 4, align = 16) float var1;
> +};
> +
> +void main()
> +{
> +}
> diff --git a/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-vec3.vert b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-vec3.vert
> new file mode 100644
> index 000000000..72a5fcc27
> --- /dev/null
> +++ b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-explicit-offset-vec3.vert
> @@ -0,0 +1,29 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.40
> +// require_extensions: GL_ARB_enhanced_layouts GL_ARB_shader_storage_buffer_object
> +// check_link: false
> +// [end config]
> +//
> +// ARB_enhanced_layouts spec says:
> +//    "It is a compile-time error to
> +//    specify an *offset* that is smaller than the offset of the previous
> +//    member in the block or that lies within the previous member of the
> +//    block."
> +//
> +// Tests whether choosing an offset that is larger than the previous element's
> +// size, but smaller than its base alignment, is accepted.
> +//
> +
> +#version 140
> +#extension GL_ARB_enhanced_layouts : enable
> +#extension GL_ARB_shader_storage_buffer_object : enable
> +
> +layout(std430) buffer b {
> +       layout(offset = 0) vec3 var1;
> +       layout(offset = 12) float var2;
> +};
> +
> +void main()
> +{
> +}
> diff --git a/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-override-explicit-block-alignment.vert b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-override-explicit-block-alignment.vert
> new file mode 100644
> index 000000000..476af121b
> --- /dev/null
> +++ b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ssbo-override-explicit-block-alignment.vert
> @@ -0,0 +1,31 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.40
> +// require_extensions: GL_ARB_enhanced_layouts GL_ARB_shader_storage_buffer_object
> +// check_link: false
> +// [end config]
> +//
> +// ARB_enhanced_layouts spec says:
> +//    "The *align* qualifier, when used on a block, has the same effect as
> +//    qualifying each member with the same *align* value as declared on the
> +//    block, and gets the same compile-time results and errors as if this had
> +//    been done.  As described in general earlier, an individual member can
> +//    specify its own *align*, which overrides the block-level *align*, but
> +//    just for that member."
> +//
> +// Tests whether a block member with an explicit alignment requirement
> +// overriding the block-level alignment succeeds.
> +//
> +
> +#version 140
> +#extension GL_ARB_enhanced_layouts : enable
> +#extension GL_ARB_shader_storage_buffer_object : enable
> +
> +layout(std430, align = 16) buffer b {
> +       layout(offset = 8, align = 8) vec2 var1;
> +       layout(offset = 16) float var2; // would be inside `var1` without align = 8
> +};
> +
> +void main()
> +{
> +}
> diff --git a/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-align-mismatch-error.vert b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-align-mismatch-error.vert
> new file mode 100644
> index 000000000..5e4b24c40
> --- /dev/null
> +++ b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-align-mismatch-error.vert
> @@ -0,0 +1,38 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.40
> +// require_extensions: GL_ARB_enhanced_layouts
> +// check_link: false
> +// [end config]
> +//
> +// ARB_enhanced_layouts spec says:
> +//    "The /actual alignment/ of a member will be the greater of the specified
> +//    *align* alignment and the standard (e.g., *std140*) base alignment for the
> +//    member's type.  The /actual offset/ of a member is computed as follows:
> +//    If *offset* was declared, start with that offset, otherwise start with the
> +//    next available offset.  If the resulting offset is not a multiple of the
> +//    /actual alignment/, increase it to the first offset that is a multiple of
> +//    the /actual alignment/.  This results in the /actual offset/ the member
> +//    will have."
> +//
> +//    "It is a compile-time error to
> +//    specify an *offset* that is smaller than the offset of the previous
> +//    member in the block or that lies within the previous member of the
> +//    block."
> +//
> +// Tests whether a block with conflicting offset and alignment requirements
> +// followed by a field with an explicit offset that lies within the actual
> +// position of the previous member fails.
> +//
> +
> +#version 140
> +#extension GL_ARB_enhanced_layouts : enable
> +
> +layout(std140) uniform block {
> +       layout(offset = 8, align = 16) vec2 var1; // starts at actual offset 16
> +       layout(offset = 20) float var2; // error: inside var1
> +};
> +
> +void main()
> +{
> +}
> diff --git a/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-align-mismatch.vert b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-align-mismatch.vert
> new file mode 100644
> index 000000000..1a862572d
> --- /dev/null
> +++ b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-align-mismatch.vert
> @@ -0,0 +1,31 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.40
> +// require_extensions: GL_ARB_enhanced_layouts
> +// check_link: false
> +// [end config]
> +//
> +// ARB_enhanced_layouts spec says:
> +//    "The /actual alignment/ of a member will be the greater of the specified
> +//    *align* alignment and the standard (e.g., *std140*) base alignment for the
> +//    member's type.  The /actual offset/ of a member is computed as follows:
> +//    If *offset* was declared, start with that offset, otherwise start with the
> +//    next available offset.  If the resulting offset is not a multiple of the
> +//    /actual alignment/, increase it to the first offset that is a multiple of
> +//    the /actual alignment/.  This results in the /actual offset/ the member
> +//    will have."
> +//
> +// Tests whether a block with conflicting offset and alignment requirements
> +// is accepted.
> +//
> +
> +#version 140
> +#extension GL_ARB_enhanced_layouts : enable
> +
> +layout(std140) uniform block {
> +       layout(offset = 4, align = 16) float var1;
> +};
> +
> +void main()
> +{
> +}
> diff --git a/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-vec3.vert b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-vec3.vert
> new file mode 100644
> index 000000000..6f8f9abdd
> --- /dev/null
> +++ b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-explicit-offset-vec3.vert
> @@ -0,0 +1,28 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.40
> +// require_extensions: GL_ARB_enhanced_layouts
> +// check_link: false
> +// [end config]
> +//
> +// ARB_enhanced_layouts spec says:
> +//    "It is a compile-time error to
> +//    specify an *offset* that is smaller than the offset of the previous
> +//    member in the block or that lies within the previous member of the
> +//    block."
> +//
> +// Tests whether choosing an offset that is larger than the previous element's
> +// size, but smaller than its base alignment, is accepted.
> +//
> +
> +#version 140
> +#extension GL_ARB_enhanced_layouts : enable
> +
> +layout(std140) uniform block {
> +       layout(offset = 0) vec3 var1;
> +       layout(offset = 12) float var2;
> +};
> +
> +void main()
> +{
> +}
> diff --git a/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-override-explicit-block-alignment.vert b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-override-explicit-block-alignment.vert
> new file mode 100644
> index 000000000..a065f65d5
> --- /dev/null
> +++ b/tests/spec/arb_enhanced_layouts/compiler/explicit-offsets/ubo-override-explicit-block-alignment.vert
> @@ -0,0 +1,30 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.40
> +// require_extensions: GL_ARB_enhanced_layouts
> +// check_link: false
> +// [end config]
> +//
> +// ARB_enhanced_layouts spec says:
> +//    "The *align* qualifier, when used on a block, has the same effect as
> +//    qualifying each member with the same *align* value as declared on the
> +//    block, and gets the same compile-time results and errors as if this had
> +//    been done.  As described in general earlier, an individual member can
> +//    specify its own *align*, which overrides the block-level *align*, but
> +//    just for that member."
> +//
> +// Tests whether a block member with an explicit alignment requirement
> +// overriding the block-level alignment succeeds.
> +//
> +
> +#version 140
> +#extension GL_ARB_enhanced_layouts : enable
> +
> +layout(std140, align = 16) uniform block {
> +       layout(offset = 8, align = 8) vec2 var1;
> +       layout(offset = 16) float var2; // would be inside `var1` without align = 8
> +};
> +
> +void main()
> +{
> +}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 1546 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20181217/6a4448d4/attachment.key>


More information about the Piglit mailing list