1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 2.0 Module 3e5c31af7Sopenharmony_ci * ------------------------------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci *//*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief Negative Shader API tests. 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es2fNegativeShaderApiTests.hpp" 25e5c31af7Sopenharmony_ci#include "es2fApiCase.hpp" 26e5c31af7Sopenharmony_ci#include "gluShaderProgram.hpp" 27e5c31af7Sopenharmony_ci#include "gluContextInfo.hpp" 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_ci#include "glwDefs.hpp" 30e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 31e5c31af7Sopenharmony_ci 32e5c31af7Sopenharmony_ci#include "deStringUtil.hpp" 33e5c31af7Sopenharmony_ci 34e5c31af7Sopenharmony_ciusing namespace glw; // GL types 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_cinamespace deqp 37e5c31af7Sopenharmony_ci{ 38e5c31af7Sopenharmony_cinamespace gles2 39e5c31af7Sopenharmony_ci{ 40e5c31af7Sopenharmony_cinamespace Functional 41e5c31af7Sopenharmony_ci{ 42e5c31af7Sopenharmony_ci 43e5c31af7Sopenharmony_cistatic const char* vertexShaderSource = "void main (void) { gl_Position = vec4(0.0); }\n\0"; 44e5c31af7Sopenharmony_cistatic const char* fragmentShaderSource = "void main (void) { gl_FragColor = vec4(0.0); }\n\0"; 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_cistatic const char* uniformTestVertSource = "uniform mediump vec4 vTest;\n" 47e5c31af7Sopenharmony_ci "uniform mediump mat4 vMatrix;\n" 48e5c31af7Sopenharmony_ci "void main (void)\n" 49e5c31af7Sopenharmony_ci "{\n" 50e5c31af7Sopenharmony_ci " gl_Position = vMatrix * vTest;\n" 51e5c31af7Sopenharmony_ci "}\n\0"; 52e5c31af7Sopenharmony_cistatic const char* uniformTestFragSource = "uniform mediump ivec4 fTest;\n" 53e5c31af7Sopenharmony_ci "uniform sampler2D fSampler;\n" 54e5c31af7Sopenharmony_ci "void main (void)\n" 55e5c31af7Sopenharmony_ci "{\n" 56e5c31af7Sopenharmony_ci " gl_FragColor.xy = vec4(fTest).xy;\n" 57e5c31af7Sopenharmony_ci " gl_FragColor.zw = texture2D(fSampler, vec2(0.0, 0.0)).zw;\n" 58e5c31af7Sopenharmony_ci "}\n\0"; 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_ciusing tcu::TestLog; 61e5c31af7Sopenharmony_ci 62e5c31af7Sopenharmony_ciNegativeShaderApiTests::NegativeShaderApiTests (Context& context) 63e5c31af7Sopenharmony_ci : TestCaseGroup(context, "shader", "Negative Shader API Cases") 64e5c31af7Sopenharmony_ci{ 65e5c31af7Sopenharmony_ci} 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ciNegativeShaderApiTests::~NegativeShaderApiTests (void) 68e5c31af7Sopenharmony_ci{ 69e5c31af7Sopenharmony_ci} 70e5c31af7Sopenharmony_ci 71e5c31af7Sopenharmony_civoid NegativeShaderApiTests::init (void) 72e5c31af7Sopenharmony_ci{ 73e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(create_shader, "Invalid glCreateShader() usage", 74e5c31af7Sopenharmony_ci { 75e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if shaderType is not an accepted value."); 76e5c31af7Sopenharmony_ci glCreateShader(-1); 77e5c31af7Sopenharmony_ci expectError(GL_INVALID_ENUM); 78e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 79e5c31af7Sopenharmony_ci }); 80e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(shader_source, "Invalid glShaderSource() usage", 81e5c31af7Sopenharmony_ci { 82e5c31af7Sopenharmony_ci GLboolean shaderCompilerSupported; 83e5c31af7Sopenharmony_ci glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported); 84e5c31af7Sopenharmony_ci if (!shaderCompilerSupported) 85e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// Shader compiler not supported, always expect GL_INVALID_OPERATION" << TestLog::EndMessage; 86e5c31af7Sopenharmony_ci else 87e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// Shader compiler supported" << TestLog::EndMessage; 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."); 90e5c31af7Sopenharmony_ci glShaderSource(1, 0, 0, 0); 91e5c31af7Sopenharmony_ci expectError(shaderCompilerSupported ? GL_INVALID_VALUE : GL_INVALID_OPERATION); 92e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 93e5c31af7Sopenharmony_ci 94e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if count is less than 0."); 95e5c31af7Sopenharmony_ci GLuint shader = glCreateShader(GL_VERTEX_SHADER); 96e5c31af7Sopenharmony_ci glShaderSource(shader, -1, 0, 0); 97e5c31af7Sopenharmony_ci expectError(shaderCompilerSupported ? GL_INVALID_VALUE : GL_INVALID_OPERATION); 98e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 99e5c31af7Sopenharmony_ci 100e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object."); 101e5c31af7Sopenharmony_ci GLuint program = glCreateProgram(); 102e5c31af7Sopenharmony_ci glShaderSource(program, 0, 0, 0); 103e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 104e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 105e5c31af7Sopenharmony_ci 106e5c31af7Sopenharmony_ci glDeleteProgram(program); 107e5c31af7Sopenharmony_ci glDeleteShader(shader); 108e5c31af7Sopenharmony_ci }); 109e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(compile_shader, "Invalid glCompileShader() usage", 110e5c31af7Sopenharmony_ci { 111e5c31af7Sopenharmony_ci GLboolean shaderCompilerSupported; 112e5c31af7Sopenharmony_ci glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported); 113e5c31af7Sopenharmony_ci if (!shaderCompilerSupported) 114e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// Shader compiler not supported, always expect GL_INVALID_OPERATION" << TestLog::EndMessage; 115e5c31af7Sopenharmony_ci else 116e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// Shader compiler supported" << TestLog::EndMessage; 117e5c31af7Sopenharmony_ci 118e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."); 119e5c31af7Sopenharmony_ci glCompileShader(9); 120e5c31af7Sopenharmony_ci expectError(shaderCompilerSupported ? GL_INVALID_VALUE : GL_INVALID_OPERATION); 121e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 122e5c31af7Sopenharmony_ci 123e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object."); 124e5c31af7Sopenharmony_ci GLuint program = glCreateProgram(); 125e5c31af7Sopenharmony_ci glCompileShader(program); 126e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 127e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 128e5c31af7Sopenharmony_ci 129e5c31af7Sopenharmony_ci glDeleteProgram(program); 130e5c31af7Sopenharmony_ci }); 131e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(delete_shader, "Invalid glDeleteShader() usage", 132e5c31af7Sopenharmony_ci { 133e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."); 134e5c31af7Sopenharmony_ci glDeleteShader(9); 135e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 136e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 137e5c31af7Sopenharmony_ci }); 138e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(shader_binary, "Invalid glShaderBinary() usage", 139e5c31af7Sopenharmony_ci { 140e5c31af7Sopenharmony_ci std::vector<deInt32> binaryFormats; 141e5c31af7Sopenharmony_ci getSupportedExtensions(GL_NUM_SHADER_BINARY_FORMATS, GL_SHADER_BINARY_FORMATS, binaryFormats); 142e5c31af7Sopenharmony_ci deBool shaderBinarySupported = !binaryFormats.empty(); 143e5c31af7Sopenharmony_ci if (!shaderBinarySupported) 144e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// Shader binaries not supported." << TestLog::EndMessage; 145e5c31af7Sopenharmony_ci else 146e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// Shader binaries supported" << TestLog::EndMessage; 147e5c31af7Sopenharmony_ci 148e5c31af7Sopenharmony_ci GLuint shaders[2]; 149e5c31af7Sopenharmony_ci 150e5c31af7Sopenharmony_ci shaders[0] = glCreateShader(GL_VERTEX_SHADER); 151e5c31af7Sopenharmony_ci shaders[1] = glCreateShader(GL_VERTEX_SHADER); 152e5c31af7Sopenharmony_ci GLuint program = glCreateProgram(); 153e5c31af7Sopenharmony_ci 154e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if binaryformat is not a supported format returned in GL_SHADER_BINARY_FORMATS."); 155e5c31af7Sopenharmony_ci glShaderBinary(1, &shaders[0], -1, 0, 0); 156e5c31af7Sopenharmony_ci expectError(GL_INVALID_ENUM); 157e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 158e5c31af7Sopenharmony_ci 159e5c31af7Sopenharmony_ci if (shaderBinarySupported) 160e5c31af7Sopenharmony_ci { 161e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if any value in shaders is not a value generated by OpenGL."); 162e5c31af7Sopenharmony_ci shaders[0] = 137; 163e5c31af7Sopenharmony_ci glShaderBinary(1, &shaders[0], binaryFormats[0], 0, 0); 164e5c31af7Sopenharmony_ci expectError(shaderBinarySupported ? GL_INVALID_VALUE : GL_INVALID_OPERATION); 165e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 166e5c31af7Sopenharmony_ci 167e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n or length is negative."); 168e5c31af7Sopenharmony_ci shaders[0] = glCreateShader(GL_VERTEX_SHADER); 169e5c31af7Sopenharmony_ci glShaderBinary(-1, &shaders[0], binaryFormats[0], 0, 0); 170e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION, GL_INVALID_VALUE); 171e5c31af7Sopenharmony_ci glShaderBinary(1, &shaders[0], binaryFormats[0], 0, -1); 172e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION, GL_INVALID_VALUE); 173e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 174e5c31af7Sopenharmony_ci 175e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if any value in shaders is not a shader object."); 176e5c31af7Sopenharmony_ci glShaderBinary(1, &program, binaryFormats[0], 0, 0); 177e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION, GL_INVALID_VALUE); 178e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 179e5c31af7Sopenharmony_ci 180e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if there is more than one vertex shader object handle or more than one fragment shader object handle in shaders."); 181e5c31af7Sopenharmony_ci shaders[0] = glCreateShader(GL_VERTEX_SHADER); 182e5c31af7Sopenharmony_ci shaders[1] = glCreateShader(GL_VERTEX_SHADER); 183e5c31af7Sopenharmony_ci glShaderBinary(2, &shaders[0], binaryFormats[0], 0, 1); 184e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION, GL_INVALID_VALUE); 185e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 186e5c31af7Sopenharmony_ci } 187e5c31af7Sopenharmony_ci 188e5c31af7Sopenharmony_ci glDeleteShader(shaders[0]); 189e5c31af7Sopenharmony_ci glDeleteShader(shaders[1]); 190e5c31af7Sopenharmony_ci glDeleteProgram(program); 191e5c31af7Sopenharmony_ci 192e5c31af7Sopenharmony_ci // \note: The format of the data pointed to by binary does not match binaryformat. 193e5c31af7Sopenharmony_ci }); 194e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(attach_shader, "Invalid glAttachShader() usage", 195e5c31af7Sopenharmony_ci { 196e5c31af7Sopenharmony_ci GLuint shader1 = glCreateShader(GL_VERTEX_SHADER); 197e5c31af7Sopenharmony_ci GLuint shader2 = glCreateShader(GL_VERTEX_SHADER); 198e5c31af7Sopenharmony_ci GLuint program = glCreateProgram(); 199e5c31af7Sopenharmony_ci 200e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object."); 201e5c31af7Sopenharmony_ci glAttachShader(shader1, shader1); 202e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 203e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 204e5c31af7Sopenharmony_ci 205e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object."); 206e5c31af7Sopenharmony_ci glAttachShader(program, program); 207e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 208e5c31af7Sopenharmony_ci glAttachShader(shader1, program); 209e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 210e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 211e5c31af7Sopenharmony_ci 212e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL."); 213e5c31af7Sopenharmony_ci glAttachShader(program, -1); 214e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 215e5c31af7Sopenharmony_ci glAttachShader(-1, shader1); 216e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 217e5c31af7Sopenharmony_ci glAttachShader(-1, -1); 218e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 219e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 220e5c31af7Sopenharmony_ci 221e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is already attached to program, or if another shader object of the same type as shader is already attached to program."); 222e5c31af7Sopenharmony_ci glAttachShader(program, shader1); 223e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 224e5c31af7Sopenharmony_ci glAttachShader(program, shader1); 225e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 226e5c31af7Sopenharmony_ci glAttachShader(program, shader2); 227e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 228e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 229e5c31af7Sopenharmony_ci 230e5c31af7Sopenharmony_ci glDeleteProgram(program); 231e5c31af7Sopenharmony_ci glDeleteShader(shader1); 232e5c31af7Sopenharmony_ci glDeleteShader(shader2); 233e5c31af7Sopenharmony_ci }); 234e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(detach_shader, "Invalid glDetachShader() usage", 235e5c31af7Sopenharmony_ci { 236e5c31af7Sopenharmony_ci GLuint shader = glCreateShader(GL_VERTEX_SHADER); 237e5c31af7Sopenharmony_ci GLuint program = glCreateProgram(); 238e5c31af7Sopenharmony_ci 239e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL."); 240e5c31af7Sopenharmony_ci glDetachShader(-1, shader); 241e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 242e5c31af7Sopenharmony_ci glDetachShader(program, -1); 243e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 244e5c31af7Sopenharmony_ci glDetachShader(-1, -1); 245e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 246e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 247e5c31af7Sopenharmony_ci 248e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object."); 249e5c31af7Sopenharmony_ci glDetachShader(shader, shader); 250e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 251e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 252e5c31af7Sopenharmony_ci 253e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object."); 254e5c31af7Sopenharmony_ci glDetachShader(program, program); 255e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 256e5c31af7Sopenharmony_ci glDetachShader(shader, program); 257e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 258e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 259e5c31af7Sopenharmony_ci 260e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not attached to program."); 261e5c31af7Sopenharmony_ci glDetachShader(program, shader); 262e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 263e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 264e5c31af7Sopenharmony_ci 265e5c31af7Sopenharmony_ci glDeleteProgram(program); 266e5c31af7Sopenharmony_ci glDeleteShader(shader); 267e5c31af7Sopenharmony_ci }); 268e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(link_program, "Invalid glLinkProgram() usage", 269e5c31af7Sopenharmony_ci { 270e5c31af7Sopenharmony_ci GLuint shader = glCreateShader(GL_VERTEX_SHADER); 271e5c31af7Sopenharmony_ci 272e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 273e5c31af7Sopenharmony_ci glLinkProgram(-1); 274e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 275e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 276e5c31af7Sopenharmony_ci 277e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object."); 278e5c31af7Sopenharmony_ci glLinkProgram(shader); 279e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 280e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 281e5c31af7Sopenharmony_ci 282e5c31af7Sopenharmony_ci glDeleteShader(shader); 283e5c31af7Sopenharmony_ci }); 284e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(use_program, "Invalid glUseProgram() usage", 285e5c31af7Sopenharmony_ci { 286e5c31af7Sopenharmony_ci GLuint shader = glCreateShader(GL_VERTEX_SHADER); 287e5c31af7Sopenharmony_ci 288e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is neither 0 nor a value generated by OpenGL."); 289e5c31af7Sopenharmony_ci glUseProgram(-1); 290e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 291e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 292e5c31af7Sopenharmony_ci 293e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object."); 294e5c31af7Sopenharmony_ci glUseProgram(shader); 295e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 296e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 297e5c31af7Sopenharmony_ci 298e5c31af7Sopenharmony_ci glUseProgram(0); 299e5c31af7Sopenharmony_ci glDeleteShader(shader); 300e5c31af7Sopenharmony_ci }); 301e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(delete_program, "Invalid glDeleteProgram() usage", 302e5c31af7Sopenharmony_ci { 303e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 304e5c31af7Sopenharmony_ci glDeleteProgram(-1); 305e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 306e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 307e5c31af7Sopenharmony_ci }); 308e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(get_active_attrib, "Invalid glGetActiveAttrib() usage", 309e5c31af7Sopenharmony_ci { 310e5c31af7Sopenharmony_ci GLuint shader = glCreateShader(GL_VERTEX_SHADER); 311e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 312e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 313e5c31af7Sopenharmony_ci 314e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 315e5c31af7Sopenharmony_ci glGetActiveAttrib(-1, 0, 0, 0, 0, 0, 0); 316e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 317e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 318e5c31af7Sopenharmony_ci 319e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object."); 320e5c31af7Sopenharmony_ci glGetActiveAttrib(shader, 0, 0, 0, 0, 0, 0); 321e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 322e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 323e5c31af7Sopenharmony_ci 324e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to the number of active attribute variables in program."); 325e5c31af7Sopenharmony_ci glGetActiveAttrib(program.getProgram(), 0, 0, 0, 0, 0, 0); 326e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 327e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 328e5c31af7Sopenharmony_ci 329e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is less than 0."); 330e5c31af7Sopenharmony_ci glGetActiveAttrib(program.getProgram(), 0, -1, 0, 0, 0, 0); 331e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 332e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 333e5c31af7Sopenharmony_ci 334e5c31af7Sopenharmony_ci glUseProgram(0); 335e5c31af7Sopenharmony_ci glDeleteShader(shader); 336e5c31af7Sopenharmony_ci }); 337e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(get_attrib_location, "Invalid glGetAttribLocation() usage", 338e5c31af7Sopenharmony_ci { 339e5c31af7Sopenharmony_ci GLuint programEmpty = glCreateProgram(); 340e5c31af7Sopenharmony_ci GLuint shader = glCreateShader(GL_VERTEX_SHADER); 341e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 342e5c31af7Sopenharmony_ci 343e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked."); 344e5c31af7Sopenharmony_ci glBindAttribLocation(programEmpty, 0, "test"); 345e5c31af7Sopenharmony_ci glGetAttribLocation(programEmpty, "test"); 346e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 347e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 348e5c31af7Sopenharmony_ci 349e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a program or shader object."); 350e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 351e5c31af7Sopenharmony_ci glBindAttribLocation(program.getProgram(), 0, "test"); 352e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 353e5c31af7Sopenharmony_ci glGetAttribLocation(program.getProgram(), "test"); 354e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 355e5c31af7Sopenharmony_ci glGetAttribLocation(-2, "test"); 356e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 357e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 358e5c31af7Sopenharmony_ci 359e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object."); 360e5c31af7Sopenharmony_ci glGetAttribLocation(shader, "test"); 361e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 362e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 363e5c31af7Sopenharmony_ci 364e5c31af7Sopenharmony_ci glUseProgram(0); 365e5c31af7Sopenharmony_ci glDeleteShader(shader); 366e5c31af7Sopenharmony_ci glDeleteProgram(programEmpty); 367e5c31af7Sopenharmony_ci }); 368e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(get_uniform_location, "Invalid glGetUniformLocation() usage", 369e5c31af7Sopenharmony_ci { 370e5c31af7Sopenharmony_ci GLuint programEmpty = glCreateProgram(); 371e5c31af7Sopenharmony_ci GLuint shader = glCreateShader(GL_VERTEX_SHADER); 372e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 373e5c31af7Sopenharmony_ci 374e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked."); 375e5c31af7Sopenharmony_ci glGetUniformLocation(programEmpty, "test"); 376e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 377e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 378e5c31af7Sopenharmony_ci 379e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 380e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 381e5c31af7Sopenharmony_ci glGetUniformLocation(-2, "test"); 382e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 383e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 384e5c31af7Sopenharmony_ci 385e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object."); 386e5c31af7Sopenharmony_ci glGetAttribLocation(shader, "test"); 387e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 388e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 389e5c31af7Sopenharmony_ci 390e5c31af7Sopenharmony_ci glUseProgram(0); 391e5c31af7Sopenharmony_ci glDeleteProgram(programEmpty); 392e5c31af7Sopenharmony_ci glDeleteShader(shader); 393e5c31af7Sopenharmony_ci }); 394e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(bind_attrib_location, "Invalid glBindAttribLocation() usage", 395e5c31af7Sopenharmony_ci { 396e5c31af7Sopenharmony_ci GLuint program = glCreateProgram(); 397e5c31af7Sopenharmony_ci GLuint maxIndex = m_context.getContextInfo().getInt(GL_MAX_VERTEX_ATTRIBS); 398e5c31af7Sopenharmony_ci GLuint shader = glCreateShader(GL_VERTEX_SHADER); 399e5c31af7Sopenharmony_ci 400e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS."); 401e5c31af7Sopenharmony_ci glBindAttribLocation(program, maxIndex, "test"); 402e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 403e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 404e5c31af7Sopenharmony_ci 405e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if name starts with the reserved prefix \"gl_\"."); 406e5c31af7Sopenharmony_ci glBindAttribLocation(program, maxIndex-1, "gl_test"); 407e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 408e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 409e5c31af7Sopenharmony_ci 410e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 411e5c31af7Sopenharmony_ci glBindAttribLocation(-1, maxIndex-1, "test"); 412e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 413e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 414e5c31af7Sopenharmony_ci 415e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object."); 416e5c31af7Sopenharmony_ci glBindAttribLocation(shader, maxIndex-1, "test"); 417e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 418e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 419e5c31af7Sopenharmony_ci 420e5c31af7Sopenharmony_ci glDeleteProgram(program); 421e5c31af7Sopenharmony_ci glDeleteShader(shader); 422e5c31af7Sopenharmony_ci }); 423e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(get_active_uniform, "Invalid glGetActiveUniform() usage", 424e5c31af7Sopenharmony_ci { 425e5c31af7Sopenharmony_ci GLuint shader = glCreateShader(GL_VERTEX_SHADER); 426e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 427e5c31af7Sopenharmony_ci 428e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 429e5c31af7Sopenharmony_ci glGetActiveUniform(-1, 0, 0, 0, 0, 0, 0); 430e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 431e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 432e5c31af7Sopenharmony_ci 433e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object."); 434e5c31af7Sopenharmony_ci glGetActiveUniform(shader, 0, 0, 0, 0, 0, 0); 435e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 436e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 437e5c31af7Sopenharmony_ci 438e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to the number of active attribute variables in program."); 439e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 440e5c31af7Sopenharmony_ci glGetActiveUniform(program.getProgram(), 5, 0, 0, 0, 0, 0); 441e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 442e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 443e5c31af7Sopenharmony_ci 444e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is less than 0."); 445e5c31af7Sopenharmony_ci glGetActiveUniform(program.getProgram(), 0, -1, 0, 0, 0, 0); 446e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 447e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 448e5c31af7Sopenharmony_ci 449e5c31af7Sopenharmony_ci glUseProgram(0); 450e5c31af7Sopenharmony_ci glDeleteShader(shader); 451e5c31af7Sopenharmony_ci }); 452e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(validate_program, "Invalid glValidateProgram() usage", 453e5c31af7Sopenharmony_ci { 454e5c31af7Sopenharmony_ci GLuint shader = glCreateShader(GL_VERTEX_SHADER); 455e5c31af7Sopenharmony_ci 456e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 457e5c31af7Sopenharmony_ci glValidateProgram(-1); 458e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 459e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 460e5c31af7Sopenharmony_ci 461e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object."); 462e5c31af7Sopenharmony_ci glValidateProgram(shader); 463e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 464e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 465e5c31af7Sopenharmony_ci 466e5c31af7Sopenharmony_ci glDeleteShader(shader); 467e5c31af7Sopenharmony_ci }); 468e5c31af7Sopenharmony_ci 469e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(release_shader_compiler, "Invalid glReleaseShaderCompiler() usage", 470e5c31af7Sopenharmony_ci { 471e5c31af7Sopenharmony_ci GLboolean shaderCompilerSupported; 472e5c31af7Sopenharmony_ci glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported); 473e5c31af7Sopenharmony_ci 474e5c31af7Sopenharmony_ci m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a shader compiler is not supported."); 475e5c31af7Sopenharmony_ci glReleaseShaderCompiler(); 476e5c31af7Sopenharmony_ci expectError(shaderCompilerSupported ? GL_NONE : GL_INVALID_OPERATION); 477e5c31af7Sopenharmony_ci m_log << TestLog::EndSection; 478e5c31af7Sopenharmony_ci }); 479e5c31af7Sopenharmony_ci 480e5c31af7Sopenharmony_ci // glUniform*f 481e5c31af7Sopenharmony_ci 482e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformf_invalid_program, "Invalid glUniform{1234}f() usage", 483e5c31af7Sopenharmony_ci { 484e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object."); 485e5c31af7Sopenharmony_ci glUseProgram(0); 486e5c31af7Sopenharmony_ci glUniform1f(-1, 0.0f); 487e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 488e5c31af7Sopenharmony_ci glUniform2f(-1, 0.0f, 0.0f); 489e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 490e5c31af7Sopenharmony_ci glUniform3f(-1, 0.0f, 0.0f, 0.0f); 491e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 492e5c31af7Sopenharmony_ci glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f); 493e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 494e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 495e5c31af7Sopenharmony_ci }); 496e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformf_incompatible_type, "Invalid glUniform{1234}f() usage", 497e5c31af7Sopenharmony_ci { 498e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 499e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 500e5c31af7Sopenharmony_ci GLint vUnif = glGetUniformLocation(program.getProgram(), "vTest"); // vec4 501e5c31af7Sopenharmony_ci GLint fUnif = glGetUniformLocation(program.getProgram(), "fTest"); // ivec4 502e5c31af7Sopenharmony_ci GLint fSampler = glGetUniformLocation(program.getProgram(), "fSampler"); // sampler2D 503e5c31af7Sopenharmony_ci 504e5c31af7Sopenharmony_ci if (vUnif == -1 || fUnif == -1 || fSampler == -1) 505e5c31af7Sopenharmony_ci { 506e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 507e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location"); 508e5c31af7Sopenharmony_ci } 509e5c31af7Sopenharmony_ci 510e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command."); 511e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 512e5c31af7Sopenharmony_ci glUniform1f(vUnif, 0.0f); 513e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 514e5c31af7Sopenharmony_ci glUniform2f(vUnif, 0.0f, 0.0f); 515e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 516e5c31af7Sopenharmony_ci glUniform3f(vUnif, 0.0f, 0.0f, 0.0f); 517e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 518e5c31af7Sopenharmony_ci glUniform4f(vUnif, 0.0f, 0.0f, 0.0f, 0.0f); 519e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 520e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 521e5c31af7Sopenharmony_ci 522e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if one of the floating-point variants of this function is used to load a uniform variable of type int, ivec2, ivec3, or ivec4."); 523e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 524e5c31af7Sopenharmony_ci glUniform4f(fUnif, 0.0f, 0.0f, 0.0f, 0.0f); 525e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 526e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 527e5c31af7Sopenharmony_ci 528e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than glUniform1i and glUniform1iv."); 529e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 530e5c31af7Sopenharmony_ci glUniform1f(fSampler, 0.0f); 531e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 532e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 533e5c31af7Sopenharmony_ci 534e5c31af7Sopenharmony_ci glUseProgram(0); 535e5c31af7Sopenharmony_ci }); 536e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformf_invalid_location, "Invalid glUniform{1234}f() usage", 537e5c31af7Sopenharmony_ci { 538e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 539e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 540e5c31af7Sopenharmony_ci 541e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 542e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 543e5c31af7Sopenharmony_ci glUniform1f(-2, 0.0f); 544e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 545e5c31af7Sopenharmony_ci glUniform2f(-2, 0.0f, 0.0f); 546e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 547e5c31af7Sopenharmony_ci glUniform3f(-2, 0.0f, 0.0f, 0.0f); 548e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 549e5c31af7Sopenharmony_ci glUniform4f(-2, 0.0f, 0.0f, 0.0f, 0.0f); 550e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 551e5c31af7Sopenharmony_ci 552e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 553e5c31af7Sopenharmony_ci glUniform1f(-1, 0.0f); 554e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 555e5c31af7Sopenharmony_ci glUniform2f(-1, 0.0f, 0.0f); 556e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 557e5c31af7Sopenharmony_ci glUniform3f(-1, 0.0f, 0.0f, 0.0f); 558e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 559e5c31af7Sopenharmony_ci glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f); 560e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 561e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 562e5c31af7Sopenharmony_ci 563e5c31af7Sopenharmony_ci glUseProgram(0); 564e5c31af7Sopenharmony_ci }); 565e5c31af7Sopenharmony_ci 566e5c31af7Sopenharmony_ci // glUniform*fv 567e5c31af7Sopenharmony_ci 568e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformfv_invalid_program, "Invalid glUniform{1234}fv() usage", 569e5c31af7Sopenharmony_ci { 570e5c31af7Sopenharmony_ci std::vector<GLfloat> data(4); 571e5c31af7Sopenharmony_ci 572e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object."); 573e5c31af7Sopenharmony_ci glUseProgram(0); 574e5c31af7Sopenharmony_ci glUniform1fv(-1, 1, &data[0]); 575e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 576e5c31af7Sopenharmony_ci glUniform2fv(-1, 1, &data[0]); 577e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 578e5c31af7Sopenharmony_ci glUniform3fv(-1, 1, &data[0]); 579e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 580e5c31af7Sopenharmony_ci glUniform4fv(-1, 1, &data[0]); 581e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 582e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 583e5c31af7Sopenharmony_ci }); 584e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformfv_incompatible_type, "Invalid glUniform{1234}fv() usage", 585e5c31af7Sopenharmony_ci { 586e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 587e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 588e5c31af7Sopenharmony_ci GLint vUnif = glGetUniformLocation(program.getProgram(), "vTest"); // vec4 589e5c31af7Sopenharmony_ci GLint fUnif = glGetUniformLocation(program.getProgram(), "fTest"); // ivec4 590e5c31af7Sopenharmony_ci GLint fSampler = glGetUniformLocation(program.getProgram(), "fSampler"); // sampler2D 591e5c31af7Sopenharmony_ci 592e5c31af7Sopenharmony_ci if (vUnif == -1 || fUnif == -1 || fSampler == -1) 593e5c31af7Sopenharmony_ci { 594e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 595e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location"); 596e5c31af7Sopenharmony_ci } 597e5c31af7Sopenharmony_ci 598e5c31af7Sopenharmony_ci std::vector<GLfloat> data(4); 599e5c31af7Sopenharmony_ci 600e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command."); 601e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 602e5c31af7Sopenharmony_ci glUniform1fv(vUnif, 1, &data[0]); 603e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 604e5c31af7Sopenharmony_ci glUniform2fv(vUnif, 1, &data[0]); 605e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 606e5c31af7Sopenharmony_ci glUniform3fv(vUnif, 1, &data[0]); 607e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 608e5c31af7Sopenharmony_ci glUniform4fv(vUnif, 1, &data[0]); 609e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 610e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 611e5c31af7Sopenharmony_ci 612e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if one of the floating-point variants of this function is used to load a uniform variable of type int, ivec2, ivec3, or ivec4."); 613e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 614e5c31af7Sopenharmony_ci glUniform4fv(fUnif, 1, &data[0]); 615e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 616e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 617e5c31af7Sopenharmony_ci 618e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than glUniform1i and glUniform1iv."); 619e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 620e5c31af7Sopenharmony_ci glUniform1fv(fSampler, 1, &data[0]); 621e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 622e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 623e5c31af7Sopenharmony_ci 624e5c31af7Sopenharmony_ci glUseProgram(0); 625e5c31af7Sopenharmony_ci }); 626e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformfv_invalid_location, "Invalid glUniform{1234}fv() usage", 627e5c31af7Sopenharmony_ci { 628e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 629e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 630e5c31af7Sopenharmony_ci 631e5c31af7Sopenharmony_ci std::vector<GLfloat> data(4); 632e5c31af7Sopenharmony_ci 633e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 634e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 635e5c31af7Sopenharmony_ci glUniform1fv(-2, 1, &data[0]); 636e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 637e5c31af7Sopenharmony_ci glUniform2fv(-2, 1, &data[0]); 638e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 639e5c31af7Sopenharmony_ci glUniform3fv(-2, 1, &data[0]); 640e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 641e5c31af7Sopenharmony_ci glUniform4fv(-2, 1, &data[0]); 642e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 643e5c31af7Sopenharmony_ci 644e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 645e5c31af7Sopenharmony_ci glUniform1fv(-1, 1, &data[0]); 646e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 647e5c31af7Sopenharmony_ci glUniform2fv(-1, 1, &data[0]); 648e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 649e5c31af7Sopenharmony_ci glUniform3fv(-1, 1, &data[0]); 650e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 651e5c31af7Sopenharmony_ci glUniform4fv(-1, 1, &data[0]); 652e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 653e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 654e5c31af7Sopenharmony_ci 655e5c31af7Sopenharmony_ci glUseProgram(0); 656e5c31af7Sopenharmony_ci }); 657e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformfv_invalid_count, "Invalid glUniform{1234}fv() usage", 658e5c31af7Sopenharmony_ci { 659e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 660e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 661e5c31af7Sopenharmony_ci GLint vUnif = glGetUniformLocation(program.getProgram(), "vTest"); // vec4 662e5c31af7Sopenharmony_ci 663e5c31af7Sopenharmony_ci if (vUnif == -1) 664e5c31af7Sopenharmony_ci { 665e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 666e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location"); 667e5c31af7Sopenharmony_ci } 668e5c31af7Sopenharmony_ci 669e5c31af7Sopenharmony_ci std::vector<GLfloat> data(8); 670e5c31af7Sopenharmony_ci 671e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable."); 672e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 673e5c31af7Sopenharmony_ci glUniform1fv(vUnif, 2, &data[0]); 674e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 675e5c31af7Sopenharmony_ci glUniform2fv(vUnif, 2, &data[0]); 676e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 677e5c31af7Sopenharmony_ci glUniform3fv(vUnif, 2, &data[0]); 678e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 679e5c31af7Sopenharmony_ci glUniform4fv(vUnif, 2, &data[0]); 680e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 681e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 682e5c31af7Sopenharmony_ci 683e5c31af7Sopenharmony_ci glUseProgram(0); 684e5c31af7Sopenharmony_ci }); 685e5c31af7Sopenharmony_ci 686e5c31af7Sopenharmony_ci // glUniform*i 687e5c31af7Sopenharmony_ci 688e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformi_invalid_program, "Invalid glUniform{1234}i() usage", 689e5c31af7Sopenharmony_ci { 690e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object."); 691e5c31af7Sopenharmony_ci glUseProgram(0); 692e5c31af7Sopenharmony_ci glUniform1i(-1, 0); 693e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 694e5c31af7Sopenharmony_ci glUniform2i(-1, 0, 0); 695e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 696e5c31af7Sopenharmony_ci glUniform3i(-1, 0, 0, 0); 697e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 698e5c31af7Sopenharmony_ci glUniform4i(-1, 0, 0, 0, 0); 699e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 700e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 701e5c31af7Sopenharmony_ci }); 702e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformi_incompatible_type, "Invalid glUniform{1234}i() usage", 703e5c31af7Sopenharmony_ci { 704e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 705e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 706e5c31af7Sopenharmony_ci GLint vUnif = glGetUniformLocation(program.getProgram(), "vTest"); // vec4 707e5c31af7Sopenharmony_ci GLint fUnif = glGetUniformLocation(program.getProgram(), "fTest"); // ivec4 708e5c31af7Sopenharmony_ci GLint fSampler = glGetUniformLocation(program.getProgram(), "fSampler"); // sampler2D 709e5c31af7Sopenharmony_ci 710e5c31af7Sopenharmony_ci if (vUnif == -1 || fUnif == -1 || fSampler == -1) 711e5c31af7Sopenharmony_ci { 712e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 713e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location"); 714e5c31af7Sopenharmony_ci } 715e5c31af7Sopenharmony_ci 716e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command."); 717e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 718e5c31af7Sopenharmony_ci glUniform1i(fUnif, 0); 719e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 720e5c31af7Sopenharmony_ci glUniform2i(fUnif, 0, 0); 721e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 722e5c31af7Sopenharmony_ci glUniform3i(fUnif, 0, 0, 0); 723e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 724e5c31af7Sopenharmony_ci glUniform4i(fUnif, 0, 0, 0, 0); 725e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 726e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 727e5c31af7Sopenharmony_ci 728e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if one of the integer variants of this function is used to load a uniform variable of type float, vec2, vec3, or vec4."); 729e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 730e5c31af7Sopenharmony_ci glUniform4i(vUnif, 0, 0, 0, 0); 731e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 732e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 733e5c31af7Sopenharmony_ci 734e5c31af7Sopenharmony_ci glUseProgram(0); 735e5c31af7Sopenharmony_ci }); 736e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformi_invalid_location, "Invalid glUniform{1234}i() usage", 737e5c31af7Sopenharmony_ci { 738e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 739e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 740e5c31af7Sopenharmony_ci 741e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 742e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 743e5c31af7Sopenharmony_ci glUniform1i(-2, 0); 744e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 745e5c31af7Sopenharmony_ci glUniform2i(-2, 0, 0); 746e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 747e5c31af7Sopenharmony_ci glUniform3i(-2, 0, 0, 0); 748e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 749e5c31af7Sopenharmony_ci glUniform4i(-2, 0, 0, 0, 0); 750e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 751e5c31af7Sopenharmony_ci 752e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 753e5c31af7Sopenharmony_ci glUniform1i(-1, 0); 754e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 755e5c31af7Sopenharmony_ci glUniform2i(-1, 0, 0); 756e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 757e5c31af7Sopenharmony_ci glUniform3i(-1, 0, 0, 0); 758e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 759e5c31af7Sopenharmony_ci glUniform4i(-1, 0, 0, 0, 0); 760e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 761e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 762e5c31af7Sopenharmony_ci 763e5c31af7Sopenharmony_ci glUseProgram(0); 764e5c31af7Sopenharmony_ci }); 765e5c31af7Sopenharmony_ci 766e5c31af7Sopenharmony_ci // glUniform*iv 767e5c31af7Sopenharmony_ci 768e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformiv_invalid_program, "Invalid glUniform{1234}iv() usage", 769e5c31af7Sopenharmony_ci { 770e5c31af7Sopenharmony_ci std::vector<GLint> data(4); 771e5c31af7Sopenharmony_ci 772e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object."); 773e5c31af7Sopenharmony_ci glUseProgram(0); 774e5c31af7Sopenharmony_ci glUniform1iv(-1, 1, &data[0]); 775e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 776e5c31af7Sopenharmony_ci glUniform2iv(-1, 1, &data[0]); 777e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 778e5c31af7Sopenharmony_ci glUniform3iv(-1, 1, &data[0]); 779e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 780e5c31af7Sopenharmony_ci glUniform4iv(-1, 1, &data[0]); 781e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 782e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 783e5c31af7Sopenharmony_ci }); 784e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformiv_incompatible_type, "Invalid glUniform{1234}iv() usage", 785e5c31af7Sopenharmony_ci { 786e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 787e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 788e5c31af7Sopenharmony_ci GLint vUnif = glGetUniformLocation(program.getProgram(), "vTest"); // vec4 789e5c31af7Sopenharmony_ci GLint fUnif = glGetUniformLocation(program.getProgram(), "fTest"); // ivec4 790e5c31af7Sopenharmony_ci GLint fSampler = glGetUniformLocation(program.getProgram(), "fSampler"); // sampler2D 791e5c31af7Sopenharmony_ci 792e5c31af7Sopenharmony_ci if (vUnif == -1 || fUnif == -1 || fSampler == -1) 793e5c31af7Sopenharmony_ci { 794e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 795e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location"); 796e5c31af7Sopenharmony_ci } 797e5c31af7Sopenharmony_ci 798e5c31af7Sopenharmony_ci std::vector<GLint> data(4); 799e5c31af7Sopenharmony_ci 800e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command."); 801e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 802e5c31af7Sopenharmony_ci glUniform1iv(fUnif, 1, &data[0]); 803e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 804e5c31af7Sopenharmony_ci glUniform2iv(fUnif, 1, &data[0]); 805e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 806e5c31af7Sopenharmony_ci glUniform3iv(fUnif, 1, &data[0]); 807e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 808e5c31af7Sopenharmony_ci glUniform4iv(fUnif, 1, &data[0]); 809e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 810e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 811e5c31af7Sopenharmony_ci 812e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if one of the integer variants of this function is used to load a uniform variable of type float, vec2, vec3, or vec4."); 813e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 814e5c31af7Sopenharmony_ci glUniform4iv(vUnif, 1, &data[0]); 815e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 816e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 817e5c31af7Sopenharmony_ci 818e5c31af7Sopenharmony_ci glUseProgram(0); 819e5c31af7Sopenharmony_ci }); 820e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformiv_invalid_location, "Invalid glUniform{1234}iv() usage", 821e5c31af7Sopenharmony_ci { 822e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 823e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 824e5c31af7Sopenharmony_ci 825e5c31af7Sopenharmony_ci std::vector<GLint> data(4); 826e5c31af7Sopenharmony_ci 827e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 828e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 829e5c31af7Sopenharmony_ci glUniform1iv(-2, 1, &data[0]); 830e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 831e5c31af7Sopenharmony_ci glUniform2iv(-2, 1, &data[0]); 832e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 833e5c31af7Sopenharmony_ci glUniform3iv(-2, 1, &data[0]); 834e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 835e5c31af7Sopenharmony_ci glUniform4iv(-2, 1, &data[0]); 836e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 837e5c31af7Sopenharmony_ci 838e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 839e5c31af7Sopenharmony_ci glUniform1iv(-1, 1, &data[0]); 840e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 841e5c31af7Sopenharmony_ci glUniform2iv(-1, 1, &data[0]); 842e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 843e5c31af7Sopenharmony_ci glUniform3iv(-1, 1, &data[0]); 844e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 845e5c31af7Sopenharmony_ci glUniform4iv(-1, 1, &data[0]); 846e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 847e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 848e5c31af7Sopenharmony_ci 849e5c31af7Sopenharmony_ci glUseProgram(0); 850e5c31af7Sopenharmony_ci }); 851e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniformiv_invalid_count, "Invalid glUniform{1234}iv() usage", 852e5c31af7Sopenharmony_ci { 853e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 854e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 855e5c31af7Sopenharmony_ci GLint fUnif = glGetUniformLocation(program.getProgram(), "fTest"); // ivec4 856e5c31af7Sopenharmony_ci 857e5c31af7Sopenharmony_ci if (fUnif == -1) 858e5c31af7Sopenharmony_ci { 859e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 860e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location"); 861e5c31af7Sopenharmony_ci } 862e5c31af7Sopenharmony_ci 863e5c31af7Sopenharmony_ci std::vector<GLint> data(8); 864e5c31af7Sopenharmony_ci 865e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable."); 866e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 867e5c31af7Sopenharmony_ci glUniform1iv(fUnif, 2, &data[0]); 868e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 869e5c31af7Sopenharmony_ci glUniform2iv(fUnif, 2, &data[0]); 870e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 871e5c31af7Sopenharmony_ci glUniform3iv(fUnif, 2, &data[0]); 872e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 873e5c31af7Sopenharmony_ci glUniform4iv(fUnif, 2, &data[0]); 874e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 875e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 876e5c31af7Sopenharmony_ci 877e5c31af7Sopenharmony_ci glUseProgram(0); 878e5c31af7Sopenharmony_ci }); 879e5c31af7Sopenharmony_ci 880e5c31af7Sopenharmony_ci // glUniformMatrix*fv 881e5c31af7Sopenharmony_ci 882e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniform_matrixfv_invalid_program, "Invalid glUniformMatrix{234}fv() usage", 883e5c31af7Sopenharmony_ci { 884e5c31af7Sopenharmony_ci std::vector<GLfloat> data(16); 885e5c31af7Sopenharmony_ci 886e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object."); 887e5c31af7Sopenharmony_ci glUseProgram(0); 888e5c31af7Sopenharmony_ci glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]); 889e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 890e5c31af7Sopenharmony_ci glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]); 891e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 892e5c31af7Sopenharmony_ci glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]); 893e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 894e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 895e5c31af7Sopenharmony_ci }); 896e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniform_matrixfv_incompatible_type, "Invalid glUniformMatrix{234}fv() usage", 897e5c31af7Sopenharmony_ci { 898e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 899e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 900e5c31af7Sopenharmony_ci GLint vMatUnif = glGetUniformLocation(program.getProgram(), "vMatrix"); // mat4 901e5c31af7Sopenharmony_ci GLint fSamplerUnif = glGetUniformLocation(program.getProgram(), "fSampler"); // sampler2D 902e5c31af7Sopenharmony_ci 903e5c31af7Sopenharmony_ci m_log << program; 904e5c31af7Sopenharmony_ci 905e5c31af7Sopenharmony_ci if (vMatUnif == -1 || fSamplerUnif == -1) 906e5c31af7Sopenharmony_ci { 907e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 908e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location"); 909e5c31af7Sopenharmony_ci } 910e5c31af7Sopenharmony_ci 911e5c31af7Sopenharmony_ci std::vector<GLfloat> data(16); 912e5c31af7Sopenharmony_ci 913e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command."); 914e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 915e5c31af7Sopenharmony_ci glUniformMatrix2fv(vMatUnif, 1, GL_FALSE, &data[0]); 916e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 917e5c31af7Sopenharmony_ci glUniformMatrix3fv(vMatUnif, 1, GL_FALSE, &data[0]); 918e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 919e5c31af7Sopenharmony_ci glUniformMatrix4fv(vMatUnif, 1, GL_FALSE, &data[0]); 920e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 921e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 922e5c31af7Sopenharmony_ci 923e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than glUniform1i and glUniform1iv."); 924e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 925e5c31af7Sopenharmony_ci glUniformMatrix4fv(fSamplerUnif, 1, GL_FALSE, &data[0]); 926e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 927e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 928e5c31af7Sopenharmony_ci 929e5c31af7Sopenharmony_ci glUseProgram(0); 930e5c31af7Sopenharmony_ci }); 931e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniform_matrixfv_invalid_location, "Invalid glUniformMatrix{234}fv() usage", 932e5c31af7Sopenharmony_ci { 933e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 934e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 935e5c31af7Sopenharmony_ci 936e5c31af7Sopenharmony_ci m_log << program; 937e5c31af7Sopenharmony_ci 938e5c31af7Sopenharmony_ci std::vector<GLfloat> data(16); 939e5c31af7Sopenharmony_ci 940e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 941e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 942e5c31af7Sopenharmony_ci glUniformMatrix2fv(-2, 1, GL_FALSE, &data[0]); 943e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 944e5c31af7Sopenharmony_ci glUniformMatrix3fv(-2, 1, GL_FALSE, &data[0]); 945e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 946e5c31af7Sopenharmony_ci glUniformMatrix4fv(-2, 1, GL_FALSE, &data[0]); 947e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 948e5c31af7Sopenharmony_ci 949e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 950e5c31af7Sopenharmony_ci glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]); 951e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 952e5c31af7Sopenharmony_ci glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]); 953e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 954e5c31af7Sopenharmony_ci glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]); 955e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 956e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 957e5c31af7Sopenharmony_ci 958e5c31af7Sopenharmony_ci glUseProgram(0); 959e5c31af7Sopenharmony_ci }); 960e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniform_matrixfv_invalid_count, "Invalid glUniformMatrix{234}fv() usage", 961e5c31af7Sopenharmony_ci { 962e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 963e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 964e5c31af7Sopenharmony_ci GLint vMatUnif = glGetUniformLocation(program.getProgram(), "vMatrix"); // mat4 965e5c31af7Sopenharmony_ci 966e5c31af7Sopenharmony_ci m_log << program; 967e5c31af7Sopenharmony_ci 968e5c31af7Sopenharmony_ci if (vMatUnif == -1) 969e5c31af7Sopenharmony_ci { 970e5c31af7Sopenharmony_ci m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 971e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location"); 972e5c31af7Sopenharmony_ci } 973e5c31af7Sopenharmony_ci 974e5c31af7Sopenharmony_ci 975e5c31af7Sopenharmony_ci std::vector<GLfloat> data(32); 976e5c31af7Sopenharmony_ci 977e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable."); 978e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 979e5c31af7Sopenharmony_ci glUniformMatrix2fv(vMatUnif, 2, GL_FALSE, &data[0]); 980e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 981e5c31af7Sopenharmony_ci glUniformMatrix3fv(vMatUnif, 2, GL_FALSE, &data[0]); 982e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 983e5c31af7Sopenharmony_ci glUniformMatrix4fv(vMatUnif, 2, GL_FALSE, &data[0]); 984e5c31af7Sopenharmony_ci expectError(GL_INVALID_OPERATION); 985e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 986e5c31af7Sopenharmony_ci 987e5c31af7Sopenharmony_ci glUseProgram(0); 988e5c31af7Sopenharmony_ci }); 989e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(uniform_matrixfv_invalid_transpose, "Invalid glUniformMatrix{234}fv() usage", 990e5c31af7Sopenharmony_ci { 991e5c31af7Sopenharmony_ci if (de::beginsWith((const char*)glGetString(GL_VERSION), "OpenGL ES 2.0 ")) 992e5c31af7Sopenharmony_ci { 993e5c31af7Sopenharmony_ci DE_ASSERT(m_context.getRenderContext().getType().getMajorVersion() < 3); 994e5c31af7Sopenharmony_ci DE_ASSERT(m_context.getRenderContext().getType().getMinorVersion() == 0); 995e5c31af7Sopenharmony_ci DE_ASSERT(m_context.getRenderContext().getType().getProfile() == glu::PROFILE_ES); 996e5c31af7Sopenharmony_ci 997e5c31af7Sopenharmony_ci glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 998e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 999e5c31af7Sopenharmony_ci 1000e5c31af7Sopenharmony_ci m_log << program; 1001e5c31af7Sopenharmony_ci 1002e5c31af7Sopenharmony_ci std::vector<GLfloat> data(16); 1003e5c31af7Sopenharmony_ci 1004e5c31af7Sopenharmony_ci m_log << tcu::TestLog::Section("", "GL_INVALID_VALUE is generated if transpose is not GL_FALSE."); 1005e5c31af7Sopenharmony_ci glUseProgram(program.getProgram()); 1006e5c31af7Sopenharmony_ci glUniformMatrix2fv(0, 1, GL_TRUE, &data[0]); 1007e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 1008e5c31af7Sopenharmony_ci glUniformMatrix3fv(0, 1, GL_TRUE, &data[0]); 1009e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 1010e5c31af7Sopenharmony_ci glUniformMatrix4fv(0, 1, GL_TRUE, &data[0]); 1011e5c31af7Sopenharmony_ci expectError(GL_INVALID_VALUE); 1012e5c31af7Sopenharmony_ci m_log << tcu::TestLog::EndSection; 1013e5c31af7Sopenharmony_ci 1014e5c31af7Sopenharmony_ci glUseProgram(0); 1015e5c31af7Sopenharmony_ci } 1016e5c31af7Sopenharmony_ci }); 1017e5c31af7Sopenharmony_ci} 1018e5c31af7Sopenharmony_ci 1019e5c31af7Sopenharmony_ci} // Functional 1020e5c31af7Sopenharmony_ci} // gles2 1021e5c31af7Sopenharmony_ci} // deqp 1022