ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_direct_state_access / get-textures.c
blob5286b4605c82b949b866a8878d163fe0886bd8ca
1 /*
2 * Copyright 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
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
21 * DEALINGS IN THE SOFTWARE.
24 /** @file get-textures.c
26 * Tests glGetTextureImage to see if it behaves in the expected way,
27 * throwing the correct errors, etc.
30 #include "piglit-util-gl.h"
32 PIGLIT_GL_TEST_CONFIG_BEGIN
34 config.supports_gl_compat_version = 20;
35 config.supports_gl_core_version = 31;
37 config.window_visual = PIGLIT_GL_VISUAL_RGBA |
38 PIGLIT_GL_VISUAL_DOUBLE;
39 config.khr_no_error_support = PIGLIT_NO_ERRORS;
41 PIGLIT_GL_TEST_CONFIG_END
43 void
44 piglit_init(int argc, char **argv)
46 piglit_require_extension("GL_ARB_direct_state_access");
47 piglit_require_extension("GL_ARB_texture_storage");
50 enum piglit_result
51 piglit_display(void)
53 bool pass = true;
54 GLuint name;
55 GLubyte *data = malloc(50 * 50 * 6 * 4 * sizeof(GLubyte));
56 GLubyte *image = malloc(50 * 50 * 4 * sizeof(GLubyte));
58 if (piglit_khr_no_error)
59 goto valid_call;
61 /* Throw some invalid inputs at glGetTextureImage. */
63 /* Non-gen-ed name */
64 glGetTextureImage(3, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, data);
65 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
67 /* Unsupported target. */
68 glGenTextures(1, &name);
69 glBindTexture(GL_TEXTURE_CUBE_MAP_POSITIVE_X, name);
70 glGetTextureImage(name, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, data);
71 pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;
72 glDeleteTextures(1, &name);
74 /* Unsupported dsa target for non-dsa version. */
75 glGetTexImage(GL_TEXTURE_CUBE_MAP, 0, GL_RGBA, GL_UNSIGNED_BYTE,
76 data);
77 pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;
79 /* No Storage
81 * The spec doesn't say what should happen in this case. This is
82 * addressed by Khronos Bug 13223.
84 glCreateTextures(GL_TEXTURE_CUBE_MAP, 1, &name);
85 glGetTextureImage(name, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, data);
86 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
87 glDeleteTextures(1, &name);
89 /* Insufficient storage
91 * The spec doesn't say what should happen in this case. This is
92 * addressed by Khronos Bug 13223.
94 glCreateTextures(GL_TEXTURE_CUBE_MAP, 1, &name);
95 glBindTexture(GL_TEXTURE_CUBE_MAP, name);
96 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0,
97 GL_RGBA8, 50, 50, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
98 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0,
99 GL_RGBA8, 50, 50, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
100 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0,
101 GL_RGBA8, 50, 50, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
102 /* Note: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y not set */
103 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0,
104 GL_RGBA8, 50, 50, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
105 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0,
106 GL_RGBA8, 50, 50, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
107 glGetTextureImage(name, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, data);
108 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
109 glDeleteTextures(1, &name);
111 valid_call:
112 /* Trivial, but should work. */
113 glCreateTextures(GL_TEXTURE_CUBE_MAP, 1, &name);
114 glTextureStorage2D(name, 1, GL_RGBA8, 50, 50);
115 glGetTextureImage(name, 0, GL_RGBA, GL_UNSIGNED_BYTE,
116 50 * 50 * 6 * 4, data);
117 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
119 free(data);
120 free(image);
122 return pass ? PIGLIT_PASS : PIGLIT_FAIL;