summaryrefslogtreecommitdiff
path: root/tests/spec/arb_shader_image_load_store/execution/disable_early_z.shader_test
blob: e970757bdfea344c4b39e49e94b2c8777aa802f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Test that Z runs lates when the fragment shader contains stores.
#
[require]
GL >= 3.3
GLSL >= 3.30
GL_ARB_shader_image_load_store
SIZE 256 256
depthbuffer

[vertex shader]
#version 130
in vec4 piglit_vertex;

void main()
{
	gl_Position = piglit_vertex;
	gl_Position.z = 1.0;
}

[fragment shader]
#version 330
#extension GL_ARB_shader_image_load_store: enable

uniform int read;
uniform vec4 in_color;
layout(rgba8) uniform image2D img;
out vec4 outcolor;

void main()
{
	vec4 color;
	if (read != 0) {
		color = imageLoad(img, ivec2(gl_FragCoord));
	} else {
		color = in_color;
		imageStore(img, ivec2(gl_FragCoord), color);
	}
	outcolor = color;
}

[test]
texture rgbw 0 (256, 256) GL_RGBA8
uniform int img 0
image texture 0 GL_RGBA8

# Clear framebuffer
clear color 1.0 0.0 0.0 1.0
clear depth 0.0
clear

# Clear texture
uniform int read 0
uniform vec4 in_color 0.0 0.0 1.0 1.0
draw rect -1 -1 2 2
probe all rgba 0.0 0.0 1.0 1.0

memory barrier GL_SHADER_IMAGE_ACCESS_BARRIER_BIT

# Check that Z test kills pixels
uniform vec4 in_color 1.0 1.0 0.0 1.0
enable GL_DEPTH_TEST
draw rect -1 -1 2 2
probe all rgba 0.0 0.0 1.0 1.0

memory barrier GL_SHADER_IMAGE_ACCESS_BARRIER_BIT

# Check that the texture was still modified
disable GL_DEPTH_TEST
uniform int read 1
uniform vec4 in_color 0.0 0.0 0.0 0.0
draw rect -1 -1 2 2
probe all rgba 1.0 1.0 0.0 1.0