2 * Copyright (c) 2014 Intel Corporation
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
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
24 /** @file glsl-vs-int-attrib.c
26 * Tests that we can set an integer vertex attribute to a value that
27 * looks like a signalling NaN if it were interpreted as a float. If
28 * an implementation passes this through a floating point variable it
29 * might incorrectly get corrupted to a quiet NaN.
32 #include "piglit-util-gl.h"
34 PIGLIT_GL_TEST_CONFIG_BEGIN
36 config
.supports_gl_compat_version
= 20;
38 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
40 PIGLIT_GL_TEST_CONFIG_END
42 /* This value looks like a signalling NaN if it were interpreted as a
44 #define TEST_VALUE 0x7f817f81
47 #define STRINGIFY(x) STR(x)
53 "attribute vec4 piglit_vertex;\n"
54 "attribute uint a_value;\n"
59 " if (a_value == " STRINGIFY(TEST_VALUE
) "u)\n"
60 " gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
62 " gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
63 " gl_Position = piglit_vertex;\n"
66 static const float green
[] = { 0.0f
, 1.0f
, 0.0f
};
75 prog
= piglit_build_simple_program(vertex_source
,
76 NULL
/* fs_source */);
79 attrib
= glGetAttribLocation(prog
, "a_value");
80 glVertexAttribI1ui(attrib
, TEST_VALUE
);
82 piglit_draw_rect(-1, -1, 2, 2);
83 pass
= piglit_probe_pixel_rgb(0, 0, green
);
86 glDeleteProgram(prog
);
92 piglit_init(int argc
, char **argv
)
96 /* We need to be able to call glVertexAttribI1ui */
97 if (piglit_get_gl_version() < 30
98 && !piglit_is_extension_supported("GL_EXT_gpu_shader4")) {
99 printf("OpenGL 3.0 or GL_EXT_gpu_shader4 is required.\n");
100 piglit_report_result(PIGLIT_SKIP
);
103 piglit_require_GLSL_version(130);
107 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);