aboutsummaryrefslogtreecommitdiff
path: root/tests/spec/ext_packed_float/getteximage-invalid-format-for-packed-type.c
blob: 975a731739e26656b915e4859ad21e6cdc71825e (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * Copyright © 2011 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 *
 *
 */

/**
 * file tests/spec/ext_packed_float/getteximage-invalid-format-for-packed-type.c
 * test with some invalid type when the format is not GL_RGB.
 *
 * Page 262 (page 282 of the PDF) of the OpenGL 4.2 Compatibility
 * Profile spec says:
 *
 *     "The number of components per packed pixel is fixed by the
 *     type, and must match the number of components per group
 *     indicated by the format parameter, as listed in table 3.8.
 *     The error INVALID_OPERATION is generated by any command
 *     processing pixel rectangles if a mismatch occurs."
 *
 * Table 3.8 says:
 *
 *"type Parameter Token Name      ...  Matching Pixel Formats"
 * UNSIGNED_BYTE_3_3_2                  RGB, RGB_INTEGER
 * UNSIGNED_BYTE_2_3_3_REV              RGB, RGB_INTEGER
 * UNSIGNED_SHORT_5_6_5                 RGB, RGB_INTEGER
 * UNSIGNED_SHORT_5_6_5_REV             RGB, RGB_INTEGER
 * UNSIGNED_SHORT_4_4_4_4               RGBA, BGRA, RGBA_INTEGER,
 *                                      BGRA_INTEGER
 * UNSIGNED_SHORT_4_4_4_4_REV           RGBA, BGRA, RGBA_INTEGER,
 *                                      BGRA_INTEGER
 * UNSIGNED_SHORT_5_5_5_1               RGBA, BGRA, RGBA_INTEGER,
 *                                      BGRA_INTEGER
 * UNSIGNED_SHORT_1_5_5_5_REV           RGBA, BGRA, RGBA_INTEGER,
 *                                      BGRA_INTEGER
 * UNSIGNED_INT_8_8_8_8                 RGBA, BGRA, RGBA_INTEGER,
 *                                      BGRA_INTEGER
 * UNSIGNED_INT_8_8_8_8_REV             RGBA, BGRA, RGBA_INTEGER,
 *                                      BGRA_INTEGER
 * UNSIGNED_INT_10_10_10_2              RGBA, BGRA, RGBA_INTEGER,
 *                                      BGRA_INTEGER
 * UNSIGNED_INT_2_10_10_10_REV          RGBA, BGRA, RGBA_INTEGER,
 *                                      BGRA_INTEGER
 * UNSIGNED_INT_24_8                    DEPTH_STENCIL
 * UNSIGNED_INT_10F_11F_11F_REV         RGB, RGB_INTEGER
 * UNSIGNED_INT_5_9_9_9_REV             RGB, RGB_INTEGER
 * FLOAT_32_UNSIGNED_INT_24_8_REV       DEPTH_STENCIL"
 *
 *
 */

#include "piglit-util-gl-common.h"

PIGLIT_GL_TEST_MAIN(
    100 /*window_width*/,
    100 /*window_height*/,
    PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE)

static const GLenum formatTypes[] = {
	GL_RGBA,
	GL_RGB,
	GL_RED,
	GL_GREEN,
	GL_BLUE,
	GL_ALPHA,
	GL_LUMINANCE,
	GL_LUMINANCE_ALPHA,
};

static const GLenum testedTypes[] = {
	GL_UNSIGNED_BYTE_3_3_2,
	GL_UNSIGNED_BYTE_2_3_3_REV,
	GL_UNSIGNED_SHORT_5_6_5,
	GL_UNSIGNED_SHORT_5_6_5_REV,
	GL_UNSIGNED_INT_10F_11F_11F_REV,
};


enum piglit_result
piglit_display(void)
{
	return PIGLIT_FAIL;
}


void
piglit_init(int argc, char **argv)
{
	long rcvError, expError = GL_NO_ERROR;
	GLfloat pxBuffer[4];
	int i, j;

	piglit_require_extension("GL_EXT_packed_float");

	for (j = 0; j < ARRAY_SIZE(testedTypes); j++) {
		for (i = 0; i< ARRAY_SIZE(formatTypes); i++) {
			glGetTexImage(GL_TEXTURE_2D, 0, formatTypes[i],
				      testedTypes[j], pxBuffer);
			rcvError = glGetError();
			if (formatTypes[i] == GL_RGB)
				expError = GL_NO_ERROR;
			else
				expError = GL_INVALID_OPERATION;

			if (rcvError != expError)
				piglit_report_result(PIGLIT_FAIL);
		}
	}
	piglit_report_result(PIGLIT_PASS);
}