Commit 88da753a authored by Karol Herbst's avatar Karol Herbst

arb_bindless_texture: add test where we pass a handle through a function

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's avatarKarol Herbst <kherbst@redhat.com>
Reviewed-by: Samuel Pitoiset's avatarSamuel Pitoiset <samuel.pitoiset@gmail.com>
parent 126b26fc
// [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));
}
// [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));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment