[Piglit] [PATCH v3] arb_bindless_texture: add test where we pass a handle through a function

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed Apr 25 11:14:26 UTC 2018


Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

Thanks Karol.

On 04/25/2018 12:09 PM, Karol Herbst wrote:
> currently fails in mesa with:
> ir_dereference_variable @ 0x1446830 specifies undeclared variable `wrongHandle' @ 0xffd1b0
> 
> v2: add image test
>      convert to compiler test
>      quote the spec
> v3: use inout
> 
> Signed-off-by: Karol Herbst <kherbst at redhat.com>
> ---
>   .../compiler/images/func-call-uvec2-image.frag     | 36 ++++++++++++++++++++++
>   .../samplers/func-call-uvec2-texture2D.frag        | 35 +++++++++++++++++++++
>   2 files changed, 71 insertions(+)
>   create mode 100644 tests/spec/arb_bindless_texture/compiler/images/func-call-uvec2-image.frag
>   create mode 100644 tests/spec/arb_bindless_texture/compiler/samplers/func-call-uvec2-texture2D.frag
> 
> diff --git a/tests/spec/arb_bindless_texture/compiler/images/func-call-uvec2-image.frag b/tests/spec/arb_bindless_texture/compiler/images/func-call-uvec2-image.frag
> new file mode 100644
> index 000000000..cfa3fbac1
> --- /dev/null
> +++ b/tests/spec/arb_bindless_texture/compiler/images/func-call-uvec2-image.frag
> @@ -0,0 +1,36 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 3.30
> +// require_extensions: GL_ARB_bindless_texture GL_ARB_shader_image_load_store
> +// [end config]
> +
> +#version 330
> +#extension GL_ARB_bindless_texture: require
> +#extension GL_ARB_shader_image_load_store: enable
> +
> +layout (bindless_image) writeonly uniform image2D img;
> +uniform uvec2 handleOffset;
> +
> +out vec4 finalColor;
> +
> +// The ARB_bindless_texture spec says:
> +//
> +//  "Replace Section 4.1.7 (Samplers), p. 25"
> +//
> +//   "Samplers can be used as l-values, so can be assigned into and used as
> +//   "out" and "inout" function parameters."
> +
> +void adjustImageHandle(inout writeonly image2D img)
> +{
> +	uvec2 handle = uvec2(img);
> +	handle.x -= 0x12345678u;
> +	handle.y -= 0x9abcdef0u;
> +	img = image2D(handle + handleOffset);
> +}
> +
> +void main()
> +{
> +	writeonly image2D _img = img;
> +	adjustImageHandle(_img);
> +	imageStore(_img, ivec2(0, 0), vec4(1, 2, 3, 4));
> +}
> diff --git a/tests/spec/arb_bindless_texture/compiler/samplers/func-call-uvec2-texture2D.frag b/tests/spec/arb_bindless_texture/compiler/samplers/func-call-uvec2-texture2D.frag
> new file mode 100644
> index 000000000..9faf41000
> --- /dev/null
> +++ b/tests/spec/arb_bindless_texture/compiler/samplers/func-call-uvec2-texture2D.frag
> @@ -0,0 +1,35 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 3.30
> +// require_extensions: GL_ARB_bindless_texture
> +// [end config]
> +
> +#version 330
> +#extension GL_ARB_bindless_texture: require
> +
> +layout (bindless_sampler) uniform sampler2D tex;
> +uniform uvec2 handleOffset;
> +
> +out vec4 finalColor;
> +
> +// The ARB_bindless_texture spec says:
> +//
> +//  "Replace Section 4.1.7 (Samplers), p. 25"
> +//
> +//   "Samplers can be used as l-values, so can be assigned into and used as
> +//   "out" and "inout" function parameters."
> +
> +void adjustSamplerHandle(inout sampler2D s)
> +{
> +	uvec2 handle = uvec2(s);
> +	handle.x -= 0x12345678u;
> +	handle.y -= 0x9abcdef0u;
> +	s = sampler2D(handle + handleOffset);
> +}
> +
> +void main()
> +{
> +	sampler2D s = tex;
> +	adjustSamplerHandle(s);
> +	finalColor = texture2D(s, vec2(0, 0));
> +}
> 


More information about the Piglit mailing list