ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_sampler_objects / framebufferblit.c
blob74348b826e20c7a0c8a1e143a35809868fbdce94
1 /*
2 * Copyright © 2012 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
13 * Software.
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
21 * IN THE SOFTWARE.
24 /**
25 * @file framebufferblit.c
27 * Tests interaction between GL_ARB_sampler_objects and
28 * GL_EXT_framebuffer_blit. There was a bug in mesa in which the
29 * fbblit would accidentally apply an active sampler object from a
30 * texture.
32 * To test this, ask for a nearest blit stretching from single pixel
33 * to the window, and check if the LINEAR on the sampler object makes
34 * the neighbors of that pixel get filtered in.
37 #include "piglit-util-gl.h"
39 PIGLIT_GL_TEST_CONFIG_BEGIN
41 config.supports_gl_compat_version = 10;
43 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
45 PIGLIT_GL_TEST_CONFIG_END
47 enum piglit_result
48 piglit_display(void)
50 bool pass = true;
51 GLuint tex, sampler, fb;
52 const float tex_data[16] = {0, 1, 0, 0,
53 1, 0, 0, 0,
54 1, 0, 0, 0,
55 1, 0, 0, 0};
56 const float *green = tex_data;
58 glClearColor(0, 0, 1, 0);
59 glClear(GL_COLOR_BUFFER_BIT);
61 glGenTextures(1, &tex);
62 glBindTexture(GL_TEXTURE_2D, tex);
63 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 2, 2, 0,
64 GL_RGBA, GL_FLOAT, tex_data);
66 glGenFramebuffers(1, &fb);
67 glBindFramebuffer(GL_FRAMEBUFFER, fb);
69 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
70 GL_COLOR_ATTACHMENT0_EXT,
71 GL_TEXTURE_2D,
72 tex,
73 0);
74 if (!piglit_check_gl_error(GL_NO_ERROR))
75 piglit_report_result(PIGLIT_FAIL);
77 glGenSamplers(1, &sampler);
78 glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
79 glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
80 glBindSampler(0, sampler);
82 glBindFramebuffer(GL_READ_FRAMEBUFFER, fb);
83 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
84 glBlitFramebuffer(0, 0, 1, 1,
85 0, 0, piglit_width, piglit_height,
86 GL_COLOR_BUFFER_BIT, GL_NEAREST);
88 glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo);
89 pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green);
90 piglit_present_results();
92 glDeleteSamplers(1, &sampler);
93 glDeleteTextures(1, &tex);
94 glDeleteFramebuffers(1, &fb);
96 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
100 void
101 piglit_init(int argc, char **argv)
103 piglit_require_extension("GL_ARB_sampler_objects");
104 piglit_require_extension("GL_EXT_framebuffer_blit");
105 piglit_require_extension("GL_EXT_texture_swizzle");
107 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);