framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / ext_packed_depth_stencil / readdrawpixels.c
blob7be6664c54e96bd7e5a4fecacb50339d3b81b5d6
1 /*
2 * Copyright © 2014 VMware, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
24 /**
25 * Test GL_EXT_packed_depth_stencil with glRead/DrawPixels
26 * Based on an original Glean test written by Brian Paul.
29 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
32 config.supports_gl_compat_version = 12;
33 config.window_visual = (PIGLIT_GL_VISUAL_RGBA |
34 PIGLIT_GL_VISUAL_DEPTH |
35 PIGLIT_GL_VISUAL_STENCIL);
36 config.khr_no_error_support = PIGLIT_NO_ERRORS;
37 PIGLIT_GL_TEST_CONFIG_END
40 static bool
41 test_readdrawpixels(void)
43 /*reference image data */
44 static const GLuint image[4] = {
45 0x00000000,
46 0x000000ff,
47 0xffffff00,
48 0xffffffff
50 GLuint readback[4];
51 GLuint stencilMap[2] = { 2, 2 }; /* map all stencil values to 2 */
52 int i;
54 glWindowPos2i(0, 0);
55 glDrawPixels(2, 2, GL_DEPTH_STENCIL_EXT,
56 GL_UNSIGNED_INT_24_8_EXT, image);
57 if (!piglit_check_gl_error(GL_NO_ERROR))
58 return false;
60 glReadPixels(0, 0, 2, 2, GL_DEPTH_STENCIL_EXT,
61 GL_UNSIGNED_INT_24_8_EXT, readback);
62 if (!piglit_check_gl_error(GL_NO_ERROR))
63 return false;
65 for (i = 0; i < 4; i++) {
66 if (image[i] != readback[i]) {
67 printf("Image returned by glReadPixels didn't match"
68 " the expected result (0x%x != 0x%x)\n",
69 readback[i], image[i]);
70 return false;
74 /* test depth scale/bias and stencil mapping (in a trivial way) */
75 glPixelTransferf(GL_DEPTH_SCALE, 0.0); /* map all depths to 1.0 */
76 glPixelTransferf(GL_DEPTH_BIAS, 1.0);
77 glPixelMapuiv(GL_PIXEL_MAP_S_TO_S, 2, stencilMap);
78 glPixelTransferi(GL_MAP_STENCIL, 1);
79 glReadPixels(0, 0, 2, 2, GL_DEPTH_STENCIL_EXT,
80 GL_UNSIGNED_INT_24_8_EXT, readback);
81 if (!piglit_check_gl_error(GL_NO_ERROR))
82 return false;
84 for (i = 0; i < 4; i++) {
85 if (readback[i] != 0xffffff02) {
86 printf("Image returned by glReadPixels didn't match"
87 " the expected result (0x%x != 0xffffff02)\n",
88 readback[i]);
89 return false;
92 glPixelTransferf(GL_DEPTH_SCALE, 1.0);
93 glPixelTransferf(GL_DEPTH_BIAS, 0.0);
94 glPixelTransferi(GL_MAP_STENCIL, 0);
96 return true;
100 void
101 piglit_init(int argc, char **argv)
103 bool pass = true;
105 piglit_require_extension("GL_EXT_packed_depth_stencil");
107 pass = test_readdrawpixels() && pass;
109 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
113 enum piglit_result
114 piglit_display(void)
116 /* unused */
117 return PIGLIT_FAIL;