Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1 | // |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2 | // Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved. |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // validationES2.cpp: Validation functions for OpenGL ES 2.0 entry point parameters |
| 8 | |
Jamie Madill | 778bf09 | 2018-11-14 09:54:36 -0500 | [diff] [blame] | 9 | #include "libANGLE/validationES2_autogen.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 10 | |
| 11 | #include <cstdint> |
| 12 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 13 | #include "common/mathutil.h" |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 14 | #include "common/string_utils.h" |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 15 | #include "common/utilities.h" |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 16 | #include "libANGLE/Context.h" |
Brandon Jones | 6cad566 | 2017-06-14 13:25:13 -0700 | [diff] [blame] | 17 | #include "libANGLE/ErrorStrings.h" |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 18 | #include "libANGLE/Fence.h" |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 19 | #include "libANGLE/Framebuffer.h" |
| 20 | #include "libANGLE/FramebufferAttachment.h" |
| 21 | #include "libANGLE/Renderbuffer.h" |
| 22 | #include "libANGLE/Shader.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 23 | #include "libANGLE/Texture.h" |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 24 | #include "libANGLE/Uniform.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 25 | #include "libANGLE/VertexArray.h" |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 26 | #include "libANGLE/formatutils.h" |
| 27 | #include "libANGLE/validationES.h" |
Jamie Madill | 778bf09 | 2018-11-14 09:54:36 -0500 | [diff] [blame] | 28 | #include "libANGLE/validationES2.h" |
| 29 | #include "libANGLE/validationES3_autogen.h" |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 30 | |
| 31 | namespace gl |
| 32 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 33 | using namespace err; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 34 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 35 | namespace |
| 36 | { |
| 37 | |
| 38 | bool IsPartialBlit(gl::Context *context, |
| 39 | const FramebufferAttachment *readBuffer, |
| 40 | const FramebufferAttachment *writeBuffer, |
| 41 | GLint srcX0, |
| 42 | GLint srcY0, |
| 43 | GLint srcX1, |
| 44 | GLint srcY1, |
| 45 | GLint dstX0, |
| 46 | GLint dstY0, |
| 47 | GLint dstX1, |
| 48 | GLint dstY1) |
| 49 | { |
| 50 | const Extents &writeSize = writeBuffer->getSize(); |
| 51 | const Extents &readSize = readBuffer->getSize(); |
| 52 | |
| 53 | if (srcX0 != 0 || srcY0 != 0 || dstX0 != 0 || dstY0 != 0 || dstX1 != writeSize.width || |
| 54 | dstY1 != writeSize.height || srcX1 != readSize.width || srcY1 != readSize.height) |
| 55 | { |
| 56 | return true; |
| 57 | } |
| 58 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 59 | if (context->getState().isScissorTestEnabled()) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 60 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 61 | const Rectangle &scissor = context->getState().getScissor(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 62 | return scissor.x > 0 || scissor.y > 0 || scissor.width < writeSize.width || |
| 63 | scissor.height < writeSize.height; |
| 64 | } |
| 65 | |
| 66 | return false; |
| 67 | } |
| 68 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 69 | template <typename T> |
| 70 | bool ValidatePathInstances(gl::Context *context, |
| 71 | GLsizei numPaths, |
| 72 | const void *paths, |
| 73 | GLuint pathBase) |
| 74 | { |
| 75 | const auto *array = static_cast<const T *>(paths); |
| 76 | |
| 77 | for (GLsizei i = 0; i < numPaths; ++i) |
| 78 | { |
| 79 | const GLuint pathName = array[i] + pathBase; |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 80 | if (context->isPathGenerated(pathName) && !context->isPath(pathName)) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 81 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 82 | context->validationError(GL_INVALID_OPERATION, kNoSuchPath); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 83 | return false; |
| 84 | } |
| 85 | } |
| 86 | return true; |
| 87 | } |
| 88 | |
| 89 | bool ValidateInstancedPathParameters(gl::Context *context, |
| 90 | GLsizei numPaths, |
| 91 | GLenum pathNameType, |
| 92 | const void *paths, |
| 93 | GLuint pathBase, |
| 94 | GLenum transformType, |
| 95 | const GLfloat *transformValues) |
| 96 | { |
| 97 | if (!context->getExtensions().pathRendering) |
| 98 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 99 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 100 | return false; |
| 101 | } |
| 102 | |
| 103 | if (paths == nullptr) |
| 104 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 105 | context->validationError(GL_INVALID_VALUE, kInvalidPathNameArray); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 106 | return false; |
| 107 | } |
| 108 | |
| 109 | if (numPaths < 0) |
| 110 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 111 | context->validationError(GL_INVALID_VALUE, kInvalidPathNumPaths); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 112 | return false; |
| 113 | } |
| 114 | |
| 115 | if (!angle::IsValueInRangeForNumericType<std::uint32_t>(numPaths)) |
| 116 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 117 | context->validationError(GL_INVALID_OPERATION, kIntegerOverflow); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 118 | return false; |
| 119 | } |
| 120 | |
| 121 | std::uint32_t pathNameTypeSize = 0; |
| 122 | std::uint32_t componentCount = 0; |
| 123 | |
| 124 | switch (pathNameType) |
| 125 | { |
| 126 | case GL_UNSIGNED_BYTE: |
| 127 | pathNameTypeSize = sizeof(GLubyte); |
| 128 | if (!ValidatePathInstances<GLubyte>(context, numPaths, paths, pathBase)) |
| 129 | return false; |
| 130 | break; |
| 131 | |
| 132 | case GL_BYTE: |
| 133 | pathNameTypeSize = sizeof(GLbyte); |
| 134 | if (!ValidatePathInstances<GLbyte>(context, numPaths, paths, pathBase)) |
| 135 | return false; |
| 136 | break; |
| 137 | |
| 138 | case GL_UNSIGNED_SHORT: |
| 139 | pathNameTypeSize = sizeof(GLushort); |
| 140 | if (!ValidatePathInstances<GLushort>(context, numPaths, paths, pathBase)) |
| 141 | return false; |
| 142 | break; |
| 143 | |
| 144 | case GL_SHORT: |
| 145 | pathNameTypeSize = sizeof(GLshort); |
| 146 | if (!ValidatePathInstances<GLshort>(context, numPaths, paths, pathBase)) |
| 147 | return false; |
| 148 | break; |
| 149 | |
| 150 | case GL_UNSIGNED_INT: |
| 151 | pathNameTypeSize = sizeof(GLuint); |
| 152 | if (!ValidatePathInstances<GLuint>(context, numPaths, paths, pathBase)) |
| 153 | return false; |
| 154 | break; |
| 155 | |
| 156 | case GL_INT: |
| 157 | pathNameTypeSize = sizeof(GLint); |
| 158 | if (!ValidatePathInstances<GLint>(context, numPaths, paths, pathBase)) |
| 159 | return false; |
| 160 | break; |
| 161 | |
| 162 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 163 | context->validationError(GL_INVALID_ENUM, kInvalidPathNameType); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 164 | return false; |
| 165 | } |
| 166 | |
| 167 | switch (transformType) |
| 168 | { |
| 169 | case GL_NONE: |
| 170 | componentCount = 0; |
| 171 | break; |
| 172 | case GL_TRANSLATE_X_CHROMIUM: |
| 173 | case GL_TRANSLATE_Y_CHROMIUM: |
| 174 | componentCount = 1; |
| 175 | break; |
| 176 | case GL_TRANSLATE_2D_CHROMIUM: |
| 177 | componentCount = 2; |
| 178 | break; |
| 179 | case GL_TRANSLATE_3D_CHROMIUM: |
| 180 | componentCount = 3; |
| 181 | break; |
| 182 | case GL_AFFINE_2D_CHROMIUM: |
| 183 | case GL_TRANSPOSE_AFFINE_2D_CHROMIUM: |
| 184 | componentCount = 6; |
| 185 | break; |
| 186 | case GL_AFFINE_3D_CHROMIUM: |
| 187 | case GL_TRANSPOSE_AFFINE_3D_CHROMIUM: |
| 188 | componentCount = 12; |
| 189 | break; |
| 190 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 191 | context->validationError(GL_INVALID_ENUM, kInvalidTransformation); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 192 | return false; |
| 193 | } |
| 194 | if (componentCount != 0 && transformValues == nullptr) |
| 195 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 196 | context->validationError(GL_INVALID_VALUE, kNoTransformArray); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 197 | return false; |
| 198 | } |
| 199 | |
| 200 | angle::CheckedNumeric<std::uint32_t> checkedSize(0); |
| 201 | checkedSize += (numPaths * pathNameTypeSize); |
| 202 | checkedSize += (numPaths * sizeof(GLfloat) * componentCount); |
| 203 | if (!checkedSize.IsValid()) |
| 204 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 205 | context->validationError(GL_INVALID_OPERATION, kIntegerOverflow); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 206 | return false; |
| 207 | } |
| 208 | |
| 209 | return true; |
| 210 | } |
| 211 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 212 | bool IsValidCopyTextureSourceInternalFormatEnum(GLenum internalFormat) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 213 | { |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 214 | // Table 1.1 from the CHROMIUM_copy_texture spec |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 215 | switch (GetUnsizedFormat(internalFormat)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 216 | { |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 217 | case GL_RED: |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 218 | case GL_ALPHA: |
| 219 | case GL_LUMINANCE: |
| 220 | case GL_LUMINANCE_ALPHA: |
| 221 | case GL_RGB: |
| 222 | case GL_RGBA: |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 223 | case GL_RGB8: |
| 224 | case GL_RGBA8: |
| 225 | case GL_BGRA_EXT: |
| 226 | case GL_BGRA8_EXT: |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 227 | return true; |
| 228 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 229 | default: |
| 230 | return false; |
| 231 | } |
| 232 | } |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 233 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 234 | bool IsValidCopySubTextureSourceInternalFormat(GLenum internalFormat) |
| 235 | { |
| 236 | return IsValidCopyTextureSourceInternalFormatEnum(internalFormat); |
| 237 | } |
| 238 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 239 | bool IsValidCopyTextureDestinationInternalFormatEnum(GLint internalFormat) |
| 240 | { |
| 241 | // Table 1.0 from the CHROMIUM_copy_texture spec |
| 242 | switch (internalFormat) |
| 243 | { |
| 244 | case GL_RGB: |
| 245 | case GL_RGBA: |
| 246 | case GL_RGB8: |
| 247 | case GL_RGBA8: |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 248 | case GL_BGRA_EXT: |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 249 | case GL_BGRA8_EXT: |
| 250 | case GL_SRGB_EXT: |
| 251 | case GL_SRGB_ALPHA_EXT: |
| 252 | case GL_R8: |
| 253 | case GL_R8UI: |
| 254 | case GL_RG8: |
| 255 | case GL_RG8UI: |
| 256 | case GL_SRGB8: |
| 257 | case GL_RGB565: |
| 258 | case GL_RGB8UI: |
Geoff Lang | 6be3d4c | 2017-06-16 15:54:15 -0400 | [diff] [blame] | 259 | case GL_RGB10_A2: |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 260 | case GL_SRGB8_ALPHA8: |
| 261 | case GL_RGB5_A1: |
| 262 | case GL_RGBA4: |
| 263 | case GL_RGBA8UI: |
| 264 | case GL_RGB9_E5: |
| 265 | case GL_R16F: |
| 266 | case GL_R32F: |
| 267 | case GL_RG16F: |
| 268 | case GL_RG32F: |
| 269 | case GL_RGB16F: |
| 270 | case GL_RGB32F: |
| 271 | case GL_RGBA16F: |
| 272 | case GL_RGBA32F: |
| 273 | case GL_R11F_G11F_B10F: |
Brandon Jones | 340b7b8 | 2017-06-26 13:02:31 -0700 | [diff] [blame] | 274 | case GL_LUMINANCE: |
| 275 | case GL_LUMINANCE_ALPHA: |
| 276 | case GL_ALPHA: |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 277 | return true; |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 278 | |
| 279 | default: |
| 280 | return false; |
| 281 | } |
| 282 | } |
| 283 | |
Geoff Lang | 6be3d4c | 2017-06-16 15:54:15 -0400 | [diff] [blame] | 284 | bool IsValidCopySubTextureDestionationInternalFormat(GLenum internalFormat) |
| 285 | { |
| 286 | return IsValidCopyTextureDestinationInternalFormatEnum(internalFormat); |
| 287 | } |
| 288 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 289 | bool IsValidCopyTextureDestinationFormatType(Context *context, GLint internalFormat, GLenum type) |
| 290 | { |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 291 | if (!IsValidCopyTextureDestinationInternalFormatEnum(internalFormat)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 292 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 293 | context->validationError(GL_INVALID_OPERATION, kInvalidInternalFormat); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 294 | return false; |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 295 | } |
| 296 | |
Geoff Lang | c0094ec | 2017-08-16 14:16:24 -0400 | [diff] [blame] | 297 | if (!ValidES3FormatCombination(GetUnsizedFormat(internalFormat), type, internalFormat)) |
| 298 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 299 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
Geoff Lang | c0094ec | 2017-08-16 14:16:24 -0400 | [diff] [blame] | 300 | return false; |
| 301 | } |
| 302 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 303 | const InternalFormat &internalFormatInfo = GetInternalFormatInfo(internalFormat, type); |
| 304 | if (!internalFormatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 305 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 306 | context->validationError(GL_INVALID_OPERATION, kInvalidInternalFormat); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 307 | return false; |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | return true; |
| 311 | } |
| 312 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 313 | bool IsValidCopyTextureDestinationTargetEnum(Context *context, TextureTarget target) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 314 | { |
| 315 | switch (target) |
| 316 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 317 | case TextureTarget::_2D: |
| 318 | case TextureTarget::CubeMapNegativeX: |
| 319 | case TextureTarget::CubeMapNegativeY: |
| 320 | case TextureTarget::CubeMapNegativeZ: |
| 321 | case TextureTarget::CubeMapPositiveX: |
| 322 | case TextureTarget::CubeMapPositiveY: |
| 323 | case TextureTarget::CubeMapPositiveZ: |
Geoff Lang | 63458a3 | 2017-10-30 15:16:53 -0400 | [diff] [blame] | 324 | return true; |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 325 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 326 | case TextureTarget::Rectangle: |
Geoff Lang | 63458a3 | 2017-10-30 15:16:53 -0400 | [diff] [blame] | 327 | return context->getExtensions().textureRectangle; |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 328 | |
| 329 | default: |
| 330 | return false; |
| 331 | } |
| 332 | } |
| 333 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 334 | bool IsValidCopyTextureDestinationTarget(Context *context, |
| 335 | TextureType textureType, |
| 336 | TextureTarget target) |
Geoff Lang | 63458a3 | 2017-10-30 15:16:53 -0400 | [diff] [blame] | 337 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 338 | return TextureTargetToType(target) == textureType; |
Geoff Lang | 63458a3 | 2017-10-30 15:16:53 -0400 | [diff] [blame] | 339 | } |
| 340 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 341 | bool IsValidCopyTextureSourceTarget(Context *context, TextureType type) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 342 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 343 | switch (type) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 344 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 345 | case TextureType::_2D: |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 346 | return true; |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 347 | case TextureType::Rectangle: |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 348 | return context->getExtensions().textureRectangle; |
Geoff Lang | be607ad | 2018-11-29 10:14:22 -0500 | [diff] [blame] | 349 | case TextureType::External: |
| 350 | return context->getExtensions().eglImageExternal; |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 351 | default: |
| 352 | return false; |
| 353 | } |
| 354 | } |
| 355 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 356 | bool IsValidCopyTextureSourceLevel(Context *context, TextureType type, GLint level) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 357 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 358 | if (!ValidMipLevel(context, type, level)) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 359 | { |
| 360 | return false; |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 361 | } |
| 362 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 363 | if (level > 0 && context->getClientVersion() < ES_3_0) |
| 364 | { |
| 365 | return false; |
| 366 | } |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 367 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 368 | return true; |
| 369 | } |
| 370 | |
| 371 | bool IsValidCopyTextureDestinationLevel(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 372 | TextureType type, |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 373 | GLint level, |
| 374 | GLsizei width, |
Brandon Jones | 2878379 | 2018-03-05 09:37:32 -0800 | [diff] [blame] | 375 | GLsizei height, |
| 376 | bool isSubImage) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 377 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 378 | if (!ValidMipLevel(context, type, level)) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 379 | { |
| 380 | return false; |
| 381 | } |
| 382 | |
Brandon Jones | 2878379 | 2018-03-05 09:37:32 -0800 | [diff] [blame] | 383 | if (!ValidImageSizeParameters(context, type, level, width, height, 1, isSubImage)) |
| 384 | { |
| 385 | return false; |
| 386 | } |
| 387 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 388 | const Caps &caps = context->getCaps(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 389 | switch (type) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 390 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 391 | case TextureType::_2D: |
| 392 | return static_cast<GLuint>(width) <= (caps.max2DTextureSize >> level) && |
| 393 | static_cast<GLuint>(height) <= (caps.max2DTextureSize >> level); |
| 394 | case TextureType::Rectangle: |
| 395 | ASSERT(level == 0); |
| 396 | return static_cast<GLuint>(width) <= (caps.max2DTextureSize >> level) && |
| 397 | static_cast<GLuint>(height) <= (caps.max2DTextureSize >> level); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 398 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 399 | case TextureType::CubeMap: |
| 400 | return static_cast<GLuint>(width) <= (caps.maxCubeMapTextureSize >> level) && |
| 401 | static_cast<GLuint>(height) <= (caps.maxCubeMapTextureSize >> level); |
| 402 | default: |
| 403 | return true; |
| 404 | } |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 405 | } |
| 406 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 407 | bool IsValidStencilFunc(GLenum func) |
| 408 | { |
| 409 | switch (func) |
| 410 | { |
| 411 | case GL_NEVER: |
| 412 | case GL_ALWAYS: |
| 413 | case GL_LESS: |
| 414 | case GL_LEQUAL: |
| 415 | case GL_EQUAL: |
| 416 | case GL_GEQUAL: |
| 417 | case GL_GREATER: |
| 418 | case GL_NOTEQUAL: |
| 419 | return true; |
| 420 | |
| 421 | default: |
| 422 | return false; |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | bool IsValidStencilFace(GLenum face) |
| 427 | { |
| 428 | switch (face) |
| 429 | { |
| 430 | case GL_FRONT: |
| 431 | case GL_BACK: |
| 432 | case GL_FRONT_AND_BACK: |
| 433 | return true; |
| 434 | |
| 435 | default: |
| 436 | return false; |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | bool IsValidStencilOp(GLenum op) |
| 441 | { |
| 442 | switch (op) |
| 443 | { |
| 444 | case GL_ZERO: |
| 445 | case GL_KEEP: |
| 446 | case GL_REPLACE: |
| 447 | case GL_INCR: |
| 448 | case GL_DECR: |
| 449 | case GL_INVERT: |
| 450 | case GL_INCR_WRAP: |
| 451 | case GL_DECR_WRAP: |
| 452 | return true; |
| 453 | |
| 454 | default: |
| 455 | return false; |
| 456 | } |
| 457 | } |
| 458 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 459 | bool ValidateES2CopyTexImageParameters(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 460 | TextureTarget target, |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 461 | GLint level, |
| 462 | GLenum internalformat, |
| 463 | bool isSubImage, |
| 464 | GLint xoffset, |
| 465 | GLint yoffset, |
| 466 | GLint x, |
| 467 | GLint y, |
| 468 | GLsizei width, |
| 469 | GLsizei height, |
| 470 | GLint border) |
| 471 | { |
| 472 | if (!ValidTexture2DDestinationTarget(context, target)) |
| 473 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 474 | context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 475 | return false; |
| 476 | } |
| 477 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 478 | TextureType texType = TextureTargetToType(target); |
| 479 | if (!ValidImageSizeParameters(context, texType, level, width, height, 1, isSubImage)) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 480 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 481 | // Error is already handled. |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 482 | return false; |
| 483 | } |
| 484 | |
| 485 | Format textureFormat = Format::Invalid(); |
| 486 | if (!ValidateCopyTexImageParametersBase(context, target, level, internalformat, isSubImage, |
| 487 | xoffset, yoffset, 0, x, y, width, height, border, |
| 488 | &textureFormat)) |
| 489 | { |
| 490 | return false; |
| 491 | } |
| 492 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 493 | const gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 494 | GLenum colorbufferFormat = |
| 495 | framebuffer->getReadColorbuffer()->getFormat().info->sizedInternalFormat; |
| 496 | const auto &formatInfo = *textureFormat.info; |
| 497 | |
| 498 | // [OpenGL ES 2.0.24] table 3.9 |
| 499 | if (isSubImage) |
| 500 | { |
| 501 | switch (formatInfo.format) |
| 502 | { |
| 503 | case GL_ALPHA: |
| 504 | if (colorbufferFormat != GL_ALPHA8_EXT && colorbufferFormat != GL_RGBA4 && |
Geoff Lang | 0c09e26 | 2017-05-03 09:43:13 -0400 | [diff] [blame] | 505 | colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES && |
| 506 | colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_BGR5_A1_ANGLEX) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 507 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 508 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 509 | return false; |
| 510 | } |
| 511 | break; |
| 512 | case GL_LUMINANCE: |
| 513 | if (colorbufferFormat != GL_R8_EXT && colorbufferFormat != GL_RG8_EXT && |
| 514 | colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES && |
| 515 | colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && |
Geoff Lang | 0c09e26 | 2017-05-03 09:43:13 -0400 | [diff] [blame] | 516 | colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGRA8_EXT && |
| 517 | colorbufferFormat != GL_BGR5_A1_ANGLEX) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 518 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 519 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 520 | return false; |
| 521 | } |
| 522 | break; |
| 523 | case GL_RED_EXT: |
| 524 | if (colorbufferFormat != GL_R8_EXT && colorbufferFormat != GL_RG8_EXT && |
| 525 | colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES && |
| 526 | colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && |
| 527 | colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_R32F && |
| 528 | colorbufferFormat != GL_RG32F && colorbufferFormat != GL_RGB32F && |
Geoff Lang | 0c09e26 | 2017-05-03 09:43:13 -0400 | [diff] [blame] | 529 | colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT && |
| 530 | colorbufferFormat != GL_BGR5_A1_ANGLEX) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 531 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 532 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 533 | return false; |
| 534 | } |
| 535 | break; |
| 536 | case GL_RG_EXT: |
| 537 | if (colorbufferFormat != GL_RG8_EXT && colorbufferFormat != GL_RGB565 && |
| 538 | colorbufferFormat != GL_RGB8_OES && colorbufferFormat != GL_RGBA4 && |
| 539 | colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_RGBA8_OES && |
| 540 | colorbufferFormat != GL_RG32F && colorbufferFormat != GL_RGB32F && |
Geoff Lang | 0c09e26 | 2017-05-03 09:43:13 -0400 | [diff] [blame] | 541 | colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT && |
| 542 | colorbufferFormat != GL_BGR5_A1_ANGLEX) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 543 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 544 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 545 | return false; |
| 546 | } |
| 547 | break; |
| 548 | case GL_RGB: |
| 549 | if (colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES && |
| 550 | colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && |
| 551 | colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_RGB32F && |
Geoff Lang | 0c09e26 | 2017-05-03 09:43:13 -0400 | [diff] [blame] | 552 | colorbufferFormat != GL_RGBA32F && colorbufferFormat != GL_BGRA8_EXT && |
| 553 | colorbufferFormat != GL_BGR5_A1_ANGLEX) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 554 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 555 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 556 | return false; |
| 557 | } |
| 558 | break; |
| 559 | case GL_LUMINANCE_ALPHA: |
| 560 | case GL_RGBA: |
| 561 | if (colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && |
Geoff Lang | 0c09e26 | 2017-05-03 09:43:13 -0400 | [diff] [blame] | 562 | colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_RGBA32F && |
| 563 | colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_BGR5_A1_ANGLEX) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 564 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 565 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 566 | return false; |
| 567 | } |
| 568 | break; |
| 569 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 570 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 571 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 572 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 573 | case GL_ETC1_RGB8_OES: |
| 574 | case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: |
| 575 | case GL_COMPRESSED_RGB8_LOSSY_DECODE_ETC2_ANGLE: |
| 576 | case GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE: |
| 577 | case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE: |
| 578 | case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE: |
Olli Etuaho | f2ed299 | 2018-10-04 13:54:42 +0300 | [diff] [blame] | 579 | case GL_COMPRESSED_RGBA_BPTC_UNORM_EXT: |
| 580 | case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: |
| 581 | case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: |
| 582 | case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 583 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 584 | return false; |
| 585 | case GL_DEPTH_COMPONENT: |
| 586 | case GL_DEPTH_STENCIL_OES: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 587 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 588 | return false; |
| 589 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 590 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 591 | return false; |
| 592 | } |
| 593 | |
| 594 | if (formatInfo.type == GL_FLOAT && !context->getExtensions().textureFloat) |
| 595 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 596 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 597 | return false; |
| 598 | } |
| 599 | } |
| 600 | else |
| 601 | { |
| 602 | switch (internalformat) |
| 603 | { |
| 604 | case GL_ALPHA: |
| 605 | if (colorbufferFormat != GL_ALPHA8_EXT && colorbufferFormat != GL_RGBA4 && |
| 606 | colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_BGRA8_EXT && |
| 607 | colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX) |
| 608 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 609 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 610 | return false; |
| 611 | } |
| 612 | break; |
| 613 | case GL_LUMINANCE: |
| 614 | if (colorbufferFormat != GL_R8_EXT && colorbufferFormat != GL_RG8_EXT && |
| 615 | colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES && |
| 616 | colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && |
| 617 | colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES && |
| 618 | colorbufferFormat != GL_BGR5_A1_ANGLEX) |
| 619 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 620 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 621 | return false; |
| 622 | } |
| 623 | break; |
| 624 | case GL_RED_EXT: |
| 625 | if (colorbufferFormat != GL_R8_EXT && colorbufferFormat != GL_RG8_EXT && |
| 626 | colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES && |
| 627 | colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && |
| 628 | colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES && |
| 629 | colorbufferFormat != GL_BGR5_A1_ANGLEX) |
| 630 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 631 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 632 | return false; |
| 633 | } |
| 634 | break; |
| 635 | case GL_RG_EXT: |
| 636 | if (colorbufferFormat != GL_RG8_EXT && colorbufferFormat != GL_RGB565 && |
| 637 | colorbufferFormat != GL_RGB8_OES && colorbufferFormat != GL_RGBA4 && |
| 638 | colorbufferFormat != GL_RGB5_A1 && colorbufferFormat != GL_BGRA8_EXT && |
| 639 | colorbufferFormat != GL_RGBA8_OES && colorbufferFormat != GL_BGR5_A1_ANGLEX) |
| 640 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 641 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 642 | return false; |
| 643 | } |
| 644 | break; |
| 645 | case GL_RGB: |
| 646 | if (colorbufferFormat != GL_RGB565 && colorbufferFormat != GL_RGB8_OES && |
| 647 | colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && |
| 648 | colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES && |
| 649 | colorbufferFormat != GL_BGR5_A1_ANGLEX) |
| 650 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 651 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 652 | return false; |
| 653 | } |
| 654 | break; |
| 655 | case GL_LUMINANCE_ALPHA: |
| 656 | case GL_RGBA: |
| 657 | if (colorbufferFormat != GL_RGBA4 && colorbufferFormat != GL_RGB5_A1 && |
| 658 | colorbufferFormat != GL_BGRA8_EXT && colorbufferFormat != GL_RGBA8_OES && |
| 659 | colorbufferFormat != GL_BGR5_A1_ANGLEX) |
| 660 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 661 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 662 | return false; |
| 663 | } |
| 664 | break; |
| 665 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 666 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 667 | if (context->getExtensions().textureCompressionDXT1) |
| 668 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 669 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 670 | return false; |
| 671 | } |
| 672 | else |
| 673 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 674 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 675 | return false; |
| 676 | } |
| 677 | break; |
| 678 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 679 | if (context->getExtensions().textureCompressionDXT3) |
| 680 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 681 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 682 | return false; |
| 683 | } |
| 684 | else |
| 685 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 686 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 687 | return false; |
| 688 | } |
| 689 | break; |
| 690 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 691 | if (context->getExtensions().textureCompressionDXT5) |
| 692 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 693 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 694 | return false; |
| 695 | } |
| 696 | else |
| 697 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 698 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 699 | return false; |
| 700 | } |
| 701 | break; |
| 702 | case GL_ETC1_RGB8_OES: |
| 703 | if (context->getExtensions().compressedETC1RGB8Texture) |
| 704 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 705 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 706 | return false; |
| 707 | } |
| 708 | else |
| 709 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 710 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 711 | return false; |
| 712 | } |
| 713 | break; |
| 714 | case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: |
| 715 | case GL_COMPRESSED_RGB8_LOSSY_DECODE_ETC2_ANGLE: |
| 716 | case GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE: |
| 717 | case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE: |
| 718 | case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE: |
| 719 | if (context->getExtensions().lossyETCDecode) |
| 720 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 721 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 722 | return false; |
| 723 | } |
| 724 | else |
| 725 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 726 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 727 | return false; |
| 728 | } |
| 729 | break; |
| 730 | case GL_DEPTH_COMPONENT: |
| 731 | case GL_DEPTH_COMPONENT16: |
| 732 | case GL_DEPTH_COMPONENT32_OES: |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 733 | if (context->getExtensions().depthTextureAny()) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 734 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 735 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 736 | return false; |
| 737 | } |
| 738 | else |
| 739 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 740 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 741 | return false; |
| 742 | } |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 743 | break; |
| 744 | case GL_DEPTH_STENCIL_OES: |
| 745 | case GL_DEPTH24_STENCIL8_OES: |
| 746 | if (context->getExtensions().depthTextureAny() || |
| 747 | context->getExtensions().packedDepthStencil) |
| 748 | { |
| 749 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
| 750 | return false; |
| 751 | } |
| 752 | else |
| 753 | { |
| 754 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
| 755 | return false; |
| 756 | } |
| 757 | break; |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 758 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 759 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 760 | return false; |
| 761 | } |
| 762 | } |
| 763 | |
| 764 | // If width or height is zero, it is a no-op. Return false without setting an error. |
| 765 | return (width > 0 && height > 0); |
| 766 | } |
| 767 | |
| 768 | bool ValidCap(const Context *context, GLenum cap, bool queryOnly) |
| 769 | { |
| 770 | switch (cap) |
| 771 | { |
| 772 | // EXT_multisample_compatibility |
| 773 | case GL_MULTISAMPLE_EXT: |
| 774 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 775 | return context->getExtensions().multisampleCompatibility; |
| 776 | |
| 777 | case GL_CULL_FACE: |
| 778 | case GL_POLYGON_OFFSET_FILL: |
| 779 | case GL_SAMPLE_ALPHA_TO_COVERAGE: |
| 780 | case GL_SAMPLE_COVERAGE: |
| 781 | case GL_SCISSOR_TEST: |
| 782 | case GL_STENCIL_TEST: |
| 783 | case GL_DEPTH_TEST: |
| 784 | case GL_BLEND: |
| 785 | case GL_DITHER: |
| 786 | return true; |
| 787 | |
| 788 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 789 | case GL_RASTERIZER_DISCARD: |
| 790 | return (context->getClientMajorVersion() >= 3); |
| 791 | |
| 792 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 793 | case GL_DEBUG_OUTPUT: |
| 794 | return context->getExtensions().debug; |
| 795 | |
| 796 | case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 797 | return queryOnly && context->getExtensions().bindGeneratesResource; |
| 798 | |
| 799 | case GL_CLIENT_ARRAYS_ANGLE: |
| 800 | return queryOnly && context->getExtensions().clientArrays; |
| 801 | |
| 802 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 803 | return context->getExtensions().sRGBWriteControl; |
| 804 | |
| 805 | case GL_SAMPLE_MASK: |
| 806 | return context->getClientVersion() >= Version(3, 1); |
| 807 | |
Geoff Lang | b433e87 | 2017-10-05 14:01:47 -0400 | [diff] [blame] | 808 | case GL_ROBUST_RESOURCE_INITIALIZATION_ANGLE: |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 809 | return queryOnly && context->getExtensions().robustResourceInitialization; |
| 810 | |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 811 | // GLES1 emulation: GLES1-specific caps |
| 812 | case GL_ALPHA_TEST: |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 813 | case GL_VERTEX_ARRAY: |
| 814 | case GL_NORMAL_ARRAY: |
| 815 | case GL_COLOR_ARRAY: |
| 816 | case GL_TEXTURE_COORD_ARRAY: |
Lingfeng Yang | 23dc90b | 2018-04-23 09:01:49 -0700 | [diff] [blame] | 817 | case GL_TEXTURE_2D: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 818 | case GL_LIGHTING: |
| 819 | case GL_LIGHT0: |
| 820 | case GL_LIGHT1: |
| 821 | case GL_LIGHT2: |
| 822 | case GL_LIGHT3: |
| 823 | case GL_LIGHT4: |
| 824 | case GL_LIGHT5: |
| 825 | case GL_LIGHT6: |
| 826 | case GL_LIGHT7: |
| 827 | case GL_NORMALIZE: |
| 828 | case GL_RESCALE_NORMAL: |
| 829 | case GL_COLOR_MATERIAL: |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 830 | case GL_CLIP_PLANE0: |
| 831 | case GL_CLIP_PLANE1: |
| 832 | case GL_CLIP_PLANE2: |
| 833 | case GL_CLIP_PLANE3: |
| 834 | case GL_CLIP_PLANE4: |
| 835 | case GL_CLIP_PLANE5: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 836 | case GL_FOG: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 837 | case GL_POINT_SMOOTH: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 838 | case GL_LINE_SMOOTH: |
| 839 | case GL_COLOR_LOGIC_OP: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 840 | return context->getClientVersion() < Version(2, 0); |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 841 | case GL_POINT_SIZE_ARRAY_OES: |
| 842 | return context->getClientVersion() < Version(2, 0) && |
| 843 | context->getExtensions().pointSizeArray; |
Lingfeng Yang | 23dc90b | 2018-04-23 09:01:49 -0700 | [diff] [blame] | 844 | case GL_TEXTURE_CUBE_MAP: |
| 845 | return context->getClientVersion() < Version(2, 0) && |
| 846 | context->getExtensions().textureCubeMap; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 847 | case GL_POINT_SPRITE_OES: |
| 848 | return context->getClientVersion() < Version(2, 0) && |
| 849 | context->getExtensions().pointSprite; |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 850 | default: |
| 851 | return false; |
| 852 | } |
| 853 | } |
| 854 | |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 855 | // Return true if a character belongs to the ASCII subset as defined in GLSL ES 1.0 spec section |
| 856 | // 3.1. |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 857 | bool IsValidESSLCharacter(unsigned char c) |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 858 | { |
| 859 | // Printing characters are valid except " $ ` @ \ ' DEL. |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 860 | if (c >= 32 && c <= 126 && c != '"' && c != '$' && c != '`' && c != '@' && c != '\\' && |
| 861 | c != '\'') |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 862 | { |
| 863 | return true; |
| 864 | } |
| 865 | |
| 866 | // Horizontal tab, line feed, vertical tab, form feed, carriage return are also valid. |
| 867 | if (c >= 9 && c <= 13) |
| 868 | { |
| 869 | return true; |
| 870 | } |
| 871 | |
| 872 | return false; |
| 873 | } |
| 874 | |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 875 | bool IsValidESSLString(const char *str, size_t len) |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 876 | { |
Geoff Lang | a71a98e | 2017-06-19 15:15:00 -0400 | [diff] [blame] | 877 | for (size_t i = 0; i < len; i++) |
| 878 | { |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 879 | if (!IsValidESSLCharacter(str[i])) |
Geoff Lang | a71a98e | 2017-06-19 15:15:00 -0400 | [diff] [blame] | 880 | { |
| 881 | return false; |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | return true; |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 886 | } |
| 887 | |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 888 | bool IsValidESSLShaderSourceString(const char *str, size_t len, bool lineContinuationAllowed) |
| 889 | { |
| 890 | enum class ParseState |
| 891 | { |
| 892 | // Have not seen an ASCII non-whitespace character yet on |
| 893 | // this line. Possible that we might see a preprocessor |
| 894 | // directive. |
| 895 | BEGINING_OF_LINE, |
| 896 | |
| 897 | // Have seen at least one ASCII non-whitespace character |
| 898 | // on this line. |
| 899 | MIDDLE_OF_LINE, |
| 900 | |
| 901 | // Handling a preprocessor directive. Passes through all |
| 902 | // characters up to the end of the line. Disables comment |
| 903 | // processing. |
| 904 | IN_PREPROCESSOR_DIRECTIVE, |
| 905 | |
| 906 | // Handling a single-line comment. The comment text is |
| 907 | // replaced with a single space. |
| 908 | IN_SINGLE_LINE_COMMENT, |
| 909 | |
| 910 | // Handling a multi-line comment. Newlines are passed |
| 911 | // through to preserve line numbers. |
| 912 | IN_MULTI_LINE_COMMENT |
| 913 | }; |
| 914 | |
| 915 | ParseState state = ParseState::BEGINING_OF_LINE; |
| 916 | size_t pos = 0; |
| 917 | |
| 918 | while (pos < len) |
| 919 | { |
| 920 | char c = str[pos]; |
| 921 | char next = pos + 1 < len ? str[pos + 1] : 0; |
| 922 | |
| 923 | // Check for newlines |
| 924 | if (c == '\n' || c == '\r') |
| 925 | { |
| 926 | if (state != ParseState::IN_MULTI_LINE_COMMENT) |
| 927 | { |
| 928 | state = ParseState::BEGINING_OF_LINE; |
| 929 | } |
| 930 | |
| 931 | pos++; |
| 932 | continue; |
| 933 | } |
| 934 | |
| 935 | switch (state) |
| 936 | { |
| 937 | case ParseState::BEGINING_OF_LINE: |
| 938 | if (c == ' ') |
| 939 | { |
| 940 | // Maintain the BEGINING_OF_LINE state until a non-space is seen |
| 941 | pos++; |
| 942 | } |
| 943 | else if (c == '#') |
| 944 | { |
| 945 | state = ParseState::IN_PREPROCESSOR_DIRECTIVE; |
| 946 | pos++; |
| 947 | } |
| 948 | else |
| 949 | { |
| 950 | // Don't advance, re-process this character with the MIDDLE_OF_LINE state |
| 951 | state = ParseState::MIDDLE_OF_LINE; |
| 952 | } |
| 953 | break; |
| 954 | |
| 955 | case ParseState::MIDDLE_OF_LINE: |
| 956 | if (c == '/' && next == '/') |
| 957 | { |
| 958 | state = ParseState::IN_SINGLE_LINE_COMMENT; |
| 959 | pos++; |
| 960 | } |
| 961 | else if (c == '/' && next == '*') |
| 962 | { |
| 963 | state = ParseState::IN_MULTI_LINE_COMMENT; |
| 964 | pos++; |
| 965 | } |
| 966 | else if (lineContinuationAllowed && c == '\\' && (next == '\n' || next == '\r')) |
| 967 | { |
| 968 | // Skip line continuation characters |
| 969 | } |
| 970 | else if (!IsValidESSLCharacter(c)) |
| 971 | { |
| 972 | return false; |
| 973 | } |
| 974 | pos++; |
| 975 | break; |
| 976 | |
| 977 | case ParseState::IN_PREPROCESSOR_DIRECTIVE: |
Bryan Bernhart (Intel Americas Inc) | 335d8bf | 2017-10-23 15:41:43 -0700 | [diff] [blame] | 978 | // Line-continuation characters may not be permitted. |
| 979 | // Otherwise, just pass it through. Do not parse comments in this state. |
| 980 | if (!lineContinuationAllowed && c == '\\') |
| 981 | { |
| 982 | return false; |
| 983 | } |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 984 | pos++; |
| 985 | break; |
| 986 | |
| 987 | case ParseState::IN_SINGLE_LINE_COMMENT: |
| 988 | // Line-continuation characters are processed before comment processing. |
| 989 | // Advance string if a new line character is immediately behind |
| 990 | // line-continuation character. |
| 991 | if (c == '\\' && (next == '\n' || next == '\r')) |
| 992 | { |
| 993 | pos++; |
| 994 | } |
| 995 | pos++; |
| 996 | break; |
| 997 | |
| 998 | case ParseState::IN_MULTI_LINE_COMMENT: |
| 999 | if (c == '*' && next == '/') |
| 1000 | { |
| 1001 | state = ParseState::MIDDLE_OF_LINE; |
| 1002 | pos++; |
| 1003 | } |
| 1004 | pos++; |
| 1005 | break; |
| 1006 | } |
| 1007 | } |
| 1008 | |
| 1009 | return true; |
| 1010 | } |
| 1011 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 1012 | bool ValidateWebGLNamePrefix(Context *context, const GLchar *name) |
Brandon Jones | ed5b46f | 2017-07-21 08:39:17 -0700 | [diff] [blame] | 1013 | { |
| 1014 | ASSERT(context->isWebGL()); |
| 1015 | |
| 1016 | // WebGL 1.0 [Section 6.16] GLSL Constructs |
| 1017 | // Identifiers starting with "webgl_" and "_webgl_" are reserved for use by WebGL. |
| 1018 | if (strncmp(name, "webgl_", 6) == 0 || strncmp(name, "_webgl_", 7) == 0) |
| 1019 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1020 | context->validationError(GL_INVALID_OPERATION, kWebglBindAttribLocationReservedPrefix); |
Brandon Jones | ed5b46f | 2017-07-21 08:39:17 -0700 | [diff] [blame] | 1021 | return false; |
| 1022 | } |
| 1023 | |
| 1024 | return true; |
| 1025 | } |
| 1026 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 1027 | bool ValidateWebGLNameLength(Context *context, size_t length) |
Brandon Jones | ed5b46f | 2017-07-21 08:39:17 -0700 | [diff] [blame] | 1028 | { |
| 1029 | ASSERT(context->isWebGL()); |
| 1030 | |
| 1031 | if (context->isWebGL1() && length > 256) |
| 1032 | { |
| 1033 | // WebGL 1.0 [Section 6.21] Maxmimum Uniform and Attribute Location Lengths |
| 1034 | // WebGL imposes a limit of 256 characters on the lengths of uniform and attribute |
| 1035 | // locations. |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1036 | context->validationError(GL_INVALID_VALUE, kWebglNameLengthLimitExceeded); |
Brandon Jones | ed5b46f | 2017-07-21 08:39:17 -0700 | [diff] [blame] | 1037 | |
| 1038 | return false; |
| 1039 | } |
| 1040 | else if (length > 1024) |
| 1041 | { |
| 1042 | // WebGL 2.0 [Section 4.3.2] WebGL 2.0 imposes a limit of 1024 characters on the lengths of |
| 1043 | // uniform and attribute locations. |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1044 | context->validationError(GL_INVALID_VALUE, kWebgl2NameLengthLimitExceeded); |
Brandon Jones | ed5b46f | 2017-07-21 08:39:17 -0700 | [diff] [blame] | 1045 | return false; |
| 1046 | } |
| 1047 | |
| 1048 | return true; |
| 1049 | } |
| 1050 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 1051 | bool ValidateMatrixMode(Context *context, GLenum matrixMode) |
| 1052 | { |
| 1053 | if (!context->getExtensions().pathRendering) |
| 1054 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 1055 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 1056 | return false; |
| 1057 | } |
| 1058 | |
| 1059 | if (matrixMode != GL_PATH_MODELVIEW_CHROMIUM && matrixMode != GL_PATH_PROJECTION_CHROMIUM) |
| 1060 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1061 | context->validationError(GL_INVALID_ENUM, kInvalidMatrixMode); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 1062 | return false; |
| 1063 | } |
| 1064 | return true; |
| 1065 | } |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 1066 | |
| 1067 | bool ValidBlendFunc(const Context *context, GLenum val) |
| 1068 | { |
| 1069 | const gl::Extensions &ext = context->getExtensions(); |
| 1070 | |
| 1071 | // these are always valid for src and dst. |
| 1072 | switch (val) |
| 1073 | { |
| 1074 | case GL_ZERO: |
| 1075 | case GL_ONE: |
| 1076 | case GL_SRC_COLOR: |
| 1077 | case GL_ONE_MINUS_SRC_COLOR: |
| 1078 | case GL_DST_COLOR: |
| 1079 | case GL_ONE_MINUS_DST_COLOR: |
| 1080 | case GL_SRC_ALPHA: |
| 1081 | case GL_ONE_MINUS_SRC_ALPHA: |
| 1082 | case GL_DST_ALPHA: |
| 1083 | case GL_ONE_MINUS_DST_ALPHA: |
| 1084 | case GL_CONSTANT_COLOR: |
| 1085 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 1086 | case GL_CONSTANT_ALPHA: |
| 1087 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 1088 | return true; |
| 1089 | |
| 1090 | // EXT_blend_func_extended. |
| 1091 | case GL_SRC1_COLOR_EXT: |
| 1092 | case GL_SRC1_ALPHA_EXT: |
| 1093 | case GL_ONE_MINUS_SRC1_COLOR_EXT: |
| 1094 | case GL_ONE_MINUS_SRC1_ALPHA_EXT: |
| 1095 | case GL_SRC_ALPHA_SATURATE_EXT: |
| 1096 | return ext.blendFuncExtended; |
| 1097 | |
| 1098 | default: |
| 1099 | return false; |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | bool ValidSrcBlendFunc(const Context *context, GLenum val) |
| 1104 | { |
| 1105 | if (ValidBlendFunc(context, val)) |
| 1106 | return true; |
| 1107 | |
| 1108 | if (val == GL_SRC_ALPHA_SATURATE) |
| 1109 | return true; |
| 1110 | |
| 1111 | return false; |
| 1112 | } |
| 1113 | |
| 1114 | bool ValidDstBlendFunc(const Context *context, GLenum val) |
| 1115 | { |
| 1116 | if (ValidBlendFunc(context, val)) |
| 1117 | return true; |
| 1118 | |
| 1119 | if (val == GL_SRC_ALPHA_SATURATE) |
| 1120 | { |
| 1121 | if (context->getClientMajorVersion() >= 3) |
| 1122 | return true; |
| 1123 | } |
| 1124 | |
| 1125 | return false; |
| 1126 | } |
Michael Spang | ab6a59b | 2019-05-21 21:26:26 -0400 | [diff] [blame^] | 1127 | |
| 1128 | bool IsValidImageLayout(ImageLayout layout) |
| 1129 | { |
| 1130 | switch (layout) |
| 1131 | { |
| 1132 | case ImageLayout::General: |
| 1133 | case ImageLayout::ColorAttachment: |
| 1134 | case ImageLayout::DepthStencilAttachment: |
| 1135 | case ImageLayout::DepthStencilReadOnlyAttachment: |
| 1136 | case ImageLayout::ShaderReadOnly: |
| 1137 | case ImageLayout::TransferSrc: |
| 1138 | case ImageLayout::TransferDst: |
| 1139 | case ImageLayout::DepthReadOnlyStencilAttachment: |
| 1140 | case ImageLayout::DepthAttachmentStencilReadOnly: |
| 1141 | return true; |
| 1142 | |
| 1143 | default: |
| 1144 | return false; |
| 1145 | } |
| 1146 | } |
| 1147 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1148 | } // anonymous namespace |
| 1149 | |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 1150 | bool ValidateES2TexImageParameters(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1151 | TextureTarget target, |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 1152 | GLint level, |
| 1153 | GLenum internalformat, |
| 1154 | bool isCompressed, |
| 1155 | bool isSubImage, |
| 1156 | GLint xoffset, |
| 1157 | GLint yoffset, |
| 1158 | GLsizei width, |
| 1159 | GLsizei height, |
| 1160 | GLint border, |
| 1161 | GLenum format, |
| 1162 | GLenum type, |
| 1163 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1164 | const void *pixels) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1165 | { |
Jamie Madill | 6f38f82 | 2014-06-06 17:12:20 -0400 | [diff] [blame] | 1166 | if (!ValidTexture2DDestinationTarget(context, target)) |
| 1167 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1168 | context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1169 | return false; |
Jamie Madill | 6f38f82 | 2014-06-06 17:12:20 -0400 | [diff] [blame] | 1170 | } |
| 1171 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1172 | TextureType texType = TextureTargetToType(target); |
| 1173 | if (!ValidImageSizeParameters(context, texType, level, width, height, 1, isSubImage)) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1174 | { |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 1175 | // Error already handled. |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1176 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1177 | } |
| 1178 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1179 | if (!ValidMipLevel(context, texType, level)) |
Brandon Jones | 6cad566 | 2017-06-14 13:25:13 -0700 | [diff] [blame] | 1180 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1181 | context->validationError(GL_INVALID_VALUE, kInvalidMipLevel); |
Brandon Jones | 6cad566 | 2017-06-14 13:25:13 -0700 | [diff] [blame] | 1182 | return false; |
| 1183 | } |
| 1184 | |
| 1185 | if (xoffset < 0 || std::numeric_limits<GLsizei>::max() - xoffset < width || |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1186 | std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 1187 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1188 | context->validationError(GL_INVALID_VALUE, kResourceMaxTextureSize); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1189 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1190 | } |
| 1191 | |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 1192 | const gl::Caps &caps = context->getCaps(); |
| 1193 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1194 | switch (texType) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1195 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1196 | case TextureType::_2D: |
| 1197 | if (static_cast<GLuint>(width) > (caps.max2DTextureSize >> level) || |
| 1198 | static_cast<GLuint>(height) > (caps.max2DTextureSize >> level)) |
| 1199 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1200 | context->validationError(GL_INVALID_VALUE, kResourceMaxTextureSize); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1201 | return false; |
| 1202 | } |
| 1203 | break; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1204 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1205 | case TextureType::Rectangle: |
| 1206 | ASSERT(level == 0); |
| 1207 | if (static_cast<GLuint>(width) > caps.maxRectangleTextureSize || |
| 1208 | static_cast<GLuint>(height) > caps.maxRectangleTextureSize) |
| 1209 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1210 | context->validationError(GL_INVALID_VALUE, kResourceMaxTextureSize); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1211 | return false; |
| 1212 | } |
| 1213 | if (isCompressed) |
| 1214 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 1215 | context->validationError(GL_INVALID_ENUM, kRectangleTextureCompressed); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1216 | return false; |
| 1217 | } |
| 1218 | break; |
| 1219 | |
| 1220 | case TextureType::CubeMap: |
| 1221 | if (!isSubImage && width != height) |
| 1222 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1223 | context->validationError(GL_INVALID_VALUE, kCubemapFacesEqualDimensions); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1224 | return false; |
| 1225 | } |
| 1226 | |
| 1227 | if (static_cast<GLuint>(width) > (caps.maxCubeMapTextureSize >> level) || |
| 1228 | static_cast<GLuint>(height) > (caps.maxCubeMapTextureSize >> level)) |
| 1229 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1230 | context->validationError(GL_INVALID_VALUE, kResourceMaxTextureSize); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1231 | return false; |
| 1232 | } |
| 1233 | break; |
| 1234 | |
| 1235 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1236 | context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget); |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1237 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1238 | } |
| 1239 | |
Jamie Madill | cfc73cc | 2019-04-08 16:26:51 -0400 | [diff] [blame] | 1240 | gl::Texture *texture = context->getTextureByType(texType); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1241 | if (!texture) |
| 1242 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1243 | context->validationError(GL_INVALID_OPERATION, kBufferNotBound); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1244 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1245 | } |
| 1246 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1247 | // Verify zero border |
| 1248 | if (border != 0) |
| 1249 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1250 | context->validationError(GL_INVALID_VALUE, kInvalidBorder); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1251 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1252 | } |
| 1253 | |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1254 | bool nonEqualFormatsAllowed = false; |
| 1255 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1256 | if (isCompressed) |
| 1257 | { |
tmartino | 0ccd5ae | 2015-10-01 14:33:14 -0400 | [diff] [blame] | 1258 | GLenum actualInternalFormat = |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1259 | isSubImage ? texture->getFormat(target, level).info->sizedInternalFormat |
| 1260 | : internalformat; |
Geoff Lang | e88e454 | 2018-05-03 15:05:57 -0400 | [diff] [blame] | 1261 | |
| 1262 | const InternalFormat &internalFormatInfo = GetSizedInternalFormatInfo(actualInternalFormat); |
| 1263 | |
| 1264 | if (!internalFormatInfo.compressed) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1265 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1266 | context->validationError(GL_INVALID_ENUM, kInvalidInternalFormat); |
Geoff Lang | e88e454 | 2018-05-03 15:05:57 -0400 | [diff] [blame] | 1267 | return false; |
| 1268 | } |
| 1269 | |
| 1270 | if (!internalFormatInfo.textureSupport(context->getClientVersion(), |
| 1271 | context->getExtensions())) |
| 1272 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1273 | context->validationError(GL_INVALID_ENUM, kInvalidInternalFormat); |
Geoff Lang | e88e454 | 2018-05-03 15:05:57 -0400 | [diff] [blame] | 1274 | return false; |
tmartino | 0ccd5ae | 2015-10-01 14:33:14 -0400 | [diff] [blame] | 1275 | } |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 1276 | |
| 1277 | if (isSubImage) |
tmartino | 0ccd5ae | 2015-10-01 14:33:14 -0400 | [diff] [blame] | 1278 | { |
Geoff Lang | e88e454 | 2018-05-03 15:05:57 -0400 | [diff] [blame] | 1279 | // From the OES_compressed_ETC1_RGB8_texture spec: |
| 1280 | // INVALID_OPERATION is generated by CompressedTexSubImage2D, TexSubImage2D, or |
| 1281 | // CopyTexSubImage2D if the texture image <level> bound to <target> has internal format |
| 1282 | // ETC1_RGB8_OES. |
| 1283 | if (actualInternalFormat == GL_ETC1_RGB8_OES) |
| 1284 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1285 | context->validationError(GL_INVALID_OPERATION, kInvalidInternalFormat); |
Geoff Lang | e88e454 | 2018-05-03 15:05:57 -0400 | [diff] [blame] | 1286 | return false; |
| 1287 | } |
| 1288 | |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 1289 | if (!ValidCompressedSubImageSize(context, actualInternalFormat, xoffset, yoffset, width, |
| 1290 | height, texture->getWidth(target, level), |
| 1291 | texture->getHeight(target, level))) |
| 1292 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 1293 | context->validationError(GL_INVALID_OPERATION, kInvalidCompressedImageSize); |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 1294 | return false; |
| 1295 | } |
| 1296 | |
| 1297 | if (format != actualInternalFormat) |
| 1298 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1299 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 1300 | return false; |
| 1301 | } |
| 1302 | } |
| 1303 | else |
| 1304 | { |
| 1305 | if (!ValidCompressedImageSize(context, actualInternalFormat, level, width, height)) |
| 1306 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 1307 | context->validationError(GL_INVALID_OPERATION, kInvalidCompressedImageSize); |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 1308 | return false; |
| 1309 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1310 | } |
| 1311 | } |
| 1312 | else |
| 1313 | { |
| 1314 | // validate <type> by itself (used as secondary key below) |
| 1315 | switch (type) |
| 1316 | { |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1317 | case GL_UNSIGNED_BYTE: |
| 1318 | case GL_UNSIGNED_SHORT_5_6_5: |
| 1319 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 1320 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 1321 | case GL_UNSIGNED_SHORT: |
| 1322 | case GL_UNSIGNED_INT: |
| 1323 | case GL_UNSIGNED_INT_24_8_OES: |
| 1324 | case GL_HALF_FLOAT_OES: |
| 1325 | case GL_FLOAT: |
| 1326 | break; |
| 1327 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1328 | context->validationError(GL_INVALID_ENUM, kInvalidType); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1329 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1330 | } |
| 1331 | |
| 1332 | // validate <format> + <type> combinations |
| 1333 | // - invalid <format> -> sets INVALID_ENUM |
| 1334 | // - invalid <format>+<type> combination -> sets INVALID_OPERATION |
| 1335 | switch (format) |
| 1336 | { |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1337 | case GL_ALPHA: |
| 1338 | case GL_LUMINANCE: |
| 1339 | case GL_LUMINANCE_ALPHA: |
| 1340 | switch (type) |
| 1341 | { |
| 1342 | case GL_UNSIGNED_BYTE: |
| 1343 | case GL_FLOAT: |
| 1344 | case GL_HALF_FLOAT_OES: |
| 1345 | break; |
| 1346 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1347 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1348 | return false; |
| 1349 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1350 | break; |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1351 | case GL_RED: |
| 1352 | case GL_RG: |
| 1353 | if (!context->getExtensions().textureRG) |
| 1354 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1355 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1356 | return false; |
| 1357 | } |
| 1358 | switch (type) |
| 1359 | { |
| 1360 | case GL_UNSIGNED_BYTE: |
Bryan Bernhart (Intel Americas Inc) | 2a35741 | 2017-09-05 10:42:47 -0700 | [diff] [blame] | 1361 | break; |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1362 | case GL_FLOAT: |
| 1363 | case GL_HALF_FLOAT_OES: |
Bryan Bernhart (Intel Americas Inc) | 2a35741 | 2017-09-05 10:42:47 -0700 | [diff] [blame] | 1364 | if (!context->getExtensions().textureFloat) |
| 1365 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1366 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Bryan Bernhart (Intel Americas Inc) | 2a35741 | 2017-09-05 10:42:47 -0700 | [diff] [blame] | 1367 | return false; |
| 1368 | } |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1369 | break; |
| 1370 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1371 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1372 | return false; |
| 1373 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1374 | break; |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1375 | case GL_RGB: |
| 1376 | switch (type) |
| 1377 | { |
| 1378 | case GL_UNSIGNED_BYTE: |
| 1379 | case GL_UNSIGNED_SHORT_5_6_5: |
| 1380 | case GL_FLOAT: |
| 1381 | case GL_HALF_FLOAT_OES: |
| 1382 | break; |
| 1383 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1384 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1385 | return false; |
| 1386 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1387 | break; |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1388 | case GL_RGBA: |
| 1389 | switch (type) |
| 1390 | { |
| 1391 | case GL_UNSIGNED_BYTE: |
| 1392 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 1393 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 1394 | case GL_FLOAT: |
| 1395 | case GL_HALF_FLOAT_OES: |
| 1396 | break; |
| 1397 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1398 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1399 | return false; |
| 1400 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1401 | break; |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1402 | case GL_BGRA_EXT: |
Bryan Bernhart (Intel Americas Inc) | 2a35741 | 2017-09-05 10:42:47 -0700 | [diff] [blame] | 1403 | if (!context->getExtensions().textureFormatBGRA8888) |
| 1404 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1405 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Bryan Bernhart (Intel Americas Inc) | 2a35741 | 2017-09-05 10:42:47 -0700 | [diff] [blame] | 1406 | return false; |
| 1407 | } |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1408 | switch (type) |
| 1409 | { |
| 1410 | case GL_UNSIGNED_BYTE: |
| 1411 | break; |
| 1412 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1413 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1414 | return false; |
| 1415 | } |
| 1416 | break; |
| 1417 | case GL_SRGB_EXT: |
| 1418 | case GL_SRGB_ALPHA_EXT: |
| 1419 | if (!context->getExtensions().sRGB) |
| 1420 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1421 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1422 | return false; |
| 1423 | } |
| 1424 | switch (type) |
| 1425 | { |
| 1426 | case GL_UNSIGNED_BYTE: |
| 1427 | break; |
| 1428 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1429 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1430 | return false; |
| 1431 | } |
| 1432 | break; |
| 1433 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are |
| 1434 | // handled below |
| 1435 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1436 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1437 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1438 | break; |
| 1439 | case GL_DEPTH_COMPONENT: |
| 1440 | switch (type) |
| 1441 | { |
| 1442 | case GL_UNSIGNED_SHORT: |
| 1443 | case GL_UNSIGNED_INT: |
| 1444 | break; |
| 1445 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1446 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1447 | return false; |
| 1448 | } |
| 1449 | break; |
| 1450 | case GL_DEPTH_STENCIL_OES: |
| 1451 | switch (type) |
| 1452 | { |
| 1453 | case GL_UNSIGNED_INT_24_8_OES: |
| 1454 | break; |
| 1455 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1456 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1457 | return false; |
| 1458 | } |
| 1459 | break; |
| 1460 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1461 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1462 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1463 | } |
| 1464 | |
| 1465 | switch (format) |
| 1466 | { |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1467 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1468 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1469 | if (context->getExtensions().textureCompressionDXT1) |
| 1470 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1471 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1472 | return false; |
| 1473 | } |
| 1474 | else |
| 1475 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1476 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1477 | return false; |
| 1478 | } |
| 1479 | break; |
| 1480 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1481 | if (context->getExtensions().textureCompressionDXT3) |
| 1482 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1483 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1484 | return false; |
| 1485 | } |
| 1486 | else |
| 1487 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1488 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1489 | return false; |
| 1490 | } |
| 1491 | break; |
| 1492 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1493 | if (context->getExtensions().textureCompressionDXT5) |
| 1494 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1495 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1496 | return false; |
| 1497 | } |
| 1498 | else |
| 1499 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1500 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1501 | return false; |
| 1502 | } |
| 1503 | break; |
| 1504 | case GL_ETC1_RGB8_OES: |
| 1505 | if (context->getExtensions().compressedETC1RGB8Texture) |
| 1506 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1507 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1508 | return false; |
| 1509 | } |
| 1510 | else |
| 1511 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1512 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1513 | return false; |
| 1514 | } |
| 1515 | break; |
| 1516 | case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: |
Minmin Gong | 390208b | 2017-02-28 18:03:06 -0800 | [diff] [blame] | 1517 | case GL_COMPRESSED_RGB8_LOSSY_DECODE_ETC2_ANGLE: |
| 1518 | case GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE: |
| 1519 | case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE: |
| 1520 | case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE: |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1521 | if (context->getExtensions().lossyETCDecode) |
| 1522 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 1523 | context->validationError(GL_INVALID_OPERATION, kInvalidFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1524 | return false; |
| 1525 | } |
| 1526 | else |
| 1527 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 1528 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1529 | return false; |
| 1530 | } |
| 1531 | break; |
| 1532 | case GL_DEPTH_COMPONENT: |
| 1533 | case GL_DEPTH_STENCIL_OES: |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 1534 | if (!context->getExtensions().depthTextureANGLE && |
| 1535 | !(context->getExtensions().packedDepthStencil && |
| 1536 | context->getExtensions().depthTextureOES)) |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1537 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1538 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1539 | return false; |
| 1540 | } |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1541 | if (target != TextureTarget::_2D) |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1542 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1543 | context->validationError(GL_INVALID_OPERATION, kMismatchedTargetAndFormat); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1544 | return false; |
| 1545 | } |
| 1546 | // OES_depth_texture supports loading depth data and multiple levels, |
| 1547 | // but ANGLE_depth_texture does not |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 1548 | if (!context->getExtensions().depthTextureOES) |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1549 | { |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 1550 | if (pixels != nullptr) |
| 1551 | { |
| 1552 | context->validationError(GL_INVALID_OPERATION, kPixelDataNotNull); |
| 1553 | return false; |
| 1554 | } |
| 1555 | if (level != 0) |
| 1556 | { |
| 1557 | context->validationError(GL_INVALID_OPERATION, kLevelNotZero); |
| 1558 | return false; |
| 1559 | } |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1560 | } |
| 1561 | break; |
| 1562 | default: |
| 1563 | break; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1564 | } |
| 1565 | |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1566 | if (!isSubImage) |
| 1567 | { |
| 1568 | switch (internalformat) |
| 1569 | { |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1570 | // Core ES 2.0 formats |
| 1571 | case GL_ALPHA: |
| 1572 | case GL_LUMINANCE: |
| 1573 | case GL_LUMINANCE_ALPHA: |
| 1574 | case GL_RGB: |
| 1575 | case GL_RGBA: |
| 1576 | break; |
| 1577 | |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1578 | case GL_RGBA32F: |
| 1579 | if (!context->getExtensions().colorBufferFloatRGBA) |
| 1580 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 1581 | context->validationError(GL_INVALID_ENUM, kInvalidFormat); |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1582 | return false; |
| 1583 | } |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1584 | |
| 1585 | nonEqualFormatsAllowed = true; |
| 1586 | |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1587 | if (type != GL_FLOAT) |
| 1588 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1589 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1590 | return false; |
| 1591 | } |
| 1592 | if (format != GL_RGBA) |
| 1593 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1594 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1595 | return false; |
| 1596 | } |
| 1597 | break; |
| 1598 | |
| 1599 | case GL_RGB32F: |
| 1600 | if (!context->getExtensions().colorBufferFloatRGB) |
| 1601 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 1602 | context->validationError(GL_INVALID_ENUM, kInvalidFormat); |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1603 | return false; |
| 1604 | } |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1605 | |
| 1606 | nonEqualFormatsAllowed = true; |
| 1607 | |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1608 | if (type != GL_FLOAT) |
| 1609 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1610 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1611 | return false; |
| 1612 | } |
| 1613 | if (format != GL_RGB) |
| 1614 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1615 | context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat); |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1616 | return false; |
| 1617 | } |
| 1618 | break; |
| 1619 | |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1620 | case GL_BGRA_EXT: |
| 1621 | if (!context->getExtensions().textureFormatBGRA8888) |
| 1622 | { |
| 1623 | context->validationError(GL_INVALID_ENUM, kInvalidFormat); |
| 1624 | return false; |
| 1625 | } |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1626 | break; |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1627 | |
| 1628 | case GL_DEPTH_COMPONENT: |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 1629 | if (!(context->getExtensions().depthTextureAny())) |
| 1630 | { |
| 1631 | context->validationError(GL_INVALID_ENUM, kInvalidFormat); |
| 1632 | return false; |
| 1633 | } |
| 1634 | break; |
| 1635 | |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1636 | case GL_DEPTH_STENCIL: |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 1637 | if (!(context->getExtensions().depthTextureANGLE || |
| 1638 | context->getExtensions().packedDepthStencil)) |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1639 | { |
| 1640 | context->validationError(GL_INVALID_ENUM, kInvalidFormat); |
| 1641 | return false; |
| 1642 | } |
| 1643 | break; |
| 1644 | |
| 1645 | case GL_RED: |
| 1646 | case GL_RG: |
| 1647 | if (!context->getExtensions().textureRG) |
| 1648 | { |
| 1649 | context->validationError(GL_INVALID_ENUM, kInvalidFormat); |
| 1650 | return false; |
| 1651 | } |
| 1652 | break; |
| 1653 | |
| 1654 | case GL_SRGB_EXT: |
| 1655 | case GL_SRGB_ALPHA_EXT: |
| 1656 | if (!context->getExtensions().sRGB) |
| 1657 | { |
| 1658 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
| 1659 | return false; |
| 1660 | } |
| 1661 | break; |
| 1662 | |
| 1663 | default: |
| 1664 | context->validationError(GL_INVALID_VALUE, kInvalidInternalFormat); |
| 1665 | return false; |
Geoff Lang | 6e898aa | 2017-06-02 11:17:26 -0400 | [diff] [blame] | 1666 | } |
| 1667 | } |
| 1668 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1669 | if (type == GL_FLOAT) |
| 1670 | { |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1671 | if (!context->getExtensions().textureFloat) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1672 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1673 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1674 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1675 | } |
| 1676 | } |
| 1677 | else if (type == GL_HALF_FLOAT_OES) |
| 1678 | { |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1679 | if (!context->getExtensions().textureHalfFloat) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1680 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1681 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1682 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1683 | } |
| 1684 | } |
| 1685 | } |
| 1686 | |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1687 | if (isSubImage) |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 1688 | { |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1689 | const InternalFormat &textureInternalFormat = *texture->getFormat(target, level).info; |
| 1690 | if (textureInternalFormat.internalFormat == GL_NONE) |
| 1691 | { |
| 1692 | context->validationError(GL_INVALID_OPERATION, kInvalidTextureLevel); |
| 1693 | return false; |
| 1694 | } |
| 1695 | |
Tim Van Patten | 5f388c2 | 2019-03-14 09:54:23 -0600 | [diff] [blame] | 1696 | if (format != textureInternalFormat.format) |
| 1697 | { |
| 1698 | context->validationError(GL_INVALID_OPERATION, err::kTextureFormatMismatch); |
| 1699 | return false; |
| 1700 | } |
| 1701 | |
| 1702 | if (context->getExtensions().webglCompatibility) |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1703 | { |
| 1704 | if (GetInternalFormatInfo(format, type).sizedInternalFormat != |
| 1705 | textureInternalFormat.sizedInternalFormat) |
| 1706 | { |
Tim Van Patten | 5f388c2 | 2019-03-14 09:54:23 -0600 | [diff] [blame] | 1707 | context->validationError(GL_INVALID_OPERATION, kTextureTypeMismatch); |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1708 | return false; |
| 1709 | } |
| 1710 | } |
| 1711 | |
| 1712 | if (static_cast<size_t>(xoffset + width) > texture->getWidth(target, level) || |
| 1713 | static_cast<size_t>(yoffset + height) > texture->getHeight(target, level)) |
| 1714 | { |
| 1715 | context->validationError(GL_INVALID_VALUE, kOffsetOverflow); |
| 1716 | return false; |
| 1717 | } |
| 1718 | |
| 1719 | if (width > 0 && height > 0 && pixels == nullptr && |
| 1720 | context->getState().getTargetBuffer(BufferBinding::PixelUnpack) == nullptr) |
| 1721 | { |
| 1722 | context->validationError(GL_INVALID_VALUE, kPixelDataNull); |
| 1723 | return false; |
| 1724 | } |
| 1725 | } |
| 1726 | else |
| 1727 | { |
| 1728 | if (texture->getImmutableFormat()) |
| 1729 | { |
| 1730 | context->validationError(GL_INVALID_OPERATION, kTextureIsImmutable); |
| 1731 | return false; |
| 1732 | } |
| 1733 | } |
| 1734 | |
| 1735 | // From GL_CHROMIUM_color_buffer_float_rgb[a]: |
| 1736 | // GL_RGB[A] / GL_RGB[A]32F becomes an allowable format / internalformat parameter pair for |
| 1737 | // TexImage2D. The restriction in section 3.7.1 of the OpenGL ES 2.0 spec that the |
| 1738 | // internalformat parameter and format parameter of TexImage2D must match is lifted for this |
| 1739 | // case. |
| 1740 | if (!isSubImage && !isCompressed && internalformat != format && !nonEqualFormatsAllowed) |
| 1741 | { |
| 1742 | context->validationError(GL_INVALID_OPERATION, kInvalidFormatCombination); |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 1743 | return false; |
| 1744 | } |
| 1745 | |
Tim Van Patten | 208af3e | 2019-03-19 09:15:55 -0600 | [diff] [blame] | 1746 | GLenum sizeCheckFormat = isSubImage ? format : internalformat; |
| 1747 | return ValidImageDataSize(context, texType, width, height, 1, sizeCheckFormat, type, pixels, |
| 1748 | imageSize); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1749 | } |
| 1750 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1751 | bool ValidateES2TexStorageParameters(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1752 | TextureType target, |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1753 | GLsizei levels, |
| 1754 | GLenum internalformat, |
| 1755 | GLsizei width, |
| 1756 | GLsizei height) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1757 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1758 | if (target != TextureType::_2D && target != TextureType::CubeMap && |
| 1759 | target != TextureType::Rectangle) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1760 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1761 | context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1762 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1763 | } |
| 1764 | |
| 1765 | if (width < 1 || height < 1 || levels < 1) |
| 1766 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1767 | context->validationError(GL_INVALID_VALUE, kTextureSizeTooSmall); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1768 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1769 | } |
| 1770 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1771 | if (target == TextureType::CubeMap && width != height) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1772 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1773 | context->validationError(GL_INVALID_VALUE, kCubemapFacesEqualDimensions); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1774 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1775 | } |
| 1776 | |
| 1777 | if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1) |
| 1778 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1779 | context->validationError(GL_INVALID_OPERATION, kInvalidMipLevels); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1780 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1781 | } |
| 1782 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1783 | const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalformat); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1784 | if (formatInfo.format == GL_NONE || formatInfo.type == GL_NONE) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1785 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1786 | context->validationError(GL_INVALID_ENUM, kInvalidFormat); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1787 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1788 | } |
| 1789 | |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 1790 | const gl::Caps &caps = context->getCaps(); |
| 1791 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1792 | switch (target) |
| 1793 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1794 | case TextureType::_2D: |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1795 | if (static_cast<GLuint>(width) > caps.max2DTextureSize || |
| 1796 | static_cast<GLuint>(height) > caps.max2DTextureSize) |
| 1797 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1798 | context->validationError(GL_INVALID_VALUE, kResourceMaxTextureSize); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1799 | return false; |
| 1800 | } |
| 1801 | break; |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1802 | case TextureType::Rectangle: |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 1803 | if (levels != 1) |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1804 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1805 | context->validationError(GL_INVALID_VALUE, kInvalidMipLevel); |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 1806 | return false; |
| 1807 | } |
| 1808 | |
| 1809 | if (static_cast<GLuint>(width) > caps.maxRectangleTextureSize || |
| 1810 | static_cast<GLuint>(height) > caps.maxRectangleTextureSize) |
| 1811 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1812 | context->validationError(GL_INVALID_VALUE, kResourceMaxTextureSize); |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1813 | return false; |
| 1814 | } |
| 1815 | if (formatInfo.compressed) |
| 1816 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1817 | context->validationError(GL_INVALID_ENUM, kRectangleTextureCompressed); |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1818 | return false; |
| 1819 | } |
| 1820 | break; |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1821 | case TextureType::CubeMap: |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1822 | if (static_cast<GLuint>(width) > caps.maxCubeMapTextureSize || |
| 1823 | static_cast<GLuint>(height) > caps.maxCubeMapTextureSize) |
| 1824 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1825 | context->validationError(GL_INVALID_VALUE, kResourceMaxTextureSize); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1826 | return false; |
| 1827 | } |
| 1828 | break; |
| 1829 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1830 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1831 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1832 | } |
| 1833 | |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1834 | if (levels != 1 && !context->getExtensions().textureNPOT) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1835 | { |
| 1836 | if (!gl::isPow2(width) || !gl::isPow2(height)) |
| 1837 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1838 | context->validationError(GL_INVALID_OPERATION, kDimensionsMustBePow2); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1839 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1840 | } |
| 1841 | } |
| 1842 | |
| 1843 | switch (internalformat) |
| 1844 | { |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1845 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1846 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1847 | if (!context->getExtensions().textureCompressionDXT1) |
| 1848 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1849 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1850 | return false; |
| 1851 | } |
| 1852 | break; |
| 1853 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1854 | if (!context->getExtensions().textureCompressionDXT3) |
| 1855 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1856 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1857 | return false; |
| 1858 | } |
| 1859 | break; |
| 1860 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1861 | if (!context->getExtensions().textureCompressionDXT5) |
| 1862 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1863 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1864 | return false; |
| 1865 | } |
| 1866 | break; |
| 1867 | case GL_ETC1_RGB8_OES: |
| 1868 | if (!context->getExtensions().compressedETC1RGB8Texture) |
| 1869 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1870 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1871 | return false; |
| 1872 | } |
| 1873 | break; |
| 1874 | case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: |
Minmin Gong | 390208b | 2017-02-28 18:03:06 -0800 | [diff] [blame] | 1875 | case GL_COMPRESSED_RGB8_LOSSY_DECODE_ETC2_ANGLE: |
| 1876 | case GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE: |
| 1877 | case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE: |
| 1878 | case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE: |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1879 | if (!context->getExtensions().lossyETCDecode) |
| 1880 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 1881 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1882 | return false; |
| 1883 | } |
| 1884 | break; |
| 1885 | case GL_RGBA32F_EXT: |
| 1886 | case GL_RGB32F_EXT: |
| 1887 | case GL_ALPHA32F_EXT: |
| 1888 | case GL_LUMINANCE32F_EXT: |
| 1889 | case GL_LUMINANCE_ALPHA32F_EXT: |
| 1890 | if (!context->getExtensions().textureFloat) |
| 1891 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1892 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1893 | return false; |
| 1894 | } |
| 1895 | break; |
| 1896 | case GL_RGBA16F_EXT: |
| 1897 | case GL_RGB16F_EXT: |
| 1898 | case GL_ALPHA16F_EXT: |
| 1899 | case GL_LUMINANCE16F_EXT: |
| 1900 | case GL_LUMINANCE_ALPHA16F_EXT: |
| 1901 | if (!context->getExtensions().textureHalfFloat) |
| 1902 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1903 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1904 | return false; |
| 1905 | } |
| 1906 | break; |
| 1907 | case GL_R8_EXT: |
| 1908 | case GL_RG8_EXT: |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 1909 | if (!context->getExtensions().textureRG) |
| 1910 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1911 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 1912 | return false; |
| 1913 | } |
| 1914 | break; |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1915 | case GL_R16F_EXT: |
| 1916 | case GL_RG16F_EXT: |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 1917 | if (!context->getExtensions().textureRG || !context->getExtensions().textureHalfFloat) |
| 1918 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1919 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 1920 | return false; |
| 1921 | } |
| 1922 | break; |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1923 | case GL_R32F_EXT: |
| 1924 | case GL_RG32F_EXT: |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 1925 | if (!context->getExtensions().textureRG || !context->getExtensions().textureFloat) |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1926 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1927 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1928 | return false; |
| 1929 | } |
| 1930 | break; |
| 1931 | case GL_DEPTH_COMPONENT16: |
| 1932 | case GL_DEPTH_COMPONENT32_OES: |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 1933 | if (!(context->getExtensions().depthTextureAny())) |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1934 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1935 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1936 | return false; |
| 1937 | } |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1938 | if (target != TextureType::_2D) |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1939 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1940 | context->validationError(GL_INVALID_OPERATION, kInvalidTextureTarget); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1941 | return false; |
| 1942 | } |
| 1943 | // ANGLE_depth_texture only supports 1-level textures |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 1944 | if (!context->getExtensions().depthTextureOES) |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1945 | { |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 1946 | if (levels != 1) |
| 1947 | { |
| 1948 | context->validationError(GL_INVALID_OPERATION, kInvalidMipLevels); |
| 1949 | return false; |
| 1950 | } |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1951 | } |
| 1952 | break; |
Courtney Goeltzenleuchter | eaf2d92 | 2019-04-18 16:31:25 -0600 | [diff] [blame] | 1953 | case GL_DEPTH24_STENCIL8_OES: |
| 1954 | if (!(context->getExtensions().depthTextureANGLE || |
| 1955 | (context->getExtensions().packedDepthStencil && |
| 1956 | context->getExtensions().textureStorage))) |
| 1957 | { |
| 1958 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
| 1959 | return false; |
| 1960 | } |
| 1961 | if (target != TextureType::_2D) |
| 1962 | { |
| 1963 | context->validationError(GL_INVALID_OPERATION, kInvalidTextureTarget); |
| 1964 | return false; |
| 1965 | } |
| 1966 | if (!context->getExtensions().packedDepthStencil) |
| 1967 | { |
| 1968 | // ANGLE_depth_texture only supports 1-level textures |
| 1969 | if (levels != 1) |
| 1970 | { |
| 1971 | context->validationError(GL_INVALID_OPERATION, kInvalidMipLevels); |
| 1972 | return false; |
| 1973 | } |
| 1974 | } |
| 1975 | break; |
| 1976 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1977 | default: |
| 1978 | break; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1979 | } |
| 1980 | |
Jamie Madill | cfc73cc | 2019-04-08 16:26:51 -0400 | [diff] [blame] | 1981 | gl::Texture *texture = context->getTextureByType(target); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1982 | if (!texture || texture->id() == 0) |
| 1983 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1984 | context->validationError(GL_INVALID_OPERATION, kMissingTexture); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1985 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1986 | } |
| 1987 | |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 1988 | if (texture->getImmutableFormat()) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1989 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 1990 | context->validationError(GL_INVALID_OPERATION, kTextureIsImmutable); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1991 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1992 | } |
| 1993 | |
| 1994 | return true; |
| 1995 | } |
| 1996 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1997 | bool ValidateDiscardFramebufferEXT(Context *context, |
| 1998 | GLenum target, |
| 1999 | GLsizei numAttachments, |
Austin Kinross | 0833263 | 2015-05-05 13:35:47 -0700 | [diff] [blame] | 2000 | const GLenum *attachments) |
| 2001 | { |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2002 | if (!context->getExtensions().discardFramebuffer) |
| 2003 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2004 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2005 | return false; |
| 2006 | } |
| 2007 | |
Austin Kinross | 0833263 | 2015-05-05 13:35:47 -0700 | [diff] [blame] | 2008 | bool defaultFramebuffer = false; |
| 2009 | |
| 2010 | switch (target) |
| 2011 | { |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 2012 | case GL_FRAMEBUFFER: |
| 2013 | defaultFramebuffer = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2014 | (context->getState().getTargetFramebuffer(GL_FRAMEBUFFER)->id() == 0); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 2015 | break; |
| 2016 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2017 | context->validationError(GL_INVALID_ENUM, kInvalidFramebufferTarget); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 2018 | return false; |
Austin Kinross | 0833263 | 2015-05-05 13:35:47 -0700 | [diff] [blame] | 2019 | } |
| 2020 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 2021 | return ValidateDiscardFramebufferBase(context, target, numAttachments, attachments, |
| 2022 | defaultFramebuffer); |
Austin Kinross | 0833263 | 2015-05-05 13:35:47 -0700 | [diff] [blame] | 2023 | } |
| 2024 | |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2025 | bool ValidateBindVertexArrayOES(Context *context, GLuint array) |
| 2026 | { |
| 2027 | if (!context->getExtensions().vertexArrayObject) |
| 2028 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2029 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2030 | return false; |
| 2031 | } |
| 2032 | |
| 2033 | return ValidateBindVertexArrayBase(context, array); |
| 2034 | } |
| 2035 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 2036 | bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n, const GLuint *arrays) |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2037 | { |
| 2038 | if (!context->getExtensions().vertexArrayObject) |
| 2039 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2040 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2041 | return false; |
| 2042 | } |
| 2043 | |
Olli Etuaho | 41997e7 | 2016-03-10 13:38:39 +0200 | [diff] [blame] | 2044 | return ValidateGenOrDelete(context, n); |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2045 | } |
| 2046 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 2047 | bool ValidateGenVertexArraysOES(Context *context, GLsizei n, GLuint *arrays) |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2048 | { |
| 2049 | if (!context->getExtensions().vertexArrayObject) |
| 2050 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2051 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2052 | return false; |
| 2053 | } |
| 2054 | |
Olli Etuaho | 41997e7 | 2016-03-10 13:38:39 +0200 | [diff] [blame] | 2055 | return ValidateGenOrDelete(context, n); |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2056 | } |
| 2057 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 2058 | bool ValidateIsVertexArrayOES(Context *context, GLuint array) |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2059 | { |
| 2060 | if (!context->getExtensions().vertexArrayObject) |
| 2061 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2062 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2063 | return false; |
| 2064 | } |
| 2065 | |
| 2066 | return true; |
| 2067 | } |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 2068 | |
| 2069 | bool ValidateProgramBinaryOES(Context *context, |
| 2070 | GLuint program, |
| 2071 | GLenum binaryFormat, |
| 2072 | const void *binary, |
| 2073 | GLint length) |
| 2074 | { |
| 2075 | if (!context->getExtensions().getProgramBinary) |
| 2076 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2077 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 2078 | return false; |
| 2079 | } |
| 2080 | |
| 2081 | return ValidateProgramBinaryBase(context, program, binaryFormat, binary, length); |
| 2082 | } |
| 2083 | |
| 2084 | bool ValidateGetProgramBinaryOES(Context *context, |
| 2085 | GLuint program, |
| 2086 | GLsizei bufSize, |
| 2087 | GLsizei *length, |
| 2088 | GLenum *binaryFormat, |
| 2089 | void *binary) |
| 2090 | { |
| 2091 | if (!context->getExtensions().getProgramBinary) |
| 2092 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2093 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 2094 | return false; |
| 2095 | } |
| 2096 | |
| 2097 | return ValidateGetProgramBinaryBase(context, program, bufSize, length, binaryFormat, binary); |
| 2098 | } |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2099 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2100 | static bool ValidDebugSource(GLenum source, bool mustBeThirdPartyOrApplication) |
| 2101 | { |
| 2102 | switch (source) |
| 2103 | { |
| 2104 | case GL_DEBUG_SOURCE_API: |
| 2105 | case GL_DEBUG_SOURCE_SHADER_COMPILER: |
| 2106 | case GL_DEBUG_SOURCE_WINDOW_SYSTEM: |
| 2107 | case GL_DEBUG_SOURCE_OTHER: |
| 2108 | // Only THIRD_PARTY and APPLICATION sources are allowed to be manually inserted |
| 2109 | return !mustBeThirdPartyOrApplication; |
| 2110 | |
| 2111 | case GL_DEBUG_SOURCE_THIRD_PARTY: |
| 2112 | case GL_DEBUG_SOURCE_APPLICATION: |
| 2113 | return true; |
| 2114 | |
| 2115 | default: |
| 2116 | return false; |
| 2117 | } |
| 2118 | } |
| 2119 | |
| 2120 | static bool ValidDebugType(GLenum type) |
| 2121 | { |
| 2122 | switch (type) |
| 2123 | { |
| 2124 | case GL_DEBUG_TYPE_ERROR: |
| 2125 | case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: |
| 2126 | case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: |
| 2127 | case GL_DEBUG_TYPE_PERFORMANCE: |
| 2128 | case GL_DEBUG_TYPE_PORTABILITY: |
| 2129 | case GL_DEBUG_TYPE_OTHER: |
| 2130 | case GL_DEBUG_TYPE_MARKER: |
| 2131 | case GL_DEBUG_TYPE_PUSH_GROUP: |
| 2132 | case GL_DEBUG_TYPE_POP_GROUP: |
| 2133 | return true; |
| 2134 | |
| 2135 | default: |
| 2136 | return false; |
| 2137 | } |
| 2138 | } |
| 2139 | |
| 2140 | static bool ValidDebugSeverity(GLenum severity) |
| 2141 | { |
| 2142 | switch (severity) |
| 2143 | { |
| 2144 | case GL_DEBUG_SEVERITY_HIGH: |
| 2145 | case GL_DEBUG_SEVERITY_MEDIUM: |
| 2146 | case GL_DEBUG_SEVERITY_LOW: |
| 2147 | case GL_DEBUG_SEVERITY_NOTIFICATION: |
| 2148 | return true; |
| 2149 | |
| 2150 | default: |
| 2151 | return false; |
| 2152 | } |
| 2153 | } |
| 2154 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2155 | bool ValidateDebugMessageControlKHR(Context *context, |
| 2156 | GLenum source, |
| 2157 | GLenum type, |
| 2158 | GLenum severity, |
| 2159 | GLsizei count, |
| 2160 | const GLuint *ids, |
| 2161 | GLboolean enabled) |
| 2162 | { |
| 2163 | if (!context->getExtensions().debug) |
| 2164 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2165 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2166 | return false; |
| 2167 | } |
| 2168 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2169 | if (!ValidDebugSource(source, false) && source != GL_DONT_CARE) |
| 2170 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2171 | context->validationError(GL_INVALID_ENUM, kInvalidDebugSource); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2172 | return false; |
| 2173 | } |
| 2174 | |
| 2175 | if (!ValidDebugType(type) && type != GL_DONT_CARE) |
| 2176 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2177 | context->validationError(GL_INVALID_ENUM, kInvalidDebugType); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2178 | return false; |
| 2179 | } |
| 2180 | |
| 2181 | if (!ValidDebugSeverity(severity) && severity != GL_DONT_CARE) |
| 2182 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2183 | context->validationError(GL_INVALID_ENUM, kInvalidDebugSeverity); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2184 | return false; |
| 2185 | } |
| 2186 | |
| 2187 | if (count > 0) |
| 2188 | { |
| 2189 | if (source == GL_DONT_CARE || type == GL_DONT_CARE) |
| 2190 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2191 | context->validationError(GL_INVALID_OPERATION, kInvalidDebugSourceType); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2192 | return false; |
| 2193 | } |
| 2194 | |
| 2195 | if (severity != GL_DONT_CARE) |
| 2196 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2197 | context->validationError(GL_INVALID_OPERATION, kInvalidDebugSeverity); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2198 | return false; |
| 2199 | } |
| 2200 | } |
| 2201 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2202 | return true; |
| 2203 | } |
| 2204 | |
| 2205 | bool ValidateDebugMessageInsertKHR(Context *context, |
| 2206 | GLenum source, |
| 2207 | GLenum type, |
| 2208 | GLuint id, |
| 2209 | GLenum severity, |
| 2210 | GLsizei length, |
| 2211 | const GLchar *buf) |
| 2212 | { |
| 2213 | if (!context->getExtensions().debug) |
| 2214 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2215 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2216 | return false; |
| 2217 | } |
| 2218 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2219 | if (!context->getState().getDebug().isOutputEnabled()) |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2220 | { |
| 2221 | // If the DEBUG_OUTPUT state is disabled calls to DebugMessageInsert are discarded and do |
| 2222 | // not generate an error. |
| 2223 | return false; |
| 2224 | } |
| 2225 | |
| 2226 | if (!ValidDebugSeverity(severity)) |
| 2227 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2228 | context->validationError(GL_INVALID_ENUM, kInvalidDebugSource); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2229 | return false; |
| 2230 | } |
| 2231 | |
| 2232 | if (!ValidDebugType(type)) |
| 2233 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2234 | context->validationError(GL_INVALID_ENUM, kInvalidDebugType); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2235 | return false; |
| 2236 | } |
| 2237 | |
| 2238 | if (!ValidDebugSource(source, true)) |
| 2239 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2240 | context->validationError(GL_INVALID_ENUM, kInvalidDebugSource); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2241 | return false; |
| 2242 | } |
| 2243 | |
| 2244 | size_t messageLength = (length < 0) ? strlen(buf) : length; |
| 2245 | if (messageLength > context->getExtensions().maxDebugMessageLength) |
| 2246 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2247 | context->validationError(GL_INVALID_VALUE, kExceedsMaxDebugMessageLength); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2248 | return false; |
| 2249 | } |
| 2250 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2251 | return true; |
| 2252 | } |
| 2253 | |
| 2254 | bool ValidateDebugMessageCallbackKHR(Context *context, |
| 2255 | GLDEBUGPROCKHR callback, |
| 2256 | const void *userParam) |
| 2257 | { |
| 2258 | if (!context->getExtensions().debug) |
| 2259 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2260 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2261 | return false; |
| 2262 | } |
| 2263 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2264 | return true; |
| 2265 | } |
| 2266 | |
| 2267 | bool ValidateGetDebugMessageLogKHR(Context *context, |
| 2268 | GLuint count, |
| 2269 | GLsizei bufSize, |
| 2270 | GLenum *sources, |
| 2271 | GLenum *types, |
| 2272 | GLuint *ids, |
| 2273 | GLenum *severities, |
| 2274 | GLsizei *lengths, |
| 2275 | GLchar *messageLog) |
| 2276 | { |
| 2277 | if (!context->getExtensions().debug) |
| 2278 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2279 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2280 | return false; |
| 2281 | } |
| 2282 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2283 | if (bufSize < 0 && messageLog != nullptr) |
| 2284 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2285 | context->validationError(GL_INVALID_VALUE, kNegativeBufferSize); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2286 | return false; |
| 2287 | } |
| 2288 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2289 | return true; |
| 2290 | } |
| 2291 | |
| 2292 | bool ValidatePushDebugGroupKHR(Context *context, |
| 2293 | GLenum source, |
| 2294 | GLuint id, |
| 2295 | GLsizei length, |
| 2296 | const GLchar *message) |
| 2297 | { |
| 2298 | if (!context->getExtensions().debug) |
| 2299 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2300 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2301 | return false; |
| 2302 | } |
| 2303 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2304 | if (!ValidDebugSource(source, true)) |
| 2305 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2306 | context->validationError(GL_INVALID_ENUM, kInvalidDebugSource); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2307 | return false; |
| 2308 | } |
| 2309 | |
| 2310 | size_t messageLength = (length < 0) ? strlen(message) : length; |
| 2311 | if (messageLength > context->getExtensions().maxDebugMessageLength) |
| 2312 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2313 | context->validationError(GL_INVALID_VALUE, kExceedsMaxDebugMessageLength); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2314 | return false; |
| 2315 | } |
| 2316 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2317 | size_t currentStackSize = context->getState().getDebug().getGroupStackDepth(); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2318 | if (currentStackSize >= context->getExtensions().maxDebugGroupStackDepth) |
| 2319 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2320 | context->validationError(GL_STACK_OVERFLOW, kExceedsMaxDebugGroupStackDepth); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2321 | return false; |
| 2322 | } |
| 2323 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2324 | return true; |
| 2325 | } |
| 2326 | |
| 2327 | bool ValidatePopDebugGroupKHR(Context *context) |
| 2328 | { |
| 2329 | if (!context->getExtensions().debug) |
| 2330 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2331 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2332 | return false; |
| 2333 | } |
| 2334 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2335 | size_t currentStackSize = context->getState().getDebug().getGroupStackDepth(); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2336 | if (currentStackSize <= 1) |
| 2337 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2338 | context->validationError(GL_STACK_UNDERFLOW, kCannotPopDefaultDebugGroup); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2339 | return false; |
| 2340 | } |
| 2341 | |
| 2342 | return true; |
| 2343 | } |
| 2344 | |
| 2345 | static bool ValidateObjectIdentifierAndName(Context *context, GLenum identifier, GLuint name) |
| 2346 | { |
| 2347 | switch (identifier) |
| 2348 | { |
| 2349 | case GL_BUFFER: |
| 2350 | if (context->getBuffer(name) == nullptr) |
| 2351 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2352 | context->validationError(GL_INVALID_VALUE, kInvalidBufferName); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2353 | return false; |
| 2354 | } |
| 2355 | return true; |
| 2356 | |
| 2357 | case GL_SHADER: |
| 2358 | if (context->getShader(name) == nullptr) |
| 2359 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2360 | context->validationError(GL_INVALID_VALUE, kInvalidShaderName); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2361 | return false; |
| 2362 | } |
| 2363 | return true; |
| 2364 | |
| 2365 | case GL_PROGRAM: |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2366 | if (context->getProgramNoResolveLink(name) == nullptr) |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2367 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2368 | context->validationError(GL_INVALID_VALUE, kInvalidProgramName); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2369 | return false; |
| 2370 | } |
| 2371 | return true; |
| 2372 | |
| 2373 | case GL_VERTEX_ARRAY: |
| 2374 | if (context->getVertexArray(name) == nullptr) |
| 2375 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2376 | context->validationError(GL_INVALID_VALUE, kInvalidVertexArrayName); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2377 | return false; |
| 2378 | } |
| 2379 | return true; |
| 2380 | |
| 2381 | case GL_QUERY: |
| 2382 | if (context->getQuery(name) == nullptr) |
| 2383 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2384 | context->validationError(GL_INVALID_VALUE, kInvalidQueryName); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2385 | return false; |
| 2386 | } |
| 2387 | return true; |
| 2388 | |
| 2389 | case GL_TRANSFORM_FEEDBACK: |
| 2390 | if (context->getTransformFeedback(name) == nullptr) |
| 2391 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2392 | context->validationError(GL_INVALID_VALUE, kInvalidTransformFeedbackName); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2393 | return false; |
| 2394 | } |
| 2395 | return true; |
| 2396 | |
| 2397 | case GL_SAMPLER: |
| 2398 | if (context->getSampler(name) == nullptr) |
| 2399 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2400 | context->validationError(GL_INVALID_VALUE, kInvalidSamplerName); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2401 | return false; |
| 2402 | } |
| 2403 | return true; |
| 2404 | |
| 2405 | case GL_TEXTURE: |
| 2406 | if (context->getTexture(name) == nullptr) |
| 2407 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2408 | context->validationError(GL_INVALID_VALUE, kInvalidTextureName); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2409 | return false; |
| 2410 | } |
| 2411 | return true; |
| 2412 | |
| 2413 | case GL_RENDERBUFFER: |
| 2414 | if (context->getRenderbuffer(name) == nullptr) |
| 2415 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2416 | context->validationError(GL_INVALID_VALUE, kInvalidRenderbufferName); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2417 | return false; |
| 2418 | } |
| 2419 | return true; |
| 2420 | |
| 2421 | case GL_FRAMEBUFFER: |
| 2422 | if (context->getFramebuffer(name) == nullptr) |
| 2423 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2424 | context->validationError(GL_INVALID_VALUE, kInvalidFramebufferName); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2425 | return false; |
| 2426 | } |
| 2427 | return true; |
| 2428 | |
| 2429 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2430 | context->validationError(GL_INVALID_ENUM, kInvalidIndentifier); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2431 | return false; |
| 2432 | } |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2433 | } |
| 2434 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 2435 | static bool ValidateLabelLength(Context *context, GLsizei length, const GLchar *label) |
| 2436 | { |
| 2437 | size_t labelLength = 0; |
| 2438 | |
| 2439 | if (length < 0) |
| 2440 | { |
| 2441 | if (label != nullptr) |
| 2442 | { |
| 2443 | labelLength = strlen(label); |
| 2444 | } |
| 2445 | } |
| 2446 | else |
| 2447 | { |
| 2448 | labelLength = static_cast<size_t>(length); |
| 2449 | } |
| 2450 | |
| 2451 | if (labelLength > context->getExtensions().maxLabelLength) |
| 2452 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2453 | context->validationError(GL_INVALID_VALUE, kExceedsMaxLabelLength); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 2454 | return false; |
| 2455 | } |
| 2456 | |
| 2457 | return true; |
| 2458 | } |
| 2459 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2460 | bool ValidateObjectLabelKHR(Context *context, |
| 2461 | GLenum identifier, |
| 2462 | GLuint name, |
| 2463 | GLsizei length, |
| 2464 | const GLchar *label) |
| 2465 | { |
| 2466 | if (!context->getExtensions().debug) |
| 2467 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2468 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2469 | return false; |
| 2470 | } |
| 2471 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2472 | if (!ValidateObjectIdentifierAndName(context, identifier, name)) |
| 2473 | { |
| 2474 | return false; |
| 2475 | } |
| 2476 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 2477 | if (!ValidateLabelLength(context, length, label)) |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2478 | { |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2479 | return false; |
| 2480 | } |
| 2481 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2482 | return true; |
| 2483 | } |
| 2484 | |
| 2485 | bool ValidateGetObjectLabelKHR(Context *context, |
| 2486 | GLenum identifier, |
| 2487 | GLuint name, |
| 2488 | GLsizei bufSize, |
| 2489 | GLsizei *length, |
| 2490 | GLchar *label) |
| 2491 | { |
| 2492 | if (!context->getExtensions().debug) |
| 2493 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2494 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2495 | return false; |
| 2496 | } |
| 2497 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2498 | if (bufSize < 0) |
| 2499 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2500 | context->validationError(GL_INVALID_VALUE, kNegativeBufferSize); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2501 | return false; |
| 2502 | } |
| 2503 | |
| 2504 | if (!ValidateObjectIdentifierAndName(context, identifier, name)) |
| 2505 | { |
| 2506 | return false; |
| 2507 | } |
| 2508 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 2509 | return true; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2510 | } |
| 2511 | |
| 2512 | static bool ValidateObjectPtrName(Context *context, const void *ptr) |
| 2513 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 2514 | if (context->getSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr))) == nullptr) |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2515 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2516 | context->validationError(GL_INVALID_VALUE, kInvalidSyncPointer); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2517 | return false; |
| 2518 | } |
| 2519 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2520 | return true; |
| 2521 | } |
| 2522 | |
| 2523 | bool ValidateObjectPtrLabelKHR(Context *context, |
| 2524 | const void *ptr, |
| 2525 | GLsizei length, |
| 2526 | const GLchar *label) |
| 2527 | { |
| 2528 | if (!context->getExtensions().debug) |
| 2529 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2530 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2531 | return false; |
| 2532 | } |
| 2533 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2534 | if (!ValidateObjectPtrName(context, ptr)) |
| 2535 | { |
| 2536 | return false; |
| 2537 | } |
| 2538 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 2539 | if (!ValidateLabelLength(context, length, label)) |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2540 | { |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2541 | return false; |
| 2542 | } |
| 2543 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2544 | return true; |
| 2545 | } |
| 2546 | |
| 2547 | bool ValidateGetObjectPtrLabelKHR(Context *context, |
| 2548 | const void *ptr, |
| 2549 | GLsizei bufSize, |
| 2550 | GLsizei *length, |
| 2551 | GLchar *label) |
| 2552 | { |
| 2553 | if (!context->getExtensions().debug) |
| 2554 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2555 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2556 | return false; |
| 2557 | } |
| 2558 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2559 | if (bufSize < 0) |
| 2560 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2561 | context->validationError(GL_INVALID_VALUE, kNegativeBufferSize); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2562 | return false; |
| 2563 | } |
| 2564 | |
| 2565 | if (!ValidateObjectPtrName(context, ptr)) |
| 2566 | { |
| 2567 | return false; |
| 2568 | } |
| 2569 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 2570 | return true; |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2571 | } |
| 2572 | |
| 2573 | bool ValidateGetPointervKHR(Context *context, GLenum pname, void **params) |
| 2574 | { |
| 2575 | if (!context->getExtensions().debug) |
| 2576 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2577 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2578 | return false; |
| 2579 | } |
| 2580 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2581 | // TODO: represent this in Context::getQueryParameterInfo. |
| 2582 | switch (pname) |
| 2583 | { |
| 2584 | case GL_DEBUG_CALLBACK_FUNCTION: |
| 2585 | case GL_DEBUG_CALLBACK_USER_PARAM: |
| 2586 | break; |
| 2587 | |
| 2588 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2589 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2590 | return false; |
| 2591 | } |
| 2592 | |
Geoff Lang | e102fee | 2015-12-10 11:23:30 -0500 | [diff] [blame] | 2593 | return true; |
| 2594 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2595 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2596 | bool ValidateGetPointervRobustANGLERobustANGLE(Context *context, |
| 2597 | GLenum pname, |
| 2598 | GLsizei bufSize, |
| 2599 | GLsizei *length, |
| 2600 | void **params) |
| 2601 | { |
| 2602 | UNIMPLEMENTED(); |
| 2603 | return false; |
| 2604 | } |
| 2605 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2606 | bool ValidateBlitFramebufferANGLE(Context *context, |
| 2607 | GLint srcX0, |
| 2608 | GLint srcY0, |
| 2609 | GLint srcX1, |
| 2610 | GLint srcY1, |
| 2611 | GLint dstX0, |
| 2612 | GLint dstY0, |
| 2613 | GLint dstX1, |
| 2614 | GLint dstY1, |
| 2615 | GLbitfield mask, |
| 2616 | GLenum filter) |
| 2617 | { |
| 2618 | if (!context->getExtensions().framebufferBlit) |
| 2619 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2620 | context->validationError(GL_INVALID_OPERATION, kBlitExtensionNotAvailable); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2621 | return false; |
| 2622 | } |
| 2623 | |
| 2624 | if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0) |
| 2625 | { |
| 2626 | // TODO(jmadill): Determine if this should be available on other implementations. |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2627 | context->validationError(GL_INVALID_OPERATION, kBlitExtensionScaleOrFlip); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2628 | return false; |
| 2629 | } |
| 2630 | |
| 2631 | if (filter == GL_LINEAR) |
| 2632 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2633 | context->validationError(GL_INVALID_ENUM, kBlitExtensionLinear); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2634 | return false; |
| 2635 | } |
| 2636 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2637 | Framebuffer *readFramebuffer = context->getState().getReadFramebuffer(); |
| 2638 | Framebuffer *drawFramebuffer = context->getState().getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2639 | |
| 2640 | if (mask & GL_COLOR_BUFFER_BIT) |
| 2641 | { |
| 2642 | const FramebufferAttachment *readColorAttachment = readFramebuffer->getReadColorbuffer(); |
| 2643 | const FramebufferAttachment *drawColorAttachment = drawFramebuffer->getFirstColorbuffer(); |
| 2644 | |
| 2645 | if (readColorAttachment && drawColorAttachment) |
| 2646 | { |
| 2647 | if (!(readColorAttachment->type() == GL_TEXTURE && |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 2648 | readColorAttachment->getTextureImageIndex().getType() == TextureType::_2D) && |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2649 | readColorAttachment->type() != GL_RENDERBUFFER && |
| 2650 | readColorAttachment->type() != GL_FRAMEBUFFER_DEFAULT) |
| 2651 | { |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 2652 | context->validationError(GL_INVALID_OPERATION, |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2653 | kBlitExtensionFromInvalidAttachmentType); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2654 | return false; |
| 2655 | } |
| 2656 | |
Geoff Lang | a15472a | 2015-08-11 11:48:03 -0400 | [diff] [blame] | 2657 | for (size_t drawbufferIdx = 0; |
| 2658 | drawbufferIdx < drawFramebuffer->getDrawbufferStateCount(); ++drawbufferIdx) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2659 | { |
Geoff Lang | a15472a | 2015-08-11 11:48:03 -0400 | [diff] [blame] | 2660 | const FramebufferAttachment *attachment = |
| 2661 | drawFramebuffer->getDrawBuffer(drawbufferIdx); |
| 2662 | if (attachment) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2663 | { |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2664 | if (!(attachment->type() == GL_TEXTURE && |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 2665 | attachment->getTextureImageIndex().getType() == TextureType::_2D) && |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2666 | attachment->type() != GL_RENDERBUFFER && |
| 2667 | attachment->type() != GL_FRAMEBUFFER_DEFAULT) |
| 2668 | { |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 2669 | context->validationError(GL_INVALID_OPERATION, |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2670 | kBlitExtensionToInvalidAttachmentType); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2671 | return false; |
| 2672 | } |
| 2673 | |
| 2674 | // Return an error if the destination formats do not match |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 2675 | if (!Format::EquivalentForBlit(attachment->getFormat(), |
| 2676 | readColorAttachment->getFormat())) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2677 | { |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 2678 | context->validationError(GL_INVALID_OPERATION, |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2679 | kBlitExtensionFormatMismatch); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2680 | return false; |
| 2681 | } |
| 2682 | } |
| 2683 | } |
| 2684 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 2685 | GLint samples = readFramebuffer->getSamples(context); |
Jamie Madill | e98b1b5 | 2018-03-08 09:47:23 -0500 | [diff] [blame] | 2686 | if (samples != 0 && |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2687 | IsPartialBlit(context, readColorAttachment, drawColorAttachment, srcX0, srcY0, |
| 2688 | srcX1, srcY1, dstX0, dstY0, dstX1, dstY1)) |
| 2689 | { |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 2690 | context->validationError(GL_INVALID_OPERATION, |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2691 | kBlitExtensionMultisampledWholeBufferBlit); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2692 | return false; |
| 2693 | } |
| 2694 | } |
| 2695 | } |
| 2696 | |
| 2697 | GLenum masks[] = {GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT}; |
| 2698 | GLenum attachments[] = {GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT}; |
| 2699 | for (size_t i = 0; i < 2; i++) |
| 2700 | { |
| 2701 | if (mask & masks[i]) |
| 2702 | { |
| 2703 | const FramebufferAttachment *readBuffer = |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 2704 | readFramebuffer->getAttachment(context, attachments[i]); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2705 | const FramebufferAttachment *drawBuffer = |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 2706 | drawFramebuffer->getAttachment(context, attachments[i]); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2707 | |
| 2708 | if (readBuffer && drawBuffer) |
| 2709 | { |
| 2710 | if (IsPartialBlit(context, readBuffer, drawBuffer, srcX0, srcY0, srcX1, srcY1, |
| 2711 | dstX0, dstY0, dstX1, dstY1)) |
| 2712 | { |
| 2713 | // only whole-buffer copies are permitted |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 2714 | context->validationError(GL_INVALID_OPERATION, |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2715 | kBlitExtensionDepthStencilWholeBufferBlit); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2716 | return false; |
| 2717 | } |
| 2718 | |
| 2719 | if (readBuffer->getSamples() != 0 || drawBuffer->getSamples() != 0) |
| 2720 | { |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 2721 | context->validationError(GL_INVALID_OPERATION, |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2722 | kBlitExtensionMultisampledDepthOrStencil); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2723 | return false; |
| 2724 | } |
| 2725 | } |
| 2726 | } |
| 2727 | } |
| 2728 | |
| 2729 | return ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, |
| 2730 | dstX1, dstY1, mask, filter); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 2731 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2732 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 2733 | bool ValidateClear(Context *context, GLbitfield mask) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2734 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2735 | Framebuffer *fbo = context->getState().getDrawFramebuffer(); |
Olli Etuaho | 94c91a9 | 2018-07-19 15:10:24 +0300 | [diff] [blame] | 2736 | const Extensions &extensions = context->getExtensions(); |
Jamie Madill | e98b1b5 | 2018-03-08 09:47:23 -0500 | [diff] [blame] | 2737 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 2738 | if (!ValidateFramebufferComplete(context, fbo)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2739 | { |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2740 | return false; |
| 2741 | } |
| 2742 | |
| 2743 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) |
| 2744 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2745 | context->validationError(GL_INVALID_VALUE, kInvalidClearMask); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2746 | return false; |
| 2747 | } |
| 2748 | |
Olli Etuaho | 94c91a9 | 2018-07-19 15:10:24 +0300 | [diff] [blame] | 2749 | if (extensions.webglCompatibility && (mask & GL_COLOR_BUFFER_BIT) != 0) |
Geoff Lang | 76e6565 | 2017-03-27 14:58:02 -0400 | [diff] [blame] | 2750 | { |
| 2751 | constexpr GLenum validComponentTypes[] = {GL_FLOAT, GL_UNSIGNED_NORMALIZED, |
| 2752 | GL_SIGNED_NORMALIZED}; |
| 2753 | |
Corentin Wallez | 59c4159 | 2017-07-11 13:19:54 -0400 | [diff] [blame] | 2754 | for (GLuint drawBufferIdx = 0; drawBufferIdx < fbo->getDrawbufferStateCount(); |
Geoff Lang | 76e6565 | 2017-03-27 14:58:02 -0400 | [diff] [blame] | 2755 | drawBufferIdx++) |
| 2756 | { |
| 2757 | if (!ValidateWebGLFramebufferAttachmentClearType( |
| 2758 | context, drawBufferIdx, validComponentTypes, ArraySize(validComponentTypes))) |
| 2759 | { |
| 2760 | return false; |
| 2761 | } |
| 2762 | } |
| 2763 | } |
| 2764 | |
Mingyu Hu | ebab670 | 2019-04-19 14:36:45 -0700 | [diff] [blame] | 2765 | if ((extensions.multiview || extensions.multiview2) && extensions.disjointTimerQuery) |
Olli Etuaho | 94c91a9 | 2018-07-19 15:10:24 +0300 | [diff] [blame] | 2766 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2767 | const State &state = context->getState(); |
Olli Etuaho | 94c91a9 | 2018-07-19 15:10:24 +0300 | [diff] [blame] | 2768 | Framebuffer *framebuffer = state.getDrawFramebuffer(); |
| 2769 | if (framebuffer->getNumViews() > 1 && state.isQueryActive(QueryType::TimeElapsed)) |
| 2770 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2771 | context->validationError(GL_INVALID_OPERATION, kMultiviewTimerQuery); |
Olli Etuaho | 94c91a9 | 2018-07-19 15:10:24 +0300 | [diff] [blame] | 2772 | return false; |
| 2773 | } |
| 2774 | } |
| 2775 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2776 | return true; |
| 2777 | } |
| 2778 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 2779 | bool ValidateDrawBuffersEXT(Context *context, GLsizei n, const GLenum *bufs) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2780 | { |
| 2781 | if (!context->getExtensions().drawBuffers) |
| 2782 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2783 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2784 | return false; |
| 2785 | } |
| 2786 | |
| 2787 | return ValidateDrawBuffersBase(context, n, bufs); |
| 2788 | } |
| 2789 | |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2790 | bool ValidateTexImage2D(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2791 | TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2792 | GLint level, |
| 2793 | GLint internalformat, |
| 2794 | GLsizei width, |
| 2795 | GLsizei height, |
| 2796 | GLint border, |
| 2797 | GLenum format, |
| 2798 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2799 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2800 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2801 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2802 | { |
| 2803 | return ValidateES2TexImageParameters(context, target, level, internalformat, false, false, |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 2804 | 0, 0, width, height, border, format, type, -1, pixels); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2805 | } |
| 2806 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2807 | ASSERT(context->getClientMajorVersion() >= 3); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2808 | return ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false, 0, |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 2809 | 0, 0, width, height, 1, border, format, type, -1, |
| 2810 | pixels); |
| 2811 | } |
| 2812 | |
Brandon Jones | 416aaf9 | 2018-04-10 08:10:16 -0700 | [diff] [blame] | 2813 | bool ValidateTexImage2DRobustANGLE(Context *context, |
| 2814 | TextureTarget target, |
| 2815 | GLint level, |
| 2816 | GLint internalformat, |
| 2817 | GLsizei width, |
| 2818 | GLsizei height, |
| 2819 | GLint border, |
| 2820 | GLenum format, |
| 2821 | GLenum type, |
| 2822 | GLsizei bufSize, |
| 2823 | const void *pixels) |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 2824 | { |
| 2825 | if (!ValidateRobustEntryPoint(context, bufSize)) |
| 2826 | { |
| 2827 | return false; |
| 2828 | } |
| 2829 | |
| 2830 | if (context->getClientMajorVersion() < 3) |
| 2831 | { |
| 2832 | return ValidateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 2833 | 0, 0, width, height, border, format, type, bufSize, |
| 2834 | pixels); |
| 2835 | } |
| 2836 | |
| 2837 | ASSERT(context->getClientMajorVersion() >= 3); |
| 2838 | return ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false, 0, |
| 2839 | 0, 0, width, height, 1, border, format, type, bufSize, |
| 2840 | pixels); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2841 | } |
| 2842 | |
| 2843 | bool ValidateTexSubImage2D(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2844 | TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2845 | GLint level, |
| 2846 | GLint xoffset, |
| 2847 | GLint yoffset, |
| 2848 | GLsizei width, |
| 2849 | GLsizei height, |
| 2850 | GLenum format, |
| 2851 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2852 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2853 | { |
| 2854 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2855 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2856 | { |
| 2857 | return ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, xoffset, |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 2858 | yoffset, width, height, 0, format, type, -1, pixels); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2859 | } |
| 2860 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2861 | ASSERT(context->getClientMajorVersion() >= 3); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2862 | return ValidateES3TexImage2DParameters(context, target, level, GL_NONE, false, true, xoffset, |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 2863 | yoffset, 0, width, height, 1, 0, format, type, -1, |
| 2864 | pixels); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2865 | } |
| 2866 | |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 2867 | bool ValidateTexSubImage2DRobustANGLE(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2868 | TextureTarget target, |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 2869 | GLint level, |
| 2870 | GLint xoffset, |
| 2871 | GLint yoffset, |
| 2872 | GLsizei width, |
| 2873 | GLsizei height, |
| 2874 | GLenum format, |
| 2875 | GLenum type, |
| 2876 | GLsizei bufSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2877 | const void *pixels) |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 2878 | { |
| 2879 | if (!ValidateRobustEntryPoint(context, bufSize)) |
| 2880 | { |
| 2881 | return false; |
| 2882 | } |
| 2883 | |
| 2884 | if (context->getClientMajorVersion() < 3) |
| 2885 | { |
| 2886 | return ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, xoffset, |
| 2887 | yoffset, width, height, 0, format, type, bufSize, |
| 2888 | pixels); |
| 2889 | } |
| 2890 | |
| 2891 | ASSERT(context->getClientMajorVersion() >= 3); |
| 2892 | return ValidateES3TexImage2DParameters(context, target, level, GL_NONE, false, true, xoffset, |
| 2893 | yoffset, 0, width, height, 1, 0, format, type, bufSize, |
| 2894 | pixels); |
| 2895 | } |
| 2896 | |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2897 | bool ValidateCompressedTexImage2D(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2898 | TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2899 | GLint level, |
| 2900 | GLenum internalformat, |
| 2901 | GLsizei width, |
| 2902 | GLsizei height, |
| 2903 | GLint border, |
| 2904 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2905 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2906 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2907 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2908 | { |
| 2909 | if (!ValidateES2TexImageParameters(context, target, level, internalformat, true, false, 0, |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 2910 | 0, width, height, border, GL_NONE, GL_NONE, -1, data)) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2911 | { |
| 2912 | return false; |
| 2913 | } |
| 2914 | } |
| 2915 | else |
| 2916 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2917 | ASSERT(context->getClientMajorVersion() >= 3); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2918 | if (!ValidateES3TexImage2DParameters(context, target, level, internalformat, true, false, 0, |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 2919 | 0, 0, width, height, 1, border, GL_NONE, GL_NONE, -1, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2920 | data)) |
| 2921 | { |
| 2922 | return false; |
| 2923 | } |
| 2924 | } |
| 2925 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 2926 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(internalformat); |
Jamie Madill | ca2ff38 | 2018-07-11 09:01:17 -0400 | [diff] [blame] | 2927 | |
| 2928 | GLuint blockSize = 0; |
| 2929 | if (!formatInfo.computeCompressedImageSize(gl::Extents(width, height, 1), &blockSize)) |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 2930 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2931 | context->validationError(GL_INVALID_OPERATION, kIntegerOverflow); |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 2932 | return false; |
| 2933 | } |
| 2934 | |
Jamie Madill | ca2ff38 | 2018-07-11 09:01:17 -0400 | [diff] [blame] | 2935 | if (imageSize < 0 || static_cast<GLuint>(imageSize) != blockSize) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2936 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 2937 | context->validationError(GL_INVALID_VALUE, kCompressedTextureDimensionsMustMatchData); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2938 | return false; |
| 2939 | } |
| 2940 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2941 | if (target == TextureTarget::Rectangle) |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 2942 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 2943 | context->validationError(GL_INVALID_ENUM, kRectangleTextureCompressed); |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 2944 | return false; |
| 2945 | } |
| 2946 | |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2947 | return true; |
| 2948 | } |
| 2949 | |
Corentin Wallez | b293160 | 2017-04-11 15:58:57 -0400 | [diff] [blame] | 2950 | bool ValidateCompressedTexImage2DRobustANGLE(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2951 | TextureTarget target, |
Corentin Wallez | b293160 | 2017-04-11 15:58:57 -0400 | [diff] [blame] | 2952 | GLint level, |
| 2953 | GLenum internalformat, |
| 2954 | GLsizei width, |
| 2955 | GLsizei height, |
| 2956 | GLint border, |
| 2957 | GLsizei imageSize, |
| 2958 | GLsizei dataSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2959 | const void *data) |
Corentin Wallez | b293160 | 2017-04-11 15:58:57 -0400 | [diff] [blame] | 2960 | { |
| 2961 | if (!ValidateRobustCompressedTexImageBase(context, imageSize, dataSize)) |
| 2962 | { |
| 2963 | return false; |
| 2964 | } |
| 2965 | |
| 2966 | return ValidateCompressedTexImage2D(context, target, level, internalformat, width, height, |
| 2967 | border, imageSize, data); |
| 2968 | } |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2969 | |
Corentin Wallez | b293160 | 2017-04-11 15:58:57 -0400 | [diff] [blame] | 2970 | bool ValidateCompressedTexSubImage2DRobustANGLE(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2971 | TextureTarget target, |
Corentin Wallez | b293160 | 2017-04-11 15:58:57 -0400 | [diff] [blame] | 2972 | GLint level, |
| 2973 | GLint xoffset, |
| 2974 | GLint yoffset, |
| 2975 | GLsizei width, |
| 2976 | GLsizei height, |
| 2977 | GLenum format, |
| 2978 | GLsizei imageSize, |
| 2979 | GLsizei dataSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2980 | const void *data) |
Corentin Wallez | b293160 | 2017-04-11 15:58:57 -0400 | [diff] [blame] | 2981 | { |
| 2982 | if (!ValidateRobustCompressedTexImageBase(context, imageSize, dataSize)) |
| 2983 | { |
| 2984 | return false; |
| 2985 | } |
| 2986 | |
| 2987 | return ValidateCompressedTexSubImage2D(context, target, level, xoffset, yoffset, width, height, |
| 2988 | format, imageSize, data); |
| 2989 | } |
| 2990 | |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2991 | bool ValidateCompressedTexSubImage2D(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2992 | TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2993 | GLint level, |
| 2994 | GLint xoffset, |
| 2995 | GLint yoffset, |
| 2996 | GLsizei width, |
| 2997 | GLsizei height, |
| 2998 | GLenum format, |
| 2999 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3000 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3001 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3002 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3003 | { |
| 3004 | if (!ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true, xoffset, |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 3005 | yoffset, width, height, 0, format, GL_NONE, -1, data)) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3006 | { |
| 3007 | return false; |
| 3008 | } |
| 3009 | } |
| 3010 | else |
| 3011 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3012 | ASSERT(context->getClientMajorVersion() >= 3); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3013 | if (!ValidateES3TexImage2DParameters(context, target, level, GL_NONE, true, true, xoffset, |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 3014 | yoffset, 0, width, height, 1, 0, format, GL_NONE, -1, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3015 | data)) |
| 3016 | { |
| 3017 | return false; |
| 3018 | } |
| 3019 | } |
| 3020 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3021 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(format); |
Jamie Madill | ca2ff38 | 2018-07-11 09:01:17 -0400 | [diff] [blame] | 3022 | GLuint blockSize = 0; |
| 3023 | if (!formatInfo.computeCompressedImageSize(gl::Extents(width, height, 1), &blockSize)) |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 3024 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3025 | context->validationError(GL_INVALID_OPERATION, kIntegerOverflow); |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 3026 | return false; |
| 3027 | } |
| 3028 | |
Jamie Madill | ca2ff38 | 2018-07-11 09:01:17 -0400 | [diff] [blame] | 3029 | if (imageSize < 0 || static_cast<GLuint>(imageSize) != blockSize) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3030 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3031 | context->validationError(GL_INVALID_VALUE, kInvalidCompressedImageSize); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3032 | return false; |
| 3033 | } |
| 3034 | |
| 3035 | return true; |
| 3036 | } |
| 3037 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 3038 | bool ValidateGetBufferPointervOES(Context *context, |
| 3039 | BufferBinding target, |
| 3040 | GLenum pname, |
| 3041 | void **params) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3042 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3043 | if (!context->getExtensions().mapBuffer) |
| 3044 | { |
| 3045 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3046 | return false; |
| 3047 | } |
| 3048 | |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 3049 | return ValidateGetBufferPointervBase(context, target, pname, nullptr, params); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3050 | } |
| 3051 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 3052 | bool ValidateMapBufferOES(Context *context, BufferBinding target, GLenum access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3053 | { |
| 3054 | if (!context->getExtensions().mapBuffer) |
| 3055 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3056 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3057 | return false; |
| 3058 | } |
| 3059 | |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3060 | if (!context->isValidBufferBinding(target)) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3061 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3062 | context->validationError(GL_INVALID_ENUM, kInvalidBufferTypes); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3063 | return false; |
| 3064 | } |
| 3065 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3066 | Buffer *buffer = context->getState().getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3067 | |
| 3068 | if (buffer == nullptr) |
| 3069 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3070 | context->validationError(GL_INVALID_OPERATION, kBufferNotMappable); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3071 | return false; |
| 3072 | } |
| 3073 | |
| 3074 | if (access != GL_WRITE_ONLY_OES) |
| 3075 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3076 | context->validationError(GL_INVALID_ENUM, kInvalidAccessBits); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3077 | return false; |
| 3078 | } |
| 3079 | |
| 3080 | if (buffer->isMapped()) |
| 3081 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3082 | context->validationError(GL_INVALID_OPERATION, kBufferAlreadyMapped); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3083 | return false; |
| 3084 | } |
| 3085 | |
Geoff Lang | 79f7104 | 2017-08-14 16:43:43 -0400 | [diff] [blame] | 3086 | return ValidateMapBufferBase(context, target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3087 | } |
| 3088 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 3089 | bool ValidateUnmapBufferOES(Context *context, BufferBinding target) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3090 | { |
| 3091 | if (!context->getExtensions().mapBuffer) |
| 3092 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3093 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3094 | return false; |
| 3095 | } |
| 3096 | |
| 3097 | return ValidateUnmapBufferBase(context, target); |
| 3098 | } |
| 3099 | |
| 3100 | bool ValidateMapBufferRangeEXT(Context *context, |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 3101 | BufferBinding target, |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3102 | GLintptr offset, |
| 3103 | GLsizeiptr length, |
| 3104 | GLbitfield access) |
| 3105 | { |
| 3106 | if (!context->getExtensions().mapBufferRange) |
| 3107 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3108 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3109 | return false; |
| 3110 | } |
| 3111 | |
| 3112 | return ValidateMapBufferRangeBase(context, target, offset, length, access); |
| 3113 | } |
| 3114 | |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3115 | bool ValidateBufferStorageMemEXT(Context *context, |
| 3116 | TextureType target, |
| 3117 | GLsizeiptr size, |
| 3118 | GLuint memory, |
| 3119 | GLuint64 offset) |
| 3120 | { |
| 3121 | if (!context->getExtensions().memoryObject) |
| 3122 | { |
| 3123 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3124 | return false; |
| 3125 | } |
| 3126 | |
| 3127 | UNIMPLEMENTED(); |
| 3128 | return false; |
| 3129 | } |
| 3130 | |
| 3131 | bool ValidateCreateMemoryObjectsEXT(Context *context, GLsizei n, GLuint *memoryObjects) |
| 3132 | { |
| 3133 | if (!context->getExtensions().memoryObject) |
| 3134 | { |
| 3135 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3136 | return false; |
| 3137 | } |
| 3138 | |
Michael Spang | fb201c5 | 2019-04-03 14:57:35 -0400 | [diff] [blame] | 3139 | return ValidateGenOrDelete(context, n); |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3140 | } |
| 3141 | |
| 3142 | bool ValidateDeleteMemoryObjectsEXT(Context *context, GLsizei n, const GLuint *memoryObjects) |
| 3143 | { |
| 3144 | if (!context->getExtensions().memoryObject) |
| 3145 | { |
| 3146 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3147 | return false; |
| 3148 | } |
| 3149 | |
Michael Spang | fb201c5 | 2019-04-03 14:57:35 -0400 | [diff] [blame] | 3150 | return ValidateGenOrDelete(context, n); |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3151 | } |
| 3152 | |
| 3153 | bool ValidateGetMemoryObjectParameterivEXT(Context *context, |
| 3154 | GLuint memoryObject, |
| 3155 | GLenum pname, |
| 3156 | GLint *params) |
| 3157 | { |
| 3158 | if (!context->getExtensions().memoryObject) |
| 3159 | { |
| 3160 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3161 | return false; |
| 3162 | } |
| 3163 | |
| 3164 | UNIMPLEMENTED(); |
| 3165 | return false; |
| 3166 | } |
| 3167 | |
| 3168 | bool ValidateGetUnsignedBytevEXT(Context *context, GLenum pname, GLubyte *data) |
| 3169 | { |
| 3170 | if (!context->getExtensions().memoryObject && !context->getExtensions().semaphore) |
| 3171 | { |
| 3172 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3173 | return false; |
| 3174 | } |
| 3175 | |
| 3176 | UNIMPLEMENTED(); |
| 3177 | return false; |
| 3178 | } |
| 3179 | |
| 3180 | bool ValidateGetUnsignedBytei_vEXT(Context *context, GLenum target, GLuint index, GLubyte *data) |
| 3181 | { |
| 3182 | if (!context->getExtensions().memoryObject && !context->getExtensions().semaphore) |
| 3183 | { |
| 3184 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3185 | return false; |
| 3186 | } |
| 3187 | |
| 3188 | UNIMPLEMENTED(); |
| 3189 | return false; |
| 3190 | } |
| 3191 | |
| 3192 | bool ValidateIsMemoryObjectEXT(Context *context, GLuint memoryObject) |
| 3193 | { |
| 3194 | if (!context->getExtensions().memoryObject) |
| 3195 | { |
| 3196 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3197 | return false; |
| 3198 | } |
| 3199 | |
Michael Spang | fb201c5 | 2019-04-03 14:57:35 -0400 | [diff] [blame] | 3200 | return true; |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3201 | } |
| 3202 | |
| 3203 | bool ValidateMemoryObjectParameterivEXT(Context *context, |
| 3204 | GLuint memoryObject, |
| 3205 | GLenum pname, |
| 3206 | const GLint *params) |
| 3207 | { |
| 3208 | if (!context->getExtensions().memoryObject) |
| 3209 | { |
| 3210 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3211 | return false; |
| 3212 | } |
| 3213 | |
| 3214 | UNIMPLEMENTED(); |
| 3215 | return false; |
| 3216 | } |
| 3217 | |
| 3218 | bool ValidateTexStorageMem2DEXT(Context *context, |
| 3219 | TextureType target, |
| 3220 | GLsizei levels, |
| 3221 | GLenum internalFormat, |
| 3222 | GLsizei width, |
| 3223 | GLsizei height, |
| 3224 | GLuint memory, |
| 3225 | GLuint64 offset) |
| 3226 | { |
| 3227 | if (!context->getExtensions().memoryObject) |
| 3228 | { |
| 3229 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3230 | return false; |
| 3231 | } |
| 3232 | |
Michael Spang | f02a767 | 2019-04-09 18:45:23 -0400 | [diff] [blame] | 3233 | if (context->getClientMajorVersion() < 3) |
| 3234 | { |
| 3235 | return ValidateES2TexStorageParameters(context, target, levels, internalFormat, width, |
| 3236 | height); |
| 3237 | } |
| 3238 | |
| 3239 | ASSERT(context->getClientMajorVersion() >= 3); |
| 3240 | return ValidateES3TexStorage2DParameters(context, target, levels, internalFormat, width, height, |
| 3241 | 1); |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3242 | } |
| 3243 | |
| 3244 | bool ValidateTexStorageMem3DEXT(Context *context, |
| 3245 | TextureType target, |
| 3246 | GLsizei levels, |
| 3247 | GLenum internalFormat, |
| 3248 | GLsizei width, |
| 3249 | GLsizei height, |
| 3250 | GLsizei depth, |
| 3251 | GLuint memory, |
| 3252 | GLuint64 offset) |
| 3253 | { |
| 3254 | if (!context->getExtensions().memoryObject) |
| 3255 | { |
| 3256 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3257 | return false; |
| 3258 | } |
| 3259 | |
| 3260 | UNIMPLEMENTED(); |
| 3261 | return false; |
| 3262 | } |
| 3263 | |
Michael Spang | 9de3ddb | 2019-04-03 16:23:40 -0400 | [diff] [blame] | 3264 | bool ValidateImportMemoryFdEXT(Context *context, |
| 3265 | GLuint memory, |
| 3266 | GLuint64 size, |
Michael Spang | e0da9ce | 2019-04-16 14:34:51 -0400 | [diff] [blame] | 3267 | HandleType handleType, |
Michael Spang | 9de3ddb | 2019-04-03 16:23:40 -0400 | [diff] [blame] | 3268 | GLint fd) |
| 3269 | { |
| 3270 | if (!context->getExtensions().memoryObjectFd) |
| 3271 | { |
| 3272 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3273 | return false; |
| 3274 | } |
| 3275 | |
Michael Spang | 3b2c6bf | 2019-04-16 17:19:50 -0400 | [diff] [blame] | 3276 | switch (handleType) |
| 3277 | { |
| 3278 | case HandleType::OpaqueFd: |
| 3279 | break; |
| 3280 | default: |
| 3281 | context->validationError(GL_INVALID_ENUM, kInvalidHandleType); |
| 3282 | return false; |
| 3283 | } |
| 3284 | |
| 3285 | return true; |
Michael Spang | 9de3ddb | 2019-04-03 16:23:40 -0400 | [diff] [blame] | 3286 | } |
| 3287 | |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3288 | bool ValidateDeleteSemaphoresEXT(Context *context, GLsizei n, const GLuint *semaphores) |
| 3289 | { |
| 3290 | if (!context->getExtensions().semaphore) |
| 3291 | { |
| 3292 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3293 | return false; |
| 3294 | } |
| 3295 | |
Michael Spang | 5093ba6 | 2019-05-14 17:36:36 -0400 | [diff] [blame] | 3296 | return ValidateGenOrDelete(context, n); |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3297 | } |
| 3298 | |
| 3299 | bool ValidateGenSemaphoresEXT(Context *context, GLsizei n, GLuint *semaphores) |
| 3300 | { |
| 3301 | if (!context->getExtensions().semaphore) |
| 3302 | { |
| 3303 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3304 | return false; |
| 3305 | } |
| 3306 | |
Michael Spang | 5093ba6 | 2019-05-14 17:36:36 -0400 | [diff] [blame] | 3307 | return ValidateGenOrDelete(context, n); |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3308 | } |
| 3309 | |
| 3310 | bool ValidateGetSemaphoreParameterui64vEXT(Context *context, |
| 3311 | GLuint semaphore, |
| 3312 | GLenum pname, |
| 3313 | GLuint64 *params) |
| 3314 | { |
| 3315 | if (!context->getExtensions().semaphore) |
| 3316 | { |
| 3317 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3318 | return false; |
| 3319 | } |
| 3320 | |
| 3321 | UNIMPLEMENTED(); |
| 3322 | return false; |
| 3323 | } |
| 3324 | |
| 3325 | bool ValidateIsSemaphoreEXT(Context *context, GLuint semaphore) |
| 3326 | { |
| 3327 | if (!context->getExtensions().semaphore) |
| 3328 | { |
| 3329 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3330 | return false; |
| 3331 | } |
| 3332 | |
Michael Spang | 5093ba6 | 2019-05-14 17:36:36 -0400 | [diff] [blame] | 3333 | return true; |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3334 | } |
| 3335 | |
| 3336 | bool ValidateSemaphoreParameterui64vEXT(Context *context, |
| 3337 | GLuint semaphore, |
| 3338 | GLenum pname, |
| 3339 | const GLuint64 *params) |
| 3340 | { |
| 3341 | if (!context->getExtensions().semaphore) |
| 3342 | { |
| 3343 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3344 | return false; |
| 3345 | } |
| 3346 | |
| 3347 | UNIMPLEMENTED(); |
| 3348 | return false; |
| 3349 | } |
| 3350 | |
| 3351 | bool ValidateSignalSemaphoreEXT(Context *context, |
| 3352 | GLuint semaphore, |
| 3353 | GLuint numBufferBarriers, |
| 3354 | const GLuint *buffers, |
| 3355 | GLuint numTextureBarriers, |
| 3356 | const GLuint *textures, |
| 3357 | const GLenum *dstLayouts) |
| 3358 | { |
| 3359 | if (!context->getExtensions().semaphore) |
| 3360 | { |
| 3361 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3362 | return false; |
| 3363 | } |
| 3364 | |
Michael Spang | ab6a59b | 2019-05-21 21:26:26 -0400 | [diff] [blame^] | 3365 | for (GLuint i = 0; i < numTextureBarriers; ++i) |
| 3366 | { |
| 3367 | if (!IsValidImageLayout(FromGLenum<ImageLayout>(dstLayouts[i]))) |
| 3368 | { |
| 3369 | context->validationError(GL_INVALID_ENUM, kInvalidImageLayout); |
| 3370 | return false; |
| 3371 | } |
| 3372 | } |
| 3373 | |
| 3374 | return true; |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3375 | } |
| 3376 | |
| 3377 | bool ValidateWaitSemaphoreEXT(Context *context, |
| 3378 | GLuint semaphore, |
| 3379 | GLuint numBufferBarriers, |
| 3380 | const GLuint *buffers, |
| 3381 | GLuint numTextureBarriers, |
| 3382 | const GLuint *textures, |
| 3383 | const GLenum *srcLayouts) |
| 3384 | { |
| 3385 | if (!context->getExtensions().semaphore) |
| 3386 | { |
| 3387 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3388 | return false; |
| 3389 | } |
| 3390 | |
Michael Spang | ab6a59b | 2019-05-21 21:26:26 -0400 | [diff] [blame^] | 3391 | for (GLuint i = 0; i < numTextureBarriers; ++i) |
| 3392 | { |
| 3393 | if (!IsValidImageLayout(FromGLenum<ImageLayout>(srcLayouts[i]))) |
| 3394 | { |
| 3395 | context->validationError(GL_INVALID_ENUM, kInvalidImageLayout); |
| 3396 | return false; |
| 3397 | } |
| 3398 | } |
| 3399 | |
| 3400 | return true; |
Michael Spang | 7a8c3e5 | 2019-04-03 14:49:57 -0400 | [diff] [blame] | 3401 | } |
| 3402 | |
Michael Spang | e0da9ce | 2019-04-16 14:34:51 -0400 | [diff] [blame] | 3403 | bool ValidateImportSemaphoreFdEXT(Context *context, |
| 3404 | GLuint semaphore, |
| 3405 | HandleType handleType, |
| 3406 | GLint fd) |
Michael Spang | 9de3ddb | 2019-04-03 16:23:40 -0400 | [diff] [blame] | 3407 | { |
| 3408 | if (!context->getExtensions().semaphoreFd) |
| 3409 | { |
| 3410 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 3411 | return false; |
| 3412 | } |
| 3413 | |
Michael Spang | 6bb193c | 2019-05-22 16:32:21 -0400 | [diff] [blame] | 3414 | switch (handleType) |
| 3415 | { |
| 3416 | case HandleType::OpaqueFd: |
| 3417 | break; |
| 3418 | default: |
| 3419 | context->validationError(GL_INVALID_ENUM, kInvalidHandleType); |
| 3420 | return false; |
| 3421 | } |
| 3422 | |
| 3423 | return true; |
Michael Spang | 9de3ddb | 2019-04-03 16:23:40 -0400 | [diff] [blame] | 3424 | } |
| 3425 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 3426 | bool ValidateMapBufferBase(Context *context, BufferBinding target) |
Geoff Lang | 79f7104 | 2017-08-14 16:43:43 -0400 | [diff] [blame] | 3427 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3428 | Buffer *buffer = context->getState().getTargetBuffer(target); |
Geoff Lang | 79f7104 | 2017-08-14 16:43:43 -0400 | [diff] [blame] | 3429 | ASSERT(buffer != nullptr); |
| 3430 | |
| 3431 | // Check if this buffer is currently being used as a transform feedback output buffer |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3432 | TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback(); |
Geoff Lang | 79f7104 | 2017-08-14 16:43:43 -0400 | [diff] [blame] | 3433 | if (transformFeedback != nullptr && transformFeedback->isActive()) |
| 3434 | { |
| 3435 | for (size_t i = 0; i < transformFeedback->getIndexedBufferCount(); i++) |
| 3436 | { |
| 3437 | const auto &transformFeedbackBuffer = transformFeedback->getIndexedBuffer(i); |
| 3438 | if (transformFeedbackBuffer.get() == buffer) |
| 3439 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3440 | context->validationError(GL_INVALID_OPERATION, kBufferBoundForTransformFeedback); |
Geoff Lang | 79f7104 | 2017-08-14 16:43:43 -0400 | [diff] [blame] | 3441 | return false; |
| 3442 | } |
| 3443 | } |
| 3444 | } |
| 3445 | |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 3446 | if (context->getExtensions().webglCompatibility && |
| 3447 | buffer->isBoundForTransformFeedbackAndOtherUse()) |
| 3448 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3449 | context->validationError(GL_INVALID_OPERATION, kBufferBoundForTransformFeedback); |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 3450 | return false; |
| 3451 | } |
| 3452 | |
Geoff Lang | 79f7104 | 2017-08-14 16:43:43 -0400 | [diff] [blame] | 3453 | return true; |
| 3454 | } |
| 3455 | |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3456 | bool ValidateFlushMappedBufferRangeEXT(Context *context, |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 3457 | BufferBinding target, |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3458 | GLintptr offset, |
| 3459 | GLsizeiptr length) |
| 3460 | { |
| 3461 | if (!context->getExtensions().mapBufferRange) |
| 3462 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3463 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3464 | return false; |
| 3465 | } |
| 3466 | |
| 3467 | return ValidateFlushMappedBufferRangeBase(context, target, offset, length); |
| 3468 | } |
| 3469 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 3470 | bool ValidateBindUniformLocationCHROMIUM(Context *context, |
| 3471 | GLuint program, |
| 3472 | GLint location, |
| 3473 | const GLchar *name) |
| 3474 | { |
| 3475 | if (!context->getExtensions().bindUniformLocation) |
| 3476 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3477 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 3478 | return false; |
| 3479 | } |
| 3480 | |
| 3481 | Program *programObject = GetValidProgram(context, program); |
| 3482 | if (!programObject) |
| 3483 | { |
| 3484 | return false; |
| 3485 | } |
| 3486 | |
| 3487 | if (location < 0) |
| 3488 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3489 | context->validationError(GL_INVALID_VALUE, kNegativeLocation); |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 3490 | return false; |
| 3491 | } |
| 3492 | |
| 3493 | const Caps &caps = context->getCaps(); |
| 3494 | if (static_cast<size_t>(location) >= |
| 3495 | (caps.maxVertexUniformVectors + caps.maxFragmentUniformVectors) * 4) |
| 3496 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3497 | context->validationError(GL_INVALID_VALUE, kInvalidBindUniformLocation); |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 3498 | return false; |
| 3499 | } |
| 3500 | |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 3501 | // The WebGL spec (section 6.20) disallows strings containing invalid ESSL characters for |
| 3502 | // shader-related entry points |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 3503 | if (context->getExtensions().webglCompatibility && !IsValidESSLString(name, strlen(name))) |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 3504 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3505 | context->validationError(GL_INVALID_VALUE, kInvalidNameCharacters); |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 3506 | return false; |
| 3507 | } |
| 3508 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 3509 | if (strncmp(name, "gl_", 3) == 0) |
| 3510 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3511 | context->validationError(GL_INVALID_VALUE, kNameBeginsWithGL); |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 3512 | return false; |
| 3513 | } |
| 3514 | |
| 3515 | return true; |
| 3516 | } |
| 3517 | |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 3518 | bool ValidateCoverageModulationCHROMIUM(Context *context, GLenum components) |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 3519 | { |
| 3520 | if (!context->getExtensions().framebufferMixedSamples) |
| 3521 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3522 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 3523 | return false; |
| 3524 | } |
| 3525 | switch (components) |
| 3526 | { |
| 3527 | case GL_RGB: |
| 3528 | case GL_RGBA: |
| 3529 | case GL_ALPHA: |
| 3530 | case GL_NONE: |
| 3531 | break; |
| 3532 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3533 | context->validationError(GL_INVALID_ENUM, kInvalidCoverageComponents); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 3534 | return false; |
| 3535 | } |
| 3536 | |
| 3537 | return true; |
| 3538 | } |
| 3539 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3540 | // CHROMIUM_path_rendering |
| 3541 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3542 | bool ValidateMatrixLoadfCHROMIUM(Context *context, GLenum matrixMode, const GLfloat *matrix) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3543 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3544 | if (!ValidateMatrixMode(context, matrixMode)) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3545 | { |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3546 | return false; |
| 3547 | } |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3548 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3549 | if (matrix == nullptr) |
| 3550 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3551 | context->validationError(GL_INVALID_OPERATION, kInvalidPathMatrix); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3552 | return false; |
| 3553 | } |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3554 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3555 | return true; |
| 3556 | } |
| 3557 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3558 | bool ValidateMatrixLoadIdentityCHROMIUM(Context *context, GLenum matrixMode) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3559 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3560 | return ValidateMatrixMode(context, matrixMode); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3561 | } |
| 3562 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3563 | bool ValidateGenPathsCHROMIUM(Context *context, GLsizei range) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3564 | { |
| 3565 | if (!context->getExtensions().pathRendering) |
| 3566 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3567 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3568 | return false; |
| 3569 | } |
| 3570 | |
| 3571 | // range = 0 is undefined in NV_path_rendering. |
| 3572 | // we add stricter semantic check here and require a non zero positive range. |
| 3573 | if (range <= 0) |
| 3574 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3575 | context->validationError(GL_INVALID_VALUE, kInvalidRange); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3576 | return false; |
| 3577 | } |
| 3578 | |
| 3579 | if (!angle::IsValueInRangeForNumericType<std::uint32_t>(range)) |
| 3580 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3581 | context->validationError(GL_INVALID_OPERATION, kIntegerOverflow); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3582 | return false; |
| 3583 | } |
| 3584 | |
| 3585 | return true; |
| 3586 | } |
| 3587 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3588 | bool ValidateDeletePathsCHROMIUM(Context *context, GLuint path, GLsizei range) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3589 | { |
| 3590 | if (!context->getExtensions().pathRendering) |
| 3591 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3592 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3593 | return false; |
| 3594 | } |
| 3595 | |
| 3596 | // range = 0 is undefined in NV_path_rendering. |
| 3597 | // we add stricter semantic check here and require a non zero positive range. |
| 3598 | if (range <= 0) |
| 3599 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3600 | context->validationError(GL_INVALID_VALUE, kInvalidRange); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3601 | return false; |
| 3602 | } |
| 3603 | |
| 3604 | angle::CheckedNumeric<std::uint32_t> checkedRange(path); |
| 3605 | checkedRange += range; |
| 3606 | |
| 3607 | if (!angle::IsValueInRangeForNumericType<std::uint32_t>(range) || !checkedRange.IsValid()) |
| 3608 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3609 | context->validationError(GL_INVALID_OPERATION, kIntegerOverflow); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3610 | return false; |
| 3611 | } |
| 3612 | return true; |
| 3613 | } |
| 3614 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3615 | bool ValidatePathCommandsCHROMIUM(Context *context, |
| 3616 | GLuint path, |
| 3617 | GLsizei numCommands, |
| 3618 | const GLubyte *commands, |
| 3619 | GLsizei numCoords, |
| 3620 | GLenum coordType, |
| 3621 | const void *coords) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3622 | { |
| 3623 | if (!context->getExtensions().pathRendering) |
| 3624 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3625 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3626 | return false; |
| 3627 | } |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3628 | if (!context->isPathGenerated(path)) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3629 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3630 | context->validationError(GL_INVALID_OPERATION, kNoSuchPath); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3631 | return false; |
| 3632 | } |
| 3633 | |
| 3634 | if (numCommands < 0) |
| 3635 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3636 | context->validationError(GL_INVALID_VALUE, kInvalidPathNumCommands); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3637 | return false; |
| 3638 | } |
| 3639 | else if (numCommands > 0) |
| 3640 | { |
| 3641 | if (!commands) |
| 3642 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3643 | context->validationError(GL_INVALID_VALUE, kInvalidPathCommandsArray); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3644 | return false; |
| 3645 | } |
| 3646 | } |
| 3647 | |
| 3648 | if (numCoords < 0) |
| 3649 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3650 | context->validationError(GL_INVALID_VALUE, kInvalidPathNumCoords); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3651 | return false; |
| 3652 | } |
| 3653 | else if (numCoords > 0) |
| 3654 | { |
| 3655 | if (!coords) |
| 3656 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3657 | context->validationError(GL_INVALID_VALUE, kInvalidPathNumCoordsArray); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3658 | return false; |
| 3659 | } |
| 3660 | } |
| 3661 | |
| 3662 | std::uint32_t coordTypeSize = 0; |
| 3663 | switch (coordType) |
| 3664 | { |
| 3665 | case GL_BYTE: |
| 3666 | coordTypeSize = sizeof(GLbyte); |
| 3667 | break; |
| 3668 | |
| 3669 | case GL_UNSIGNED_BYTE: |
| 3670 | coordTypeSize = sizeof(GLubyte); |
| 3671 | break; |
| 3672 | |
| 3673 | case GL_SHORT: |
| 3674 | coordTypeSize = sizeof(GLshort); |
| 3675 | break; |
| 3676 | |
| 3677 | case GL_UNSIGNED_SHORT: |
| 3678 | coordTypeSize = sizeof(GLushort); |
| 3679 | break; |
| 3680 | |
| 3681 | case GL_FLOAT: |
| 3682 | coordTypeSize = sizeof(GLfloat); |
| 3683 | break; |
| 3684 | |
| 3685 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3686 | context->validationError(GL_INVALID_ENUM, kInvalidPathCoordinateType); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3687 | return false; |
| 3688 | } |
| 3689 | |
| 3690 | angle::CheckedNumeric<std::uint32_t> checkedSize(numCommands); |
| 3691 | checkedSize += (coordTypeSize * numCoords); |
| 3692 | if (!checkedSize.IsValid()) |
| 3693 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3694 | context->validationError(GL_INVALID_OPERATION, kIntegerOverflow); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3695 | return false; |
| 3696 | } |
| 3697 | |
| 3698 | // early return skips command data validation when it doesn't exist. |
| 3699 | if (!commands) |
| 3700 | return true; |
| 3701 | |
| 3702 | GLsizei expectedNumCoords = 0; |
| 3703 | for (GLsizei i = 0; i < numCommands; ++i) |
| 3704 | { |
| 3705 | switch (commands[i]) |
| 3706 | { |
| 3707 | case GL_CLOSE_PATH_CHROMIUM: // no coordinates. |
| 3708 | break; |
| 3709 | case GL_MOVE_TO_CHROMIUM: |
| 3710 | case GL_LINE_TO_CHROMIUM: |
| 3711 | expectedNumCoords += 2; |
| 3712 | break; |
| 3713 | case GL_QUADRATIC_CURVE_TO_CHROMIUM: |
| 3714 | expectedNumCoords += 4; |
| 3715 | break; |
| 3716 | case GL_CUBIC_CURVE_TO_CHROMIUM: |
| 3717 | expectedNumCoords += 6; |
| 3718 | break; |
| 3719 | case GL_CONIC_CURVE_TO_CHROMIUM: |
| 3720 | expectedNumCoords += 5; |
| 3721 | break; |
| 3722 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3723 | context->validationError(GL_INVALID_ENUM, kInvalidPathCommand); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3724 | return false; |
| 3725 | } |
| 3726 | } |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3727 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3728 | if (expectedNumCoords != numCoords) |
| 3729 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3730 | context->validationError(GL_INVALID_VALUE, kInvalidPathNumCoords); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3731 | return false; |
| 3732 | } |
| 3733 | |
| 3734 | return true; |
| 3735 | } |
| 3736 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3737 | bool ValidatePathParameterfCHROMIUM(Context *context, GLuint path, GLenum pname, GLfloat value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3738 | { |
| 3739 | if (!context->getExtensions().pathRendering) |
| 3740 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3741 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3742 | return false; |
| 3743 | } |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3744 | if (!context->isPathGenerated(path)) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3745 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3746 | context->validationError(GL_INVALID_OPERATION, kNoSuchPath); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3747 | return false; |
| 3748 | } |
| 3749 | |
| 3750 | switch (pname) |
| 3751 | { |
| 3752 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 3753 | if (value < 0.0f) |
| 3754 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3755 | context->validationError(GL_INVALID_VALUE, kInvalidPathStrokeWidth); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3756 | return false; |
| 3757 | } |
| 3758 | break; |
| 3759 | case GL_PATH_END_CAPS_CHROMIUM: |
| 3760 | switch (static_cast<GLenum>(value)) |
| 3761 | { |
| 3762 | case GL_FLAT_CHROMIUM: |
| 3763 | case GL_SQUARE_CHROMIUM: |
| 3764 | case GL_ROUND_CHROMIUM: |
| 3765 | break; |
| 3766 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3767 | context->validationError(GL_INVALID_ENUM, kInvalidPathEndCaps); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3768 | return false; |
| 3769 | } |
| 3770 | break; |
| 3771 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 3772 | switch (static_cast<GLenum>(value)) |
| 3773 | { |
| 3774 | case GL_MITER_REVERT_CHROMIUM: |
| 3775 | case GL_BEVEL_CHROMIUM: |
| 3776 | case GL_ROUND_CHROMIUM: |
| 3777 | break; |
| 3778 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3779 | context->validationError(GL_INVALID_ENUM, kInvalidPathJoinStyle); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3780 | return false; |
| 3781 | } |
Nico Weber | 41b072b | 2018-02-09 10:01:32 -0500 | [diff] [blame] | 3782 | break; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3783 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 3784 | if (value < 0.0f) |
| 3785 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3786 | context->validationError(GL_INVALID_VALUE, kInvalidPathMiterLimit); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3787 | return false; |
| 3788 | } |
| 3789 | break; |
| 3790 | |
| 3791 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 3792 | // no errors, only clamping. |
| 3793 | break; |
| 3794 | |
| 3795 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3796 | context->validationError(GL_INVALID_ENUM, kInvalidPathParameter); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3797 | return false; |
| 3798 | } |
| 3799 | return true; |
| 3800 | } |
| 3801 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3802 | bool ValidatePathParameteriCHROMIUM(Context *context, GLuint path, GLenum pname, GLint value) |
| 3803 | { |
| 3804 | // TODO(jmadill): Use proper clamping cast. |
| 3805 | return ValidatePathParameterfCHROMIUM(context, path, pname, static_cast<GLfloat>(value)); |
| 3806 | } |
| 3807 | |
| 3808 | bool ValidateGetPathParameterfvCHROMIUM(Context *context, GLuint path, GLenum pname, GLfloat *value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3809 | { |
| 3810 | if (!context->getExtensions().pathRendering) |
| 3811 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3812 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3813 | return false; |
| 3814 | } |
| 3815 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3816 | if (!context->isPathGenerated(path)) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3817 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3818 | context->validationError(GL_INVALID_OPERATION, kNoSuchPath); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3819 | return false; |
| 3820 | } |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3821 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3822 | if (!value) |
| 3823 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3824 | context->validationError(GL_INVALID_VALUE, kInvalidPathValueArray); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3825 | return false; |
| 3826 | } |
| 3827 | |
| 3828 | switch (pname) |
| 3829 | { |
| 3830 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 3831 | case GL_PATH_END_CAPS_CHROMIUM: |
| 3832 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 3833 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 3834 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 3835 | break; |
| 3836 | |
| 3837 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3838 | context->validationError(GL_INVALID_ENUM, kInvalidPathParameter); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3839 | return false; |
| 3840 | } |
| 3841 | |
| 3842 | return true; |
| 3843 | } |
| 3844 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3845 | bool ValidateGetPathParameterivCHROMIUM(Context *context, GLuint path, GLenum pname, GLint *value) |
| 3846 | { |
| 3847 | return ValidateGetPathParameterfvCHROMIUM(context, path, pname, |
| 3848 | reinterpret_cast<GLfloat *>(value)); |
| 3849 | } |
| 3850 | |
| 3851 | bool ValidatePathStencilFuncCHROMIUM(Context *context, GLenum func, GLint ref, GLuint mask) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3852 | { |
| 3853 | if (!context->getExtensions().pathRendering) |
| 3854 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3855 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3856 | return false; |
| 3857 | } |
| 3858 | |
| 3859 | switch (func) |
| 3860 | { |
| 3861 | case GL_NEVER: |
| 3862 | case GL_ALWAYS: |
| 3863 | case GL_LESS: |
| 3864 | case GL_LEQUAL: |
| 3865 | case GL_EQUAL: |
| 3866 | case GL_GEQUAL: |
| 3867 | case GL_GREATER: |
| 3868 | case GL_NOTEQUAL: |
| 3869 | break; |
| 3870 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3871 | context->validationError(GL_INVALID_ENUM, kInvalidStencil); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3872 | return false; |
| 3873 | } |
| 3874 | |
| 3875 | return true; |
| 3876 | } |
| 3877 | |
| 3878 | // Note that the spec specifies that for the path drawing commands |
| 3879 | // if the path object is not an existing path object the command |
| 3880 | // does nothing and no error is generated. |
| 3881 | // However if the path object exists but has not been specified any |
| 3882 | // commands then an error is generated. |
| 3883 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3884 | bool ValidateStencilFillPathCHROMIUM(Context *context, GLuint path, GLenum fillMode, GLuint mask) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3885 | { |
| 3886 | if (!context->getExtensions().pathRendering) |
| 3887 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3888 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3889 | return false; |
| 3890 | } |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3891 | if (context->isPathGenerated(path) && !context->isPath(path)) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3892 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3893 | context->validationError(GL_INVALID_OPERATION, kNoSuchPath); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3894 | return false; |
| 3895 | } |
| 3896 | |
| 3897 | switch (fillMode) |
| 3898 | { |
| 3899 | case GL_COUNT_UP_CHROMIUM: |
| 3900 | case GL_COUNT_DOWN_CHROMIUM: |
| 3901 | break; |
| 3902 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3903 | context->validationError(GL_INVALID_ENUM, kInvalidFillMode); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3904 | return false; |
| 3905 | } |
| 3906 | |
| 3907 | if (!isPow2(mask + 1)) |
| 3908 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3909 | context->validationError(GL_INVALID_VALUE, kInvalidStencilBitMask); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3910 | return false; |
| 3911 | } |
| 3912 | |
| 3913 | return true; |
| 3914 | } |
| 3915 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3916 | bool ValidateStencilStrokePathCHROMIUM(Context *context, GLuint path, GLint reference, GLuint mask) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3917 | { |
| 3918 | if (!context->getExtensions().pathRendering) |
| 3919 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3920 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3921 | return false; |
| 3922 | } |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3923 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3924 | if (context->isPathGenerated(path) && !context->isPath(path)) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3925 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3926 | context->validationError(GL_INVALID_OPERATION, kNoPathOrNoPathData); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3927 | return false; |
| 3928 | } |
| 3929 | |
| 3930 | return true; |
| 3931 | } |
| 3932 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3933 | bool ValidateCoverPathCHROMIUM(Context *context, GLuint path, GLenum coverMode) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3934 | { |
| 3935 | if (!context->getExtensions().pathRendering) |
| 3936 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3937 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3938 | return false; |
| 3939 | } |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3940 | if (context->isPathGenerated(path) && !context->isPath(path)) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3941 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3942 | context->validationError(GL_INVALID_OPERATION, kNoSuchPath); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3943 | return false; |
| 3944 | } |
| 3945 | |
| 3946 | switch (coverMode) |
| 3947 | { |
| 3948 | case GL_CONVEX_HULL_CHROMIUM: |
| 3949 | case GL_BOUNDING_BOX_CHROMIUM: |
| 3950 | break; |
| 3951 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 3952 | context->validationError(GL_INVALID_ENUM, kInvalidCoverMode); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3953 | return false; |
| 3954 | } |
| 3955 | return true; |
| 3956 | } |
| 3957 | |
Jamie Madill | 778bf09 | 2018-11-14 09:54:36 -0500 | [diff] [blame] | 3958 | bool ValidateCoverFillPathCHROMIUM(Context *context, GLuint path, GLenum coverMode) |
| 3959 | { |
| 3960 | return ValidateCoverPathCHROMIUM(context, path, coverMode); |
| 3961 | } |
| 3962 | |
| 3963 | bool ValidateCoverStrokePathCHROMIUM(Context *context, GLuint path, GLenum coverMode) |
| 3964 | { |
| 3965 | return ValidateCoverPathCHROMIUM(context, path, coverMode); |
| 3966 | } |
| 3967 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3968 | bool ValidateStencilThenCoverFillPathCHROMIUM(Context *context, |
| 3969 | GLuint path, |
| 3970 | GLenum fillMode, |
| 3971 | GLuint mask, |
| 3972 | GLenum coverMode) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3973 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3974 | return ValidateStencilFillPathCHROMIUM(context, path, fillMode, mask) && |
| 3975 | ValidateCoverPathCHROMIUM(context, path, coverMode); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3976 | } |
| 3977 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3978 | bool ValidateStencilThenCoverStrokePathCHROMIUM(Context *context, |
| 3979 | GLuint path, |
| 3980 | GLint reference, |
| 3981 | GLuint mask, |
| 3982 | GLenum coverMode) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3983 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3984 | return ValidateStencilStrokePathCHROMIUM(context, path, reference, mask) && |
| 3985 | ValidateCoverPathCHROMIUM(context, path, coverMode); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3986 | } |
| 3987 | |
Brandon Jones | d104918 | 2018-03-28 10:02:20 -0700 | [diff] [blame] | 3988 | bool ValidateIsPathCHROMIUM(Context *context, GLuint path) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3989 | { |
| 3990 | if (!context->getExtensions().pathRendering) |
| 3991 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 3992 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 3993 | return false; |
| 3994 | } |
| 3995 | return true; |
| 3996 | } |
| 3997 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 3998 | bool ValidateCoverFillPathInstancedCHROMIUM(Context *context, |
| 3999 | GLsizei numPaths, |
| 4000 | GLenum pathNameType, |
| 4001 | const void *paths, |
| 4002 | GLuint pathBase, |
| 4003 | GLenum coverMode, |
| 4004 | GLenum transformType, |
| 4005 | const GLfloat *transformValues) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4006 | { |
| 4007 | if (!ValidateInstancedPathParameters(context, numPaths, pathNameType, paths, pathBase, |
| 4008 | transformType, transformValues)) |
| 4009 | return false; |
| 4010 | |
| 4011 | switch (coverMode) |
| 4012 | { |
| 4013 | case GL_CONVEX_HULL_CHROMIUM: |
| 4014 | case GL_BOUNDING_BOX_CHROMIUM: |
| 4015 | case GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM: |
| 4016 | break; |
| 4017 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4018 | context->validationError(GL_INVALID_ENUM, kInvalidCoverMode); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4019 | return false; |
| 4020 | } |
| 4021 | |
| 4022 | return true; |
| 4023 | } |
| 4024 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4025 | bool ValidateCoverStrokePathInstancedCHROMIUM(Context *context, |
| 4026 | GLsizei numPaths, |
| 4027 | GLenum pathNameType, |
| 4028 | const void *paths, |
| 4029 | GLuint pathBase, |
| 4030 | GLenum coverMode, |
| 4031 | GLenum transformType, |
| 4032 | const GLfloat *transformValues) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4033 | { |
| 4034 | if (!ValidateInstancedPathParameters(context, numPaths, pathNameType, paths, pathBase, |
| 4035 | transformType, transformValues)) |
| 4036 | return false; |
| 4037 | |
| 4038 | switch (coverMode) |
| 4039 | { |
| 4040 | case GL_CONVEX_HULL_CHROMIUM: |
| 4041 | case GL_BOUNDING_BOX_CHROMIUM: |
| 4042 | case GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM: |
| 4043 | break; |
| 4044 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4045 | context->validationError(GL_INVALID_ENUM, kInvalidCoverMode); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4046 | return false; |
| 4047 | } |
| 4048 | |
| 4049 | return true; |
| 4050 | } |
| 4051 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4052 | bool ValidateStencilFillPathInstancedCHROMIUM(Context *context, |
| 4053 | GLsizei numPaths, |
| 4054 | GLenum pathNameType, |
| 4055 | const void *paths, |
| 4056 | GLuint pathBase, |
| 4057 | GLenum fillMode, |
| 4058 | GLuint mask, |
| 4059 | GLenum transformType, |
| 4060 | const GLfloat *transformValues) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4061 | { |
| 4062 | |
| 4063 | if (!ValidateInstancedPathParameters(context, numPaths, pathNameType, paths, pathBase, |
| 4064 | transformType, transformValues)) |
| 4065 | return false; |
| 4066 | |
| 4067 | switch (fillMode) |
| 4068 | { |
| 4069 | case GL_COUNT_UP_CHROMIUM: |
| 4070 | case GL_COUNT_DOWN_CHROMIUM: |
| 4071 | break; |
| 4072 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4073 | context->validationError(GL_INVALID_ENUM, kInvalidFillMode); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4074 | return false; |
| 4075 | } |
| 4076 | if (!isPow2(mask + 1)) |
| 4077 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4078 | context->validationError(GL_INVALID_VALUE, kInvalidStencilBitMask); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4079 | return false; |
| 4080 | } |
| 4081 | return true; |
| 4082 | } |
| 4083 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4084 | bool ValidateStencilStrokePathInstancedCHROMIUM(Context *context, |
| 4085 | GLsizei numPaths, |
| 4086 | GLenum pathNameType, |
| 4087 | const void *paths, |
| 4088 | GLuint pathBase, |
| 4089 | GLint reference, |
| 4090 | GLuint mask, |
| 4091 | GLenum transformType, |
| 4092 | const GLfloat *transformValues) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4093 | { |
| 4094 | if (!ValidateInstancedPathParameters(context, numPaths, pathNameType, paths, pathBase, |
| 4095 | transformType, transformValues)) |
| 4096 | return false; |
| 4097 | |
| 4098 | // no more validation here. |
| 4099 | |
| 4100 | return true; |
| 4101 | } |
| 4102 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4103 | bool ValidateStencilThenCoverFillPathInstancedCHROMIUM(Context *context, |
| 4104 | GLsizei numPaths, |
| 4105 | GLenum pathNameType, |
| 4106 | const void *paths, |
| 4107 | GLuint pathBase, |
| 4108 | GLenum fillMode, |
| 4109 | GLuint mask, |
| 4110 | GLenum coverMode, |
| 4111 | GLenum transformType, |
| 4112 | const GLfloat *transformValues) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4113 | { |
| 4114 | if (!ValidateInstancedPathParameters(context, numPaths, pathNameType, paths, pathBase, |
| 4115 | transformType, transformValues)) |
| 4116 | return false; |
| 4117 | |
| 4118 | switch (coverMode) |
| 4119 | { |
| 4120 | case GL_CONVEX_HULL_CHROMIUM: |
| 4121 | case GL_BOUNDING_BOX_CHROMIUM: |
| 4122 | case GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM: |
| 4123 | break; |
| 4124 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4125 | context->validationError(GL_INVALID_ENUM, kInvalidCoverMode); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4126 | return false; |
| 4127 | } |
| 4128 | |
| 4129 | switch (fillMode) |
| 4130 | { |
| 4131 | case GL_COUNT_UP_CHROMIUM: |
| 4132 | case GL_COUNT_DOWN_CHROMIUM: |
| 4133 | break; |
| 4134 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4135 | context->validationError(GL_INVALID_ENUM, kInvalidFillMode); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4136 | return false; |
| 4137 | } |
| 4138 | if (!isPow2(mask + 1)) |
| 4139 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4140 | context->validationError(GL_INVALID_VALUE, kInvalidStencilBitMask); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4141 | return false; |
| 4142 | } |
| 4143 | |
| 4144 | return true; |
| 4145 | } |
| 4146 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4147 | bool ValidateStencilThenCoverStrokePathInstancedCHROMIUM(Context *context, |
| 4148 | GLsizei numPaths, |
| 4149 | GLenum pathNameType, |
| 4150 | const void *paths, |
| 4151 | GLuint pathBase, |
| 4152 | GLint reference, |
| 4153 | GLuint mask, |
| 4154 | GLenum coverMode, |
| 4155 | GLenum transformType, |
| 4156 | const GLfloat *transformValues) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4157 | { |
| 4158 | if (!ValidateInstancedPathParameters(context, numPaths, pathNameType, paths, pathBase, |
| 4159 | transformType, transformValues)) |
| 4160 | return false; |
| 4161 | |
| 4162 | switch (coverMode) |
| 4163 | { |
| 4164 | case GL_CONVEX_HULL_CHROMIUM: |
| 4165 | case GL_BOUNDING_BOX_CHROMIUM: |
| 4166 | case GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM: |
| 4167 | break; |
| 4168 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4169 | context->validationError(GL_INVALID_ENUM, kInvalidCoverMode); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 4170 | return false; |
| 4171 | } |
| 4172 | |
| 4173 | return true; |
| 4174 | } |
| 4175 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4176 | bool ValidateBindFragmentInputLocationCHROMIUM(Context *context, |
| 4177 | GLuint program, |
| 4178 | GLint location, |
| 4179 | const GLchar *name) |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4180 | { |
| 4181 | if (!context->getExtensions().pathRendering) |
| 4182 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4183 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4184 | return false; |
| 4185 | } |
| 4186 | |
| 4187 | const GLint MaxLocation = context->getCaps().maxVaryingVectors * 4; |
| 4188 | if (location >= MaxLocation) |
| 4189 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4190 | context->validationError(GL_INVALID_VALUE, kInvalidVaryingLocation); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4191 | return false; |
| 4192 | } |
| 4193 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 4194 | const auto *programObject = context->getProgramNoResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4195 | if (!programObject) |
| 4196 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4197 | context->validationError(GL_INVALID_OPERATION, kProgramNotBound); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4198 | return false; |
| 4199 | } |
| 4200 | |
| 4201 | if (!name) |
| 4202 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4203 | context->validationError(GL_INVALID_VALUE, kMissingName); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4204 | return false; |
| 4205 | } |
| 4206 | |
| 4207 | if (angle::BeginsWith(name, "gl_")) |
| 4208 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4209 | context->validationError(GL_INVALID_OPERATION, kNameBeginsWithGL); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4210 | return false; |
| 4211 | } |
| 4212 | |
| 4213 | return true; |
| 4214 | } |
| 4215 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4216 | bool ValidateProgramPathFragmentInputGenCHROMIUM(Context *context, |
| 4217 | GLuint program, |
| 4218 | GLint location, |
| 4219 | GLenum genMode, |
| 4220 | GLint components, |
| 4221 | const GLfloat *coeffs) |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4222 | { |
| 4223 | if (!context->getExtensions().pathRendering) |
| 4224 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4225 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4226 | return false; |
| 4227 | } |
| 4228 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 4229 | const auto *programObject = context->getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4230 | if (!programObject || programObject->isFlaggedForDeletion()) |
| 4231 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4232 | context->validationError(GL_INVALID_OPERATION, kProgramDoesNotExist); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4233 | return false; |
| 4234 | } |
| 4235 | |
| 4236 | if (!programObject->isLinked()) |
| 4237 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4238 | context->validationError(GL_INVALID_OPERATION, kProgramNotLinked); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4239 | return false; |
| 4240 | } |
| 4241 | |
| 4242 | switch (genMode) |
| 4243 | { |
| 4244 | case GL_NONE: |
| 4245 | if (components != 0) |
| 4246 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4247 | context->validationError(GL_INVALID_VALUE, kInvalidComponents); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4248 | return false; |
| 4249 | } |
| 4250 | break; |
| 4251 | |
| 4252 | case GL_OBJECT_LINEAR_CHROMIUM: |
| 4253 | case GL_EYE_LINEAR_CHROMIUM: |
| 4254 | case GL_CONSTANT_CHROMIUM: |
| 4255 | if (components < 1 || components > 4) |
| 4256 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4257 | context->validationError(GL_INVALID_VALUE, kInvalidComponents); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4258 | return false; |
| 4259 | } |
| 4260 | if (!coeffs) |
| 4261 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4262 | context->validationError(GL_INVALID_VALUE, kInvalidPathCoefficientsArray); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4263 | return false; |
| 4264 | } |
| 4265 | break; |
| 4266 | |
| 4267 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4268 | context->validationError(GL_INVALID_ENUM, kInvalidPathGenMode); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4269 | return false; |
| 4270 | } |
| 4271 | |
| 4272 | // If the location is -1 then the command is silently ignored |
| 4273 | // and no further validation is needed. |
| 4274 | if (location == -1) |
| 4275 | return true; |
| 4276 | |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 4277 | const auto &binding = programObject->getFragmentInputBindingInfo(location); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4278 | |
| 4279 | if (!binding.valid) |
| 4280 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4281 | context->validationError(GL_INVALID_OPERATION, kInvalidFragmentInputBinding); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4282 | return false; |
| 4283 | } |
| 4284 | |
| 4285 | if (binding.type != GL_NONE) |
| 4286 | { |
| 4287 | GLint expectedComponents = 0; |
| 4288 | switch (binding.type) |
| 4289 | { |
| 4290 | case GL_FLOAT: |
| 4291 | expectedComponents = 1; |
| 4292 | break; |
| 4293 | case GL_FLOAT_VEC2: |
| 4294 | expectedComponents = 2; |
| 4295 | break; |
| 4296 | case GL_FLOAT_VEC3: |
| 4297 | expectedComponents = 3; |
| 4298 | break; |
| 4299 | case GL_FLOAT_VEC4: |
| 4300 | expectedComponents = 4; |
| 4301 | break; |
| 4302 | default: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4303 | context->validationError(GL_INVALID_OPERATION, kFragmentInputTypeNotFloatingPoint); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4304 | return false; |
| 4305 | } |
| 4306 | if (expectedComponents != components && genMode != GL_NONE) |
| 4307 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4308 | context->validationError(GL_INVALID_OPERATION, kInvalidPathComponents); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 4309 | return false; |
| 4310 | } |
| 4311 | } |
| 4312 | return true; |
| 4313 | } |
| 4314 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4315 | bool ValidateCopyTextureCHROMIUM(Context *context, |
| 4316 | GLuint sourceId, |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 4317 | GLint sourceLevel, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4318 | TextureTarget destTarget, |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4319 | GLuint destId, |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 4320 | GLint destLevel, |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4321 | GLint internalFormat, |
| 4322 | GLenum destType, |
| 4323 | GLboolean unpackFlipY, |
| 4324 | GLboolean unpackPremultiplyAlpha, |
| 4325 | GLboolean unpackUnmultiplyAlpha) |
| 4326 | { |
| 4327 | if (!context->getExtensions().copyTexture) |
| 4328 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4329 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4330 | return false; |
| 4331 | } |
| 4332 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4333 | const Texture *source = context->getTexture(sourceId); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4334 | if (source == nullptr) |
| 4335 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4336 | context->validationError(GL_INVALID_VALUE, kInvalidSourceTexture); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4337 | return false; |
| 4338 | } |
| 4339 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4340 | if (!IsValidCopyTextureSourceTarget(context, source->getType())) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4341 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4342 | context->validationError(GL_INVALID_OPERATION, kInvalidInternalFormat); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4343 | return false; |
| 4344 | } |
| 4345 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4346 | TextureType sourceType = source->getType(); |
| 4347 | ASSERT(sourceType != TextureType::CubeMap); |
| 4348 | TextureTarget sourceTarget = NonCubeTextureTypeToTarget(sourceType); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4349 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4350 | if (!IsValidCopyTextureSourceLevel(context, sourceType, sourceLevel)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4351 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4352 | context->validationError(GL_INVALID_VALUE, kInvalidSourceTextureLevel); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4353 | return false; |
| 4354 | } |
| 4355 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4356 | GLsizei sourceWidth = static_cast<GLsizei>(source->getWidth(sourceTarget, sourceLevel)); |
| 4357 | GLsizei sourceHeight = static_cast<GLsizei>(source->getHeight(sourceTarget, sourceLevel)); |
| 4358 | if (sourceWidth == 0 || sourceHeight == 0) |
| 4359 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4360 | context->validationError(GL_INVALID_OPERATION, kInvalidInternalFormat); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4361 | return false; |
| 4362 | } |
| 4363 | |
| 4364 | const InternalFormat &sourceFormat = *source->getFormat(sourceTarget, sourceLevel).info; |
| 4365 | if (!IsValidCopyTextureSourceInternalFormatEnum(sourceFormat.internalFormat)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4366 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4367 | context->validationError(GL_INVALID_OPERATION, kInvalidSourceTextureInternalFormat); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4368 | return false; |
| 4369 | } |
| 4370 | |
Geoff Lang | 63458a3 | 2017-10-30 15:16:53 -0400 | [diff] [blame] | 4371 | if (!IsValidCopyTextureDestinationTargetEnum(context, destTarget)) |
| 4372 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4373 | context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget); |
Geoff Lang | 63458a3 | 2017-10-30 15:16:53 -0400 | [diff] [blame] | 4374 | return false; |
| 4375 | } |
| 4376 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4377 | const Texture *dest = context->getTexture(destId); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4378 | if (dest == nullptr) |
| 4379 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4380 | context->validationError(GL_INVALID_VALUE, kInvalidDestinationTexture); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4381 | return false; |
| 4382 | } |
| 4383 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4384 | if (!IsValidCopyTextureDestinationTarget(context, dest->getType(), destTarget)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4385 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4386 | context->validationError(GL_INVALID_VALUE, kInvalidDestinationTextureType); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4387 | return false; |
| 4388 | } |
| 4389 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4390 | if (!IsValidCopyTextureDestinationLevel(context, dest->getType(), destLevel, sourceWidth, |
Brandon Jones | 2878379 | 2018-03-05 09:37:32 -0800 | [diff] [blame] | 4391 | sourceHeight, false)) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4392 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4393 | context->validationError(GL_INVALID_VALUE, kInvalidMipLevel); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4394 | return false; |
| 4395 | } |
| 4396 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4397 | if (!IsValidCopyTextureDestinationFormatType(context, internalFormat, destType)) |
| 4398 | { |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4399 | return false; |
| 4400 | } |
| 4401 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4402 | if (dest->getType() == TextureType::CubeMap && sourceWidth != sourceHeight) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4403 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4404 | context->validationError(GL_INVALID_VALUE, kCubemapFacesEqualDimensions); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4405 | return false; |
| 4406 | } |
| 4407 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4408 | if (dest->getImmutableFormat()) |
| 4409 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4410 | context->validationError(GL_INVALID_OPERATION, kDestinationImmutable); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4411 | return false; |
| 4412 | } |
| 4413 | |
| 4414 | return true; |
| 4415 | } |
| 4416 | |
| 4417 | bool ValidateCopySubTextureCHROMIUM(Context *context, |
| 4418 | GLuint sourceId, |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 4419 | GLint sourceLevel, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4420 | TextureTarget destTarget, |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4421 | GLuint destId, |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 4422 | GLint destLevel, |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4423 | GLint xoffset, |
| 4424 | GLint yoffset, |
| 4425 | GLint x, |
| 4426 | GLint y, |
| 4427 | GLsizei width, |
| 4428 | GLsizei height, |
| 4429 | GLboolean unpackFlipY, |
| 4430 | GLboolean unpackPremultiplyAlpha, |
| 4431 | GLboolean unpackUnmultiplyAlpha) |
| 4432 | { |
| 4433 | if (!context->getExtensions().copyTexture) |
| 4434 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4435 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4436 | return false; |
| 4437 | } |
| 4438 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4439 | const Texture *source = context->getTexture(sourceId); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4440 | if (source == nullptr) |
| 4441 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4442 | context->validationError(GL_INVALID_VALUE, kInvalidSourceTexture); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4443 | return false; |
| 4444 | } |
| 4445 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4446 | if (!IsValidCopyTextureSourceTarget(context, source->getType())) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4447 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4448 | context->validationError(GL_INVALID_VALUE, kInvalidSourceTextureType); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4449 | return false; |
| 4450 | } |
| 4451 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4452 | TextureType sourceType = source->getType(); |
| 4453 | ASSERT(sourceType != TextureType::CubeMap); |
| 4454 | TextureTarget sourceTarget = NonCubeTextureTypeToTarget(sourceType); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4455 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4456 | if (!IsValidCopyTextureSourceLevel(context, sourceType, sourceLevel)) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4457 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4458 | context->validationError(GL_INVALID_VALUE, kInvalidMipLevel); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4459 | return false; |
| 4460 | } |
| 4461 | |
| 4462 | if (source->getWidth(sourceTarget, sourceLevel) == 0 || |
| 4463 | source->getHeight(sourceTarget, sourceLevel) == 0) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4464 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4465 | context->validationError(GL_INVALID_VALUE, kInvalidSourceTextureLevel); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4466 | return false; |
| 4467 | } |
| 4468 | |
| 4469 | if (x < 0 || y < 0) |
| 4470 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4471 | context->validationError(GL_INVALID_VALUE, kNegativeOffset); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4472 | return false; |
| 4473 | } |
| 4474 | |
| 4475 | if (width < 0 || height < 0) |
| 4476 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4477 | context->validationError(GL_INVALID_VALUE, kNegativeSize); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4478 | return false; |
| 4479 | } |
| 4480 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4481 | if (static_cast<size_t>(x + width) > source->getWidth(sourceTarget, sourceLevel) || |
| 4482 | static_cast<size_t>(y + height) > source->getHeight(sourceTarget, sourceLevel)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4483 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4484 | context->validationError(GL_INVALID_VALUE, kSourceTextureTooSmall); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4485 | return false; |
| 4486 | } |
| 4487 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4488 | const Format &sourceFormat = source->getFormat(sourceTarget, sourceLevel); |
| 4489 | if (!IsValidCopySubTextureSourceInternalFormat(sourceFormat.info->internalFormat)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4490 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4491 | context->validationError(GL_INVALID_OPERATION, kInvalidInternalFormat); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4492 | return false; |
| 4493 | } |
| 4494 | |
Geoff Lang | 63458a3 | 2017-10-30 15:16:53 -0400 | [diff] [blame] | 4495 | if (!IsValidCopyTextureDestinationTargetEnum(context, destTarget)) |
| 4496 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4497 | context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget); |
Geoff Lang | 63458a3 | 2017-10-30 15:16:53 -0400 | [diff] [blame] | 4498 | return false; |
| 4499 | } |
| 4500 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4501 | const Texture *dest = context->getTexture(destId); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4502 | if (dest == nullptr) |
| 4503 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4504 | context->validationError(GL_INVALID_VALUE, kInvalidDestinationTexture); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4505 | return false; |
| 4506 | } |
| 4507 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4508 | if (!IsValidCopyTextureDestinationTarget(context, dest->getType(), destTarget)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4509 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4510 | context->validationError(GL_INVALID_VALUE, kInvalidDestinationTextureType); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4511 | return false; |
| 4512 | } |
| 4513 | |
Brandon Jones | 2878379 | 2018-03-05 09:37:32 -0800 | [diff] [blame] | 4514 | if (!IsValidCopyTextureDestinationLevel(context, dest->getType(), destLevel, width, height, |
| 4515 | true)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4516 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4517 | context->validationError(GL_INVALID_VALUE, kInvalidMipLevel); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4518 | return false; |
| 4519 | } |
| 4520 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4521 | if (dest->getWidth(destTarget, destLevel) == 0 || dest->getHeight(destTarget, destLevel) == 0) |
| 4522 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4523 | context->validationError(GL_INVALID_OPERATION, kDestinationLevelNotDefined); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4524 | return false; |
| 4525 | } |
| 4526 | |
| 4527 | const InternalFormat &destFormat = *dest->getFormat(destTarget, destLevel).info; |
| 4528 | if (!IsValidCopySubTextureDestionationInternalFormat(destFormat.internalFormat)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4529 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4530 | context->validationError(GL_INVALID_OPERATION, kInvalidFormatCombination); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4531 | return false; |
| 4532 | } |
| 4533 | |
| 4534 | if (xoffset < 0 || yoffset < 0) |
| 4535 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4536 | context->validationError(GL_INVALID_VALUE, kNegativeOffset); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4537 | return false; |
| 4538 | } |
| 4539 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 4540 | if (static_cast<size_t>(xoffset + width) > dest->getWidth(destTarget, destLevel) || |
| 4541 | static_cast<size_t>(yoffset + height) > dest->getHeight(destTarget, destLevel)) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4542 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4543 | context->validationError(GL_INVALID_VALUE, kOffsetOverflow); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4544 | return false; |
| 4545 | } |
| 4546 | |
| 4547 | return true; |
| 4548 | } |
| 4549 | |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4550 | bool ValidateCompressedCopyTextureCHROMIUM(Context *context, GLuint sourceId, GLuint destId) |
| 4551 | { |
| 4552 | if (!context->getExtensions().copyCompressedTexture) |
| 4553 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4554 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4555 | return false; |
| 4556 | } |
| 4557 | |
| 4558 | const gl::Texture *source = context->getTexture(sourceId); |
| 4559 | if (source == nullptr) |
| 4560 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4561 | context->validationError(GL_INVALID_VALUE, kInvalidSourceTexture); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4562 | return false; |
| 4563 | } |
| 4564 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4565 | if (source->getType() != TextureType::_2D) |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4566 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4567 | context->validationError(GL_INVALID_VALUE, kInvalidSourceTextureType); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4568 | return false; |
| 4569 | } |
| 4570 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4571 | if (source->getWidth(TextureTarget::_2D, 0) == 0 || |
| 4572 | source->getHeight(TextureTarget::_2D, 0) == 0) |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4573 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4574 | context->validationError(GL_INVALID_VALUE, kSourceTextureLevelZeroDefined); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4575 | return false; |
| 4576 | } |
| 4577 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4578 | const gl::Format &sourceFormat = source->getFormat(TextureTarget::_2D, 0); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4579 | if (!sourceFormat.info->compressed) |
| 4580 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4581 | context->validationError(GL_INVALID_OPERATION, kSourceTextureMustBeCompressed); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4582 | return false; |
| 4583 | } |
| 4584 | |
| 4585 | const gl::Texture *dest = context->getTexture(destId); |
| 4586 | if (dest == nullptr) |
| 4587 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4588 | context->validationError(GL_INVALID_VALUE, kInvalidDestinationTexture); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4589 | return false; |
| 4590 | } |
| 4591 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4592 | if (dest->getType() != TextureType::_2D) |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4593 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4594 | context->validationError(GL_INVALID_VALUE, kInvalidDestinationTextureType); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4595 | return false; |
| 4596 | } |
| 4597 | |
| 4598 | if (dest->getImmutableFormat()) |
| 4599 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4600 | context->validationError(GL_INVALID_OPERATION, kDestinationImmutable); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4601 | return false; |
| 4602 | } |
| 4603 | |
| 4604 | return true; |
| 4605 | } |
| 4606 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 4607 | bool ValidateCreateShader(Context *context, ShaderType type) |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 4608 | { |
| 4609 | switch (type) |
| 4610 | { |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 4611 | case ShaderType::Vertex: |
| 4612 | case ShaderType::Fragment: |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 4613 | break; |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 4614 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 4615 | case ShaderType::Compute: |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 4616 | if (context->getClientVersion() < Version(3, 1)) |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 4617 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4618 | context->validationError(GL_INVALID_ENUM, kES31Required); |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 4619 | return false; |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 4620 | } |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 4621 | break; |
| 4622 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 4623 | case ShaderType::Geometry: |
Jiawei Shao | 89be29a | 2017-11-06 14:36:45 +0800 | [diff] [blame] | 4624 | if (!context->getExtensions().geometryShader) |
| 4625 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4626 | context->validationError(GL_INVALID_ENUM, kInvalidShaderType); |
Jiawei Shao | 89be29a | 2017-11-06 14:36:45 +0800 | [diff] [blame] | 4627 | return false; |
| 4628 | } |
| 4629 | break; |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 4630 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4631 | context->validationError(GL_INVALID_ENUM, kInvalidShaderType); |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 4632 | return false; |
| 4633 | } |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4634 | |
| 4635 | return true; |
| 4636 | } |
| 4637 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4638 | bool ValidateBufferData(Context *context, |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4639 | BufferBinding target, |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4640 | GLsizeiptr size, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4641 | const void *data, |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 4642 | BufferUsage usage) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4643 | { |
| 4644 | if (size < 0) |
| 4645 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4646 | context->validationError(GL_INVALID_VALUE, kNegativeSize); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4647 | return false; |
| 4648 | } |
| 4649 | |
| 4650 | switch (usage) |
| 4651 | { |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 4652 | case BufferUsage::StreamDraw: |
| 4653 | case BufferUsage::StaticDraw: |
| 4654 | case BufferUsage::DynamicDraw: |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4655 | break; |
| 4656 | |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 4657 | case BufferUsage::StreamRead: |
| 4658 | case BufferUsage::StaticRead: |
| 4659 | case BufferUsage::DynamicRead: |
| 4660 | case BufferUsage::StreamCopy: |
| 4661 | case BufferUsage::StaticCopy: |
| 4662 | case BufferUsage::DynamicCopy: |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4663 | if (context->getClientMajorVersion() < 3) |
| 4664 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4665 | context->validationError(GL_INVALID_ENUM, kInvalidBufferUsage); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4666 | return false; |
| 4667 | } |
| 4668 | break; |
| 4669 | |
| 4670 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4671 | context->validationError(GL_INVALID_ENUM, kInvalidBufferUsage); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4672 | return false; |
| 4673 | } |
| 4674 | |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 4675 | if (!context->isValidBufferBinding(target)) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4676 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4677 | context->validationError(GL_INVALID_ENUM, kInvalidBufferTypes); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4678 | return false; |
| 4679 | } |
| 4680 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4681 | Buffer *buffer = context->getState().getTargetBuffer(target); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4682 | |
| 4683 | if (!buffer) |
| 4684 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4685 | context->validationError(GL_INVALID_OPERATION, kBufferNotBound); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4686 | return false; |
| 4687 | } |
| 4688 | |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 4689 | if (context->getExtensions().webglCompatibility && |
| 4690 | buffer->isBoundForTransformFeedbackAndOtherUse()) |
| 4691 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4692 | context->validationError(GL_INVALID_OPERATION, kBufferBoundForTransformFeedback); |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 4693 | return false; |
| 4694 | } |
| 4695 | |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4696 | return true; |
| 4697 | } |
| 4698 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4699 | bool ValidateBufferSubData(Context *context, |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4700 | BufferBinding target, |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4701 | GLintptr offset, |
| 4702 | GLsizeiptr size, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4703 | const void *data) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4704 | { |
Brandon Jones | 6cad566 | 2017-06-14 13:25:13 -0700 | [diff] [blame] | 4705 | if (size < 0) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4706 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4707 | context->validationError(GL_INVALID_VALUE, kNegativeSize); |
Brandon Jones | 6cad566 | 2017-06-14 13:25:13 -0700 | [diff] [blame] | 4708 | return false; |
| 4709 | } |
| 4710 | |
| 4711 | if (offset < 0) |
| 4712 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4713 | context->validationError(GL_INVALID_VALUE, kNegativeOffset); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4714 | return false; |
| 4715 | } |
| 4716 | |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 4717 | if (!context->isValidBufferBinding(target)) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4718 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4719 | context->validationError(GL_INVALID_ENUM, kInvalidBufferTypes); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4720 | return false; |
| 4721 | } |
| 4722 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4723 | Buffer *buffer = context->getState().getTargetBuffer(target); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4724 | |
| 4725 | if (!buffer) |
| 4726 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4727 | context->validationError(GL_INVALID_OPERATION, kBufferNotBound); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4728 | return false; |
| 4729 | } |
| 4730 | |
| 4731 | if (buffer->isMapped()) |
| 4732 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4733 | context->validationError(GL_INVALID_OPERATION, kBufferMapped); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4734 | return false; |
| 4735 | } |
| 4736 | |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 4737 | if (context->getExtensions().webglCompatibility && |
| 4738 | buffer->isBoundForTransformFeedbackAndOtherUse()) |
| 4739 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4740 | context->validationError(GL_INVALID_OPERATION, kBufferBoundForTransformFeedback); |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 4741 | return false; |
| 4742 | } |
| 4743 | |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4744 | // Check for possible overflow of size + offset |
| 4745 | angle::CheckedNumeric<size_t> checkedSize(size); |
| 4746 | checkedSize += offset; |
| 4747 | if (!checkedSize.IsValid()) |
| 4748 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4749 | context->validationError(GL_INVALID_VALUE, kParamOverflow); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4750 | return false; |
| 4751 | } |
| 4752 | |
| 4753 | if (size + offset > buffer->getSize()) |
| 4754 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4755 | context->validationError(GL_INVALID_VALUE, kInsufficientBufferSize); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 4756 | return false; |
| 4757 | } |
| 4758 | |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 4759 | return true; |
| 4760 | } |
| 4761 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 4762 | bool ValidateRequestExtensionANGLE(Context *context, const GLchar *name) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 4763 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 4764 | if (!context->getExtensions().requestExtension) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 4765 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4766 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 4767 | return false; |
| 4768 | } |
| 4769 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 4770 | if (!context->isExtensionRequestable(name)) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 4771 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4772 | context->validationError(GL_INVALID_OPERATION, kExtensionNotRequestable); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 4773 | return false; |
| 4774 | } |
| 4775 | |
| 4776 | return true; |
| 4777 | } |
| 4778 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4779 | bool ValidateActiveTexture(Context *context, GLenum texture) |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 4780 | { |
Lingfeng Yang | 038dd53 | 2018-03-29 17:31:52 -0700 | [diff] [blame] | 4781 | if (context->getClientMajorVersion() < 2) |
| 4782 | { |
| 4783 | return ValidateMultitextureUnit(context, texture); |
| 4784 | } |
| 4785 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 4786 | if (texture < GL_TEXTURE0 || |
| 4787 | texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1) |
| 4788 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4789 | context->validationError(GL_INVALID_ENUM, kInvalidCombinedImageUnit); |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 4790 | return false; |
| 4791 | } |
| 4792 | |
| 4793 | return true; |
| 4794 | } |
| 4795 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4796 | bool ValidateAttachShader(Context *context, GLuint program, GLuint shader) |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 4797 | { |
| 4798 | Program *programObject = GetValidProgram(context, program); |
| 4799 | if (!programObject) |
| 4800 | { |
| 4801 | return false; |
| 4802 | } |
| 4803 | |
| 4804 | Shader *shaderObject = GetValidShader(context, shader); |
| 4805 | if (!shaderObject) |
| 4806 | { |
| 4807 | return false; |
| 4808 | } |
| 4809 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 4810 | if (programObject->getAttachedShader(shaderObject->getType())) |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 4811 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4812 | context->validationError(GL_INVALID_OPERATION, kShaderAttachmentHasShader); |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 4813 | return false; |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 4814 | } |
| 4815 | |
| 4816 | return true; |
| 4817 | } |
| 4818 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4819 | bool ValidateBindAttribLocation(Context *context, GLuint program, GLuint index, const GLchar *name) |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4820 | { |
| 4821 | if (index >= MAX_VERTEX_ATTRIBS) |
| 4822 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4823 | context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxVertexAttribute); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4824 | return false; |
| 4825 | } |
| 4826 | |
| 4827 | if (strncmp(name, "gl_", 3) == 0) |
| 4828 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4829 | context->validationError(GL_INVALID_OPERATION, kNameBeginsWithGL); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4830 | return false; |
| 4831 | } |
| 4832 | |
Brandon Jones | ed5b46f | 2017-07-21 08:39:17 -0700 | [diff] [blame] | 4833 | if (context->isWebGL()) |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 4834 | { |
Brandon Jones | ed5b46f | 2017-07-21 08:39:17 -0700 | [diff] [blame] | 4835 | const size_t length = strlen(name); |
| 4836 | |
| 4837 | if (!IsValidESSLString(name, length)) |
| 4838 | { |
| 4839 | // The WebGL spec (section 6.20) disallows strings containing invalid ESSL characters |
| 4840 | // for shader-related entry points |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4841 | context->validationError(GL_INVALID_VALUE, kInvalidNameCharacters); |
Brandon Jones | ed5b46f | 2017-07-21 08:39:17 -0700 | [diff] [blame] | 4842 | return false; |
| 4843 | } |
| 4844 | |
| 4845 | if (!ValidateWebGLNameLength(context, length) || !ValidateWebGLNamePrefix(context, name)) |
| 4846 | { |
| 4847 | return false; |
| 4848 | } |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 4849 | } |
| 4850 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4851 | return GetValidProgram(context, program) != nullptr; |
| 4852 | } |
| 4853 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4854 | bool ValidateBindFramebuffer(Context *context, GLenum target, GLuint framebuffer) |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4855 | { |
Geoff Lang | e8afa90 | 2017-09-27 15:00:43 -0400 | [diff] [blame] | 4856 | if (!ValidFramebufferTarget(context, target)) |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4857 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4858 | context->validationError(GL_INVALID_ENUM, kInvalidFramebufferTarget); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4859 | return false; |
| 4860 | } |
| 4861 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4862 | if (!context->getState().isBindGeneratesResourceEnabled() && |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4863 | !context->isFramebufferGenerated(framebuffer)) |
| 4864 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4865 | context->validationError(GL_INVALID_OPERATION, kObjectNotGenerated); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4866 | return false; |
| 4867 | } |
| 4868 | |
| 4869 | return true; |
| 4870 | } |
| 4871 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4872 | bool ValidateBindRenderbuffer(Context *context, GLenum target, GLuint renderbuffer) |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4873 | { |
| 4874 | if (target != GL_RENDERBUFFER) |
| 4875 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4876 | context->validationError(GL_INVALID_ENUM, kInvalidRenderbufferTarget); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4877 | return false; |
| 4878 | } |
| 4879 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4880 | if (!context->getState().isBindGeneratesResourceEnabled() && |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4881 | !context->isRenderbufferGenerated(renderbuffer)) |
| 4882 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4883 | context->validationError(GL_INVALID_OPERATION, kObjectNotGenerated); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4884 | return false; |
| 4885 | } |
| 4886 | |
| 4887 | return true; |
| 4888 | } |
| 4889 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4890 | static bool ValidBlendEquationMode(const Context *context, GLenum mode) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4891 | { |
| 4892 | switch (mode) |
| 4893 | { |
| 4894 | case GL_FUNC_ADD: |
| 4895 | case GL_FUNC_SUBTRACT: |
| 4896 | case GL_FUNC_REVERSE_SUBTRACT: |
Geoff Lang | 50cac57 | 2017-09-26 17:37:43 -0400 | [diff] [blame] | 4897 | return true; |
| 4898 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4899 | case GL_MIN: |
| 4900 | case GL_MAX: |
Geoff Lang | 50cac57 | 2017-09-26 17:37:43 -0400 | [diff] [blame] | 4901 | return context->getClientVersion() >= ES_3_0 || context->getExtensions().blendMinMax; |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4902 | |
| 4903 | default: |
| 4904 | return false; |
| 4905 | } |
| 4906 | } |
| 4907 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4908 | bool ValidateBlendColor(Context *context, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 4909 | { |
| 4910 | return true; |
| 4911 | } |
| 4912 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4913 | bool ValidateBlendEquation(Context *context, GLenum mode) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4914 | { |
Geoff Lang | 50cac57 | 2017-09-26 17:37:43 -0400 | [diff] [blame] | 4915 | if (!ValidBlendEquationMode(context, mode)) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4916 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4917 | context->validationError(GL_INVALID_ENUM, kInvalidBlendEquation); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4918 | return false; |
| 4919 | } |
| 4920 | |
| 4921 | return true; |
| 4922 | } |
| 4923 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4924 | bool ValidateBlendEquationSeparate(Context *context, GLenum modeRGB, GLenum modeAlpha) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4925 | { |
Geoff Lang | 50cac57 | 2017-09-26 17:37:43 -0400 | [diff] [blame] | 4926 | if (!ValidBlendEquationMode(context, modeRGB)) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4927 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4928 | context->validationError(GL_INVALID_ENUM, kInvalidBlendEquation); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4929 | return false; |
| 4930 | } |
| 4931 | |
Geoff Lang | 50cac57 | 2017-09-26 17:37:43 -0400 | [diff] [blame] | 4932 | if (!ValidBlendEquationMode(context, modeAlpha)) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4933 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4934 | context->validationError(GL_INVALID_ENUM, kInvalidBlendEquation); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4935 | return false; |
| 4936 | } |
| 4937 | |
| 4938 | return true; |
| 4939 | } |
| 4940 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4941 | bool ValidateBlendFunc(Context *context, GLenum sfactor, GLenum dfactor) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4942 | { |
| 4943 | return ValidateBlendFuncSeparate(context, sfactor, dfactor, sfactor, dfactor); |
| 4944 | } |
| 4945 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 4946 | bool ValidateBlendFuncSeparate(Context *context, |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4947 | GLenum srcRGB, |
| 4948 | GLenum dstRGB, |
| 4949 | GLenum srcAlpha, |
| 4950 | GLenum dstAlpha) |
| 4951 | { |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 4952 | if (!ValidSrcBlendFunc(context, srcRGB)) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4953 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4954 | context->validationError(GL_INVALID_ENUM, kInvalidBlendFunction); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4955 | return false; |
| 4956 | } |
| 4957 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 4958 | if (!ValidDstBlendFunc(context, dstRGB)) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4959 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4960 | context->validationError(GL_INVALID_ENUM, kInvalidBlendFunction); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4961 | return false; |
| 4962 | } |
| 4963 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 4964 | if (!ValidSrcBlendFunc(context, srcAlpha)) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4965 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4966 | context->validationError(GL_INVALID_ENUM, kInvalidBlendFunction); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4967 | return false; |
| 4968 | } |
| 4969 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 4970 | if (!ValidDstBlendFunc(context, dstAlpha)) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4971 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 4972 | context->validationError(GL_INVALID_ENUM, kInvalidBlendFunction); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4973 | return false; |
| 4974 | } |
| 4975 | |
Frank Henigman | 146e8a1 | 2017-03-02 23:22:37 -0500 | [diff] [blame] | 4976 | if (context->getLimitations().noSimultaneousConstantColorAndAlphaBlendFunc || |
| 4977 | context->getExtensions().webglCompatibility) |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4978 | { |
| 4979 | bool constantColorUsed = |
| 4980 | (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 4981 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 4982 | |
| 4983 | bool constantAlphaUsed = |
| 4984 | (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 4985 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 4986 | |
| 4987 | if (constantColorUsed && constantAlphaUsed) |
| 4988 | { |
Frank Henigman | 146e8a1 | 2017-03-02 23:22:37 -0500 | [diff] [blame] | 4989 | if (context->getExtensions().webglCompatibility) |
| 4990 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4991 | context->validationError(GL_INVALID_OPERATION, kInvalidConstantColor); |
| 4992 | return false; |
Frank Henigman | 146e8a1 | 2017-03-02 23:22:37 -0500 | [diff] [blame] | 4993 | } |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 4994 | |
| 4995 | WARN() << kConstantColorAlphaLimitation; |
| 4996 | context->validationError(GL_INVALID_OPERATION, kConstantColorAlphaLimitation); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4997 | return false; |
| 4998 | } |
| 4999 | } |
| 5000 | |
| 5001 | return true; |
| 5002 | } |
| 5003 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 5004 | bool ValidateGetString(Context *context, GLenum name) |
| 5005 | { |
| 5006 | switch (name) |
| 5007 | { |
| 5008 | case GL_VENDOR: |
| 5009 | case GL_RENDERER: |
| 5010 | case GL_VERSION: |
| 5011 | case GL_SHADING_LANGUAGE_VERSION: |
| 5012 | case GL_EXTENSIONS: |
| 5013 | break; |
| 5014 | |
| 5015 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 5016 | if (!context->getExtensions().requestExtension) |
| 5017 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5018 | context->validationError(GL_INVALID_ENUM, kInvalidName); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 5019 | return false; |
| 5020 | } |
| 5021 | break; |
| 5022 | |
| 5023 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5024 | context->validationError(GL_INVALID_ENUM, kInvalidName); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 5025 | return false; |
| 5026 | } |
| 5027 | |
| 5028 | return true; |
| 5029 | } |
| 5030 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5031 | bool ValidateLineWidth(Context *context, GLfloat width) |
Geoff Lang | 47c4808 | 2016-12-07 15:38:13 -0500 | [diff] [blame] | 5032 | { |
| 5033 | if (width <= 0.0f || isNaN(width)) |
| 5034 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5035 | context->validationError(GL_INVALID_VALUE, kInvalidWidth); |
Geoff Lang | 47c4808 | 2016-12-07 15:38:13 -0500 | [diff] [blame] | 5036 | return false; |
| 5037 | } |
| 5038 | |
| 5039 | return true; |
| 5040 | } |
| 5041 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5042 | bool ValidateDepthRangef(Context *context, GLfloat zNear, GLfloat zFar) |
Frank Henigman | 6137ddc | 2017-02-10 18:55:07 -0500 | [diff] [blame] | 5043 | { |
| 5044 | if (context->getExtensions().webglCompatibility && zNear > zFar) |
| 5045 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5046 | context->validationError(GL_INVALID_OPERATION, kInvalidDepthRange); |
Frank Henigman | 6137ddc | 2017-02-10 18:55:07 -0500 | [diff] [blame] | 5047 | return false; |
| 5048 | } |
| 5049 | |
| 5050 | return true; |
| 5051 | } |
| 5052 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5053 | bool ValidateRenderbufferStorage(Context *context, |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5054 | GLenum target, |
| 5055 | GLenum internalformat, |
| 5056 | GLsizei width, |
| 5057 | GLsizei height) |
| 5058 | { |
| 5059 | return ValidateRenderbufferStorageParametersBase(context, target, 0, internalformat, width, |
| 5060 | height); |
| 5061 | } |
| 5062 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5063 | bool ValidateRenderbufferStorageMultisampleANGLE(Context *context, |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5064 | GLenum target, |
| 5065 | GLsizei samples, |
| 5066 | GLenum internalformat, |
| 5067 | GLsizei width, |
| 5068 | GLsizei height) |
| 5069 | { |
| 5070 | if (!context->getExtensions().framebufferMultisample) |
| 5071 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 5072 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5073 | return false; |
| 5074 | } |
| 5075 | |
| 5076 | // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 5077 | // to MAX_SAMPLES_ANGLE (Context::getCaps().maxSamples) otherwise GL_INVALID_VALUE is |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5078 | // generated. |
| 5079 | if (static_cast<GLuint>(samples) > context->getCaps().maxSamples) |
| 5080 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5081 | context->validationError(GL_INVALID_VALUE, kSamplesOutOfRange); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5082 | return false; |
| 5083 | } |
| 5084 | |
| 5085 | // ANGLE_framebuffer_multisample states GL_OUT_OF_MEMORY is generated on a failure to create |
| 5086 | // the specified storage. This is different than ES 3.0 in which a sample number higher |
| 5087 | // than the maximum sample number supported by this format generates a GL_INVALID_VALUE. |
| 5088 | // The TextureCaps::getMaxSamples method is only guarenteed to be valid when the context is ES3. |
| 5089 | if (context->getClientMajorVersion() >= 3) |
| 5090 | { |
| 5091 | const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); |
| 5092 | if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples()) |
| 5093 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5094 | context->validationError(GL_OUT_OF_MEMORY, kSamplesOutOfRange); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5095 | return false; |
| 5096 | } |
| 5097 | } |
| 5098 | |
| 5099 | return ValidateRenderbufferStorageParametersBase(context, target, samples, internalformat, |
| 5100 | width, height); |
| 5101 | } |
| 5102 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5103 | bool ValidateCheckFramebufferStatus(Context *context, GLenum target) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5104 | { |
Geoff Lang | e8afa90 | 2017-09-27 15:00:43 -0400 | [diff] [blame] | 5105 | if (!ValidFramebufferTarget(context, target)) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5106 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5107 | context->validationError(GL_INVALID_ENUM, kInvalidFramebufferTarget); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5108 | return false; |
| 5109 | } |
| 5110 | |
| 5111 | return true; |
| 5112 | } |
| 5113 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5114 | bool ValidateClearColor(Context *context, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5115 | { |
| 5116 | return true; |
| 5117 | } |
| 5118 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5119 | bool ValidateClearDepthf(Context *context, GLfloat depth) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5120 | { |
| 5121 | return true; |
| 5122 | } |
| 5123 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5124 | bool ValidateClearStencil(Context *context, GLint s) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5125 | { |
| 5126 | return true; |
| 5127 | } |
| 5128 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5129 | bool ValidateColorMask(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5130 | GLboolean red, |
| 5131 | GLboolean green, |
| 5132 | GLboolean blue, |
| 5133 | GLboolean alpha) |
| 5134 | { |
| 5135 | return true; |
| 5136 | } |
| 5137 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5138 | bool ValidateCompileShader(Context *context, GLuint shader) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5139 | { |
| 5140 | return true; |
| 5141 | } |
| 5142 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5143 | bool ValidateCreateProgram(Context *context) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5144 | { |
| 5145 | return true; |
| 5146 | } |
| 5147 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5148 | bool ValidateCullFace(Context *context, CullFaceMode mode) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5149 | { |
| 5150 | switch (mode) |
| 5151 | { |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 5152 | case CullFaceMode::Front: |
| 5153 | case CullFaceMode::Back: |
| 5154 | case CullFaceMode::FrontAndBack: |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5155 | break; |
| 5156 | |
| 5157 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5158 | context->validationError(GL_INVALID_ENUM, kInvalidCullMode); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5159 | return false; |
| 5160 | } |
| 5161 | |
| 5162 | return true; |
| 5163 | } |
| 5164 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5165 | bool ValidateDeleteProgram(Context *context, GLuint program) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5166 | { |
| 5167 | if (program == 0) |
| 5168 | { |
| 5169 | return false; |
| 5170 | } |
| 5171 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5172 | if (!context->getProgramResolveLink(program)) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5173 | { |
| 5174 | if (context->getShader(program)) |
| 5175 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5176 | context->validationError(GL_INVALID_OPERATION, kExpectedProgramName); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5177 | return false; |
| 5178 | } |
| 5179 | else |
| 5180 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5181 | context->validationError(GL_INVALID_VALUE, kInvalidProgramName); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5182 | return false; |
| 5183 | } |
| 5184 | } |
| 5185 | |
| 5186 | return true; |
| 5187 | } |
| 5188 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5189 | bool ValidateDeleteShader(Context *context, GLuint shader) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5190 | { |
| 5191 | if (shader == 0) |
| 5192 | { |
| 5193 | return false; |
| 5194 | } |
| 5195 | |
| 5196 | if (!context->getShader(shader)) |
| 5197 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5198 | if (context->getProgramResolveLink(shader)) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5199 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5200 | context->validationError(GL_INVALID_OPERATION, kInvalidShaderName); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5201 | return false; |
| 5202 | } |
| 5203 | else |
| 5204 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5205 | context->validationError(GL_INVALID_VALUE, kExpectedShaderName); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5206 | return false; |
| 5207 | } |
| 5208 | } |
| 5209 | |
| 5210 | return true; |
| 5211 | } |
| 5212 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5213 | bool ValidateDepthFunc(Context *context, GLenum func) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5214 | { |
| 5215 | switch (func) |
| 5216 | { |
| 5217 | case GL_NEVER: |
| 5218 | case GL_ALWAYS: |
| 5219 | case GL_LESS: |
| 5220 | case GL_LEQUAL: |
| 5221 | case GL_EQUAL: |
| 5222 | case GL_GREATER: |
| 5223 | case GL_GEQUAL: |
| 5224 | case GL_NOTEQUAL: |
| 5225 | break; |
| 5226 | |
| 5227 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5228 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5229 | return false; |
| 5230 | } |
| 5231 | |
| 5232 | return true; |
| 5233 | } |
| 5234 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5235 | bool ValidateDepthMask(Context *context, GLboolean flag) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5236 | { |
| 5237 | return true; |
| 5238 | } |
| 5239 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5240 | bool ValidateDetachShader(Context *context, GLuint program, GLuint shader) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5241 | { |
| 5242 | Program *programObject = GetValidProgram(context, program); |
| 5243 | if (!programObject) |
| 5244 | { |
| 5245 | return false; |
| 5246 | } |
| 5247 | |
| 5248 | Shader *shaderObject = GetValidShader(context, shader); |
| 5249 | if (!shaderObject) |
| 5250 | { |
| 5251 | return false; |
| 5252 | } |
| 5253 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 5254 | const Shader *attachedShader = programObject->getAttachedShader(shaderObject->getType()); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5255 | if (attachedShader != shaderObject) |
| 5256 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5257 | context->validationError(GL_INVALID_OPERATION, kShaderToDetachMustBeAttached); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5258 | return false; |
| 5259 | } |
| 5260 | |
| 5261 | return true; |
| 5262 | } |
| 5263 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5264 | bool ValidateDisableVertexAttribArray(Context *context, GLuint index) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5265 | { |
| 5266 | if (index >= MAX_VERTEX_ATTRIBS) |
| 5267 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5268 | context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxVertexAttribute); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5269 | return false; |
| 5270 | } |
| 5271 | |
| 5272 | return true; |
| 5273 | } |
| 5274 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5275 | bool ValidateEnableVertexAttribArray(Context *context, GLuint index) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5276 | { |
| 5277 | if (index >= MAX_VERTEX_ATTRIBS) |
| 5278 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5279 | context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxVertexAttribute); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5280 | return false; |
| 5281 | } |
| 5282 | |
| 5283 | return true; |
| 5284 | } |
| 5285 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5286 | bool ValidateFinish(Context *context) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5287 | { |
| 5288 | return true; |
| 5289 | } |
| 5290 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5291 | bool ValidateFlush(Context *context) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5292 | { |
| 5293 | return true; |
| 5294 | } |
| 5295 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5296 | bool ValidateFrontFace(Context *context, GLenum mode) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5297 | { |
| 5298 | switch (mode) |
| 5299 | { |
| 5300 | case GL_CW: |
| 5301 | case GL_CCW: |
| 5302 | break; |
| 5303 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5304 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5305 | return false; |
| 5306 | } |
| 5307 | |
| 5308 | return true; |
| 5309 | } |
| 5310 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5311 | bool ValidateGetActiveAttrib(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5312 | GLuint program, |
| 5313 | GLuint index, |
| 5314 | GLsizei bufsize, |
| 5315 | GLsizei *length, |
| 5316 | GLint *size, |
| 5317 | GLenum *type, |
| 5318 | GLchar *name) |
| 5319 | { |
| 5320 | if (bufsize < 0) |
| 5321 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5322 | context->validationError(GL_INVALID_VALUE, kNegativeBufferSize); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5323 | return false; |
| 5324 | } |
| 5325 | |
| 5326 | Program *programObject = GetValidProgram(context, program); |
| 5327 | |
| 5328 | if (!programObject) |
| 5329 | { |
| 5330 | return false; |
| 5331 | } |
| 5332 | |
| 5333 | if (index >= static_cast<GLuint>(programObject->getActiveAttributeCount())) |
| 5334 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5335 | context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxActiveUniform); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5336 | return false; |
| 5337 | } |
| 5338 | |
| 5339 | return true; |
| 5340 | } |
| 5341 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5342 | bool ValidateGetActiveUniform(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5343 | GLuint program, |
| 5344 | GLuint index, |
| 5345 | GLsizei bufsize, |
| 5346 | GLsizei *length, |
| 5347 | GLint *size, |
| 5348 | GLenum *type, |
| 5349 | GLchar *name) |
| 5350 | { |
| 5351 | if (bufsize < 0) |
| 5352 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5353 | context->validationError(GL_INVALID_VALUE, kNegativeBufferSize); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5354 | return false; |
| 5355 | } |
| 5356 | |
| 5357 | Program *programObject = GetValidProgram(context, program); |
| 5358 | |
| 5359 | if (!programObject) |
| 5360 | { |
| 5361 | return false; |
| 5362 | } |
| 5363 | |
| 5364 | if (index >= static_cast<GLuint>(programObject->getActiveUniformCount())) |
| 5365 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5366 | context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxActiveUniform); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5367 | return false; |
| 5368 | } |
| 5369 | |
| 5370 | return true; |
| 5371 | } |
| 5372 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5373 | bool ValidateGetAttachedShaders(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5374 | GLuint program, |
| 5375 | GLsizei maxcount, |
| 5376 | GLsizei *count, |
| 5377 | GLuint *shaders) |
| 5378 | { |
| 5379 | if (maxcount < 0) |
| 5380 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5381 | context->validationError(GL_INVALID_VALUE, kNegativeMaxCount); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5382 | return false; |
| 5383 | } |
| 5384 | |
| 5385 | Program *programObject = GetValidProgram(context, program); |
| 5386 | |
| 5387 | if (!programObject) |
| 5388 | { |
| 5389 | return false; |
| 5390 | } |
| 5391 | |
| 5392 | return true; |
| 5393 | } |
| 5394 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5395 | bool ValidateGetAttribLocation(Context *context, GLuint program, const GLchar *name) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5396 | { |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 5397 | // The WebGL spec (section 6.20) disallows strings containing invalid ESSL characters for |
| 5398 | // shader-related entry points |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 5399 | if (context->getExtensions().webglCompatibility && !IsValidESSLString(name, strlen(name))) |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 5400 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5401 | context->validationError(GL_INVALID_VALUE, kInvalidNameCharacters); |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 5402 | return false; |
| 5403 | } |
| 5404 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5405 | Program *programObject = GetValidProgram(context, program); |
| 5406 | |
| 5407 | if (!programObject) |
| 5408 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5409 | context->validationError(GL_INVALID_OPERATION, kProgramNotBound); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5410 | return false; |
| 5411 | } |
| 5412 | |
| 5413 | if (!programObject->isLinked()) |
| 5414 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5415 | context->validationError(GL_INVALID_OPERATION, kProgramNotLinked); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5416 | return false; |
| 5417 | } |
| 5418 | |
| 5419 | return true; |
| 5420 | } |
| 5421 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5422 | bool ValidateGetBooleanv(Context *context, GLenum pname, GLboolean *params) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5423 | { |
| 5424 | GLenum nativeType; |
| 5425 | unsigned int numParams = 0; |
| 5426 | return ValidateStateQuery(context, pname, &nativeType, &numParams); |
| 5427 | } |
| 5428 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5429 | bool ValidateGetError(Context *context) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5430 | { |
| 5431 | return true; |
| 5432 | } |
| 5433 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5434 | bool ValidateGetFloatv(Context *context, GLenum pname, GLfloat *params) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5435 | { |
| 5436 | GLenum nativeType; |
| 5437 | unsigned int numParams = 0; |
| 5438 | return ValidateStateQuery(context, pname, &nativeType, &numParams); |
| 5439 | } |
| 5440 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5441 | bool ValidateGetIntegerv(Context *context, GLenum pname, GLint *params) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5442 | { |
| 5443 | GLenum nativeType; |
| 5444 | unsigned int numParams = 0; |
| 5445 | return ValidateStateQuery(context, pname, &nativeType, &numParams); |
| 5446 | } |
| 5447 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5448 | bool ValidateGetProgramInfoLog(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5449 | GLuint program, |
| 5450 | GLsizei bufsize, |
| 5451 | GLsizei *length, |
| 5452 | GLchar *infolog) |
| 5453 | { |
| 5454 | if (bufsize < 0) |
| 5455 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5456 | context->validationError(GL_INVALID_VALUE, kNegativeBufferSize); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5457 | return false; |
| 5458 | } |
| 5459 | |
| 5460 | Program *programObject = GetValidProgram(context, program); |
| 5461 | if (!programObject) |
| 5462 | { |
| 5463 | return false; |
| 5464 | } |
| 5465 | |
| 5466 | return true; |
| 5467 | } |
| 5468 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5469 | bool ValidateGetShaderInfoLog(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5470 | GLuint shader, |
| 5471 | GLsizei bufsize, |
| 5472 | GLsizei *length, |
| 5473 | GLchar *infolog) |
| 5474 | { |
| 5475 | if (bufsize < 0) |
| 5476 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5477 | context->validationError(GL_INVALID_VALUE, kNegativeBufferSize); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5478 | return false; |
| 5479 | } |
| 5480 | |
| 5481 | Shader *shaderObject = GetValidShader(context, shader); |
| 5482 | if (!shaderObject) |
| 5483 | { |
| 5484 | return false; |
| 5485 | } |
| 5486 | |
| 5487 | return true; |
| 5488 | } |
| 5489 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5490 | bool ValidateGetShaderPrecisionFormat(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5491 | GLenum shadertype, |
| 5492 | GLenum precisiontype, |
| 5493 | GLint *range, |
| 5494 | GLint *precision) |
| 5495 | { |
| 5496 | switch (shadertype) |
| 5497 | { |
| 5498 | case GL_VERTEX_SHADER: |
| 5499 | case GL_FRAGMENT_SHADER: |
| 5500 | break; |
| 5501 | case GL_COMPUTE_SHADER: |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 5502 | context->validationError(GL_INVALID_OPERATION, kUnimplementedComputeShaderPrecision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5503 | return false; |
| 5504 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5505 | context->validationError(GL_INVALID_ENUM, kInvalidShaderType); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5506 | return false; |
| 5507 | } |
| 5508 | |
| 5509 | switch (precisiontype) |
| 5510 | { |
| 5511 | case GL_LOW_FLOAT: |
| 5512 | case GL_MEDIUM_FLOAT: |
| 5513 | case GL_HIGH_FLOAT: |
| 5514 | case GL_LOW_INT: |
| 5515 | case GL_MEDIUM_INT: |
| 5516 | case GL_HIGH_INT: |
| 5517 | break; |
| 5518 | |
| 5519 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5520 | context->validationError(GL_INVALID_ENUM, kInvalidPrecision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5521 | return false; |
| 5522 | } |
| 5523 | |
| 5524 | return true; |
| 5525 | } |
| 5526 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5527 | bool ValidateGetShaderSource(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5528 | GLuint shader, |
| 5529 | GLsizei bufsize, |
| 5530 | GLsizei *length, |
| 5531 | GLchar *source) |
| 5532 | { |
| 5533 | if (bufsize < 0) |
| 5534 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5535 | context->validationError(GL_INVALID_VALUE, kNegativeBufferSize); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5536 | return false; |
| 5537 | } |
| 5538 | |
| 5539 | Shader *shaderObject = GetValidShader(context, shader); |
| 5540 | if (!shaderObject) |
| 5541 | { |
| 5542 | return false; |
| 5543 | } |
| 5544 | |
| 5545 | return true; |
| 5546 | } |
| 5547 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5548 | bool ValidateGetUniformLocation(Context *context, GLuint program, const GLchar *name) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5549 | { |
| 5550 | if (strstr(name, "gl_") == name) |
| 5551 | { |
| 5552 | return false; |
| 5553 | } |
| 5554 | |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 5555 | // The WebGL spec (section 6.20) disallows strings containing invalid ESSL characters for |
| 5556 | // shader-related entry points |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 5557 | if (context->getExtensions().webglCompatibility && !IsValidESSLString(name, strlen(name))) |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 5558 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5559 | context->validationError(GL_INVALID_VALUE, kInvalidNameCharacters); |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 5560 | return false; |
| 5561 | } |
| 5562 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5563 | Program *programObject = GetValidProgram(context, program); |
| 5564 | |
| 5565 | if (!programObject) |
| 5566 | { |
| 5567 | return false; |
| 5568 | } |
| 5569 | |
| 5570 | if (!programObject->isLinked()) |
| 5571 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5572 | context->validationError(GL_INVALID_OPERATION, kProgramNotLinked); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5573 | return false; |
| 5574 | } |
| 5575 | |
| 5576 | return true; |
| 5577 | } |
| 5578 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5579 | bool ValidateHint(Context *context, GLenum target, GLenum mode) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5580 | { |
| 5581 | switch (mode) |
| 5582 | { |
| 5583 | case GL_FASTEST: |
| 5584 | case GL_NICEST: |
| 5585 | case GL_DONT_CARE: |
| 5586 | break; |
| 5587 | |
| 5588 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5589 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5590 | return false; |
| 5591 | } |
| 5592 | |
| 5593 | switch (target) |
| 5594 | { |
| 5595 | case GL_GENERATE_MIPMAP_HINT: |
| 5596 | break; |
| 5597 | |
Geoff Lang | e7bd218 | 2017-06-16 16:13:13 -0400 | [diff] [blame] | 5598 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: |
| 5599 | if (context->getClientVersion() < ES_3_0 && |
| 5600 | !context->getExtensions().standardDerivatives) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5601 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 5602 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5603 | return false; |
| 5604 | } |
| 5605 | break; |
| 5606 | |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 5607 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 5608 | case GL_POINT_SMOOTH_HINT: |
| 5609 | case GL_LINE_SMOOTH_HINT: |
| 5610 | case GL_FOG_HINT: |
| 5611 | if (context->getClientMajorVersion() >= 2) |
| 5612 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5613 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 5614 | return false; |
| 5615 | } |
| 5616 | break; |
| 5617 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5618 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5619 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5620 | return false; |
| 5621 | } |
| 5622 | |
| 5623 | return true; |
| 5624 | } |
| 5625 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5626 | bool ValidateIsBuffer(Context *context, GLuint buffer) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5627 | { |
| 5628 | return true; |
| 5629 | } |
| 5630 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5631 | bool ValidateIsFramebuffer(Context *context, GLuint framebuffer) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5632 | { |
| 5633 | return true; |
| 5634 | } |
| 5635 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5636 | bool ValidateIsProgram(Context *context, GLuint program) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5637 | { |
| 5638 | return true; |
| 5639 | } |
| 5640 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5641 | bool ValidateIsRenderbuffer(Context *context, GLuint renderbuffer) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5642 | { |
| 5643 | return true; |
| 5644 | } |
| 5645 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5646 | bool ValidateIsShader(Context *context, GLuint shader) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5647 | { |
| 5648 | return true; |
| 5649 | } |
| 5650 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5651 | bool ValidateIsTexture(Context *context, GLuint texture) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5652 | { |
| 5653 | return true; |
| 5654 | } |
| 5655 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5656 | bool ValidatePixelStorei(Context *context, GLenum pname, GLint param) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5657 | { |
| 5658 | if (context->getClientMajorVersion() < 3) |
| 5659 | { |
| 5660 | switch (pname) |
| 5661 | { |
| 5662 | case GL_UNPACK_IMAGE_HEIGHT: |
| 5663 | case GL_UNPACK_SKIP_IMAGES: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5664 | context->validationError(GL_INVALID_ENUM, kInvalidPname); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5665 | return false; |
| 5666 | |
| 5667 | case GL_UNPACK_ROW_LENGTH: |
| 5668 | case GL_UNPACK_SKIP_ROWS: |
| 5669 | case GL_UNPACK_SKIP_PIXELS: |
| 5670 | if (!context->getExtensions().unpackSubimage) |
| 5671 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5672 | context->validationError(GL_INVALID_ENUM, kInvalidPname); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5673 | return false; |
| 5674 | } |
| 5675 | break; |
| 5676 | |
| 5677 | case GL_PACK_ROW_LENGTH: |
| 5678 | case GL_PACK_SKIP_ROWS: |
| 5679 | case GL_PACK_SKIP_PIXELS: |
| 5680 | if (!context->getExtensions().packSubimage) |
| 5681 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5682 | context->validationError(GL_INVALID_ENUM, kInvalidPname); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5683 | return false; |
| 5684 | } |
| 5685 | break; |
| 5686 | } |
| 5687 | } |
| 5688 | |
| 5689 | if (param < 0) |
| 5690 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 5691 | context->validationError(GL_INVALID_VALUE, kNegativeParam); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5692 | return false; |
| 5693 | } |
| 5694 | |
| 5695 | switch (pname) |
| 5696 | { |
| 5697 | case GL_UNPACK_ALIGNMENT: |
| 5698 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 5699 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5700 | context->validationError(GL_INVALID_VALUE, kInvalidUnpackAlignment); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5701 | return false; |
| 5702 | } |
| 5703 | break; |
| 5704 | |
| 5705 | case GL_PACK_ALIGNMENT: |
| 5706 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 5707 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5708 | context->validationError(GL_INVALID_VALUE, kInvalidUnpackAlignment); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5709 | return false; |
| 5710 | } |
| 5711 | break; |
| 5712 | |
| 5713 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
Geoff Lang | 000dab8 | 2017-09-27 14:27:07 -0400 | [diff] [blame] | 5714 | if (!context->getExtensions().packReverseRowOrder) |
| 5715 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5716 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Geoff Lang | 000dab8 | 2017-09-27 14:27:07 -0400 | [diff] [blame] | 5717 | } |
| 5718 | break; |
| 5719 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5720 | case GL_UNPACK_ROW_LENGTH: |
| 5721 | case GL_UNPACK_IMAGE_HEIGHT: |
| 5722 | case GL_UNPACK_SKIP_IMAGES: |
| 5723 | case GL_UNPACK_SKIP_ROWS: |
| 5724 | case GL_UNPACK_SKIP_PIXELS: |
| 5725 | case GL_PACK_ROW_LENGTH: |
| 5726 | case GL_PACK_SKIP_ROWS: |
| 5727 | case GL_PACK_SKIP_PIXELS: |
| 5728 | break; |
| 5729 | |
| 5730 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5731 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5732 | return false; |
| 5733 | } |
| 5734 | |
| 5735 | return true; |
| 5736 | } |
| 5737 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5738 | bool ValidatePolygonOffset(Context *context, GLfloat factor, GLfloat units) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5739 | { |
| 5740 | return true; |
| 5741 | } |
| 5742 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5743 | bool ValidateReleaseShaderCompiler(Context *context) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5744 | { |
| 5745 | return true; |
| 5746 | } |
| 5747 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5748 | bool ValidateSampleCoverage(Context *context, GLfloat value, GLboolean invert) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5749 | { |
| 5750 | return true; |
| 5751 | } |
| 5752 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5753 | bool ValidateScissor(Context *context, GLint x, GLint y, GLsizei width, GLsizei height) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5754 | { |
| 5755 | if (width < 0 || height < 0) |
| 5756 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5757 | context->validationError(GL_INVALID_VALUE, kNegativeSize); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5758 | return false; |
| 5759 | } |
| 5760 | |
| 5761 | return true; |
| 5762 | } |
| 5763 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5764 | bool ValidateShaderBinary(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5765 | GLsizei n, |
| 5766 | const GLuint *shaders, |
| 5767 | GLenum binaryformat, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 5768 | const void *binary, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5769 | GLsizei length) |
| 5770 | { |
| 5771 | const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats; |
| 5772 | if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == |
| 5773 | shaderBinaryFormats.end()) |
| 5774 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 5775 | context->validationError(GL_INVALID_ENUM, kInvalidShaderBinaryFormat); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5776 | return false; |
| 5777 | } |
| 5778 | |
| 5779 | return true; |
| 5780 | } |
| 5781 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5782 | bool ValidateShaderSource(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5783 | GLuint shader, |
| 5784 | GLsizei count, |
| 5785 | const GLchar *const *string, |
| 5786 | const GLint *length) |
| 5787 | { |
| 5788 | if (count < 0) |
| 5789 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5790 | context->validationError(GL_INVALID_VALUE, kNegativeCount); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5791 | return false; |
| 5792 | } |
| 5793 | |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 5794 | // The WebGL spec (section 6.20) disallows strings containing invalid ESSL characters for |
| 5795 | // shader-related entry points |
| 5796 | if (context->getExtensions().webglCompatibility) |
| 5797 | { |
| 5798 | for (GLsizei i = 0; i < count; i++) |
| 5799 | { |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 5800 | size_t len = |
| 5801 | (length && length[i] >= 0) ? static_cast<size_t>(length[i]) : strlen(string[i]); |
Geoff Lang | a71a98e | 2017-06-19 15:15:00 -0400 | [diff] [blame] | 5802 | |
| 5803 | // Backslash as line-continuation is allowed in WebGL 2.0. |
Geoff Lang | cab92ee | 2017-07-19 17:32:07 -0400 | [diff] [blame] | 5804 | if (!IsValidESSLShaderSourceString(string[i], len, |
| 5805 | context->getClientVersion() >= ES_3_0)) |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 5806 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5807 | context->validationError(GL_INVALID_VALUE, kShaderSourceInvalidCharacters); |
Geoff Lang | fc32e8b | 2017-05-31 14:16:59 -0400 | [diff] [blame] | 5808 | return false; |
| 5809 | } |
| 5810 | } |
| 5811 | } |
| 5812 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5813 | Shader *shaderObject = GetValidShader(context, shader); |
| 5814 | if (!shaderObject) |
| 5815 | { |
| 5816 | return false; |
| 5817 | } |
| 5818 | |
| 5819 | return true; |
| 5820 | } |
| 5821 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5822 | bool ValidateStencilFunc(Context *context, GLenum func, GLint ref, GLuint mask) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5823 | { |
| 5824 | if (!IsValidStencilFunc(func)) |
| 5825 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5826 | context->validationError(GL_INVALID_ENUM, kInvalidStencil); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5827 | return false; |
| 5828 | } |
| 5829 | |
| 5830 | return true; |
| 5831 | } |
| 5832 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5833 | bool ValidateStencilFuncSeparate(Context *context, GLenum face, GLenum func, GLint ref, GLuint mask) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5834 | { |
| 5835 | if (!IsValidStencilFace(face)) |
| 5836 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5837 | context->validationError(GL_INVALID_ENUM, kInvalidStencil); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5838 | return false; |
| 5839 | } |
| 5840 | |
| 5841 | if (!IsValidStencilFunc(func)) |
| 5842 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5843 | context->validationError(GL_INVALID_ENUM, kInvalidStencil); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5844 | return false; |
| 5845 | } |
| 5846 | |
| 5847 | return true; |
| 5848 | } |
| 5849 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5850 | bool ValidateStencilMask(Context *context, GLuint mask) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5851 | { |
| 5852 | return true; |
| 5853 | } |
| 5854 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5855 | bool ValidateStencilMaskSeparate(Context *context, GLenum face, GLuint mask) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5856 | { |
| 5857 | if (!IsValidStencilFace(face)) |
| 5858 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5859 | context->validationError(GL_INVALID_ENUM, kInvalidStencil); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5860 | return false; |
| 5861 | } |
| 5862 | |
| 5863 | return true; |
| 5864 | } |
| 5865 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5866 | bool ValidateStencilOp(Context *context, GLenum fail, GLenum zfail, GLenum zpass) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5867 | { |
| 5868 | if (!IsValidStencilOp(fail)) |
| 5869 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5870 | context->validationError(GL_INVALID_ENUM, kInvalidStencil); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5871 | return false; |
| 5872 | } |
| 5873 | |
| 5874 | if (!IsValidStencilOp(zfail)) |
| 5875 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5876 | context->validationError(GL_INVALID_ENUM, kInvalidStencil); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5877 | return false; |
| 5878 | } |
| 5879 | |
| 5880 | if (!IsValidStencilOp(zpass)) |
| 5881 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5882 | context->validationError(GL_INVALID_ENUM, kInvalidStencil); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5883 | return false; |
| 5884 | } |
| 5885 | |
| 5886 | return true; |
| 5887 | } |
| 5888 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5889 | bool ValidateStencilOpSeparate(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5890 | GLenum face, |
| 5891 | GLenum fail, |
| 5892 | GLenum zfail, |
| 5893 | GLenum zpass) |
| 5894 | { |
| 5895 | if (!IsValidStencilFace(face)) |
| 5896 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 5897 | context->validationError(GL_INVALID_ENUM, kInvalidStencil); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5898 | return false; |
| 5899 | } |
| 5900 | |
| 5901 | return ValidateStencilOp(context, fail, zfail, zpass); |
| 5902 | } |
| 5903 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5904 | bool ValidateUniform1f(Context *context, GLint location, GLfloat x) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5905 | { |
| 5906 | return ValidateUniform(context, GL_FLOAT, location, 1); |
| 5907 | } |
| 5908 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5909 | bool ValidateUniform1fv(Context *context, GLint location, GLsizei count, const GLfloat *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5910 | { |
| 5911 | return ValidateUniform(context, GL_FLOAT, location, count); |
| 5912 | } |
| 5913 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5914 | bool ValidateUniform1i(Context *context, GLint location, GLint x) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 5915 | { |
| 5916 | return ValidateUniform1iv(context, location, 1, &x); |
| 5917 | } |
| 5918 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5919 | bool ValidateUniform2fv(Context *context, GLint location, GLsizei count, const GLfloat *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5920 | { |
| 5921 | return ValidateUniform(context, GL_FLOAT_VEC2, location, count); |
| 5922 | } |
| 5923 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5924 | bool ValidateUniform2i(Context *context, GLint location, GLint x, GLint y) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5925 | { |
| 5926 | return ValidateUniform(context, GL_INT_VEC2, location, 1); |
| 5927 | } |
| 5928 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5929 | bool ValidateUniform2iv(Context *context, GLint location, GLsizei count, const GLint *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5930 | { |
| 5931 | return ValidateUniform(context, GL_INT_VEC2, location, count); |
| 5932 | } |
| 5933 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5934 | bool ValidateUniform3f(Context *context, GLint location, GLfloat x, GLfloat y, GLfloat z) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5935 | { |
| 5936 | return ValidateUniform(context, GL_FLOAT_VEC3, location, 1); |
| 5937 | } |
| 5938 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5939 | bool ValidateUniform3fv(Context *context, GLint location, GLsizei count, const GLfloat *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5940 | { |
| 5941 | return ValidateUniform(context, GL_FLOAT_VEC3, location, count); |
| 5942 | } |
| 5943 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5944 | bool ValidateUniform3i(Context *context, GLint location, GLint x, GLint y, GLint z) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5945 | { |
| 5946 | return ValidateUniform(context, GL_INT_VEC3, location, 1); |
| 5947 | } |
| 5948 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5949 | bool ValidateUniform3iv(Context *context, GLint location, GLsizei count, const GLint *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5950 | { |
| 5951 | return ValidateUniform(context, GL_INT_VEC3, location, count); |
| 5952 | } |
| 5953 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5954 | bool ValidateUniform4f(Context *context, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5955 | { |
| 5956 | return ValidateUniform(context, GL_FLOAT_VEC4, location, 1); |
| 5957 | } |
| 5958 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5959 | bool ValidateUniform4fv(Context *context, GLint location, GLsizei count, const GLfloat *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5960 | { |
| 5961 | return ValidateUniform(context, GL_FLOAT_VEC4, location, count); |
| 5962 | } |
| 5963 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5964 | bool ValidateUniform4i(Context *context, GLint location, GLint x, GLint y, GLint z, GLint w) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5965 | { |
| 5966 | return ValidateUniform(context, GL_INT_VEC4, location, 1); |
| 5967 | } |
| 5968 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5969 | bool ValidateUniform4iv(Context *context, GLint location, GLsizei count, const GLint *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5970 | { |
| 5971 | return ValidateUniform(context, GL_INT_VEC4, location, count); |
| 5972 | } |
| 5973 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5974 | bool ValidateUniformMatrix2fv(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5975 | GLint location, |
| 5976 | GLsizei count, |
| 5977 | GLboolean transpose, |
| 5978 | const GLfloat *value) |
| 5979 | { |
| 5980 | return ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose); |
| 5981 | } |
| 5982 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5983 | bool ValidateUniformMatrix3fv(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5984 | GLint location, |
| 5985 | GLsizei count, |
| 5986 | GLboolean transpose, |
| 5987 | const GLfloat *value) |
| 5988 | { |
| 5989 | return ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose); |
| 5990 | } |
| 5991 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 5992 | bool ValidateUniformMatrix4fv(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5993 | GLint location, |
| 5994 | GLsizei count, |
| 5995 | GLboolean transpose, |
| 5996 | const GLfloat *value) |
| 5997 | { |
| 5998 | return ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose); |
| 5999 | } |
| 6000 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6001 | bool ValidateValidateProgram(Context *context, GLuint program) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6002 | { |
| 6003 | Program *programObject = GetValidProgram(context, program); |
| 6004 | |
| 6005 | if (!programObject) |
| 6006 | { |
| 6007 | return false; |
| 6008 | } |
| 6009 | |
| 6010 | return true; |
| 6011 | } |
| 6012 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6013 | bool ValidateVertexAttrib1f(Context *context, GLuint index, GLfloat x) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6014 | { |
| 6015 | return ValidateVertexAttribIndex(context, index); |
| 6016 | } |
| 6017 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6018 | bool ValidateVertexAttrib1fv(Context *context, GLuint index, const GLfloat *values) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6019 | { |
| 6020 | return ValidateVertexAttribIndex(context, index); |
| 6021 | } |
| 6022 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6023 | bool ValidateVertexAttrib2f(Context *context, GLuint index, GLfloat x, GLfloat y) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6024 | { |
| 6025 | return ValidateVertexAttribIndex(context, index); |
| 6026 | } |
| 6027 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6028 | bool ValidateVertexAttrib2fv(Context *context, GLuint index, const GLfloat *values) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6029 | { |
| 6030 | return ValidateVertexAttribIndex(context, index); |
| 6031 | } |
| 6032 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6033 | bool ValidateVertexAttrib3f(Context *context, GLuint index, GLfloat x, GLfloat y, GLfloat z) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6034 | { |
| 6035 | return ValidateVertexAttribIndex(context, index); |
| 6036 | } |
| 6037 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6038 | bool ValidateVertexAttrib3fv(Context *context, GLuint index, const GLfloat *values) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6039 | { |
| 6040 | return ValidateVertexAttribIndex(context, index); |
| 6041 | } |
| 6042 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6043 | bool ValidateVertexAttrib4f(Context *context, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6044 | GLuint index, |
| 6045 | GLfloat x, |
| 6046 | GLfloat y, |
| 6047 | GLfloat z, |
| 6048 | GLfloat w) |
| 6049 | { |
| 6050 | return ValidateVertexAttribIndex(context, index); |
| 6051 | } |
| 6052 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6053 | bool ValidateVertexAttrib4fv(Context *context, GLuint index, const GLfloat *values) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6054 | { |
| 6055 | return ValidateVertexAttribIndex(context, index); |
| 6056 | } |
| 6057 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6058 | bool ValidateViewport(Context *context, GLint x, GLint y, GLsizei width, GLsizei height) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6059 | { |
| 6060 | if (width < 0 || height < 0) |
| 6061 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6062 | context->validationError(GL_INVALID_VALUE, kViewportNegativeSize); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6063 | return false; |
| 6064 | } |
| 6065 | |
| 6066 | return true; |
| 6067 | } |
| 6068 | |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 6069 | bool ValidateGetFramebufferAttachmentParameteriv(Context *context, |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6070 | GLenum target, |
| 6071 | GLenum attachment, |
| 6072 | GLenum pname, |
| 6073 | GLint *params) |
| 6074 | { |
| 6075 | return ValidateGetFramebufferAttachmentParameterivBase(context, target, attachment, pname, |
| 6076 | nullptr); |
| 6077 | } |
| 6078 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6079 | bool ValidateGetProgramiv(Context *context, GLuint program, GLenum pname, GLint *params) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6080 | { |
| 6081 | return ValidateGetProgramivBase(context, program, pname, nullptr); |
| 6082 | } |
| 6083 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6084 | bool ValidateCopyTexImage2D(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6085 | TextureTarget target, |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6086 | GLint level, |
| 6087 | GLenum internalformat, |
| 6088 | GLint x, |
| 6089 | GLint y, |
| 6090 | GLsizei width, |
| 6091 | GLsizei height, |
| 6092 | GLint border) |
| 6093 | { |
| 6094 | if (context->getClientMajorVersion() < 3) |
| 6095 | { |
| 6096 | return ValidateES2CopyTexImageParameters(context, target, level, internalformat, false, 0, |
| 6097 | 0, x, y, width, height, border); |
| 6098 | } |
| 6099 | |
| 6100 | ASSERT(context->getClientMajorVersion() == 3); |
| 6101 | return ValidateES3CopyTexImage2DParameters(context, target, level, internalformat, false, 0, 0, |
| 6102 | 0, x, y, width, height, border); |
| 6103 | } |
| 6104 | |
| 6105 | bool ValidateCopyTexSubImage2D(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6106 | TextureTarget target, |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6107 | GLint level, |
| 6108 | GLint xoffset, |
| 6109 | GLint yoffset, |
| 6110 | GLint x, |
| 6111 | GLint y, |
| 6112 | GLsizei width, |
| 6113 | GLsizei height) |
| 6114 | { |
| 6115 | if (context->getClientMajorVersion() < 3) |
| 6116 | { |
| 6117 | return ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, |
| 6118 | yoffset, x, y, width, height, 0); |
| 6119 | } |
| 6120 | |
| 6121 | return ValidateES3CopyTexImage2DParameters(context, target, level, GL_NONE, true, xoffset, |
| 6122 | yoffset, 0, x, y, width, height, 0); |
| 6123 | } |
| 6124 | |
| 6125 | bool ValidateDeleteBuffers(Context *context, GLint n, const GLuint *) |
| 6126 | { |
| 6127 | return ValidateGenOrDelete(context, n); |
| 6128 | } |
| 6129 | |
| 6130 | bool ValidateDeleteFramebuffers(Context *context, GLint n, const GLuint *) |
| 6131 | { |
| 6132 | return ValidateGenOrDelete(context, n); |
| 6133 | } |
| 6134 | |
| 6135 | bool ValidateDeleteRenderbuffers(Context *context, GLint n, const GLuint *) |
| 6136 | { |
| 6137 | return ValidateGenOrDelete(context, n); |
| 6138 | } |
| 6139 | |
| 6140 | bool ValidateDeleteTextures(Context *context, GLint n, const GLuint *) |
| 6141 | { |
| 6142 | return ValidateGenOrDelete(context, n); |
| 6143 | } |
| 6144 | |
| 6145 | bool ValidateDisable(Context *context, GLenum cap) |
| 6146 | { |
| 6147 | if (!ValidCap(context, cap, false)) |
| 6148 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6149 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6150 | return false; |
| 6151 | } |
| 6152 | |
| 6153 | return true; |
| 6154 | } |
| 6155 | |
| 6156 | bool ValidateEnable(Context *context, GLenum cap) |
| 6157 | { |
| 6158 | if (!ValidCap(context, cap, false)) |
| 6159 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6160 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6161 | return false; |
| 6162 | } |
| 6163 | |
| 6164 | if (context->getLimitations().noSampleAlphaToCoverageSupport && |
| 6165 | cap == GL_SAMPLE_ALPHA_TO_COVERAGE) |
| 6166 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 6167 | context->validationError(GL_INVALID_OPERATION, kNoSampleAlphaToCoveragesLimitation); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6168 | |
| 6169 | // We also output an error message to the debugger window if tracing is active, so that |
| 6170 | // developers can see the error message. |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 6171 | ERR() << kNoSampleAlphaToCoveragesLimitation; |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6172 | return false; |
| 6173 | } |
| 6174 | |
| 6175 | return true; |
| 6176 | } |
| 6177 | |
| 6178 | bool ValidateFramebufferRenderbuffer(Context *context, |
| 6179 | GLenum target, |
| 6180 | GLenum attachment, |
| 6181 | GLenum renderbuffertarget, |
| 6182 | GLuint renderbuffer) |
| 6183 | { |
Geoff Lang | e8afa90 | 2017-09-27 15:00:43 -0400 | [diff] [blame] | 6184 | if (!ValidFramebufferTarget(context, target)) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6185 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6186 | context->validationError(GL_INVALID_ENUM, kInvalidFramebufferTarget); |
Brandon Jones | 6cad566 | 2017-06-14 13:25:13 -0700 | [diff] [blame] | 6187 | return false; |
| 6188 | } |
| 6189 | |
| 6190 | if (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0) |
| 6191 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6192 | context->validationError(GL_INVALID_ENUM, kInvalidRenderbufferTarget); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6193 | return false; |
| 6194 | } |
| 6195 | |
| 6196 | return ValidateFramebufferRenderbufferParameters(context, target, attachment, |
| 6197 | renderbuffertarget, renderbuffer); |
| 6198 | } |
| 6199 | |
| 6200 | bool ValidateFramebufferTexture2D(Context *context, |
| 6201 | GLenum target, |
| 6202 | GLenum attachment, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6203 | TextureTarget textarget, |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6204 | GLuint texture, |
| 6205 | GLint level) |
| 6206 | { |
| 6207 | // Attachments are required to be bound to level 0 without ES3 or the GL_OES_fbo_render_mipmap |
| 6208 | // extension |
| 6209 | if (context->getClientMajorVersion() < 3 && !context->getExtensions().fboRenderMipmap && |
| 6210 | level != 0) |
| 6211 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6212 | context->validationError(GL_INVALID_VALUE, kInvalidFramebufferTextureLevel); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6213 | return false; |
| 6214 | } |
| 6215 | |
| 6216 | if (!ValidateFramebufferTextureBase(context, target, attachment, texture, level)) |
| 6217 | { |
| 6218 | return false; |
| 6219 | } |
| 6220 | |
| 6221 | if (texture != 0) |
| 6222 | { |
| 6223 | gl::Texture *tex = context->getTexture(texture); |
| 6224 | ASSERT(tex); |
| 6225 | |
| 6226 | const gl::Caps &caps = context->getCaps(); |
| 6227 | |
| 6228 | switch (textarget) |
| 6229 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6230 | case TextureTarget::_2D: |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6231 | { |
| 6232 | if (level > gl::log2(caps.max2DTextureSize)) |
| 6233 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6234 | context->validationError(GL_INVALID_VALUE, kInvalidMipLevel); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6235 | return false; |
| 6236 | } |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 6237 | if (tex->getType() != TextureType::_2D) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6238 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6239 | context->validationError(GL_INVALID_OPERATION, kInvalidTextureTarget); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6240 | return false; |
| 6241 | } |
| 6242 | } |
| 6243 | break; |
| 6244 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6245 | case TextureTarget::Rectangle: |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 6246 | { |
| 6247 | if (level != 0) |
| 6248 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6249 | context->validationError(GL_INVALID_VALUE, kInvalidMipLevel); |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 6250 | return false; |
| 6251 | } |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 6252 | if (tex->getType() != TextureType::Rectangle) |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 6253 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 6254 | context->validationError(GL_INVALID_OPERATION, kTextureTargetMismatch); |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 6255 | return false; |
| 6256 | } |
| 6257 | } |
| 6258 | break; |
| 6259 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6260 | case TextureTarget::CubeMapNegativeX: |
| 6261 | case TextureTarget::CubeMapNegativeY: |
| 6262 | case TextureTarget::CubeMapNegativeZ: |
| 6263 | case TextureTarget::CubeMapPositiveX: |
| 6264 | case TextureTarget::CubeMapPositiveY: |
| 6265 | case TextureTarget::CubeMapPositiveZ: |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6266 | { |
| 6267 | if (level > gl::log2(caps.maxCubeMapTextureSize)) |
| 6268 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6269 | context->validationError(GL_INVALID_VALUE, kInvalidMipLevel); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6270 | return false; |
| 6271 | } |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 6272 | if (tex->getType() != TextureType::CubeMap) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6273 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 6274 | context->validationError(GL_INVALID_OPERATION, kTextureTargetMismatch); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6275 | return false; |
| 6276 | } |
| 6277 | } |
| 6278 | break; |
| 6279 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6280 | case TextureTarget::_2DMultisample: |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6281 | { |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 6282 | if (context->getClientVersion() < ES_3_1 && |
| 6283 | !context->getExtensions().textureMultisample) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6284 | { |
Jamie Madill | 610640f | 2018-11-21 17:28:41 -0500 | [diff] [blame] | 6285 | context->validationError(GL_INVALID_OPERATION, |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6286 | kMultisampleTextureExtensionOrES31Required); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6287 | return false; |
| 6288 | } |
| 6289 | |
| 6290 | if (level != 0) |
| 6291 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6292 | context->validationError(GL_INVALID_VALUE, kLevelNotZero); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6293 | return false; |
| 6294 | } |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 6295 | if (tex->getType() != TextureType::_2DMultisample) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6296 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 6297 | context->validationError(GL_INVALID_OPERATION, kTextureTargetMismatch); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6298 | return false; |
| 6299 | } |
| 6300 | } |
| 6301 | break; |
| 6302 | |
| 6303 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6304 | context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6305 | return false; |
| 6306 | } |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6307 | } |
| 6308 | |
| 6309 | return true; |
| 6310 | } |
| 6311 | |
| 6312 | bool ValidateGenBuffers(Context *context, GLint n, GLuint *) |
| 6313 | { |
| 6314 | return ValidateGenOrDelete(context, n); |
| 6315 | } |
| 6316 | |
| 6317 | bool ValidateGenFramebuffers(Context *context, GLint n, GLuint *) |
| 6318 | { |
| 6319 | return ValidateGenOrDelete(context, n); |
| 6320 | } |
| 6321 | |
| 6322 | bool ValidateGenRenderbuffers(Context *context, GLint n, GLuint *) |
| 6323 | { |
| 6324 | return ValidateGenOrDelete(context, n); |
| 6325 | } |
| 6326 | |
| 6327 | bool ValidateGenTextures(Context *context, GLint n, GLuint *) |
| 6328 | { |
| 6329 | return ValidateGenOrDelete(context, n); |
| 6330 | } |
| 6331 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6332 | bool ValidateGenerateMipmap(Context *context, TextureType target) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6333 | { |
| 6334 | if (!ValidTextureTarget(context, target)) |
| 6335 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6336 | context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6337 | return false; |
| 6338 | } |
| 6339 | |
Jamie Madill | cfc73cc | 2019-04-08 16:26:51 -0400 | [diff] [blame] | 6340 | Texture *texture = context->getTextureByType(target); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6341 | |
| 6342 | if (texture == nullptr) |
| 6343 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6344 | context->validationError(GL_INVALID_OPERATION, kTextureNotBound); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6345 | return false; |
| 6346 | } |
| 6347 | |
| 6348 | const GLuint effectiveBaseLevel = texture->getTextureState().getEffectiveBaseLevel(); |
| 6349 | |
| 6350 | // This error isn't spelled out in the spec in a very explicit way, but we interpret the spec so |
| 6351 | // that out-of-range base level has a non-color-renderable / non-texture-filterable format. |
| 6352 | if (effectiveBaseLevel >= gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) |
| 6353 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6354 | context->validationError(GL_INVALID_OPERATION, kBaseLevelOutOfRange); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6355 | return false; |
| 6356 | } |
| 6357 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6358 | TextureTarget baseTarget = (target == TextureType::CubeMap) |
| 6359 | ? TextureTarget::CubeMapPositiveX |
| 6360 | : NonCubeTextureTypeToTarget(target); |
Geoff Lang | 536eca1 | 2017-09-13 11:23:35 -0400 | [diff] [blame] | 6361 | const auto &format = *(texture->getFormat(baseTarget, effectiveBaseLevel).info); |
| 6362 | if (format.sizedInternalFormat == GL_NONE || format.compressed || format.depthBits > 0 || |
| 6363 | format.stencilBits > 0) |
Brandon Jones | 6cad566 | 2017-06-14 13:25:13 -0700 | [diff] [blame] | 6364 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6365 | context->validationError(GL_INVALID_OPERATION, kGenerateMipmapNotAllowed); |
Brandon Jones | 6cad566 | 2017-06-14 13:25:13 -0700 | [diff] [blame] | 6366 | return false; |
| 6367 | } |
| 6368 | |
Geoff Lang | 536eca1 | 2017-09-13 11:23:35 -0400 | [diff] [blame] | 6369 | // GenerateMipmap accepts formats that are unsized or both color renderable and filterable. |
| 6370 | bool formatUnsized = !format.sized; |
| 6371 | bool formatColorRenderableAndFilterable = |
| 6372 | format.filterSupport(context->getClientVersion(), context->getExtensions()) && |
Yuly Novikov | f15f886 | 2018-06-04 18:59:41 -0400 | [diff] [blame] | 6373 | format.textureAttachmentSupport(context->getClientVersion(), context->getExtensions()); |
Geoff Lang | 536eca1 | 2017-09-13 11:23:35 -0400 | [diff] [blame] | 6374 | if (!formatUnsized && !formatColorRenderableAndFilterable) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6375 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6376 | context->validationError(GL_INVALID_OPERATION, kGenerateMipmapNotAllowed); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6377 | return false; |
| 6378 | } |
| 6379 | |
Geoff Lang | 536eca1 | 2017-09-13 11:23:35 -0400 | [diff] [blame] | 6380 | // GL_EXT_sRGB adds an unsized SRGB (no alpha) format which has explicitly disabled mipmap |
| 6381 | // generation |
| 6382 | if (format.colorEncoding == GL_SRGB && format.format == GL_RGB) |
| 6383 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6384 | context->validationError(GL_INVALID_OPERATION, kGenerateMipmapNotAllowed); |
Geoff Lang | 536eca1 | 2017-09-13 11:23:35 -0400 | [diff] [blame] | 6385 | return false; |
| 6386 | } |
| 6387 | |
Jiang | e2c0084 | 2018-07-13 16:50:49 +0800 | [diff] [blame] | 6388 | // According to the OpenGL extension spec EXT_sRGB.txt, EXT_SRGB is based on ES 2.0 and |
| 6389 | // generateMipmap is not allowed if texture format is SRGB_EXT or SRGB_ALPHA_EXT. |
| 6390 | if (context->getClientVersion() < Version(3, 0) && format.colorEncoding == GL_SRGB) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6391 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6392 | context->validationError(GL_INVALID_OPERATION, kGenerateMipmapNotAllowed); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6393 | return false; |
| 6394 | } |
| 6395 | |
| 6396 | // Non-power of 2 ES2 check |
| 6397 | if (context->getClientVersion() < Version(3, 0) && !context->getExtensions().textureNPOT && |
| 6398 | (!isPow2(static_cast<int>(texture->getWidth(baseTarget, 0))) || |
| 6399 | !isPow2(static_cast<int>(texture->getHeight(baseTarget, 0))))) |
| 6400 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6401 | ASSERT(target == TextureType::_2D || target == TextureType::Rectangle || |
| 6402 | target == TextureType::CubeMap); |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6403 | context->validationError(GL_INVALID_OPERATION, kTextureNotPow2); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6404 | return false; |
| 6405 | } |
| 6406 | |
| 6407 | // Cube completeness check |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6408 | if (target == TextureType::CubeMap && !texture->getTextureState().isCubeComplete()) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6409 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6410 | context->validationError(GL_INVALID_OPERATION, kCubemapIncomplete); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6411 | return false; |
| 6412 | } |
| 6413 | |
James Darpinian | 83b2f0e | 2018-11-27 15:56:01 -0800 | [diff] [blame] | 6414 | if (context->getExtensions().webglCompatibility && |
| 6415 | (texture->getWidth(baseTarget, effectiveBaseLevel) == 0 || |
| 6416 | texture->getHeight(baseTarget, effectiveBaseLevel) == 0)) |
| 6417 | { |
| 6418 | context->validationError(GL_INVALID_OPERATION, kGenerateMipmapZeroSize); |
| 6419 | return false; |
| 6420 | } |
| 6421 | |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6422 | return true; |
| 6423 | } |
| 6424 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 6425 | bool ValidateGetBufferParameteriv(Context *context, |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 6426 | BufferBinding target, |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6427 | GLenum pname, |
| 6428 | GLint *params) |
| 6429 | { |
| 6430 | return ValidateGetBufferParameterBase(context, target, pname, false, nullptr); |
| 6431 | } |
| 6432 | |
| 6433 | bool ValidateGetRenderbufferParameteriv(Context *context, |
| 6434 | GLenum target, |
| 6435 | GLenum pname, |
| 6436 | GLint *params) |
| 6437 | { |
| 6438 | return ValidateGetRenderbufferParameterivBase(context, target, pname, nullptr); |
| 6439 | } |
| 6440 | |
| 6441 | bool ValidateGetShaderiv(Context *context, GLuint shader, GLenum pname, GLint *params) |
| 6442 | { |
| 6443 | return ValidateGetShaderivBase(context, shader, pname, nullptr); |
| 6444 | } |
| 6445 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6446 | bool ValidateGetTexParameterfv(Context *context, TextureType target, GLenum pname, GLfloat *params) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6447 | { |
| 6448 | return ValidateGetTexParameterBase(context, target, pname, nullptr); |
| 6449 | } |
| 6450 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6451 | bool ValidateGetTexParameteriv(Context *context, TextureType target, GLenum pname, GLint *params) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6452 | { |
| 6453 | return ValidateGetTexParameterBase(context, target, pname, nullptr); |
| 6454 | } |
| 6455 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 6456 | bool ValidateGetTexParameterIivOES(Context *context, |
| 6457 | TextureType target, |
| 6458 | GLenum pname, |
| 6459 | GLint *params) |
| 6460 | { |
| 6461 | if (context->getClientMajorVersion() < 3) |
| 6462 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6463 | context->validationError(GL_INVALID_OPERATION, kES3Required); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 6464 | return false; |
| 6465 | } |
| 6466 | return ValidateGetTexParameterBase(context, target, pname, nullptr); |
| 6467 | } |
| 6468 | |
| 6469 | bool ValidateGetTexParameterIuivOES(Context *context, |
| 6470 | TextureType target, |
| 6471 | GLenum pname, |
| 6472 | GLuint *params) |
| 6473 | { |
| 6474 | if (context->getClientMajorVersion() < 3) |
| 6475 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6476 | context->validationError(GL_INVALID_OPERATION, kES3Required); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 6477 | return false; |
| 6478 | } |
| 6479 | return ValidateGetTexParameterBase(context, target, pname, nullptr); |
| 6480 | } |
| 6481 | |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6482 | bool ValidateGetUniformfv(Context *context, GLuint program, GLint location, GLfloat *params) |
| 6483 | { |
| 6484 | return ValidateGetUniformBase(context, program, location); |
| 6485 | } |
| 6486 | |
| 6487 | bool ValidateGetUniformiv(Context *context, GLuint program, GLint location, GLint *params) |
| 6488 | { |
| 6489 | return ValidateGetUniformBase(context, program, location); |
| 6490 | } |
| 6491 | |
| 6492 | bool ValidateGetVertexAttribfv(Context *context, GLuint index, GLenum pname, GLfloat *params) |
| 6493 | { |
| 6494 | return ValidateGetVertexAttribBase(context, index, pname, nullptr, false, false); |
| 6495 | } |
| 6496 | |
| 6497 | bool ValidateGetVertexAttribiv(Context *context, GLuint index, GLenum pname, GLint *params) |
| 6498 | { |
| 6499 | return ValidateGetVertexAttribBase(context, index, pname, nullptr, false, false); |
| 6500 | } |
| 6501 | |
| 6502 | bool ValidateGetVertexAttribPointerv(Context *context, GLuint index, GLenum pname, void **pointer) |
| 6503 | { |
| 6504 | return ValidateGetVertexAttribBase(context, index, pname, nullptr, true, false); |
| 6505 | } |
| 6506 | |
| 6507 | bool ValidateIsEnabled(Context *context, GLenum cap) |
| 6508 | { |
| 6509 | if (!ValidCap(context, cap, true)) |
| 6510 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6511 | context->validationError(GL_INVALID_ENUM, kEnumNotSupported); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6512 | return false; |
| 6513 | } |
| 6514 | |
| 6515 | return true; |
| 6516 | } |
| 6517 | |
| 6518 | bool ValidateLinkProgram(Context *context, GLuint program) |
| 6519 | { |
| 6520 | if (context->hasActiveTransformFeedback(program)) |
| 6521 | { |
| 6522 | // ES 3.0.4 section 2.15 page 91 |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 6523 | context->validationError(GL_INVALID_OPERATION, kTransformFeedbackActiveDuringLink); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6524 | return false; |
| 6525 | } |
| 6526 | |
| 6527 | Program *programObject = GetValidProgram(context, program); |
| 6528 | if (!programObject) |
| 6529 | { |
| 6530 | return false; |
| 6531 | } |
| 6532 | |
| 6533 | return true; |
| 6534 | } |
| 6535 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 6536 | bool ValidateReadPixels(Context *context, |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6537 | GLint x, |
| 6538 | GLint y, |
| 6539 | GLsizei width, |
| 6540 | GLsizei height, |
| 6541 | GLenum format, |
| 6542 | GLenum type, |
| 6543 | void *pixels) |
| 6544 | { |
| 6545 | return ValidateReadPixelsBase(context, x, y, width, height, format, type, -1, nullptr, nullptr, |
| 6546 | nullptr, pixels); |
| 6547 | } |
| 6548 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6549 | bool ValidateTexParameterf(Context *context, TextureType target, GLenum pname, GLfloat param) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6550 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 6551 | return ValidateTexParameterBase(context, target, pname, -1, false, ¶m); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6552 | } |
| 6553 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6554 | bool ValidateTexParameterfv(Context *context, |
| 6555 | TextureType target, |
| 6556 | GLenum pname, |
| 6557 | const GLfloat *params) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6558 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 6559 | return ValidateTexParameterBase(context, target, pname, -1, true, params); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6560 | } |
| 6561 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6562 | bool ValidateTexParameteri(Context *context, TextureType target, GLenum pname, GLint param) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6563 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 6564 | return ValidateTexParameterBase(context, target, pname, -1, false, ¶m); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6565 | } |
| 6566 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6567 | bool ValidateTexParameteriv(Context *context, TextureType target, GLenum pname, const GLint *params) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6568 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 6569 | return ValidateTexParameterBase(context, target, pname, -1, true, params); |
| 6570 | } |
| 6571 | |
| 6572 | bool ValidateTexParameterIivOES(Context *context, |
| 6573 | TextureType target, |
| 6574 | GLenum pname, |
| 6575 | const GLint *params) |
| 6576 | { |
| 6577 | if (context->getClientMajorVersion() < 3) |
| 6578 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6579 | context->validationError(GL_INVALID_OPERATION, kES3Required); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 6580 | return false; |
| 6581 | } |
| 6582 | return ValidateTexParameterBase(context, target, pname, -1, true, params); |
| 6583 | } |
| 6584 | |
| 6585 | bool ValidateTexParameterIuivOES(Context *context, |
| 6586 | TextureType target, |
| 6587 | GLenum pname, |
| 6588 | const GLuint *params) |
| 6589 | { |
| 6590 | if (context->getClientMajorVersion() < 3) |
| 6591 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6592 | context->validationError(GL_INVALID_OPERATION, kES3Required); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 6593 | return false; |
| 6594 | } |
| 6595 | return ValidateTexParameterBase(context, target, pname, -1, true, params); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6596 | } |
| 6597 | |
| 6598 | bool ValidateUseProgram(Context *context, GLuint program) |
| 6599 | { |
| 6600 | if (program != 0) |
| 6601 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6602 | Program *programObject = context->getProgramResolveLink(program); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6603 | if (!programObject) |
| 6604 | { |
| 6605 | // ES 3.1.0 section 7.3 page 72 |
| 6606 | if (context->getShader(program)) |
| 6607 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6608 | context->validationError(GL_INVALID_OPERATION, kExpectedProgramName); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6609 | return false; |
| 6610 | } |
| 6611 | else |
| 6612 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6613 | context->validationError(GL_INVALID_VALUE, kInvalidProgramName); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6614 | return false; |
| 6615 | } |
| 6616 | } |
| 6617 | if (!programObject->isLinked()) |
| 6618 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6619 | context->validationError(GL_INVALID_OPERATION, kProgramNotLinked); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6620 | return false; |
| 6621 | } |
| 6622 | } |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6623 | if (context->getState().isTransformFeedbackActiveUnpaused()) |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6624 | { |
| 6625 | // ES 3.0.4 section 2.15 page 91 |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 6626 | context->validationError(GL_INVALID_OPERATION, kTransformFeedbackUseProgram); |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 6627 | return false; |
| 6628 | } |
| 6629 | |
| 6630 | return true; |
| 6631 | } |
| 6632 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6633 | bool ValidateDeleteFencesNV(Context *context, GLsizei n, const GLuint *fences) |
| 6634 | { |
| 6635 | if (!context->getExtensions().fence) |
| 6636 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6637 | context->validationError(GL_INVALID_OPERATION, kNVFenceNotSupported); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6638 | return false; |
| 6639 | } |
| 6640 | |
| 6641 | if (n < 0) |
| 6642 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6643 | context->validationError(GL_INVALID_VALUE, kNegativeCount); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6644 | return false; |
| 6645 | } |
| 6646 | |
| 6647 | return true; |
| 6648 | } |
| 6649 | |
| 6650 | bool ValidateFinishFenceNV(Context *context, GLuint fence) |
| 6651 | { |
| 6652 | if (!context->getExtensions().fence) |
| 6653 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6654 | context->validationError(GL_INVALID_OPERATION, kNVFenceNotSupported); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6655 | return false; |
| 6656 | } |
| 6657 | |
| 6658 | FenceNV *fenceObject = context->getFenceNV(fence); |
| 6659 | |
| 6660 | if (fenceObject == nullptr) |
| 6661 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6662 | context->validationError(GL_INVALID_OPERATION, kInvalidFence); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6663 | return false; |
| 6664 | } |
| 6665 | |
| 6666 | if (!fenceObject->isSet()) |
| 6667 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6668 | context->validationError(GL_INVALID_OPERATION, kInvalidFenceState); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6669 | return false; |
| 6670 | } |
| 6671 | |
| 6672 | return true; |
| 6673 | } |
| 6674 | |
| 6675 | bool ValidateGenFencesNV(Context *context, GLsizei n, GLuint *fences) |
| 6676 | { |
| 6677 | if (!context->getExtensions().fence) |
| 6678 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6679 | context->validationError(GL_INVALID_OPERATION, kNVFenceNotSupported); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6680 | return false; |
| 6681 | } |
| 6682 | |
| 6683 | if (n < 0) |
| 6684 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6685 | context->validationError(GL_INVALID_VALUE, kNegativeCount); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6686 | return false; |
| 6687 | } |
| 6688 | |
| 6689 | return true; |
| 6690 | } |
| 6691 | |
| 6692 | bool ValidateGetFenceivNV(Context *context, GLuint fence, GLenum pname, GLint *params) |
| 6693 | { |
| 6694 | if (!context->getExtensions().fence) |
| 6695 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6696 | context->validationError(GL_INVALID_OPERATION, kNVFenceNotSupported); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6697 | return false; |
| 6698 | } |
| 6699 | |
| 6700 | FenceNV *fenceObject = context->getFenceNV(fence); |
| 6701 | |
| 6702 | if (fenceObject == nullptr) |
| 6703 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6704 | context->validationError(GL_INVALID_OPERATION, kInvalidFence); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6705 | return false; |
| 6706 | } |
| 6707 | |
| 6708 | if (!fenceObject->isSet()) |
| 6709 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6710 | context->validationError(GL_INVALID_OPERATION, kInvalidFenceState); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6711 | return false; |
| 6712 | } |
| 6713 | |
| 6714 | switch (pname) |
| 6715 | { |
| 6716 | case GL_FENCE_STATUS_NV: |
| 6717 | case GL_FENCE_CONDITION_NV: |
| 6718 | break; |
| 6719 | |
| 6720 | default: |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6721 | context->validationError(GL_INVALID_ENUM, kInvalidPname); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6722 | return false; |
| 6723 | } |
| 6724 | |
| 6725 | return true; |
| 6726 | } |
| 6727 | |
| 6728 | bool ValidateGetGraphicsResetStatusEXT(Context *context) |
| 6729 | { |
| 6730 | if (!context->getExtensions().robustness) |
| 6731 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6732 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6733 | return false; |
| 6734 | } |
| 6735 | |
| 6736 | return true; |
| 6737 | } |
| 6738 | |
| 6739 | bool ValidateGetTranslatedShaderSourceANGLE(Context *context, |
| 6740 | GLuint shader, |
| 6741 | GLsizei bufsize, |
| 6742 | GLsizei *length, |
| 6743 | GLchar *source) |
| 6744 | { |
| 6745 | if (!context->getExtensions().translatedShaderSource) |
| 6746 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6747 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6748 | return false; |
| 6749 | } |
| 6750 | |
| 6751 | if (bufsize < 0) |
| 6752 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6753 | context->validationError(GL_INVALID_VALUE, kNegativeBufferSize); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6754 | return false; |
| 6755 | } |
| 6756 | |
| 6757 | Shader *shaderObject = context->getShader(shader); |
| 6758 | |
| 6759 | if (!shaderObject) |
| 6760 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6761 | context->validationError(GL_INVALID_OPERATION, kInvalidShaderName); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6762 | return false; |
| 6763 | } |
| 6764 | |
| 6765 | return true; |
| 6766 | } |
| 6767 | |
| 6768 | bool ValidateIsFenceNV(Context *context, GLuint fence) |
| 6769 | { |
| 6770 | if (!context->getExtensions().fence) |
| 6771 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6772 | context->validationError(GL_INVALID_OPERATION, kNVFenceNotSupported); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6773 | return false; |
| 6774 | } |
| 6775 | |
| 6776 | return true; |
| 6777 | } |
| 6778 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6779 | bool ValidateSetFenceNV(Context *context, GLuint fence, GLenum condition) |
| 6780 | { |
| 6781 | if (!context->getExtensions().fence) |
| 6782 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6783 | context->validationError(GL_INVALID_OPERATION, kNVFenceNotSupported); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6784 | return false; |
| 6785 | } |
| 6786 | |
| 6787 | if (condition != GL_ALL_COMPLETED_NV) |
| 6788 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6789 | context->validationError(GL_INVALID_ENUM, kInvalidFenceCondition); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6790 | return false; |
| 6791 | } |
| 6792 | |
| 6793 | FenceNV *fenceObject = context->getFenceNV(fence); |
| 6794 | |
| 6795 | if (fenceObject == nullptr) |
| 6796 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6797 | context->validationError(GL_INVALID_OPERATION, kInvalidFence); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6798 | return false; |
| 6799 | } |
| 6800 | |
| 6801 | return true; |
| 6802 | } |
| 6803 | |
| 6804 | bool ValidateTestFenceNV(Context *context, GLuint fence) |
| 6805 | { |
| 6806 | if (!context->getExtensions().fence) |
| 6807 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6808 | context->validationError(GL_INVALID_OPERATION, kNVFenceNotSupported); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6809 | return false; |
| 6810 | } |
| 6811 | |
| 6812 | FenceNV *fenceObject = context->getFenceNV(fence); |
| 6813 | |
| 6814 | if (fenceObject == nullptr) |
| 6815 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6816 | context->validationError(GL_INVALID_OPERATION, kInvalidFence); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6817 | return false; |
| 6818 | } |
| 6819 | |
| 6820 | if (fenceObject->isSet() != GL_TRUE) |
| 6821 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6822 | context->validationError(GL_INVALID_OPERATION, kInvalidFenceState); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6823 | return false; |
| 6824 | } |
| 6825 | |
| 6826 | return true; |
| 6827 | } |
| 6828 | |
| 6829 | bool ValidateTexStorage2DEXT(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6830 | TextureType type, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6831 | GLsizei levels, |
| 6832 | GLenum internalformat, |
| 6833 | GLsizei width, |
| 6834 | GLsizei height) |
| 6835 | { |
| 6836 | if (!context->getExtensions().textureStorage) |
| 6837 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6838 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6839 | return false; |
| 6840 | } |
| 6841 | |
| 6842 | if (context->getClientMajorVersion() < 3) |
| 6843 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6844 | return ValidateES2TexStorageParameters(context, type, levels, internalformat, width, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6845 | height); |
| 6846 | } |
| 6847 | |
| 6848 | ASSERT(context->getClientMajorVersion() >= 3); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6849 | return ValidateES3TexStorage2DParameters(context, type, levels, internalformat, width, height, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6850 | 1); |
| 6851 | } |
| 6852 | |
| 6853 | bool ValidateVertexAttribDivisorANGLE(Context *context, GLuint index, GLuint divisor) |
| 6854 | { |
Jonah Ryan-Davis | 2b0553c | 2019-02-08 10:07:21 -0500 | [diff] [blame] | 6855 | if (!context->getExtensions().instancedArraysANGLE) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6856 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6857 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6858 | return false; |
| 6859 | } |
| 6860 | |
| 6861 | if (index >= MAX_VERTEX_ATTRIBS) |
| 6862 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6863 | context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxVertexAttribute); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6864 | return false; |
| 6865 | } |
| 6866 | |
| 6867 | if (context->getLimitations().attributeZeroRequiresZeroDivisorInEXT) |
| 6868 | { |
| 6869 | if (index == 0 && divisor != 0) |
| 6870 | { |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 6871 | context->validationError(GL_INVALID_OPERATION, kAttributeZeroRequiresDivisorLimitation); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6872 | |
| 6873 | // We also output an error message to the debugger window if tracing is active, so |
| 6874 | // that developers can see the error message. |
Jamie Madill | c3e3731 | 2018-11-30 15:25:39 -0500 | [diff] [blame] | 6875 | ERR() << kAttributeZeroRequiresDivisorLimitation; |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6876 | return false; |
| 6877 | } |
| 6878 | } |
| 6879 | |
| 6880 | return true; |
| 6881 | } |
| 6882 | |
Jonah Ryan-Davis | 2b0553c | 2019-02-08 10:07:21 -0500 | [diff] [blame] | 6883 | bool ValidateVertexAttribDivisorEXT(Context *context, GLuint index, GLuint divisor) |
| 6884 | { |
| 6885 | if (!context->getExtensions().instancedArraysEXT) |
| 6886 | { |
| 6887 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 6888 | return false; |
| 6889 | } |
| 6890 | |
| 6891 | if (index >= MAX_VERTEX_ATTRIBS) |
| 6892 | { |
| 6893 | context->validationError(GL_INVALID_VALUE, kIndexExceedsMaxVertexAttribute); |
| 6894 | return false; |
| 6895 | } |
| 6896 | |
| 6897 | return true; |
| 6898 | } |
| 6899 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6900 | bool ValidateTexImage3DOES(Context *context, |
| 6901 | GLenum target, |
| 6902 | GLint level, |
| 6903 | GLenum internalformat, |
| 6904 | GLsizei width, |
| 6905 | GLsizei height, |
| 6906 | GLsizei depth, |
| 6907 | GLint border, |
| 6908 | GLenum format, |
| 6909 | GLenum type, |
| 6910 | const void *pixels) |
| 6911 | { |
| 6912 | UNIMPLEMENTED(); // FIXME |
| 6913 | return false; |
| 6914 | } |
| 6915 | |
| 6916 | bool ValidatePopGroupMarkerEXT(Context *context) |
| 6917 | { |
| 6918 | if (!context->getExtensions().debugMarker) |
| 6919 | { |
| 6920 | // The debug marker calls should not set error state |
| 6921 | // However, it seems reasonable to set an error state if the extension is not enabled |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6922 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 6923 | return false; |
| 6924 | } |
| 6925 | |
| 6926 | return true; |
| 6927 | } |
| 6928 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 6929 | bool ValidateTexStorage1DEXT(Context *context, |
| 6930 | GLenum target, |
| 6931 | GLsizei levels, |
| 6932 | GLenum internalformat, |
| 6933 | GLsizei width) |
| 6934 | { |
| 6935 | UNIMPLEMENTED(); |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6936 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 6937 | return false; |
| 6938 | } |
| 6939 | |
| 6940 | bool ValidateTexStorage3DEXT(Context *context, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 6941 | TextureType target, |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 6942 | GLsizei levels, |
| 6943 | GLenum internalformat, |
| 6944 | GLsizei width, |
| 6945 | GLsizei height, |
| 6946 | GLsizei depth) |
| 6947 | { |
| 6948 | if (!context->getExtensions().textureStorage) |
| 6949 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6950 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 6951 | return false; |
| 6952 | } |
| 6953 | |
| 6954 | if (context->getClientMajorVersion() < 3) |
| 6955 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6956 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 6957 | return false; |
| 6958 | } |
| 6959 | |
| 6960 | return ValidateES3TexStorage3DParameters(context, target, levels, internalformat, width, height, |
| 6961 | depth); |
| 6962 | } |
| 6963 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 6964 | bool ValidateMaxShaderCompilerThreadsKHR(Context *context, GLuint count) |
| 6965 | { |
| 6966 | if (!context->getExtensions().parallelShaderCompile) |
| 6967 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6968 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 6969 | return false; |
| 6970 | } |
| 6971 | return true; |
| 6972 | } |
| 6973 | |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 6974 | bool ValidateMultiDrawArraysANGLE(Context *context, |
| 6975 | PrimitiveMode mode, |
| 6976 | const GLint *firsts, |
| 6977 | const GLsizei *counts, |
| 6978 | GLsizei drawcount) |
| 6979 | { |
| 6980 | if (!context->getExtensions().multiDraw) |
| 6981 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 6982 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 6983 | return false; |
| 6984 | } |
| 6985 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 6986 | { |
| 6987 | if (!ValidateDrawArrays(context, mode, firsts[drawID], counts[drawID])) |
| 6988 | { |
| 6989 | return false; |
| 6990 | } |
| 6991 | } |
| 6992 | return true; |
| 6993 | } |
| 6994 | |
| 6995 | bool ValidateMultiDrawElementsANGLE(Context *context, |
| 6996 | PrimitiveMode mode, |
| 6997 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 6998 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 6999 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 7000 | GLsizei drawcount) |
| 7001 | { |
| 7002 | if (!context->getExtensions().multiDraw) |
| 7003 | { |
Jamie Madill | e0472f3 | 2018-11-27 16:32:45 -0500 | [diff] [blame] | 7004 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 7005 | return false; |
| 7006 | } |
| 7007 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 7008 | { |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 7009 | if (!ValidateDrawElements(context, mode, counts[drawID], type, indices[drawID])) |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 7010 | { |
| 7011 | return false; |
| 7012 | } |
| 7013 | } |
| 7014 | return true; |
| 7015 | } |
| 7016 | |
Jeff Gilbert | 465d609 | 2019-01-02 16:21:18 -0800 | [diff] [blame] | 7017 | bool ValidateProvokingVertexANGLE(Context *context, ProvokingVertex modePacked) |
| 7018 | { |
| 7019 | if (!context->getExtensions().provokingVertex) |
| 7020 | { |
| 7021 | context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled); |
| 7022 | return false; |
| 7023 | } |
| 7024 | |
| 7025 | switch (modePacked) |
| 7026 | { |
| 7027 | case ProvokingVertex::FirstVertexConvention: |
| 7028 | case ProvokingVertex::LastVertexConvention: |
| 7029 | break; |
| 7030 | default: |
| 7031 | context->validationError(GL_INVALID_ENUM, kInvalidProvokingVertex); |
| 7032 | return false; |
| 7033 | } |
| 7034 | |
| 7035 | return true; |
| 7036 | } |
| 7037 | |
Jamie Madill | a541048 | 2019-01-31 19:55:55 -0500 | [diff] [blame] | 7038 | void RecordBindTextureTypeError(Context *context, TextureType target) |
| 7039 | { |
| 7040 | ASSERT(!context->getStateCache().isValidBindTextureType(target)); |
| 7041 | |
| 7042 | switch (target) |
| 7043 | { |
| 7044 | case TextureType::Rectangle: |
| 7045 | ASSERT(!context->getExtensions().textureRectangle); |
| 7046 | context->validationError(GL_INVALID_ENUM, kTextureRectangleNotSupported); |
| 7047 | break; |
| 7048 | |
| 7049 | case TextureType::_3D: |
| 7050 | case TextureType::_2DArray: |
| 7051 | ASSERT(context->getClientMajorVersion() < 3); |
| 7052 | context->validationError(GL_INVALID_ENUM, kES3Required); |
| 7053 | break; |
| 7054 | |
| 7055 | case TextureType::_2DMultisample: |
| 7056 | ASSERT(context->getClientVersion() < Version(3, 1) && |
| 7057 | !context->getExtensions().textureMultisample); |
| 7058 | context->validationError(GL_INVALID_ENUM, kMultisampleTextureExtensionOrES31Required); |
| 7059 | break; |
| 7060 | |
| 7061 | case TextureType::_2DMultisampleArray: |
| 7062 | ASSERT(!context->getExtensions().textureStorageMultisample2DArray); |
| 7063 | context->validationError(GL_INVALID_ENUM, kMultisampleArrayExtensionRequired); |
| 7064 | break; |
| 7065 | |
| 7066 | case TextureType::External: |
| 7067 | ASSERT(!context->getExtensions().eglImageExternal && |
| 7068 | !context->getExtensions().eglStreamConsumerExternal); |
| 7069 | context->validationError(GL_INVALID_ENUM, kExternalTextureNotSupported); |
| 7070 | break; |
| 7071 | |
| 7072 | default: |
| 7073 | context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget); |
| 7074 | } |
| 7075 | } |
| 7076 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 7077 | } // namespace gl |