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
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
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
41 "attribute vec4 piglit_vertex;\n"
43 "gl_Position = piglit_vertex;\n"
49 "gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
50 "gl_FragDepth = 0.3;\n"
53 void piglit_init(int argc
, char **argv
)
55 piglit_require_gl_version(30);
56 piglit_require_GLSL_version(110);
60 GLint program
= piglit_build_simple_program(v_str
, f_str
);
63 piglit_report_result(PIGLIT_FAIL
);
65 glUseProgram(program
);
67 /* Create depth/stencil texture. */
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. */
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. */
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
);
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
))
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
);