ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ext_texture_integer / api-drawpixels.c
blob900a37a3269b01632021cdf468617c9d163dc047
1 /*
2 * Copyright (c) 2010 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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the 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,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NON-INFRINGEMENT. IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
25 /**
26 * @file api-teximage.c
28 * Tests GL_EXT_texture_integer's error behavior with glTexImage2D().
30 * The GL_EXT_texture_integer spec doesn't specify how glDrawPixels
31 * with an integer format is supposed to work. glDrawPixels generally
32 * generates fragments for a fragment shader with the gl_Color from
33 * the immediate data in the DrawPixels call. However, with
34 * GL_EXT_texture_integer formats, the immediate data is now integer
35 * despite gl_Color being a floating-point vec4, and the spec for
36 * other cases of possible integer-versus-float conflicts resolves
37 * that the results are undefined. It doesn't specify any particular
38 * conversion specific to drawpixels.
40 * In particular, in order for glDrawPixels of integer to be actually
41 * useful to a user, it needs to put integer values into the fragment
42 * shader without conversion, and there's no defined way to map the
43 * DrawPixels input to some user-defined (integer) fragment shader
44 * input.
46 * The GL 3.0 specification adds the following additional text in
47 * section 3.7.4 ("Rasterization of Pixel Rectangles) on page 151 of
48 * the GL 3.0 specification:
50 * "If format contains integer components, as shown in
51 * table 3.6, an INVALID OPERATION error is generated."
53 * The NVIDIA driver, which exposes both 3.0 and
54 * GL_EXT_texture_integer, follows this behavior. Resolve that this
55 * behavior is a correction to the GL_EXT_texture_integer
56 * specification and check that impleentations follow that.
59 #include "piglit-util-gl.h"
61 PIGLIT_GL_TEST_CONFIG_BEGIN
63 config.supports_gl_compat_version = 10;
64 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
65 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
67 PIGLIT_GL_TEST_CONFIG_END
69 enum piglit_result
70 piglit_display(void)
72 static const int black[4] = {0, 0, 0, 0};
73 static const float green[4] = {0, 1, 0, 0};
74 bool pass = GL_TRUE;
76 /* We don't have to do an integer FBO for this test, because
77 * no error is specified in the non-integer FBO case:
79 * "Results of rasterization are undefined if any of the
80 * selected draw buffers of the draw framebuffer have an
81 * integer format and no fragment shader is active. "
83 glClearColor(0.0, 1.0, 0.0, 0.0);
84 glClear(GL_COLOR_BUFFER_BIT);
86 glDrawPixels(1, 1, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, black);
87 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
89 /* The text in GL 3.0 specification banning
90 * glDrawPixels(integer format) precedes the restriction from
91 * GL_EXT_texture_integer which is still included in that
92 * section:
94 * "If format is one of the integer component formats as
95 * defined in table 3.6 and type is FLOAT, the error
96 * INVALID ENUM occurs."
98 * Based on this, we test for GL_INVALID_OPERATION even for FLOAT.
100 glDrawPixels(1, 1, GL_RGBA_INTEGER_EXT, GL_FLOAT, black);
101 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
103 /* Make sure that we really didn't render anything. */
104 pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green) && pass;
106 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
109 void
110 piglit_init(int argc, char **argv)
112 piglit_require_extension("GL_EXT_texture_integer");