ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_texture_view / rendering-r32ui.c
bloba28a089291283dcd71c9403a761b8b326e962631
1 /*
2 * Copyright (c) 2017 Józef Kucia <joseph.kucia@gmail.com>
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 rendering-r32ui.c
26 * Exercises a Radeonsi bug.
29 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
33 config.supports_gl_compat_version = 30;
34 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
35 config.khr_no_error_support = PIGLIT_NO_ERRORS;
37 PIGLIT_GL_TEST_CONFIG_END
39 static const char *vs =
40 "#version 130\n"
41 "void main() { \n"
42 " gl_Position = gl_Vertex;\n"
43 "}\n";
45 static const char *ps =
46 "#version 130\n"
47 "out uvec4 color;\n"
48 "void main() {\n"
49 " color = uvec4(0xff, 0, 0, 0);\n"
50 "}\n";
52 #define TEX_SIZE 64
54 enum piglit_result
55 piglit_display(void)
57 return PIGLIT_FAIL;
60 void
61 piglit_init(int argc, char **argv)
63 GLuint tex, view, framebuffer, prog;
64 GLuint data[TEX_SIZE * TEX_SIZE];
65 bool pass = true;
67 piglit_require_gl_version(30);
68 piglit_require_extension("GL_ARB_texture_view");
70 glGenTextures(1, &tex);
71 glBindTexture(GL_TEXTURE_2D, tex);
72 glTexStorage2D(GL_TEXTURE_2D, 1, GL_R32F, TEX_SIZE, TEX_SIZE);
74 glGenTextures(1, &view);
75 glTextureView(view, GL_TEXTURE_2D, tex, GL_R32UI, 0, 1, 0, 1);
77 glGenFramebuffers(1, &framebuffer);
78 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
79 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
80 GL_TEXTURE_2D, view, 0);
82 prog = piglit_build_simple_program(vs, ps);
83 glUseProgram(prog);
85 piglit_draw_rect(-1, -1, 2, 2);
87 glBindTexture(GL_TEXTURE_2D, view);
88 glGetTexImage(GL_TEXTURE_2D, 0, GL_RED_INTEGER, GL_UNSIGNED_INT,
89 data);
90 if (data[0] != 0xff) {
91 printf("Got value %#x\n", data[0]);
92 pass = false;
95 glDeleteTextures(1, &view);
96 glDeleteTextures(1, &tex);
97 glDeleteFramebuffers(1, &framebuffer);
98 glDeleteProgram(prog);
100 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
101 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);