framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / gl-3.0 / api / clearbuffer-bug.c
blobe0b3a6d592645c4ed8e43f8f128f23aaf0f28086
1 /* Copyright © 2020 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
23 /**
24 * \file clearbuffer-bug.c
25 * Verify clear buffer correctness. Based on test case in bug:
26 * https://gitlab.freedesktop.org/mesa/mesa/-/issues/3783
28 #include "piglit-util-gl.h"
30 PIGLIT_GL_TEST_CONFIG_BEGIN
31 config.supports_gl_compat_version = 30;
32 PIGLIT_GL_TEST_CONFIG_END
34 enum piglit_result
35 piglit_display(void)
37 return PIGLIT_FAIL;
40 const char *v_str =
41 "attribute vec4 piglit_vertex;\n"
42 "void main() {\n"
43 "gl_Position = piglit_vertex;\n"
44 "}";
46 const char* f_str =
47 "#version 110\n"
48 "void main() {\n"
49 "gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
50 "gl_FragDepth = 0.3;\n"
51 "}";
53 void piglit_init(int argc, char **argv)
55 piglit_require_gl_version(30);
56 piglit_require_GLSL_version(110);
58 bool pass = true;
60 GLint program = piglit_build_simple_program(v_str, f_str);
62 if (!program)
63 piglit_report_result(PIGLIT_FAIL);
65 glUseProgram(program);
67 /* Create depth/stencil texture. */
68 GLuint ds_tex;
69 glGenTextures(1, &ds_tex);
70 glBindTexture(GL_TEXTURE_2D, ds_tex);
71 glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH32F_STENCIL8, 4, 4);
73 /* Create color texture. */
74 GLuint c_tex;
75 glGenTextures(1, &c_tex);
76 glBindTexture(GL_TEXTURE_2D, c_tex);
77 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 4, 4);
79 /* Create fbo with attachments. */
80 GLuint fbo;
81 glGenFramebuffers(1, &fbo);
82 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
83 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, c_tex, 0);
84 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, ds_tex, 0);
86 GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
87 GLint error = glGetError();
89 if (status != GL_FRAMEBUFFER_COMPLETE)
90 piglit_report_result(PIGLIT_SKIP);
92 if (error != 0) {
93 pass = false;
94 goto fail;
97 glClearBufferfi(GL_DEPTH_STENCIL, 0, 0.3, 3);
99 glEnable(GL_DEPTH_TEST);
100 glDepthFunc(GL_EQUAL);
102 piglit_draw_rect(-1.0, -1.0, 2.0, 2.0);
104 float expect[] = { 1, 0, 0, 1 };
105 if (!piglit_probe_rect_rgba(0, 0, 4, 4, expect))
106 pass = false;
108 fail:
109 glDeleteTextures(1, &c_tex);
110 glDeleteTextures(1, &ds_tex);
111 glDeleteFramebuffers(1, &fbo);
112 glDeleteProgram(program);
113 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);