es31fNegativeStateApiTests.cpp revision 74a4e3ea85714c95b67c301cd06df7a78b59d832
1a89371c6f144b9049efe7689105feee2c4a38384Jason Sams/*------------------------------------------------------------------------- 2a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk * drawElements Quality Program OpenGL ES 3.0 Module 3a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * ------------------------------------------------- 4a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * 5a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * Copyright 2014 The Android Open Source Project 6a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * 7a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * Licensed under the Apache License, Version 2.0 (the "License"); 8a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * you may not use this file except in compliance with the License. 9a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * You may obtain a copy of the License at 10a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * 11a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * http://www.apache.org/licenses/LICENSE-2.0 12a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * 13a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * Unless required by applicable law or agreed to in writing, software 14a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * distributed under the License is distributed on an "AS IS" BASIS, 15a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * See the License for the specific language governing permissions and 17a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * limitations under the License. 18a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * 19a89371c6f144b9049efe7689105feee2c4a38384Jason Sams *//*! 20a89371c6f144b9049efe7689105feee2c4a38384Jason Sams * \file 21e23d239828a229eb7d4d33c9630070f0a87833e1Alex Sakhartchouk * \brief Negative GL State API tests. 22a89371c6f144b9049efe7689105feee2c4a38384Jason Sams *//*--------------------------------------------------------------------*/ 23a89371c6f144b9049efe7689105feee2c4a38384Jason Sams 24a89371c6f144b9049efe7689105feee2c4a38384Jason Sams#include "es31fNegativeStateApiTests.hpp" 25a89371c6f144b9049efe7689105feee2c4a38384Jason Sams 264a43e3ea8a0328c56ace0af1869b4c8c781a7b26Alex Sakhartchouk#include "gluCallLogWrapper.hpp" 274a43e3ea8a0328c56ace0af1869b4c8c781a7b26Alex Sakhartchouk#include "gluContextInfo.hpp" 284a43e3ea8a0328c56ace0af1869b4c8c781a7b26Alex Sakhartchouk#include "gluShaderProgram.hpp" 294a43e3ea8a0328c56ace0af1869b4c8c781a7b26Alex Sakhartchouk 304a43e3ea8a0328c56ace0af1869b4c8c781a7b26Alex Sakhartchouk#include "glwDefs.hpp" 314a43e3ea8a0328c56ace0af1869b4c8c781a7b26Alex Sakhartchouk#include "glwEnums.hpp" 324a43e3ea8a0328c56ace0af1869b4c8c781a7b26Alex Sakhartchouk 334a43e3ea8a0328c56ace0af1869b4c8c781a7b26Alex Sakhartchouk#include "deMemory.h" 34a89371c6f144b9049efe7689105feee2c4a38384Jason Sams 35a89371c6f144b9049efe7689105feee2c4a38384Jason Samsnamespace deqp 36afb743aca56c18beb7ab924e75cb6e070ef3e55aAlex Sakhartchouk{ 37a89371c6f144b9049efe7689105feee2c4a38384Jason Samsnamespace gles31 38a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk{ 39a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouknamespace Functional 40a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk{ 41a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouknamespace NegativeTestShared 42a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk{ 43a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk 44a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchoukusing tcu::TestLog; 45064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchoukusing glu::CallLogWrapper; 46a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchoukusing namespace glw; 47a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk 4844bef6fba6244292b751387f3d6c31cca96c28adChris Wailesstatic const char* uniformTestVertSource = "#version 300 es\n" 49064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchouk "uniform mediump vec4 vUnif_vec4;\n" 50064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchouk "in mediump vec4 attr;" 51064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchouk "layout(shared) uniform Block { mediump vec4 blockVar; };\n" 52a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk "void main (void)\n" 53a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk "{\n" 54a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk " gl_Position = vUnif_vec4 + blockVar + attr;\n" 55a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk "}\n\0"; 56a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchoukstatic const char* uniformTestFragSource = "#version 300 es\n" 57a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk "uniform mediump ivec4 fUnif_ivec4;\n" 5810ab8bb0fa510bdb577adce5e67b6bf35882a9ddChih-Hung Hsieh "uniform mediump uvec4 fUnif_uvec4;\n" 59253325d2a19162c1dd18de59c357e36adf4a760bAlex Sakhartchouk "layout(location = 0) out mediump vec4 fragColor;" 60253325d2a19162c1dd18de59c357e36adf4a760bAlex Sakhartchouk "void main (void)\n" 61253325d2a19162c1dd18de59c357e36adf4a760bAlex Sakhartchouk "{\n" 62e3150cfb3edb028407669e4a65e087eae77e718cJason Sams " fragColor = vec4(vec4(fUnif_ivec4) + vec4(fUnif_uvec4));\n" 63253325d2a19162c1dd18de59c357e36adf4a760bAlex Sakhartchouk "}\n\0"; 64253325d2a19162c1dd18de59c357e36adf4a760bAlex Sakhartchouk 65253325d2a19162c1dd18de59c357e36adf4a760bAlex Sakhartchouk// Enabling & disabling states 66253325d2a19162c1dd18de59c357e36adf4a760bAlex Sakhartchoukvoid enable (NegativeTestContext& ctx) 67a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk{ 68064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchouk ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values."); 69064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchouk ctx.glEnable(-1); 70a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk ctx.expectError(GL_INVALID_ENUM); 71a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk ctx.endSection(); 72a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk} 73064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchouk 74064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchoukvoid disable (NegativeTestContext& ctx) 75064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchouk{ 76a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values."); 77099d7d33e55afeb3399f6e8cf8d665223ca94939Alex Sakhartchouk ctx.glDisable(-1); 784e9a7a8ded109e16b163789274899447cef02642Alex Sakhartchouk ctx.expectError(GL_INVALID_ENUM); 794e9a7a8ded109e16b163789274899447cef02642Alex Sakhartchouk ctx.endSection(); 804e9a7a8ded109e16b163789274899447cef02642Alex Sakhartchouk} 814e9a7a8ded109e16b163789274899447cef02642Alex Sakhartchouk 82b825f67adb5d1e1751fe108e6dbf9c6f2555c283Alex Sakhartchouk// Simple state queries 83ba4aa5c768a498bc3fbb8cb5547b7a9ad6f4b771Alex Sakhartchoukvoid get_booleanv (NegativeTestContext& ctx) 84ba4aa5c768a498bc3fbb8cb5547b7a9ad6f4b771Alex Sakhartchouk{ 85ba4aa5c768a498bc3fbb8cb5547b7a9ad6f4b771Alex Sakhartchouk ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values."); 86e3150cfb3edb028407669e4a65e087eae77e718cJason Sams GLboolean params = GL_FALSE; 87a89371c6f144b9049efe7689105feee2c4a38384Jason Sams ctx.glGetBooleanv(-1, ¶ms); 88064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchouk ctx.expectError(GL_INVALID_ENUM); 89064aa7ed76db9564b041afcd4b75da5b3d12fabaAlex Sakhartchouk ctx.endSection(); 90a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk} 91a89371c6f144b9049efe7689105feee2c4a38384Jason Sams 92a89371c6f144b9049efe7689105feee2c4a38384Jason Samsvoid get_floatv (NegativeTestContext& ctx) 93afb743aca56c18beb7ab924e75cb6e070ef3e55aAlex Sakhartchouk{ 94a89371c6f144b9049efe7689105feee2c4a38384Jason Sams ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values."); 95099d7d33e55afeb3399f6e8cf8d665223ca94939Alex Sakhartchouk GLfloat params = 0.0f; 96099d7d33e55afeb3399f6e8cf8d665223ca94939Alex Sakhartchouk ctx.glGetFloatv(-1, ¶ms); 97099d7d33e55afeb3399f6e8cf8d665223ca94939Alex Sakhartchouk ctx.expectError(GL_INVALID_ENUM); 98099d7d33e55afeb3399f6e8cf8d665223ca94939Alex Sakhartchouk ctx.endSection(); 99a89371c6f144b9049efe7689105feee2c4a38384Jason Sams} 100a89371c6f144b9049efe7689105feee2c4a38384Jason Sams 1017974fc03e11f3a8dd40f794f3b33b4889483090cRahul Chaudhryvoid get_integerv (NegativeTestContext& ctx) 1027974fc03e11f3a8dd40f794f3b33b4889483090cRahul Chaudhry{ 103a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values."); 104a89371c6f144b9049efe7689105feee2c4a38384Jason Sams GLint params = -1; 105a89371c6f144b9049efe7689105feee2c4a38384Jason Sams ctx.glGetIntegerv(-1, ¶ms); 1064e9a7a8ded109e16b163789274899447cef02642Alex Sakhartchouk ctx.expectError(GL_INVALID_ENUM); 107 ctx.endSection(); 108} 109 110void get_integer64v (NegativeTestContext& ctx) 111{ 112 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values."); 113 GLint64 params = -1; 114 ctx.glGetInteger64v(-1, ¶ms); 115 ctx.expectError(GL_INVALID_ENUM); 116 ctx.endSection(); 117} 118 119void get_integeri_v (NegativeTestContext& ctx) 120{ 121 GLint data = -1; 122 GLint maxUniformBufferBindings = 0; 123 124 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value."); 125 ctx.glGetIntegeri_v(-1, 0, &data); 126 ctx.expectError(GL_INVALID_ENUM); 127 ctx.endSection(); 128 129 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target."); 130 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings); 131 ctx.expectError(GL_NO_ERROR); 132 ctx.glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, maxUniformBufferBindings, &data); 133 ctx.expectError(GL_INVALID_VALUE); 134 ctx.endSection(); 135} 136 137void get_integer64i_v (NegativeTestContext& ctx) 138{ 139 GLint64 data = (GLint64)-1; 140 GLint maxUniformBufferBindings = 0; 141 142 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value."); 143 ctx.glGetInteger64i_v(-1, 0, &data); 144 ctx.expectError(GL_INVALID_ENUM); 145 ctx.endSection(); 146 147 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target."); 148 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings); 149 ctx.expectError(GL_NO_ERROR); 150 ctx.glGetInteger64i_v(GL_UNIFORM_BUFFER_START, maxUniformBufferBindings, &data); 151 ctx.expectError(GL_INVALID_VALUE); 152 ctx.endSection(); 153} 154 155void get_string (NegativeTestContext& ctx) 156{ 157 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value."); 158 ctx.glGetString(-1); 159 ctx.expectError(GL_INVALID_ENUM); 160 ctx.endSection(); 161} 162 163void get_stringi (NegativeTestContext& ctx) 164{ 165 GLint numExtensions = 0; 166 167 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value."); 168 ctx.glGetStringi(-1, 0); 169 ctx.expectError(GL_INVALID_ENUM); 170 ctx.endSection(); 171 172 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside the valid range for indexed state name."); 173 ctx.glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); 174 ctx.glGetStringi(GL_EXTENSIONS, numExtensions); 175 ctx.expectError(GL_INVALID_VALUE); 176 ctx.endSection(); 177} 178 179// Enumerated state queries: Shaders 180 181void get_attached_shaders (NegativeTestContext& ctx) 182{ 183 GLuint shaders[1] = { 0 }; 184 GLuint shaderObject = ctx.glCreateShader(GL_VERTEX_SHADER); 185 GLuint program = ctx.glCreateProgram(); 186 GLsizei count[1] = { 0 }; 187 188 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 189 ctx.glGetAttachedShaders(-1, 1, &count[0], &shaders[0]); 190 ctx.expectError(GL_INVALID_VALUE); 191 ctx.endSection(); 192 193 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 194 ctx.glGetAttachedShaders(shaderObject, 1, &count[0], &shaders[0]); 195 ctx.expectError(GL_INVALID_OPERATION); 196 ctx.endSection(); 197 198 ctx.beginSection("GL_INVALID_VALUE is generated if maxCount is less than 0."); 199 ctx.glGetAttachedShaders(program, -1, &count[0], &shaders[0]); 200 ctx.expectError(GL_INVALID_VALUE); 201 ctx.endSection(); 202 203 ctx.glDeleteShader(shaderObject); 204 ctx.glDeleteProgram(program); 205} 206 207void get_shaderiv (NegativeTestContext& ctx) 208{ 209 GLboolean shaderCompilerSupported; 210 ctx.glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported); 211 ctx.getLog() << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage; 212 213 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 214 GLuint program = ctx.glCreateProgram(); 215 GLint param[1] = { -1 }; 216 217 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); 218 ctx.glGetShaderiv(shader, -1, ¶m[0]); 219 ctx.expectError(GL_INVALID_ENUM); 220 ctx.endSection(); 221 222 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."); 223 ctx.glGetShaderiv(-1, GL_SHADER_TYPE, ¶m[0]); 224 ctx.expectError(GL_INVALID_VALUE); 225 ctx.endSection(); 226 227 ctx.beginSection("GL_INVALID_OPERATION is generated if shader does not refer to a shader object."); 228 ctx.glGetShaderiv(program, GL_SHADER_TYPE, ¶m[0]); 229 ctx.expectError(GL_INVALID_OPERATION); 230 ctx.endSection(); 231 232 ctx.glDeleteShader(shader); 233 ctx.glDeleteProgram(program); 234} 235 236void get_shader_info_log (NegativeTestContext& ctx) 237{ 238 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 239 GLuint program = ctx.glCreateProgram(); 240 GLsizei length[1] = { -1 }; 241 char infoLog[128] = { 0 }; 242 243 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."); 244 ctx.glGetShaderInfoLog(-1, 128, &length[0], &infoLog[0]); 245 ctx.expectError(GL_INVALID_VALUE); 246 ctx.endSection(); 247 248 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object."); 249 ctx.glGetShaderInfoLog(program, 128, &length[0], &infoLog[0]); 250 ctx.expectError(GL_INVALID_OPERATION); 251 ctx.endSection(); 252 253 ctx.beginSection("GL_INVALID_VALUE is generated if maxLength is less than 0."); 254 ctx.glGetShaderInfoLog(shader, -1, &length[0], &infoLog[0]); 255 ctx.expectError(GL_INVALID_VALUE); 256 ctx.endSection(); 257 258 ctx.glDeleteShader(shader); 259 ctx.glDeleteProgram(program); 260} 261 262void get_shader_precision_format (NegativeTestContext& ctx) 263{ 264 GLboolean shaderCompilerSupported; 265 ctx.glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported); 266 ctx.getLog() << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage; 267 268 GLint range[2]; 269 GLint precision[1]; 270 271 deMemset(&range[0], 0xcd, sizeof(range)); 272 deMemset(&precision[0], 0xcd, sizeof(precision)); 273 274 ctx.beginSection("GL_INVALID_ENUM is generated if shaderType or precisionType is not an accepted value."); 275 ctx.glGetShaderPrecisionFormat (-1, GL_MEDIUM_FLOAT, &range[0], &precision[0]); 276 ctx.expectError(GL_INVALID_ENUM); 277 ctx.glGetShaderPrecisionFormat (GL_VERTEX_SHADER, -1, &range[0], &precision[0]); 278 ctx.expectError(GL_INVALID_ENUM); 279 ctx.glGetShaderPrecisionFormat (-1, -1, &range[0], &precision[0]); 280 ctx.expectError(GL_INVALID_ENUM); 281 ctx.endSection(); 282} 283 284void get_shader_source (NegativeTestContext& ctx) 285{ 286 GLsizei length[1] = { 0 }; 287 char source[1] = { 0 }; 288 GLuint program = ctx.glCreateProgram(); 289 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 290 291 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."); 292 ctx.glGetShaderSource(-1, 1, &length[0], &source[0]); 293 ctx.expectError(GL_INVALID_VALUE); 294 ctx.endSection(); 295 296 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object."); 297 ctx.glGetShaderSource(program, 1, &length[0], &source[0]); 298 ctx.expectError(GL_INVALID_OPERATION); 299 ctx.endSection(); 300 301 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0."); 302 ctx.glGetShaderSource(shader, -1, &length[0], &source[0]); 303 ctx.expectError(GL_INVALID_VALUE); 304 ctx.endSection(); 305 306 ctx.glDeleteProgram(program); 307 ctx.glDeleteShader(shader); 308} 309 310// Enumerated state queries: Programs 311 312void get_programiv (NegativeTestContext& ctx) 313{ 314 GLuint program = ctx.glCreateProgram(); 315 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 316 GLint params[1] = { 0 }; 317 318 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); 319 ctx.glGetProgramiv(program, -1, ¶ms[0]); 320 ctx.expectError(GL_INVALID_ENUM); 321 ctx.endSection(); 322 323 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 324 ctx.glGetProgramiv(-1, GL_LINK_STATUS, ¶ms[0]); 325 ctx.expectError(GL_INVALID_VALUE); 326 ctx.endSection(); 327 328 ctx.beginSection("GL_INVALID_OPERATION is generated if program does not refer to a program object."); 329 ctx.glGetProgramiv(shader, GL_LINK_STATUS, ¶ms[0]); 330 ctx.expectError(GL_INVALID_OPERATION); 331 ctx.endSection(); 332 333 ctx.glDeleteProgram(program); 334 ctx.glDeleteShader(shader); 335} 336 337void get_program_info_log (NegativeTestContext& ctx) 338{ 339 GLuint program = ctx.glCreateProgram(); 340 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 341 GLsizei length[1] = { 0 }; 342 char infoLog[1] = { 'x' }; 343 344 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 345 ctx.glGetProgramInfoLog (-1, 1, &length[0], &infoLog[0]); 346 ctx.expectError(GL_INVALID_VALUE); 347 ctx.endSection(); 348 349 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 350 ctx.glGetProgramInfoLog (shader, 1, &length[0], &infoLog[0]); 351 ctx.expectError(GL_INVALID_OPERATION); 352 ctx.endSection(); 353 354 ctx.beginSection("GL_INVALID_VALUE is generated if maxLength is less than 0."); 355 ctx.glGetProgramInfoLog (program, -1, &length[0], &infoLog[0]); 356 ctx.expectError(GL_INVALID_VALUE); 357 ctx.endSection(); 358 359 ctx.glDeleteProgram(program); 360 ctx.glDeleteShader(shader); 361} 362 363// Enumerated state queries: Shader variables 364 365void get_tex_parameterfv (NegativeTestContext& ctx) 366{ 367 GLfloat params[1] = { 0 }; 368 369 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value."); 370 ctx.glGetTexParameterfv (-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]); 371 ctx.expectError(GL_INVALID_ENUM); 372 ctx.glGetTexParameterfv (GL_TEXTURE_2D, -1, ¶ms[0]); 373 ctx.expectError(GL_INVALID_ENUM); 374 ctx.glGetTexParameterfv (-1, -1, ¶ms[0]); 375 ctx.expectError(GL_INVALID_ENUM); 376 ctx.endSection(); 377} 378 379void get_tex_parameteriv (NegativeTestContext& ctx) 380{ 381 GLint params[1] = { 0 }; 382 383 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value."); 384 ctx.glGetTexParameteriv (-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]); 385 ctx.expectError(GL_INVALID_ENUM); 386 ctx.glGetTexParameteriv (GL_TEXTURE_2D, -1, ¶ms[0]); 387 ctx.expectError(GL_INVALID_ENUM); 388 ctx.glGetTexParameteriv (-1, -1, ¶ms[0]); 389 ctx.expectError(GL_INVALID_ENUM); 390 ctx.endSection(); 391} 392 393void get_uniformfv (NegativeTestContext& ctx) 394{ 395 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 396 ctx.glUseProgram(program.getProgram()); 397 398 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "vUnif_vec4"); // vec4 399 if (unif == -1) 400 ctx.fail("Failed to retrieve uniform location"); 401 402 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 403 GLuint programEmpty = ctx.glCreateProgram(); 404 GLfloat params[4] = { 0.f }; 405 406 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 407 ctx.glGetUniformfv (-1, unif, ¶ms[0]); 408 ctx.expectError(GL_INVALID_VALUE); 409 ctx.endSection(); 410 411 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 412 ctx.glGetUniformfv (shader, unif, ¶ms[0]); 413 ctx.expectError(GL_INVALID_OPERATION); 414 ctx.endSection(); 415 416 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked."); 417 ctx.glGetUniformfv (programEmpty, unif, ¶ms[0]); 418 ctx.expectError(GL_INVALID_OPERATION); 419 ctx.endSection(); 420 421 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object."); 422 ctx.glGetUniformfv (program.getProgram(), -1, ¶ms[0]); 423 ctx.expectError(GL_INVALID_OPERATION); 424 ctx.endSection(); 425 426 ctx.glDeleteShader(shader); 427 ctx.glDeleteProgram(programEmpty); 428} 429 430void get_uniformiv (NegativeTestContext& ctx) 431{ 432 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 433 ctx.glUseProgram(program.getProgram()); 434 435 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "fUnif_ivec4"); // ivec4 436 if (unif == -1) 437 ctx.fail("Failed to retrieve uniform location"); 438 439 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 440 GLuint programEmpty = ctx.glCreateProgram(); 441 GLint params[4] = { 0 }; 442 443 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 444 ctx.glGetUniformiv (-1, unif, ¶ms[0]); 445 ctx.expectError(GL_INVALID_VALUE); 446 ctx.endSection(); 447 448 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 449 ctx.glGetUniformiv (shader, unif, ¶ms[0]); 450 ctx.expectError(GL_INVALID_OPERATION); 451 ctx.endSection(); 452 453 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked."); 454 ctx.glGetUniformiv (programEmpty, unif, ¶ms[0]); 455 ctx.expectError(GL_INVALID_OPERATION); 456 ctx.endSection(); 457 458 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object."); 459 ctx.glGetUniformiv (program.getProgram(), -1, ¶ms[0]); 460 ctx.expectError(GL_INVALID_OPERATION); 461 ctx.endSection(); 462 463 ctx.glDeleteShader(shader); 464 ctx.glDeleteProgram(programEmpty); 465} 466 467void get_uniformuiv (NegativeTestContext& ctx) 468{ 469 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 470 ctx.glUseProgram(program.getProgram()); 471 472 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "fUnif_uvec4"); // uvec4 473 if (unif == -1) 474 ctx.fail("Failed to retrieve uniform location"); 475 476 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 477 GLuint programEmpty = ctx.glCreateProgram(); 478 GLuint params[4] = { 0 }; 479 480 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 481 ctx.glGetUniformuiv (-1, unif, ¶ms[0]); 482 ctx.expectError(GL_INVALID_VALUE); 483 ctx.endSection(); 484 485 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 486 ctx.glGetUniformuiv (shader, unif, ¶ms[0]); 487 ctx.expectError(GL_INVALID_OPERATION); 488 ctx.endSection(); 489 490 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked."); 491 ctx.glGetUniformuiv (programEmpty, unif, ¶ms[0]); 492 ctx.expectError(GL_INVALID_OPERATION); 493 ctx.endSection(); 494 495 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object."); 496 ctx.glGetUniformuiv (program.getProgram(), -1, ¶ms[0]); 497 ctx.expectError(GL_INVALID_OPERATION); 498 ctx.endSection(); 499 500 ctx.glDeleteShader(shader); 501 ctx.glDeleteProgram(programEmpty); 502} 503 504void get_active_uniform (NegativeTestContext& ctx) 505{ 506 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 507 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 508 GLint numActiveUniforms = -1; 509 510 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms); 511 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage; 512 513 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 514 ctx.glGetActiveUniform(-1, 0, 0, 0, 0, 0, 0); 515 ctx.expectError(GL_INVALID_VALUE); 516 ctx.endSection(); 517 518 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 519 ctx.glGetActiveUniform(shader, 0, 0, 0, 0, 0, 0); 520 ctx.expectError(GL_INVALID_OPERATION); 521 ctx.endSection(); 522 523 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to the number of active uniform variables in program."); 524 ctx.glUseProgram(program.getProgram()); 525 ctx.glGetActiveUniform(program.getProgram(), numActiveUniforms, 0, 0, 0, 0, 0); 526 ctx.expectError(GL_INVALID_VALUE); 527 ctx.endSection(); 528 529 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0."); 530 ctx.glGetActiveUniform(program.getProgram(), 0, -1, 0, 0, 0, 0); 531 ctx.expectError(GL_INVALID_VALUE); 532 ctx.endSection(); 533 534 ctx.glUseProgram(0); 535 ctx.glDeleteShader(shader); 536} 537 538void get_active_uniformsiv (NegativeTestContext& ctx) 539{ 540 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 541 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 542 GLuint dummyUniformIndex = 1; 543 GLint dummyParamDst = -1; 544 GLint numActiveUniforms = -1; 545 546 ctx.glUseProgram(program.getProgram()); 547 548 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms); 549 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage; 550 551 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 552 ctx.glGetActiveUniformsiv(-1, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst); 553 ctx.expectError(GL_INVALID_VALUE); 554 ctx.endSection(); 555 556 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 557 ctx.glGetActiveUniformsiv(shader, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst); 558 ctx.expectError(GL_INVALID_OPERATION); 559 ctx.endSection(); 560 561 ctx.beginSection("GL_INVALID_VALUE is generated if any value in uniformIndices is greater than or equal to the value of GL_ACTIVE_UNIFORMS for program."); 562 for (int excess = 0; excess <= 2; excess++) 563 { 564 std::vector<GLuint> invalidUniformIndices; 565 invalidUniformIndices.push_back(1); 566 invalidUniformIndices.push_back(numActiveUniforms-1+excess); 567 invalidUniformIndices.push_back(1); 568 569 std::vector<GLint> dummyParamsDst(invalidUniformIndices.size()); 570 ctx.glGetActiveUniformsiv(program.getProgram(), (GLsizei)invalidUniformIndices.size(), &invalidUniformIndices[0], GL_UNIFORM_TYPE, &dummyParamsDst[0]); 571 ctx.expectError(excess == 0 ? GL_NO_ERROR : GL_INVALID_VALUE); 572 } 573 ctx.endSection(); 574 575 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted token."); 576 ctx.glGetActiveUniformsiv(program.getProgram(), 1, &dummyUniformIndex, -1, &dummyParamDst); 577 ctx.expectError(GL_INVALID_ENUM); 578 ctx.endSection(); 579 580 ctx.glUseProgram(0); 581 ctx.glDeleteShader(shader); 582} 583 584void get_active_uniform_blockiv (NegativeTestContext& ctx) 585{ 586 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 587 GLint params = -1; 588 GLint numActiveBlocks = -1; 589 590 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks); 591 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage; 592 ctx.expectError (GL_NO_ERROR); 593 594 ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockIndex is greater than or equal to the value of GL_ACTIVE_UNIFORM_BLOCKS or is not the index of an active uniform block in program."); 595 ctx.glUseProgram(program.getProgram()); 596 ctx.expectError(GL_NO_ERROR); 597 ctx.glGetActiveUniformBlockiv(program.getProgram(), numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, ¶ms); 598 ctx.expectError(GL_INVALID_VALUE); 599 ctx.endSection(); 600 601 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens."); 602 ctx.glGetActiveUniformBlockiv(program.getProgram(), 0, -1, ¶ms); 603 ctx.expectError(GL_INVALID_ENUM); 604 ctx.endSection(); 605 606 ctx.glUseProgram(0); 607} 608 609void get_active_uniform_block_name (NegativeTestContext& ctx) 610{ 611 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 612 GLsizei length = -1; 613 GLint numActiveBlocks = -1; 614 GLchar uniformBlockName[128]; 615 616 deMemset(&uniformBlockName[0], 0, sizeof(uniformBlockName)); 617 618 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks); 619 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage; 620 ctx.expectError (GL_NO_ERROR); 621 622 ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockIndex is greater than or equal to the value of GL_ACTIVE_UNIFORM_BLOCKS or is not the index of an active uniform block in program."); 623 ctx.glUseProgram(program.getProgram()); 624 ctx.expectError(GL_NO_ERROR); 625 ctx.glGetActiveUniformBlockName(program.getProgram(), numActiveBlocks, (int)sizeof(uniformBlockName), &length, &uniformBlockName[0]); 626 ctx.expectError(GL_INVALID_VALUE); 627 ctx.endSection(); 628 629 ctx.glUseProgram(0); 630} 631 632void get_active_attrib (NegativeTestContext& ctx) 633{ 634 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 635 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 636 GLint numActiveAttributes = -1; 637 638 GLsizei length = -1; 639 GLint size = -1; 640 GLenum type = -1; 641 GLchar name[32]; 642 643 deMemset(&name[0], 0, sizeof(name)); 644 645 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_ATTRIBUTES, &numActiveAttributes); 646 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_ATTRIBUTES = " << numActiveAttributes << " (expected 1)." << TestLog::EndMessage; 647 648 ctx.glUseProgram(program.getProgram()); 649 650 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 651 ctx.glGetActiveAttrib(-1, 0, 32, &length, &size, &type, &name[0]); 652 ctx.expectError(GL_INVALID_VALUE); 653 ctx.endSection(); 654 655 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 656 ctx.glGetActiveAttrib(shader, 0, 32, &length, &size, &type, &name[0]); 657 ctx.expectError(GL_INVALID_OPERATION); 658 ctx.endSection(); 659 660 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_ACTIVE_ATTRIBUTES."); 661 ctx.glGetActiveAttrib(program.getProgram(), numActiveAttributes, (int)sizeof(name), &length, &size, &type, &name[0]); 662 ctx.expectError(GL_INVALID_VALUE); 663 ctx.endSection(); 664 665 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0."); 666 ctx.glGetActiveAttrib(program.getProgram(), 0, -1, &length, &size, &type, &name[0]); 667 ctx.expectError(GL_INVALID_VALUE); 668 ctx.endSection(); 669 670 ctx.glUseProgram(0); 671 ctx.glDeleteShader(shader); 672} 673 674void get_uniform_indices (NegativeTestContext& ctx) 675{ 676 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 677 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 678 GLint numActiveBlocks = -1; 679 const GLchar* uniformName = "Block.blockVar"; 680 GLuint uniformIndices = -1; 681 682 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks); 683 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << TestLog::EndMessage; 684 ctx.expectError (GL_NO_ERROR); 685 686 ctx.beginSection("GL_INVALID_OPERATION is generated if program is a name of shader object."); 687 ctx.glGetUniformIndices(shader, 1, &uniformName, &uniformIndices); 688 ctx.expectError(GL_INVALID_OPERATION); 689 ctx.endSection(); 690 691 ctx.beginSection("GL_INVALID_VALUE is generated if program is not name of program or shader object."); 692 GLuint invalid = -1; 693 ctx.glGetUniformIndices(invalid, 1, &uniformName, &uniformIndices); 694 ctx.expectError(GL_INVALID_VALUE); 695 ctx.endSection(); 696 697 ctx.glUseProgram(0); 698 ctx.glDeleteShader(shader); 699} 700 701void get_vertex_attribfv (NegativeTestContext& ctx) 702{ 703 GLfloat params = 0.0f; 704 705 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); 706 ctx.glGetVertexAttribfv(0, -1, ¶ms); 707 ctx.expectError(GL_INVALID_ENUM); 708 ctx.endSection(); 709 710 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS."); 711 GLint maxVertexAttribs; 712 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs); 713 ctx.glGetVertexAttribfv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms); 714 ctx.expectError(GL_INVALID_VALUE); 715 ctx.endSection(); 716} 717 718void get_vertex_attribiv (NegativeTestContext& ctx) 719{ 720 GLint params = -1; 721 722 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); 723 ctx.glGetVertexAttribiv(0, -1, ¶ms); 724 ctx.expectError(GL_INVALID_ENUM); 725 ctx.endSection(); 726 727 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS."); 728 GLint maxVertexAttribs; 729 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs); 730 ctx.glGetVertexAttribiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms); 731 ctx.expectError(GL_INVALID_VALUE); 732 ctx.endSection(); 733} 734 735void get_vertex_attribi_iv (NegativeTestContext& ctx) 736{ 737 GLint params = -1; 738 739 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); 740 ctx.glGetVertexAttribIiv(0, -1, ¶ms); 741 ctx.expectError(GL_INVALID_ENUM); 742 ctx.endSection(); 743 744 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS."); 745 GLint maxVertexAttribs; 746 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs); 747 ctx.glGetVertexAttribIiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms); 748 ctx.expectError(GL_INVALID_VALUE); 749 ctx.endSection(); 750} 751 752void get_vertex_attribi_uiv (NegativeTestContext& ctx) 753{ 754 GLuint params = (GLuint)-1; 755 756 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); 757 ctx.glGetVertexAttribIuiv(0, -1, ¶ms); 758 ctx.expectError(GL_INVALID_ENUM); 759 ctx.endSection(); 760 761 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS."); 762 GLint maxVertexAttribs; 763 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs); 764 ctx.glGetVertexAttribIuiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms); 765 ctx.expectError(GL_INVALID_VALUE); 766 ctx.endSection(); 767} 768 769void get_vertex_attrib_pointerv (NegativeTestContext& ctx) 770{ 771 GLvoid* ptr[1] = { DE_NULL }; 772 773 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); 774 ctx.glGetVertexAttribPointerv(0, -1, &ptr[0]); 775 ctx.expectError(GL_INVALID_ENUM); 776 ctx.endSection(); 777 778 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS."); 779 GLint maxVertexAttribs; 780 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs); 781 ctx.glGetVertexAttribPointerv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr[0]); 782 ctx.expectError(GL_INVALID_VALUE); 783 ctx.endSection(); 784} 785 786void get_frag_data_location (NegativeTestContext& ctx) 787{ 788 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 789 GLuint program = ctx.glCreateProgram(); 790 791 ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object."); 792 ctx.glGetFragDataLocation(shader, "gl_FragColor"); 793 ctx.expectError(GL_INVALID_OPERATION); 794 ctx.endSection(); 795 796 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been linked."); 797 ctx.glGetFragDataLocation(program, "gl_FragColor"); 798 ctx.expectError(GL_INVALID_OPERATION); 799 ctx.endSection(); 800 801 ctx.glDeleteProgram(program); 802 ctx.glDeleteShader(shader); 803} 804 805// Enumerated state queries: Buffers 806 807void get_buffer_parameteriv (NegativeTestContext& ctx) 808{ 809 GLint params = -1; 810 GLuint buf; 811 ctx.glGenBuffers(1, &buf); 812 ctx.glBindBuffer(GL_ARRAY_BUFFER, buf); 813 814 ctx.beginSection("GL_INVALID_ENUM is generated if target or value is not an accepted value."); 815 ctx.glGetBufferParameteriv(-1, GL_BUFFER_SIZE, ¶ms); 816 ctx.expectError(GL_INVALID_ENUM); 817 ctx.glGetBufferParameteriv(GL_ARRAY_BUFFER, -1, ¶ms); 818 ctx.expectError(GL_INVALID_ENUM); 819 ctx.glGetBufferParameteriv(-1, -1, ¶ms); 820 ctx.expectError(GL_INVALID_ENUM); 821 ctx.endSection(); 822 823 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target."); 824 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0); 825 ctx.glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, ¶ms); 826 ctx.expectError(GL_INVALID_OPERATION); 827 ctx.endSection(); 828 829 ctx.glDeleteBuffers(1, &buf); 830} 831 832void get_buffer_parameteri64v (NegativeTestContext& ctx) 833{ 834 GLint64 params = -1; 835 GLuint buf; 836 ctx.glGenBuffers(1, &buf); 837 ctx.glBindBuffer(GL_ARRAY_BUFFER, buf); 838 839 ctx.beginSection("GL_INVALID_ENUM is generated if target or value is not an accepted value."); 840 ctx.glGetBufferParameteri64v(-1, GL_BUFFER_SIZE, ¶ms); 841 ctx.expectError(GL_INVALID_ENUM); 842 ctx.glGetBufferParameteri64v(GL_ARRAY_BUFFER , -1, ¶ms); 843 ctx.expectError(GL_INVALID_ENUM); 844 ctx.glGetBufferParameteri64v(-1, -1, ¶ms); 845 ctx.expectError(GL_INVALID_ENUM); 846 ctx.endSection(); 847 848 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target."); 849 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0); 850 ctx.glGetBufferParameteri64v(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, ¶ms); 851 ctx.expectError(GL_INVALID_OPERATION); 852 ctx.endSection(); 853 854 ctx.glDeleteBuffers(1, &buf); 855} 856 857void get_buffer_pointerv (NegativeTestContext& ctx) 858{ 859 GLvoid* params = DE_NULL; 860 GLuint buf; 861 ctx.glGenBuffers(1, &buf); 862 ctx.glBindBuffer(GL_ARRAY_BUFFER, buf); 863 864 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value."); 865 ctx.glGetBufferPointerv(GL_ARRAY_BUFFER, -1, ¶ms); 866 ctx.expectError(GL_INVALID_ENUM); 867 ctx.glGetBufferPointerv(-1, GL_BUFFER_MAP_POINTER, ¶ms); 868 ctx.expectError(GL_INVALID_ENUM); 869 ctx.endSection(); 870 871 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target."); 872 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0); 873 ctx.glGetBufferPointerv(GL_ARRAY_BUFFER, GL_BUFFER_MAP_POINTER, ¶ms); 874 ctx.expectError(GL_INVALID_OPERATION); 875 ctx.endSection(); 876 877 ctx.glDeleteBuffers(1, &buf); 878} 879 880void get_framebuffer_attachment_parameteriv (NegativeTestContext& ctx) 881{ 882 GLint params[1] = { -1 }; 883 GLuint fbo; 884 GLuint rbo[2]; 885 886 ctx.glGenFramebuffers (1, &fbo); 887 ctx.glGenRenderbuffers (2, rbo); 888 889 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo); 890 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]); 891 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 16, 16); 892 ctx.glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rbo[0]); 893 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]); 894 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_STENCIL_INDEX8, 16, 16); 895 ctx.glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]); 896 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER); 897 ctx.expectError (GL_NO_ERROR); 898 899 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens."); 900 ctx.glGetFramebufferAttachmentParameteriv(-1, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, ¶ms[0]); // TYPE is GL_RENDERBUFFER 901 ctx.expectError(GL_INVALID_ENUM); 902 ctx.endSection(); 903 904 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not valid for the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE."); 905 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, ¶ms[0]); // TYPE is GL_RENDERBUFFER 906 ctx.expectError(GL_INVALID_ENUM); 907 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0); 908 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // TYPE is GL_FRAMEBUFFER_DEFAULT 909 ctx.expectError(GL_INVALID_ENUM); 910 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo); 911 ctx.endSection(); 912 913 ctx.beginSection("GL_INVALID_OPERATION is generated if attachment is GL_DEPTH_STENCIL_ATTACHMENT and different objects are bound to the depth and stencil attachment points of target."); 914 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); 915 ctx.expectError(GL_INVALID_OPERATION); 916 ctx.endSection(); 917 918 ctx.beginSection("GL_INVALID_OPERATION is generated if the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE and pname is not GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME."); 919 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // TYPE is GL_NONE 920 ctx.expectError(GL_NO_ERROR); 921 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, ¶ms[0]); // TYPE is GL_NONE 922 ctx.expectError(GL_INVALID_OPERATION); 923 ctx.endSection(); 924 925 ctx.beginSection("GL_INVALID_OPERATION or GL_INVALID_ENUM is generated if attachment is not one of the accepted values for the current binding of target."); 926 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // A FBO is bound so GL_BACK is invalid 927 ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM); 928 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0); 929 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // Default framebuffer is bound so GL_COLOR_ATTACHMENT0 is invalid 930 ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM); 931 ctx.endSection(); 932 933 ctx.glDeleteFramebuffers(1, &fbo); 934} 935 936void get_renderbuffer_parameteriv (NegativeTestContext& ctx) 937{ 938 GLint params[1] = { -1 }; 939 GLuint rbo; 940 ctx.glGenRenderbuffers(1, &rbo); 941 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo); 942 943 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER."); 944 ctx.glGetRenderbufferParameteriv(-1, GL_RENDERBUFFER_WIDTH, ¶ms[0]); 945 ctx.expectError(GL_INVALID_ENUM); 946 ctx.endSection(); 947 948 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens."); 949 ctx.glGetRenderbufferParameteriv(GL_RENDERBUFFER, -1, ¶ms[0]); 950 ctx.expectError(GL_INVALID_ENUM); 951 ctx.endSection(); 952 953 ctx.glDeleteRenderbuffers(1, &rbo); 954 ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0); 955} 956 957void get_internalformativ (NegativeTestContext& ctx) 958{ 959 GLint params[16]; 960 961 deMemset(¶ms[0], 0xcd, sizeof(params)); 962 963 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is negative."); 964 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, -1, ¶ms[0]); 965 ctx.expectError (GL_INVALID_VALUE); 966 ctx.endSection(); 967 968 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not GL_SAMPLES or GL_NUM_SAMPLE_COUNTS."); 969 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8, -1, 16, ¶ms[0]); 970 ctx.expectError (GL_INVALID_ENUM); 971 ctx.endSection(); 972 973 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not color-, depth-, or stencil-renderable."); 974 975 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_render_snorm")) 976 { 977 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RG8_SNORM, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]); 978 ctx.expectError (GL_INVALID_ENUM); 979 } 980 981 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_COMPRESSED_RGB8_ETC2, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]); 982 ctx.expectError (GL_INVALID_ENUM); 983 ctx.endSection(); 984 985 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER."); 986 ctx.glGetInternalformativ (-1, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]); 987 ctx.expectError (GL_INVALID_ENUM); 988 ctx.glGetInternalformativ (GL_FRAMEBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]); 989 ctx.expectError (GL_INVALID_ENUM); 990 ctx.glGetInternalformativ (GL_TEXTURE_2D, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]); 991 ctx.expectError (GL_INVALID_ENUM); 992 ctx.endSection(); 993} 994 995// Query object queries 996 997void get_queryiv (NegativeTestContext& ctx) 998{ 999 GLint params = -1; 1000 1001 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value."); 1002 ctx.glGetQueryiv (GL_ANY_SAMPLES_PASSED, -1, ¶ms); 1003 ctx.expectError (GL_INVALID_ENUM); 1004 ctx.glGetQueryiv (-1, GL_CURRENT_QUERY, ¶ms); 1005 ctx.expectError (GL_INVALID_ENUM); 1006 ctx.glGetQueryiv (-1, -1, ¶ms); 1007 ctx.expectError (GL_INVALID_ENUM); 1008 ctx.endSection(); 1009} 1010 1011void get_query_objectuiv (NegativeTestContext& ctx) 1012{ 1013 GLuint params = -1; 1014 GLuint id; 1015 ctx.glGenQueries (1, &id); 1016 1017 ctx.beginSection("GL_INVALID_OPERATION is generated if id is not the name of a query object."); 1018 ctx.glGetQueryObjectuiv (-1, GL_QUERY_RESULT_AVAILABLE, ¶ms); 1019 ctx.expectError (GL_INVALID_OPERATION); 1020 ctx.getLog() << TestLog::Message << "// Note: " << id << " is not a query object yet, since it hasn't been used by glBeginQuery" << TestLog::EndMessage; 1021 ctx.glGetQueryObjectuiv (id, GL_QUERY_RESULT_AVAILABLE, ¶ms); 1022 ctx.expectError (GL_INVALID_OPERATION); 1023 ctx.endSection(); 1024 1025 ctx.glBeginQuery (GL_ANY_SAMPLES_PASSED, id); 1026 ctx.glEndQuery (GL_ANY_SAMPLES_PASSED); 1027 1028 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); 1029 ctx.glGetQueryObjectuiv (id, -1, ¶ms); 1030 ctx.expectError (GL_INVALID_ENUM); 1031 ctx.endSection(); 1032 1033 ctx.beginSection("GL_INVALID_OPERATION is generated if id is the name of a currently active query object."); 1034 ctx.glBeginQuery (GL_ANY_SAMPLES_PASSED, id); 1035 ctx.expectError (GL_NO_ERROR); 1036 ctx.glGetQueryObjectuiv (id, GL_QUERY_RESULT_AVAILABLE, ¶ms); 1037 ctx.expectError (GL_INVALID_OPERATION); 1038 ctx.glEndQuery (GL_ANY_SAMPLES_PASSED); 1039 ctx.expectError (GL_NO_ERROR); 1040 ctx.endSection(); 1041 1042 ctx.glDeleteQueries (1, &id); 1043} 1044 1045// Sync object queries 1046 1047void get_synciv (NegativeTestContext& ctx) 1048{ 1049 GLsizei length = -1; 1050 GLint values[32]; 1051 GLsync sync; 1052 1053 deMemset(&values[0], 0xcd, sizeof(values)); 1054 1055 ctx.beginSection("GL_INVALID_VALUE is generated if sync is not the name of a sync object."); 1056 ctx.glGetSynciv (0, GL_OBJECT_TYPE, 32, &length, &values[0]); 1057 ctx.expectError (GL_INVALID_VALUE); 1058 ctx.endSection(); 1059 1060 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens."); 1061 sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); 1062 ctx.expectError (GL_NO_ERROR); 1063 ctx.glGetSynciv (sync, -1, 32, &length, &values[0]); 1064 ctx.expectError (GL_INVALID_ENUM); 1065 ctx.endSection(); 1066 1067 ctx.glDeleteSync(sync); 1068} 1069 1070// Enumerated boolean state queries 1071 1072void is_enabled (NegativeTestContext& ctx) 1073{ 1074 ctx.beginSection("GL_INVALID_ENUM is generated if cap is not an accepted value."); 1075 ctx.glIsEnabled(-1); 1076 ctx.expectError(GL_INVALID_ENUM); 1077 ctx.glIsEnabled(GL_TRIANGLES); 1078 ctx.expectError(GL_INVALID_ENUM); 1079 ctx.endSection(); 1080} 1081 1082// Hints 1083 1084void hint (NegativeTestContext& ctx) 1085{ 1086 ctx.beginSection("GL_INVALID_ENUM is generated if either target or mode is not an accepted value."); 1087 ctx.glHint(GL_GENERATE_MIPMAP_HINT, -1); 1088 ctx.expectError(GL_INVALID_ENUM); 1089 ctx.glHint(-1, GL_FASTEST); 1090 ctx.expectError(GL_INVALID_ENUM); 1091 ctx.glHint(-1, -1); 1092 ctx.expectError(GL_INVALID_ENUM); 1093 ctx.endSection(); 1094} 1095 1096std::vector<FunctionContainer> getNegativeStateApiTestFunctions () 1097{ 1098 FunctionContainer funcs[] = 1099 { 1100 {enable, "enable", "Invalid glEnable() usage" }, 1101 {disable, "disable", "Invalid glDisable() usage" }, 1102 {get_booleanv, "get_booleanv", "Invalid glGetBooleanv() usage" }, 1103 {get_floatv, "get_floatv", "Invalid glGetFloatv() usage" }, 1104 {get_integerv, "get_integerv", "Invalid glGetIntegerv() usage" }, 1105 {get_integer64v, "get_integer64v", "Invalid glGetInteger64v() usage" }, 1106 {get_integeri_v, "get_integeri_v", "Invalid glGetIntegeri_v() usage" }, 1107 {get_integer64i_v, "get_integer64i_v", "Invalid glGetInteger64i_v() usage" }, 1108 {get_string, "get_string", "Invalid glGetString() usage" }, 1109 {get_stringi, "get_stringi", "Invalid glGetStringi() usage" }, 1110 {get_attached_shaders, "get_attached_shaders", "Invalid glGetAttachedShaders() usage" }, 1111 {get_shaderiv, "get_shaderiv", "Invalid glGetShaderiv() usage" }, 1112 {get_shader_info_log, "get_shader_info_log", "Invalid glGetShaderInfoLog() usage" }, 1113 {get_shader_precision_format, "get_shader_precision_format", "Invalid glGetShaderPrecisionFormat() usage" }, 1114 {get_shader_source, "get_shader_source", "Invalid glGetShaderSource() usage" }, 1115 {get_programiv, "get_programiv", "Invalid glGetProgramiv() usage" }, 1116 {get_program_info_log, "get_program_info_log", "Invalid glGetProgramInfoLog() usage" }, 1117 {get_tex_parameterfv, "get_tex_parameterfv", "Invalid glGetTexParameterfv() usage" }, 1118 {get_tex_parameteriv, "get_tex_parameteriv", "Invalid glGetTexParameteriv() usage" }, 1119 {get_uniformfv, "get_uniformfv", "Invalid glGetUniformfv() usage" }, 1120 {get_uniformiv, "get_uniformiv", "Invalid glGetUniformiv() usage" }, 1121 {get_uniformuiv, "get_uniformuiv", "Invalid glGetUniformuiv() usage" }, 1122 {get_active_uniform, "get_active_uniform", "Invalid glGetActiveUniform() usage" }, 1123 {get_active_uniformsiv, "get_active_uniformsiv", "Invalid glGetActiveUniformsiv() usage" }, 1124 {get_active_uniform_blockiv, "get_active_uniform_blockiv", "Invalid glGetActiveUniformBlockiv() usage" }, 1125 {get_active_uniform_block_name, "get_active_uniform_block_name", "Invalid glGetActiveUniformBlockName() usage" }, 1126 {get_active_attrib, "get_active_attrib", "Invalid glGetActiveAttrib() usage" }, 1127 {get_uniform_indices, "get_uniform_indices", "Invalid glGetUniformIndices() usage" }, 1128 {get_vertex_attribfv, "get_vertex_attribfv", "Invalid glGetVertexAttribfv() usage" }, 1129 {get_vertex_attribiv, "get_vertex_attribiv", "Invalid glGetVertexAttribiv() usage" }, 1130 {get_vertex_attribi_iv, "get_vertex_attribi_iv", "Invalid glGetVertexAttribIiv() usage" }, 1131 {get_vertex_attribi_uiv, "get_vertex_attribi_uiv", "Invalid glGetVertexAttribIuiv() usage" }, 1132 {get_vertex_attrib_pointerv, "get_vertex_attrib_pointerv", "Invalid glGetVertexAttribPointerv() usage" }, 1133 {get_frag_data_location, "get_frag_data_location", "Invalid glGetFragDataLocation() usage" }, 1134 {get_buffer_parameteriv, "get_buffer_parameteriv", "Invalid glGetBufferParameteriv() usage" }, 1135 {get_buffer_parameteri64v, "get_buffer_parameteri64v", "Invalid glGetBufferParameteri64v() usage" }, 1136 {get_buffer_pointerv, "get_buffer_pointerv", "Invalid glGetBufferPointerv() usage" }, 1137 {get_framebuffer_attachment_parameteriv, "get_framebuffer_attachment_parameteriv", "Invalid glGetFramebufferAttachmentParameteriv() usage"}, 1138 {get_renderbuffer_parameteriv, "get_renderbuffer_parameteriv", "Invalid glGetRenderbufferParameteriv() usage" }, 1139 {get_internalformativ, "get_internalformativ", "Invalid glGetInternalformativ() usage" }, 1140 {get_queryiv, "get_queryiv", "Invalid glGetQueryiv() usage" }, 1141 {get_query_objectuiv, "get_query_objectuiv", "Invalid glGetQueryObjectuiv() usage" }, 1142 {get_synciv, "get_synciv", "Invalid glGetSynciv() usage" }, 1143 {is_enabled, "is_enabled", "Invalid glIsEnabled() usage" }, 1144 {hint, "hint", "Invalid glHint() usage" }, 1145 }; 1146 1147 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs)); 1148} 1149 1150} // NegativeTestShared 1151} // Functional 1152} // gles3 1153} // deqp 1154