2 * Copyright © 2010 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 * Eric Anholt <eric@anholt.net>
28 /** @file glsl-fs-sampler-numbering.c
30 * Tests that drivers correctly use the sampler uniform's value to
31 * look up which gl texture unit is being used.
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config
.supports_gl_compat_version
= 10;
40 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
42 PIGLIT_GL_TEST_CONFIG_END
44 static int sampler_location
;
47 static const float white
[4] = {1, 1, 1, 1};
48 static const float black
[4] = {0, 0, 0, 0};
53 GLboolean pass
= GL_TRUE
;
54 /* result = 2 ^ args1 + args2 */
55 int x1
= piglit_width
/ 4;
56 int x2
= piglit_width
* 3 / 4;
57 int y1
= piglit_height
/ 4;
58 int y2
= piglit_height
* 3 / 4;
60 piglit_draw_rect_tex(0, 0, piglit_width
, piglit_height
,
63 pass
&= piglit_probe_pixel_rgb(x1
, y1
, black
);
64 pass
&= piglit_probe_pixel_rgb(x2
, y1
, white
);
65 pass
&= piglit_probe_pixel_rgb(x1
, y2
, white
);
66 pass
&= piglit_probe_pixel_rgb(x2
, y2
, black
);
68 piglit_present_results();
70 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
74 piglit_init(int argc
, char **argv
)
78 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
80 piglit_require_gl_version(20);
82 vs
= piglit_compile_shader(GL_VERTEX_SHADER
,
83 "shaders/glsl-tex-mvp.vert");
84 fs
= piglit_compile_shader(GL_FRAGMENT_SHADER
,
85 "shaders/glsl-tex.frag");
87 prog
= piglit_link_simple_program(vs
, fs
);
91 sampler_location
= glGetUniformLocation(prog
, "sampler");
92 glUniform1i(sampler_location
, 1);
94 glActiveTexture(GL_TEXTURE1
);
95 piglit_checkerboard_texture(0, 0, 2, 2, 1, 1, black
, white
);
96 glEnable(GL_TEXTURE_2D
);