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 * Check that drivers correctly handle the clear color when fast-clearing via
28 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
33 config
.supports_gl_compat_version
= 44;
35 PIGLIT_GL_TEST_CONFIG_END
44 clear_tex(GLuint internalFormat
, GLuint format
, GLuint type
,
45 const void *clear_pix
)
48 glGenTextures(1, &tex
);
49 glBindTexture(GL_TEXTURE_2D
, tex
);
50 glTexImage2D(GL_TEXTURE_2D
, 0, internalFormat
, 32, 32, 0, format
, type
,
52 glClearTexImage(tex
, 0, format
, type
, clear_pix
);
54 if (glGetError() != GL_NO_ERROR
)
55 piglit_report_result(PIGLIT_FAIL
);
59 test_16bpc_base(const char *fmt
, GLuint format
, const void *pix
,
60 const float *expected
)
62 printf("Testing 16bpc %s\n", fmt
);
63 clear_tex(format
, format
, GL_UNSIGNED_SHORT
, pix
);
64 return piglit_probe_texel_rgba(GL_TEXTURE_2D
, 0, 0, 0, expected
);
68 piglit_init(int argc
, char **argv
)
70 const uint16_t pix
[] = {0x3fff, 0x7fff};
71 const float a
[] = {0.0, 0.0, 0.0, 0.5};
72 const float la
[] = {0.25, 0.0, 0.0, 0.5};
75 pass
&= test_16bpc_base("A", GL_ALPHA
, &pix
[1], a
);
76 pass
&= test_16bpc_base("LA", GL_LUMINANCE_ALPHA
, &pix
[0], la
);
78 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);