1# In this test, perform an image store with a bound image, then create a
2# resident image and pass the handle through the OpenGL API.
3[require]
4GL >= 4.2
5GLSL >= 4.20
6GL_ARB_bindless_texture
7GL_ARB_shader_image_load_store
8
9[vertex shader passthrough]
10
11[fragment shader]
12#version 420
13#extension GL_ARB_bindless_texture: require
14#extension GL_ARB_shader_image_load_store: enable
15
16uniform vec4 color;
17layout (bindless_image, binding = 5) writeonly uniform image2D tex;
18out vec4 outcolor;
19
20void main()
21{
22	imageStore(tex, ivec2(gl_FragCoord.xy), color);
23	outcolor = vec4(0.0, 0.0, 0.0, 1.0);
24}
25
26[test]
27# Test with a bound image.
28# Texture 5 is the imageStore output.
29texture rgbw 5 (16, 16) GL_RGBA8
30image texture 5 GL_RGBA8
31
32# Texture 1 is the rendering output. We don't care about this.
33texture rgbw 1 (16, 16) GL_RGBA8
34
35# Store red using imageStore
36uniform vec4 color 1.0 0.0 0.0 1.0
37fb tex 2d 1
38draw rect -1 -1 2 2
39
40# Test the result of imageStore
41memory barrier GL_FRAMEBUFFER_BARRIER_BIT
42fb tex 2d 5
43probe all rgba 1.0 0.0 0.0 1.0
44
45# Test with a bindless image.
46texture rgbw 3 (16, 16) GL_RGBA8
47resident image texture 3 GL_RGBA8
48uniform handle tex 3
49
50# Store green using imageStore
51uniform vec4 color 0.0 1.0 0.0 1.0
52fb tex 2d 1
53draw rect -1 -1 2 2
54
55# Test the result of imageStore
56memory barrier GL_FRAMEBUFFER_BARRIER_BIT
57fb tex 2d 3
58probe all rgba 0.0 1.0 0.0 1.0
59