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 | // validationES3.cpp: Validation functions for OpenGL ES 3.0 entry point parameters |
| 8 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 9 | #include "libANGLE/validationES3.h" |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 10 | |
Jamie Madill | 5ea762a | 2017-06-07 14:59:51 -0400 | [diff] [blame] | 11 | #include "anglebase/numerics/safe_conversions.h" |
Jamie Madill | d2f0c74 | 2016-11-02 10:34:41 -0400 | [diff] [blame] | 12 | #include "common/mathutil.h" |
| 13 | #include "common/utilities.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 14 | #include "libANGLE/Context.h" |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 15 | #include "libANGLE/ErrorStrings.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 16 | #include "libANGLE/Framebuffer.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 17 | #include "libANGLE/FramebufferAttachment.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 18 | #include "libANGLE/Renderbuffer.h" |
| 19 | #include "libANGLE/Texture.h" |
| 20 | #include "libANGLE/formatutils.h" |
| 21 | #include "libANGLE/validationES.h" |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 22 | |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 23 | using namespace angle; |
| 24 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 25 | namespace gl |
| 26 | { |
| 27 | |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 28 | namespace |
| 29 | { |
| 30 | bool ValidateFramebufferTextureMultiviewBaseANGLE(Context *context, |
| 31 | GLenum target, |
| 32 | GLenum attachment, |
| 33 | GLuint texture, |
| 34 | GLint level, |
| 35 | GLsizei numViews) |
| 36 | { |
| 37 | if (!context->getExtensions().multiview) |
| 38 | { |
| 39 | context->handleError(InvalidOperation() << "ANGLE_multiview is not available."); |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | if (!ValidateFramebufferTextureBase(context, target, attachment, texture, level)) |
| 44 | { |
| 45 | return false; |
| 46 | } |
| 47 | |
Martin Radev | 14b2126 | 2017-08-25 13:54:37 +0300 | [diff] [blame] | 48 | if (texture != 0 && numViews < 1) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 49 | { |
| 50 | context->handleError(InvalidValue() << "numViews cannot be less than 1."); |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | const Extensions &extensions = context->getExtensions(); |
| 55 | if (static_cast<GLuint>(numViews) > extensions.maxViews) |
| 56 | { |
| 57 | context->handleError(InvalidValue() |
| 58 | << "numViews cannot be greater than GL_MAX_VIEWS_ANGLE."); |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | return true; |
| 63 | } |
| 64 | |
| 65 | bool ValidateFramebufferTextureMultiviewLevelAndFormat(Context *context, |
| 66 | Texture *texture, |
| 67 | GLint level) |
| 68 | { |
| 69 | GLenum texTarget = texture->getTarget(); |
| 70 | if (!ValidMipLevel(context, texTarget, level)) |
| 71 | { |
| 72 | ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidMipLevel); |
| 73 | return false; |
| 74 | } |
| 75 | |
| 76 | const auto &format = texture->getFormat(texTarget, level); |
| 77 | if (format.info->compressed) |
| 78 | { |
| 79 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), CompressedTexturesNotAttachable); |
| 80 | return false; |
| 81 | } |
| 82 | return true; |
| 83 | } |
| 84 | |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 85 | bool ValidateUniformES3(Context *context, GLenum uniformType, GLint location, GLint count) |
| 86 | { |
| 87 | if (context->getClientMajorVersion() < 3) |
| 88 | { |
| 89 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 90 | return false; |
| 91 | } |
| 92 | |
| 93 | return ValidateUniform(context, uniformType, location, count); |
| 94 | } |
| 95 | |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 96 | bool ValidateUniformMatrixES3(Context *context, |
| 97 | GLenum valueType, |
| 98 | GLint location, |
| 99 | GLsizei count, |
| 100 | GLboolean transpose) |
| 101 | { |
| 102 | // Check for ES3 uniform entry points |
| 103 | if (context->getClientMajorVersion() < 3) |
| 104 | { |
| 105 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 106 | return false; |
| 107 | } |
| 108 | |
| 109 | return ValidateUniformMatrix(context, valueType, location, count, transpose); |
| 110 | } |
| 111 | |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 112 | bool ValidateGenOrDeleteES3(Context *context, GLint n) |
| 113 | { |
| 114 | if (context->getClientMajorVersion() < 3) |
| 115 | { |
| 116 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 117 | return false; |
| 118 | } |
| 119 | return ValidateGenOrDelete(context, n); |
| 120 | } |
| 121 | |
| 122 | bool ValidateGenOrDeleteCountES3(Context *context, GLint count) |
| 123 | { |
| 124 | if (context->getClientMajorVersion() < 3) |
| 125 | { |
| 126 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 127 | return false; |
| 128 | } |
| 129 | if (count < 0) |
| 130 | { |
| 131 | ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeCount); |
| 132 | return false; |
| 133 | } |
| 134 | return true; |
| 135 | } |
| 136 | |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 137 | } // anonymous namespace |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 138 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 139 | static bool ValidateTexImageFormatCombination(gl::Context *context, |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 140 | GLenum target, |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 141 | GLenum internalFormat, |
| 142 | GLenum format, |
| 143 | GLenum type) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 144 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 145 | |
| 146 | // The type and format are valid if any supported internal format has that type and format |
Geoff Lang | 6d1ccf0 | 2017-04-24 14:09:58 -0400 | [diff] [blame] | 147 | if (!ValidES3Format(format)) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 148 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 149 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFormat); |
Geoff Lang | 6d1ccf0 | 2017-04-24 14:09:58 -0400 | [diff] [blame] | 150 | return false; |
| 151 | } |
| 152 | |
| 153 | if (!ValidES3Type(type)) |
| 154 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 155 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidType); |
Geoff Lang | 6d1ccf0 | 2017-04-24 14:09:58 -0400 | [diff] [blame] | 156 | return false; |
| 157 | } |
| 158 | |
| 159 | // For historical reasons, glTexImage2D and glTexImage3D pass in their internal format as a |
| 160 | // GLint instead of a GLenum. Therefor an invalid internal format gives a GL_INVALID_VALUE |
| 161 | // error instead of a GL_INVALID_ENUM error. As this validation function is only called in |
| 162 | // the validation codepaths for glTexImage2D/3D, we record a GL_INVALID_VALUE error. |
| 163 | if (!ValidES3InternalFormat(internalFormat)) |
| 164 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 165 | ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidInternalFormat); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 166 | return false; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 167 | } |
| 168 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 169 | // From the ES 3.0 spec section 3.8.3: |
| 170 | // Textures with a base internal format of DEPTH_COMPONENT or DEPTH_STENCIL are supported by |
| 171 | // texture image specification commands only if target is TEXTURE_2D, TEXTURE_2D_ARRAY, or |
| 172 | // TEXTURE_CUBE_MAP.Using these formats in conjunction with any other target will result in an |
| 173 | // INVALID_OPERATION error. |
| 174 | if (target == GL_TEXTURE_3D && (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL)) |
| 175 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 176 | context->handleError(InvalidOperation() << "Format cannot be GL_DEPTH_COMPONENT or " |
| 177 | "GL_DEPTH_STENCIL if target is " |
| 178 | "GL_TEXTURE_3D"); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 179 | return false; |
| 180 | } |
| 181 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 182 | // Check if this is a valid format combination to load texture data |
Jamie Madill | 55e9821 | 2016-10-05 16:39:13 -0400 | [diff] [blame] | 183 | if (!ValidES3FormatCombination(format, type, internalFormat)) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 184 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 185 | context->handleError(InvalidOperation() |
| 186 | << "Invalid combination of format, type and internalFormat."); |
Geoff Lang | 6d1ccf0 | 2017-04-24 14:09:58 -0400 | [diff] [blame] | 187 | return false; |
| 188 | } |
| 189 | |
| 190 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat, type); |
| 191 | if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) |
| 192 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 193 | context->handleError(InvalidOperation() << "Unsupported internal format."); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 194 | return false; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | return true; |
| 198 | } |
| 199 | |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 200 | bool ValidateES3TexImageParametersBase(Context *context, |
| 201 | GLenum target, |
| 202 | GLint level, |
| 203 | GLenum internalformat, |
| 204 | bool isCompressed, |
| 205 | bool isSubImage, |
| 206 | GLint xoffset, |
| 207 | GLint yoffset, |
| 208 | GLint zoffset, |
| 209 | GLsizei width, |
| 210 | GLsizei height, |
| 211 | GLsizei depth, |
| 212 | GLint border, |
| 213 | GLenum format, |
| 214 | GLenum type, |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 215 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 216 | const void *pixels) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 217 | { |
| 218 | // Validate image size |
Austin Kinross | 08528e1 | 2015-10-07 16:24:40 -0700 | [diff] [blame] | 219 | if (!ValidImageSizeParameters(context, target, level, width, height, depth, isSubImage)) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 220 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 221 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 222 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 223 | } |
| 224 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 225 | // Verify zero border |
| 226 | if (border != 0) |
| 227 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 228 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 229 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 230 | } |
| 231 | |
Jamie Madill | 6f38f82 | 2014-06-06 17:12:20 -0400 | [diff] [blame] | 232 | if (xoffset < 0 || yoffset < 0 || zoffset < 0 || |
| 233 | std::numeric_limits<GLsizei>::max() - xoffset < width || |
| 234 | std::numeric_limits<GLsizei>::max() - yoffset < height || |
| 235 | std::numeric_limits<GLsizei>::max() - zoffset < depth) |
| 236 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 237 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 238 | return false; |
Jamie Madill | 6f38f82 | 2014-06-06 17:12:20 -0400 | [diff] [blame] | 239 | } |
| 240 | |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 241 | const gl::Caps &caps = context->getCaps(); |
| 242 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 243 | switch (target) |
| 244 | { |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 245 | case GL_TEXTURE_2D: |
| 246 | if (static_cast<GLuint>(width) > (caps.max2DTextureSize >> level) || |
| 247 | static_cast<GLuint>(height) > (caps.max2DTextureSize >> level)) |
| 248 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 249 | context->handleError(InvalidValue()); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 250 | return false; |
| 251 | } |
| 252 | break; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 253 | |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 254 | case GL_TEXTURE_RECTANGLE_ANGLE: |
| 255 | ASSERT(level == 0); |
| 256 | if (static_cast<GLuint>(width) > caps.maxRectangleTextureSize || |
| 257 | static_cast<GLuint>(height) > caps.maxRectangleTextureSize) |
| 258 | { |
| 259 | context->handleError(InvalidValue()); |
| 260 | return false; |
| 261 | } |
| 262 | if (isCompressed) |
| 263 | { |
| 264 | context->handleError(InvalidEnum() |
| 265 | << "Rectangle texture cannot have a compressed format."); |
| 266 | return false; |
| 267 | } |
| 268 | break; |
| 269 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 270 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 271 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 272 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 273 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 274 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 275 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 276 | if (!isSubImage && width != height) |
| 277 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 278 | context->handleError(InvalidValue()); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 279 | return false; |
| 280 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 281 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 282 | if (static_cast<GLuint>(width) > (caps.maxCubeMapTextureSize >> level)) |
| 283 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 284 | context->handleError(InvalidValue()); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 285 | return false; |
| 286 | } |
| 287 | break; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 288 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 289 | case GL_TEXTURE_3D: |
| 290 | if (static_cast<GLuint>(width) > (caps.max3DTextureSize >> level) || |
| 291 | static_cast<GLuint>(height) > (caps.max3DTextureSize >> level) || |
| 292 | static_cast<GLuint>(depth) > (caps.max3DTextureSize >> level)) |
| 293 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 294 | context->handleError(InvalidValue()); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 295 | return false; |
| 296 | } |
| 297 | break; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 298 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 299 | case GL_TEXTURE_2D_ARRAY: |
| 300 | if (static_cast<GLuint>(width) > (caps.max2DTextureSize >> level) || |
| 301 | static_cast<GLuint>(height) > (caps.max2DTextureSize >> level) || |
| 302 | static_cast<GLuint>(depth) > caps.maxArrayTextureLayers) |
| 303 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 304 | context->handleError(InvalidValue()); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 305 | return false; |
| 306 | } |
| 307 | break; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 308 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 309 | default: |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 310 | context->handleError(InvalidEnum()); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 311 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 312 | } |
| 313 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 314 | gl::Texture *texture = |
| 315 | context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 316 | if (!texture) |
| 317 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 318 | context->handleError(InvalidOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 319 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 320 | } |
| 321 | |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 322 | if (texture->getImmutableFormat() && !isSubImage) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 323 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 324 | context->handleError(InvalidOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 325 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | // Validate texture formats |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 329 | GLenum actualInternalFormat = |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 330 | isSubImage ? texture->getFormat(target, level).info->internalFormat : internalformat; |
Geoff Lang | c51642b | 2016-11-14 16:18:26 -0500 | [diff] [blame] | 331 | if (isSubImage && actualInternalFormat == GL_NONE) |
| 332 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 333 | context->handleError(InvalidOperation() << "Texture level does not exist."); |
Geoff Lang | c51642b | 2016-11-14 16:18:26 -0500 | [diff] [blame] | 334 | return false; |
| 335 | } |
| 336 | |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 337 | const gl::InternalFormat &actualFormatInfo = isSubImage |
| 338 | ? *texture->getFormat(target, level).info |
| 339 | : GetInternalFormatInfo(internalformat, type); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 340 | if (isCompressed) |
| 341 | { |
tmartino | 7c10269 | 2015-10-02 16:43:40 -0400 | [diff] [blame] | 342 | if (!actualFormatInfo.compressed) |
Geoff Lang | d4f180b | 2013-09-24 13:57:44 -0400 | [diff] [blame] | 343 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 344 | context->handleError( |
| 345 | InvalidEnum() << "internalformat is not a supported compressed internal format."); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 346 | return false; |
Geoff Lang | d4f180b | 2013-09-24 13:57:44 -0400 | [diff] [blame] | 347 | } |
| 348 | |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 349 | if (isSubImage) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 350 | { |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 351 | if (!ValidCompressedSubImageSize( |
| 352 | context, actualFormatInfo.internalFormat, xoffset, yoffset, width, height, |
| 353 | texture->getWidth(target, level), texture->getHeight(target, level))) |
| 354 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 355 | context->handleError(InvalidOperation() << "Invalid compressed format dimension."); |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 356 | return false; |
| 357 | } |
| 358 | |
| 359 | if (format != actualInternalFormat) |
| 360 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 361 | context->handleError(InvalidOperation() |
| 362 | << "Format must match the internal format of the texture."); |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 363 | return false; |
| 364 | } |
Geoff Lang | 86f8116 | 2017-10-30 15:10:45 -0400 | [diff] [blame^] | 365 | |
| 366 | if (actualInternalFormat == GL_ETC1_RGB8_OES) |
| 367 | { |
| 368 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidInternalFormat); |
| 369 | return false; |
| 370 | } |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 371 | } |
| 372 | else |
| 373 | { |
| 374 | if (!ValidCompressedImageSize(context, actualInternalFormat, level, width, height)) |
| 375 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 376 | context->handleError(InvalidOperation() << "Invalid compressed format dimension."); |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 377 | return false; |
| 378 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 379 | } |
| 380 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 381 | if (!actualFormatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) |
Geoff Lang | 839ce0b | 2015-10-23 13:13:12 -0400 | [diff] [blame] | 382 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 383 | context->handleError(InvalidEnum()); |
Geoff Lang | 839ce0b | 2015-10-23 13:13:12 -0400 | [diff] [blame] | 384 | return false; |
| 385 | } |
| 386 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 387 | if (target == GL_TEXTURE_3D) |
| 388 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 389 | context->handleError(InvalidOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 390 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 391 | } |
| 392 | } |
| 393 | else |
| 394 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 395 | if (!ValidateTexImageFormatCombination(context, target, actualInternalFormat, format, type)) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 396 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 397 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 398 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | // Validate sub image parameters |
| 402 | if (isSubImage) |
| 403 | { |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 404 | if (isCompressed != actualFormatInfo.compressed) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 405 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 406 | context->handleError(InvalidOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 407 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 408 | } |
| 409 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 410 | if (xoffset < 0 || yoffset < 0 || zoffset < 0) |
| 411 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 412 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 413 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || |
| 417 | std::numeric_limits<GLsizei>::max() - yoffset < height || |
| 418 | std::numeric_limits<GLsizei>::max() - zoffset < depth) |
| 419 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 420 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 421 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 422 | } |
| 423 | |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 424 | if (static_cast<size_t>(xoffset + width) > texture->getWidth(target, level) || |
| 425 | static_cast<size_t>(yoffset + height) > texture->getHeight(target, level) || |
| 426 | static_cast<size_t>(zoffset + depth) > texture->getDepth(target, level)) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 427 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 428 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 429 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 430 | } |
| 431 | } |
| 432 | |
Geoff Lang | dbcced8 | 2017-06-06 15:55:54 -0400 | [diff] [blame] | 433 | GLenum sizeCheckFormat = isSubImage ? format : internalformat; |
| 434 | if (!ValidImageDataSize(context, target, width, height, depth, sizeCheckFormat, type, pixels, |
| 435 | imageSize)) |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 436 | { |
| 437 | return false; |
| 438 | } |
| 439 | |
Jamie Madill | efb2a6f | 2013-09-24 10:22:42 -0400 | [diff] [blame] | 440 | // Check for pixel unpack buffer related API errors |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 441 | gl::Buffer *pixelUnpackBuffer = context->getGLState().getTargetBuffer(GL_PIXEL_UNPACK_BUFFER); |
Corentin Wallez | ece7c5a | 2016-09-21 15:28:23 -0400 | [diff] [blame] | 442 | if (pixelUnpackBuffer != nullptr) |
Jamie Madill | efb2a6f | 2013-09-24 10:22:42 -0400 | [diff] [blame] | 443 | { |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 444 | // ...data is not evenly divisible into the number of bytes needed to store in memory a |
| 445 | // datum |
Jamie Madill | efb2a6f | 2013-09-24 10:22:42 -0400 | [diff] [blame] | 446 | // indicated by type. |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 447 | if (!isCompressed) |
Jamie Madill | efb2a6f | 2013-09-24 10:22:42 -0400 | [diff] [blame] | 448 | { |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 449 | size_t offset = reinterpret_cast<size_t>(pixels); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 450 | size_t dataBytesPerPixel = static_cast<size_t>(gl::GetTypeInfo(type).bytes); |
| 451 | |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 452 | if ((offset % dataBytesPerPixel) != 0) |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 453 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 454 | context->handleError(InvalidOperation() |
| 455 | << "Reads would overflow the pixel unpack buffer."); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 456 | return false; |
| 457 | } |
Jamie Madill | efb2a6f | 2013-09-24 10:22:42 -0400 | [diff] [blame] | 458 | } |
| 459 | |
Jamie Madill | 7a5f738 | 2014-03-05 15:01:24 -0500 | [diff] [blame] | 460 | // ...the buffer object's data store is currently mapped. |
Brandon Jones | d38f926 | 2014-06-18 16:26:45 -0700 | [diff] [blame] | 461 | if (pixelUnpackBuffer->isMapped()) |
Jamie Madill | 7a5f738 | 2014-03-05 15:01:24 -0500 | [diff] [blame] | 462 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 463 | context->handleError(InvalidOperation() << "Pixel unpack buffer is mapped."); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 464 | return false; |
Jamie Madill | 7a5f738 | 2014-03-05 15:01:24 -0500 | [diff] [blame] | 465 | } |
Jamie Madill | efb2a6f | 2013-09-24 10:22:42 -0400 | [diff] [blame] | 466 | } |
| 467 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 468 | return true; |
| 469 | } |
| 470 | |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 471 | bool ValidateES3TexImage2DParameters(Context *context, |
| 472 | GLenum target, |
| 473 | GLint level, |
| 474 | GLenum internalformat, |
| 475 | bool isCompressed, |
| 476 | bool isSubImage, |
| 477 | GLint xoffset, |
| 478 | GLint yoffset, |
| 479 | GLint zoffset, |
| 480 | GLsizei width, |
| 481 | GLsizei height, |
| 482 | GLsizei depth, |
| 483 | GLint border, |
| 484 | GLenum format, |
| 485 | GLenum type, |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 486 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 487 | const void *pixels) |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 488 | { |
| 489 | if (!ValidTexture2DDestinationTarget(context, target)) |
| 490 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 491 | context->handleError(InvalidEnum()); |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 492 | return false; |
| 493 | } |
| 494 | |
| 495 | return ValidateES3TexImageParametersBase(context, target, level, internalformat, isCompressed, |
| 496 | isSubImage, xoffset, yoffset, zoffset, width, height, |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 497 | depth, border, format, type, imageSize, pixels); |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | bool ValidateES3TexImage3DParameters(Context *context, |
| 501 | GLenum target, |
| 502 | GLint level, |
| 503 | GLenum internalformat, |
| 504 | bool isCompressed, |
| 505 | bool isSubImage, |
| 506 | GLint xoffset, |
| 507 | GLint yoffset, |
| 508 | GLint zoffset, |
| 509 | GLsizei width, |
| 510 | GLsizei height, |
| 511 | GLsizei depth, |
| 512 | GLint border, |
| 513 | GLenum format, |
| 514 | GLenum type, |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 515 | GLsizei bufSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 516 | const void *pixels) |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 517 | { |
| 518 | if (!ValidTexture3DDestinationTarget(context, target)) |
| 519 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 520 | context->handleError(InvalidEnum()); |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 521 | return false; |
| 522 | } |
| 523 | |
| 524 | return ValidateES3TexImageParametersBase(context, target, level, internalformat, isCompressed, |
| 525 | isSubImage, xoffset, yoffset, zoffset, width, height, |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 526 | depth, border, format, type, bufSize, pixels); |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 527 | } |
| 528 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 529 | struct EffectiveInternalFormatInfo |
| 530 | { |
Jamie Madill | 76648fe | 2016-10-05 17:01:41 -0400 | [diff] [blame] | 531 | GLenum effectiveFormat; |
| 532 | GLenum destFormat; |
| 533 | GLuint minRedBits; |
| 534 | GLuint maxRedBits; |
| 535 | GLuint minGreenBits; |
| 536 | GLuint maxGreenBits; |
| 537 | GLuint minBlueBits; |
| 538 | GLuint maxBlueBits; |
| 539 | GLuint minAlphaBits; |
| 540 | GLuint maxAlphaBits; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 541 | }; |
| 542 | |
Jamie Madill | 76648fe | 2016-10-05 17:01:41 -0400 | [diff] [blame] | 543 | static bool QueryEffectiveFormatList(const InternalFormat &srcFormat, |
| 544 | GLenum targetFormat, |
| 545 | const EffectiveInternalFormatInfo *list, |
| 546 | size_t size, |
| 547 | GLenum *outEffectiveFormat) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 548 | { |
Jamie Madill | 76648fe | 2016-10-05 17:01:41 -0400 | [diff] [blame] | 549 | for (size_t curFormat = 0; curFormat < size; ++curFormat) |
| 550 | { |
| 551 | const EffectiveInternalFormatInfo &formatInfo = list[curFormat]; |
| 552 | if ((formatInfo.destFormat == targetFormat) && |
| 553 | (formatInfo.minRedBits <= srcFormat.redBits && |
| 554 | formatInfo.maxRedBits >= srcFormat.redBits) && |
| 555 | (formatInfo.minGreenBits <= srcFormat.greenBits && |
| 556 | formatInfo.maxGreenBits >= srcFormat.greenBits) && |
| 557 | (formatInfo.minBlueBits <= srcFormat.blueBits && |
| 558 | formatInfo.maxBlueBits >= srcFormat.blueBits) && |
| 559 | (formatInfo.minAlphaBits <= srcFormat.alphaBits && |
| 560 | formatInfo.maxAlphaBits >= srcFormat.alphaBits)) |
| 561 | { |
| 562 | *outEffectiveFormat = formatInfo.effectiveFormat; |
| 563 | return true; |
| 564 | } |
| 565 | } |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 566 | |
Jamie Madill | 76648fe | 2016-10-05 17:01:41 -0400 | [diff] [blame] | 567 | *outEffectiveFormat = GL_NONE; |
| 568 | return false; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 569 | } |
| 570 | |
Jamie Madill | 76648fe | 2016-10-05 17:01:41 -0400 | [diff] [blame] | 571 | bool GetSizedEffectiveInternalFormatInfo(const InternalFormat &srcFormat, |
| 572 | GLenum *outEffectiveFormat) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 573 | { |
Jamie Madill | 76648fe | 2016-10-05 17:01:41 -0400 | [diff] [blame] | 574 | // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: |
| 575 | // Effective internal format coresponding to destination internal format and linear source |
| 576 | // buffer component sizes. |
| 577 | // | Source channel min/max sizes | |
| 578 | // Effective Internal Format | N/A | R | G | B | A | |
| 579 | // clang-format off |
| 580 | constexpr EffectiveInternalFormatInfo list[] = { |
| 581 | { GL_ALPHA8_EXT, GL_NONE, 0, 0, 0, 0, 0, 0, 1, 8 }, |
| 582 | { GL_R8, GL_NONE, 1, 8, 0, 0, 0, 0, 0, 0 }, |
| 583 | { GL_RG8, GL_NONE, 1, 8, 1, 8, 0, 0, 0, 0 }, |
| 584 | { GL_RGB565, GL_NONE, 1, 5, 1, 6, 1, 5, 0, 0 }, |
| 585 | { GL_RGB8, GL_NONE, 6, 8, 7, 8, 6, 8, 0, 0 }, |
| 586 | { GL_RGBA4, GL_NONE, 1, 4, 1, 4, 1, 4, 1, 4 }, |
| 587 | { GL_RGB5_A1, GL_NONE, 5, 5, 5, 5, 5, 5, 1, 1 }, |
| 588 | { GL_RGBA8, GL_NONE, 5, 8, 5, 8, 5, 8, 2, 8 }, |
| 589 | { GL_RGB10_A2, GL_NONE, 9, 10, 9, 10, 9, 10, 2, 2 }, |
| 590 | }; |
| 591 | // clang-format on |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 592 | |
Jamie Madill | 76648fe | 2016-10-05 17:01:41 -0400 | [diff] [blame] | 593 | return QueryEffectiveFormatList(srcFormat, GL_NONE, list, ArraySize(list), outEffectiveFormat); |
| 594 | } |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 595 | |
Jamie Madill | 76648fe | 2016-10-05 17:01:41 -0400 | [diff] [blame] | 596 | bool GetUnsizedEffectiveInternalFormatInfo(const InternalFormat &srcFormat, |
| 597 | const InternalFormat &destFormat, |
| 598 | GLenum *outEffectiveFormat) |
| 599 | { |
| 600 | constexpr GLuint umax = UINT_MAX; |
| 601 | |
| 602 | // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: |
| 603 | // Effective internal format coresponding to destination internal format andlinear source buffer |
| 604 | // component sizes. |
| 605 | // | Source channel min/max sizes | |
| 606 | // Effective Internal Format | Dest Format | R | G | B | A | |
| 607 | // clang-format off |
| 608 | constexpr EffectiveInternalFormatInfo list[] = { |
| 609 | { GL_ALPHA8_EXT, GL_ALPHA, 0, umax, 0, umax, 0, umax, 1, 8 }, |
| 610 | { GL_LUMINANCE8_EXT, GL_LUMINANCE, 1, 8, 0, umax, 0, umax, 0, umax }, |
| 611 | { GL_LUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, 1, 8, 0, umax, 0, umax, 1, 8 }, |
| 612 | { GL_RGB565, GL_RGB, 1, 5, 1, 6, 1, 5, 0, umax }, |
| 613 | { GL_RGB8, GL_RGB, 6, 8, 7, 8, 6, 8, 0, umax }, |
| 614 | { GL_RGBA4, GL_RGBA, 1, 4, 1, 4, 1, 4, 1, 4 }, |
| 615 | { GL_RGB5_A1, GL_RGBA, 5, 5, 5, 5, 5, 5, 1, 1 }, |
| 616 | { GL_RGBA8, GL_RGBA, 5, 8, 5, 8, 5, 8, 5, 8 }, |
| 617 | }; |
| 618 | // clang-format on |
| 619 | |
| 620 | return QueryEffectiveFormatList(srcFormat, destFormat.format, list, ArraySize(list), |
| 621 | outEffectiveFormat); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 622 | } |
| 623 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 624 | static bool GetEffectiveInternalFormat(const InternalFormat &srcFormat, |
| 625 | const InternalFormat &destFormat, |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 626 | GLenum *outEffectiveFormat) |
| 627 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 628 | if (destFormat.sized) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 629 | { |
Jamie Madill | 76648fe | 2016-10-05 17:01:41 -0400 | [diff] [blame] | 630 | return GetSizedEffectiveInternalFormatInfo(srcFormat, outEffectiveFormat); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 631 | } |
| 632 | else |
| 633 | { |
Jamie Madill | 76648fe | 2016-10-05 17:01:41 -0400 | [diff] [blame] | 634 | return GetUnsizedEffectiveInternalFormatInfo(srcFormat, destFormat, outEffectiveFormat); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 635 | } |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 636 | } |
| 637 | |
Corentin Wallez | 7628768 | 2016-04-25 09:23:38 -0400 | [diff] [blame] | 638 | static bool EqualOrFirstZero(GLuint first, GLuint second) |
| 639 | { |
| 640 | return first == 0 || first == second; |
| 641 | } |
| 642 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 643 | static bool IsValidES3CopyTexImageCombination(const InternalFormat &textureFormatInfo, |
| 644 | const InternalFormat &framebufferFormatInfo, |
Jamie Madill | 0c8abca | 2016-07-22 20:21:26 -0400 | [diff] [blame] | 645 | GLuint readBufferHandle) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 646 | { |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 647 | if (!ValidES3CopyConversion(textureFormatInfo.format, framebufferFormatInfo.format)) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 648 | { |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 649 | return false; |
| 650 | } |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 651 | |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 652 | // Section 3.8.5 of the GLES 3.0.3 spec states that source and destination formats |
| 653 | // must both be signed, unsigned, or fixed point and both source and destinations |
| 654 | // must be either both SRGB or both not SRGB. EXT_color_buffer_float adds allowed |
| 655 | // conversion between fixed and floating point. |
| 656 | |
| 657 | if ((textureFormatInfo.colorEncoding == GL_SRGB) != |
| 658 | (framebufferFormatInfo.colorEncoding == GL_SRGB)) |
| 659 | { |
| 660 | return false; |
| 661 | } |
| 662 | |
| 663 | if (((textureFormatInfo.componentType == GL_INT) != |
| 664 | (framebufferFormatInfo.componentType == GL_INT)) || |
| 665 | ((textureFormatInfo.componentType == GL_UNSIGNED_INT) != |
| 666 | (framebufferFormatInfo.componentType == GL_UNSIGNED_INT))) |
| 667 | { |
| 668 | return false; |
| 669 | } |
| 670 | |
| 671 | if ((textureFormatInfo.componentType == GL_UNSIGNED_NORMALIZED || |
| 672 | textureFormatInfo.componentType == GL_SIGNED_NORMALIZED || |
| 673 | textureFormatInfo.componentType == GL_FLOAT) && |
| 674 | !(framebufferFormatInfo.componentType == GL_UNSIGNED_NORMALIZED || |
| 675 | framebufferFormatInfo.componentType == GL_SIGNED_NORMALIZED || |
| 676 | framebufferFormatInfo.componentType == GL_FLOAT)) |
| 677 | { |
| 678 | return false; |
| 679 | } |
| 680 | |
| 681 | // GLES specification 3.0.3, sec 3.8.5, pg 139-140: |
| 682 | // The effective internal format of the source buffer is determined with the following rules |
| 683 | // applied in order: |
| 684 | // * If the source buffer is a texture or renderbuffer that was created with a sized internal |
| 685 | // format then the effective internal format is the source buffer's sized internal format. |
| 686 | // * If the source buffer is a texture that was created with an unsized base internal format, |
| 687 | // then the effective internal format is the source image array's effective internal |
| 688 | // format, as specified by table 3.12, which is determined from the <format> and <type> |
| 689 | // that were used when the source image array was specified by TexImage*. |
| 690 | // * Otherwise the effective internal format is determined by the row in table 3.17 or 3.18 |
| 691 | // where Destination Internal Format matches internalformat and where the [source channel |
| 692 | // sizes] are consistent with the values of the source buffer's [channel sizes]. Table 3.17 |
| 693 | // is used if the FRAMEBUFFER_ATTACHMENT_ENCODING is LINEAR and table 3.18 is used if the |
| 694 | // FRAMEBUFFER_ATTACHMENT_ENCODING is SRGB. |
Yunchao He | d7297bf | 2017-04-19 15:27:10 +0800 | [diff] [blame] | 695 | const InternalFormat *sourceEffectiveFormat = nullptr; |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 696 | if (readBufferHandle != 0) |
| 697 | { |
| 698 | // Not the default framebuffer, therefore the read buffer must be a user-created texture or |
| 699 | // renderbuffer |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 700 | if (framebufferFormatInfo.sized) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 701 | { |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 702 | sourceEffectiveFormat = &framebufferFormatInfo; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 703 | } |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 704 | else |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 705 | { |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 706 | // Renderbuffers cannot be created with an unsized internal format, so this must be an |
| 707 | // unsized-format texture. We can use the same table we use when creating textures to |
| 708 | // get its effective sized format. |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 709 | sourceEffectiveFormat = |
| 710 | &GetSizedInternalFormatInfo(framebufferFormatInfo.sizedInternalFormat); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 711 | } |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 712 | } |
| 713 | else |
| 714 | { |
| 715 | // The effective internal format must be derived from the source framebuffer's channel |
| 716 | // sizes. This is done in GetEffectiveInternalFormat for linear buffers (table 3.17) |
| 717 | if (framebufferFormatInfo.colorEncoding == GL_LINEAR) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 718 | { |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 719 | GLenum effectiveFormat; |
| 720 | if (GetEffectiveInternalFormat(framebufferFormatInfo, textureFormatInfo, |
| 721 | &effectiveFormat)) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 722 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 723 | sourceEffectiveFormat = &GetSizedInternalFormatInfo(effectiveFormat); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 724 | } |
| 725 | else |
| 726 | { |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 727 | return false; |
| 728 | } |
| 729 | } |
| 730 | else if (framebufferFormatInfo.colorEncoding == GL_SRGB) |
| 731 | { |
| 732 | // SRGB buffers can only be copied to sized format destinations according to table 3.18 |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 733 | if (textureFormatInfo.sized && |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 734 | (framebufferFormatInfo.redBits >= 1 && framebufferFormatInfo.redBits <= 8) && |
| 735 | (framebufferFormatInfo.greenBits >= 1 && framebufferFormatInfo.greenBits <= 8) && |
| 736 | (framebufferFormatInfo.blueBits >= 1 && framebufferFormatInfo.blueBits <= 8) && |
| 737 | (framebufferFormatInfo.alphaBits >= 1 && framebufferFormatInfo.alphaBits <= 8)) |
| 738 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 739 | sourceEffectiveFormat = &GetSizedInternalFormatInfo(GL_SRGB8_ALPHA8); |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 740 | } |
| 741 | else |
| 742 | { |
| 743 | return false; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 744 | } |
| 745 | } |
| 746 | else |
| 747 | { |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 748 | UNREACHABLE(); |
| 749 | return false; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 750 | } |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 751 | } |
| 752 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 753 | if (textureFormatInfo.sized) |
Jamie Madill | 21b786b | 2016-11-01 17:41:31 -0400 | [diff] [blame] | 754 | { |
| 755 | // Section 3.8.5 of the GLES 3.0.3 spec, pg 139, requires that, if the destination format is |
| 756 | // sized, component sizes of the source and destination formats must exactly match if the |
| 757 | // destination format exists. |
| 758 | if (!EqualOrFirstZero(textureFormatInfo.redBits, sourceEffectiveFormat->redBits) || |
| 759 | !EqualOrFirstZero(textureFormatInfo.greenBits, sourceEffectiveFormat->greenBits) || |
| 760 | !EqualOrFirstZero(textureFormatInfo.blueBits, sourceEffectiveFormat->blueBits) || |
| 761 | !EqualOrFirstZero(textureFormatInfo.alphaBits, sourceEffectiveFormat->alphaBits)) |
| 762 | { |
| 763 | return false; |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | return true; // A conversion function exists, and no rule in the specification has precluded |
| 768 | // conversion between these formats. |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 769 | } |
| 770 | |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 771 | bool ValidateES3CopyTexImageParametersBase(ValidationContext *context, |
| 772 | GLenum target, |
| 773 | GLint level, |
| 774 | GLenum internalformat, |
| 775 | bool isSubImage, |
| 776 | GLint xoffset, |
| 777 | GLint yoffset, |
| 778 | GLint zoffset, |
| 779 | GLint x, |
| 780 | GLint y, |
| 781 | GLsizei width, |
| 782 | GLsizei height, |
| 783 | GLint border) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 784 | { |
Jamie Madill | 0c8abca | 2016-07-22 20:21:26 -0400 | [diff] [blame] | 785 | Format textureFormat = Format::Invalid(); |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 786 | if (!ValidateCopyTexImageParametersBase(context, target, level, internalformat, isSubImage, |
Jamie Madill | 0c8abca | 2016-07-22 20:21:26 -0400 | [diff] [blame] | 787 | xoffset, yoffset, zoffset, x, y, width, height, border, |
| 788 | &textureFormat)) |
Shannon Woods | 4dfed83 | 2014-03-17 20:03:39 -0400 | [diff] [blame] | 789 | { |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 790 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 791 | } |
Jamie Madill | 0c8abca | 2016-07-22 20:21:26 -0400 | [diff] [blame] | 792 | ASSERT(textureFormat.valid() || !isSubImage); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 793 | |
Jamie Madill | 51f40ec | 2016-06-15 14:06:00 -0400 | [diff] [blame] | 794 | const auto &state = context->getGLState(); |
| 795 | gl::Framebuffer *framebuffer = state.getReadFramebuffer(); |
| 796 | GLuint readFramebufferID = framebuffer->id(); |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 797 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 798 | if (framebuffer->checkStatus(context) != GL_FRAMEBUFFER_COMPLETE) |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 799 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 800 | context->handleError(InvalidFramebufferOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 801 | return false; |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 802 | } |
| 803 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 804 | if (readFramebufferID != 0 && framebuffer->getSamples(context) != 0) |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 805 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 806 | context->handleError(InvalidOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 807 | return false; |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 808 | } |
| 809 | |
Jamie Madill | 0c8abca | 2016-07-22 20:21:26 -0400 | [diff] [blame] | 810 | const FramebufferAttachment *source = framebuffer->getReadColorbuffer(); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 811 | |
| 812 | if (isSubImage) |
| 813 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 814 | if (!IsValidES3CopyTexImageCombination(*textureFormat.info, *source->getFormat().info, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 815 | readFramebufferID)) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 816 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 817 | context->handleError(InvalidOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 818 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 819 | } |
| 820 | } |
Shannon Woods | 4d161ba | 2014-03-17 18:13:30 -0400 | [diff] [blame] | 821 | else |
| 822 | { |
Jamie Madill | 0c8abca | 2016-07-22 20:21:26 -0400 | [diff] [blame] | 823 | // Use format/type from the source FBO. (Might not be perfect for all cases?) |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 824 | const InternalFormat &framebufferFormat = *source->getFormat().info; |
| 825 | const InternalFormat ©Format = GetInternalFormatInfo(internalformat, GL_UNSIGNED_BYTE); |
Jamie Madill | 0c8abca | 2016-07-22 20:21:26 -0400 | [diff] [blame] | 826 | if (!IsValidES3CopyTexImageCombination(copyFormat, framebufferFormat, readFramebufferID)) |
Shannon Woods | 4d161ba | 2014-03-17 18:13:30 -0400 | [diff] [blame] | 827 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 828 | context->handleError(InvalidOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 829 | return false; |
Shannon Woods | 4d161ba | 2014-03-17 18:13:30 -0400 | [diff] [blame] | 830 | } |
| 831 | } |
| 832 | |
Geoff Lang | 784a8fd | 2013-09-24 12:33:16 -0400 | [diff] [blame] | 833 | // If width or height is zero, it is a no-op. Return false without setting an error. |
| 834 | return (width > 0 && height > 0); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 835 | } |
| 836 | |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 837 | bool ValidateES3CopyTexImage2DParameters(ValidationContext *context, |
| 838 | GLenum target, |
| 839 | GLint level, |
| 840 | GLenum internalformat, |
| 841 | bool isSubImage, |
| 842 | GLint xoffset, |
| 843 | GLint yoffset, |
| 844 | GLint zoffset, |
| 845 | GLint x, |
| 846 | GLint y, |
| 847 | GLsizei width, |
| 848 | GLsizei height, |
| 849 | GLint border) |
| 850 | { |
| 851 | if (!ValidTexture2DDestinationTarget(context, target)) |
| 852 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 853 | context->handleError(InvalidEnum()); |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 854 | return false; |
| 855 | } |
| 856 | |
| 857 | return ValidateES3CopyTexImageParametersBase(context, target, level, internalformat, isSubImage, |
| 858 | xoffset, yoffset, zoffset, x, y, width, height, |
| 859 | border); |
| 860 | } |
| 861 | |
| 862 | bool ValidateES3CopyTexImage3DParameters(ValidationContext *context, |
| 863 | GLenum target, |
| 864 | GLint level, |
| 865 | GLenum internalformat, |
| 866 | bool isSubImage, |
| 867 | GLint xoffset, |
| 868 | GLint yoffset, |
| 869 | GLint zoffset, |
| 870 | GLint x, |
| 871 | GLint y, |
| 872 | GLsizei width, |
| 873 | GLsizei height, |
| 874 | GLint border) |
| 875 | { |
| 876 | if (!ValidTexture3DDestinationTarget(context, target)) |
| 877 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 878 | context->handleError(InvalidEnum()); |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 879 | return false; |
| 880 | } |
| 881 | |
| 882 | return ValidateES3CopyTexImageParametersBase(context, target, level, internalformat, isSubImage, |
| 883 | xoffset, yoffset, zoffset, x, y, width, height, |
| 884 | border); |
| 885 | } |
| 886 | |
| 887 | bool ValidateES3TexStorageParametersBase(Context *context, |
| 888 | GLenum target, |
| 889 | GLsizei levels, |
| 890 | GLenum internalformat, |
| 891 | GLsizei width, |
| 892 | GLsizei height, |
| 893 | GLsizei depth) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 894 | { |
| 895 | if (width < 1 || height < 1 || depth < 1 || levels < 1) |
| 896 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 897 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 898 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 899 | } |
| 900 | |
Geoff Lang | b92c133 | 2015-09-04 12:54:55 -0400 | [diff] [blame] | 901 | GLsizei maxDim = std::max(width, height); |
| 902 | if (target != GL_TEXTURE_2D_ARRAY) |
| 903 | { |
| 904 | maxDim = std::max(maxDim, depth); |
| 905 | } |
| 906 | |
| 907 | if (levels > gl::log2(maxDim) + 1) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 908 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 909 | context->handleError(InvalidOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 910 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 911 | } |
| 912 | |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 913 | const gl::Caps &caps = context->getCaps(); |
| 914 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 915 | switch (target) |
| 916 | { |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 917 | case GL_TEXTURE_2D: |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 918 | { |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 919 | if (static_cast<GLuint>(width) > caps.max2DTextureSize || |
| 920 | static_cast<GLuint>(height) > caps.max2DTextureSize) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 921 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 922 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 923 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 924 | } |
| 925 | } |
| 926 | break; |
| 927 | |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 928 | case GL_TEXTURE_RECTANGLE_ANGLE: |
| 929 | { |
| 930 | if (static_cast<GLuint>(width) > caps.maxRectangleTextureSize || |
| 931 | static_cast<GLuint>(height) > caps.maxRectangleTextureSize || levels != 1) |
| 932 | { |
| 933 | context->handleError(InvalidValue()); |
| 934 | return false; |
| 935 | } |
| 936 | } |
| 937 | break; |
| 938 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 939 | case GL_TEXTURE_CUBE_MAP: |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 940 | { |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 941 | if (width != height) |
| 942 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 943 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 944 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 945 | } |
| 946 | |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 947 | if (static_cast<GLuint>(width) > caps.maxCubeMapTextureSize) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 948 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 949 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 950 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 951 | } |
| 952 | } |
| 953 | break; |
| 954 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 955 | case GL_TEXTURE_3D: |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 956 | { |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 957 | if (static_cast<GLuint>(width) > caps.max3DTextureSize || |
| 958 | static_cast<GLuint>(height) > caps.max3DTextureSize || |
| 959 | static_cast<GLuint>(depth) > caps.max3DTextureSize) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 960 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 961 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 962 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 963 | } |
| 964 | } |
| 965 | break; |
| 966 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 967 | case GL_TEXTURE_2D_ARRAY: |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 968 | { |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 969 | if (static_cast<GLuint>(width) > caps.max2DTextureSize || |
| 970 | static_cast<GLuint>(height) > caps.max2DTextureSize || |
| 971 | static_cast<GLuint>(depth) > caps.maxArrayTextureLayers) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 972 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 973 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 974 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 975 | } |
| 976 | } |
| 977 | break; |
| 978 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 979 | default: |
| 980 | UNREACHABLE(); |
| 981 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 982 | } |
| 983 | |
Geoff Lang | 691e58c | 2014-12-19 17:03:25 -0500 | [diff] [blame] | 984 | gl::Texture *texture = context->getTargetTexture(target); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 985 | if (!texture || texture->id() == 0) |
| 986 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 987 | context->handleError(InvalidOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 988 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 989 | } |
| 990 | |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 991 | if (texture->getImmutableFormat()) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 992 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 993 | context->handleError(InvalidOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 994 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 995 | } |
| 996 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 997 | const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalformat); |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 998 | if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 999 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1000 | context->handleError(InvalidEnum()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1001 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1002 | } |
| 1003 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1004 | if (!formatInfo.sized) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1005 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1006 | context->handleError(InvalidEnum()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1007 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1008 | } |
| 1009 | |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1010 | if (formatInfo.compressed && target == GL_TEXTURE_RECTANGLE_ANGLE) |
| 1011 | { |
| 1012 | context->handleError(InvalidEnum() << "Rectangle texture cannot have a compressed format."); |
| 1013 | return false; |
| 1014 | } |
| 1015 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1016 | return true; |
| 1017 | } |
| 1018 | |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 1019 | bool ValidateES3TexStorage2DParameters(Context *context, |
| 1020 | GLenum target, |
| 1021 | GLsizei levels, |
| 1022 | GLenum internalformat, |
| 1023 | GLsizei width, |
| 1024 | GLsizei height, |
| 1025 | GLsizei depth) |
| 1026 | { |
| 1027 | if (!ValidTexture2DTarget(context, target)) |
| 1028 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1029 | context->handleError(InvalidEnum()); |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 1030 | return false; |
| 1031 | } |
| 1032 | |
| 1033 | return ValidateES3TexStorageParametersBase(context, target, levels, internalformat, width, |
| 1034 | height, depth); |
| 1035 | } |
| 1036 | |
| 1037 | bool ValidateES3TexStorage3DParameters(Context *context, |
| 1038 | GLenum target, |
| 1039 | GLsizei levels, |
| 1040 | GLenum internalformat, |
| 1041 | GLsizei width, |
| 1042 | GLsizei height, |
| 1043 | GLsizei depth) |
| 1044 | { |
| 1045 | if (!ValidTexture3DTarget(context, target)) |
| 1046 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1047 | context->handleError(InvalidEnum()); |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 1048 | return false; |
| 1049 | } |
| 1050 | |
| 1051 | return ValidateES3TexStorageParametersBase(context, target, levels, internalformat, width, |
| 1052 | height, depth); |
| 1053 | } |
| 1054 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1055 | bool ValidateBeginQuery(gl::Context *context, GLenum target, GLuint id) |
| 1056 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1057 | if (context->getClientMajorVersion() < 3) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1058 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1059 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1060 | return false; |
| 1061 | } |
| 1062 | |
| 1063 | return ValidateBeginQueryBase(context, target, id); |
| 1064 | } |
| 1065 | |
| 1066 | bool ValidateEndQuery(gl::Context *context, GLenum target) |
| 1067 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1068 | if (context->getClientMajorVersion() < 3) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1069 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1070 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1071 | return false; |
| 1072 | } |
| 1073 | |
| 1074 | return ValidateEndQueryBase(context, target); |
| 1075 | } |
| 1076 | |
| 1077 | bool ValidateGetQueryiv(Context *context, GLenum target, GLenum pname, GLint *params) |
| 1078 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1079 | if (context->getClientMajorVersion() < 3) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1080 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1081 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1082 | return false; |
| 1083 | } |
| 1084 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1085 | return ValidateGetQueryivBase(context, target, pname, nullptr); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1086 | } |
| 1087 | |
| 1088 | bool ValidateGetQueryObjectuiv(Context *context, GLuint id, GLenum pname, GLuint *params) |
| 1089 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1090 | if (context->getClientMajorVersion() < 3) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1091 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1092 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1093 | return false; |
| 1094 | } |
| 1095 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1096 | return ValidateGetQueryObjectValueBase(context, id, pname, nullptr); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1097 | } |
| 1098 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1099 | bool ValidateFramebufferTextureLayer(Context *context, |
| 1100 | GLenum target, |
| 1101 | GLenum attachment, |
| 1102 | GLuint texture, |
| 1103 | GLint level, |
| 1104 | GLint layer) |
Jamie Madill | 570f7c8 | 2014-07-03 10:38:54 -0400 | [diff] [blame] | 1105 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1106 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 570f7c8 | 2014-07-03 10:38:54 -0400 | [diff] [blame] | 1107 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1108 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1109 | return false; |
Jamie Madill | 570f7c8 | 2014-07-03 10:38:54 -0400 | [diff] [blame] | 1110 | } |
| 1111 | |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1112 | if (!ValidateFramebufferTextureBase(context, target, attachment, texture, level)) |
| 1113 | { |
| 1114 | return false; |
| 1115 | } |
| 1116 | |
| 1117 | const gl::Caps &caps = context->getCaps(); |
| 1118 | if (texture != 0) |
| 1119 | { |
Geoff Lang | 23e0284 | 2017-10-17 13:24:09 -0400 | [diff] [blame] | 1120 | if (layer < 0) |
| 1121 | { |
| 1122 | context->handleError(InvalidValue()); |
| 1123 | return false; |
| 1124 | } |
| 1125 | |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1126 | gl::Texture *tex = context->getTexture(texture); |
| 1127 | ASSERT(tex); |
| 1128 | |
| 1129 | switch (tex->getTarget()) |
| 1130 | { |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1131 | case GL_TEXTURE_2D_ARRAY: |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1132 | { |
| 1133 | if (level > gl::log2(caps.max2DTextureSize)) |
| 1134 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1135 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1136 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | if (static_cast<GLuint>(layer) >= caps.maxArrayTextureLayers) |
| 1140 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1141 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1142 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1143 | } |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1144 | } |
| 1145 | break; |
| 1146 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1147 | case GL_TEXTURE_3D: |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1148 | { |
| 1149 | if (level > gl::log2(caps.max3DTextureSize)) |
| 1150 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1151 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1152 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | if (static_cast<GLuint>(layer) >= caps.max3DTextureSize) |
| 1156 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1157 | context->handleError(InvalidValue()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1158 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1159 | } |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1160 | } |
| 1161 | break; |
| 1162 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1163 | default: |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1164 | context->handleError(InvalidOperation()); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1165 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1166 | } |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1167 | |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 1168 | const auto &format = tex->getFormat(tex->getTarget(), level); |
| 1169 | if (format.info->compressed) |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1170 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1171 | context->handleError(InvalidOperation()); |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1172 | return false; |
| 1173 | } |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | return true; |
Jamie Madill | 570f7c8 | 2014-07-03 10:38:54 -0400 | [diff] [blame] | 1177 | } |
| 1178 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1179 | bool ValidateInvalidateFramebuffer(Context *context, |
| 1180 | GLenum target, |
| 1181 | GLsizei numAttachments, |
Austin Kinross | 0833263 | 2015-05-05 13:35:47 -0700 | [diff] [blame] | 1182 | const GLenum *attachments) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1183 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1184 | if (context->getClientMajorVersion() < 3) |
Austin Kinross | 0833263 | 2015-05-05 13:35:47 -0700 | [diff] [blame] | 1185 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 1186 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Austin Kinross | 0833263 | 2015-05-05 13:35:47 -0700 | [diff] [blame] | 1187 | return false; |
| 1188 | } |
| 1189 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1190 | bool defaultFramebuffer = false; |
| 1191 | |
| 1192 | switch (target) |
| 1193 | { |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1194 | case GL_DRAW_FRAMEBUFFER: |
| 1195 | case GL_FRAMEBUFFER: |
| 1196 | defaultFramebuffer = context->getGLState().getDrawFramebuffer()->id() == 0; |
| 1197 | break; |
| 1198 | case GL_READ_FRAMEBUFFER: |
| 1199 | defaultFramebuffer = context->getGLState().getReadFramebuffer()->id() == 0; |
| 1200 | break; |
| 1201 | default: |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 1202 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFramebufferTarget); |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1203 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1204 | } |
| 1205 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1206 | return ValidateDiscardFramebufferBase(context, target, numAttachments, attachments, |
| 1207 | defaultFramebuffer); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1208 | } |
| 1209 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 1210 | bool ValidateInvalidateSubFramebuffer(Context *context, |
| 1211 | GLenum target, |
| 1212 | GLsizei numAttachments, |
| 1213 | const GLenum *attachments, |
| 1214 | GLint x, |
| 1215 | GLint y, |
| 1216 | GLsizei width, |
| 1217 | GLsizei height) |
| 1218 | { |
| 1219 | return ValidateInvalidateFramebuffer(context, target, numAttachments, attachments); |
| 1220 | } |
| 1221 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1222 | bool ValidateClearBuffer(ValidationContext *context) |
Jamie Madill | 13f7d7d | 2014-06-20 13:21:27 -0400 | [diff] [blame] | 1223 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1224 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 13f7d7d | 2014-06-20 13:21:27 -0400 | [diff] [blame] | 1225 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1226 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1227 | return false; |
Jamie Madill | 13f7d7d | 2014-06-20 13:21:27 -0400 | [diff] [blame] | 1228 | } |
| 1229 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 1230 | if (context->getGLState().getDrawFramebuffer()->checkStatus(context) != GL_FRAMEBUFFER_COMPLETE) |
Jamie Madill | 13f7d7d | 2014-06-20 13:21:27 -0400 | [diff] [blame] | 1231 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1232 | context->handleError(InvalidFramebufferOperation()); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1233 | return false; |
Jamie Madill | 13f7d7d | 2014-06-20 13:21:27 -0400 | [diff] [blame] | 1234 | } |
| 1235 | |
| 1236 | return true; |
| 1237 | } |
| 1238 | |
Olli Etuaho | 71dfb36 | 2016-03-10 14:04:27 +0200 | [diff] [blame] | 1239 | bool ValidateDrawRangeElements(Context *context, |
| 1240 | GLenum mode, |
| 1241 | GLuint start, |
| 1242 | GLuint end, |
| 1243 | GLsizei count, |
| 1244 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1245 | const void *indices) |
Olli Etuaho | 71dfb36 | 2016-03-10 14:04:27 +0200 | [diff] [blame] | 1246 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1247 | if (context->getClientMajorVersion() < 3) |
Olli Etuaho | 71dfb36 | 2016-03-10 14:04:27 +0200 | [diff] [blame] | 1248 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 1249 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Olli Etuaho | 71dfb36 | 2016-03-10 14:04:27 +0200 | [diff] [blame] | 1250 | return false; |
| 1251 | } |
| 1252 | |
| 1253 | if (end < start) |
| 1254 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1255 | context->handleError(InvalidValue() << "end < start"); |
Olli Etuaho | 71dfb36 | 2016-03-10 14:04:27 +0200 | [diff] [blame] | 1256 | return false; |
| 1257 | } |
| 1258 | |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 1259 | if (!ValidateDrawElementsCommon(context, mode, count, type, indices, 0)) |
Olli Etuaho | 71dfb36 | 2016-03-10 14:04:27 +0200 | [diff] [blame] | 1260 | { |
| 1261 | return false; |
| 1262 | } |
| 1263 | |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 1264 | // Use the parameter buffer to retrieve and cache the index range. |
| 1265 | const auto ¶ms = context->getParams<HasIndexRange>(); |
| 1266 | const auto &indexRangeOpt = params.getIndexRange(); |
| 1267 | if (!indexRangeOpt.valid()) |
| 1268 | { |
| 1269 | // Unexpected error. |
| 1270 | return false; |
| 1271 | } |
| 1272 | |
| 1273 | if (indexRangeOpt.value().end > end || indexRangeOpt.value().start < start) |
Olli Etuaho | 71dfb36 | 2016-03-10 14:04:27 +0200 | [diff] [blame] | 1274 | { |
| 1275 | // GL spec says that behavior in this case is undefined - generating an error is fine. |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1276 | context->handleError(InvalidOperation() << "Indices are out of the start, end range."); |
Olli Etuaho | 71dfb36 | 2016-03-10 14:04:27 +0200 | [diff] [blame] | 1277 | return false; |
| 1278 | } |
| 1279 | return true; |
| 1280 | } |
| 1281 | |
He Yunchao | ced53ae | 2016-11-29 15:00:51 +0800 | [diff] [blame] | 1282 | bool ValidateGetUniformuiv(Context *context, GLuint program, GLint location, GLuint *params) |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 1283 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1284 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 1285 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1286 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1287 | return false; |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 1288 | } |
| 1289 | |
Jamie Madill | 78f4180 | 2014-08-25 15:47:55 -0400 | [diff] [blame] | 1290 | return ValidateGetUniformBase(context, program, location); |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 1291 | } |
| 1292 | |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 1293 | bool ValidateReadBuffer(Context *context, GLenum src) |
| 1294 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1295 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 1296 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1297 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 1298 | return false; |
| 1299 | } |
| 1300 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1301 | const Framebuffer *readFBO = context->getGLState().getReadFramebuffer(); |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 1302 | |
| 1303 | if (readFBO == nullptr) |
| 1304 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1305 | context->handleError(InvalidOperation() << "No active read framebuffer."); |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 1306 | return false; |
| 1307 | } |
| 1308 | |
| 1309 | if (src == GL_NONE) |
| 1310 | { |
| 1311 | return true; |
| 1312 | } |
| 1313 | |
Olli Etuaho | 84c9f59 | 2016-03-09 14:37:25 +0200 | [diff] [blame] | 1314 | if (src != GL_BACK && (src < GL_COLOR_ATTACHMENT0 || src > GL_COLOR_ATTACHMENT31)) |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 1315 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1316 | context->handleError(InvalidEnum() << "Unknown enum for 'src' in ReadBuffer"); |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 1317 | return false; |
| 1318 | } |
| 1319 | |
| 1320 | if (readFBO->id() == 0) |
| 1321 | { |
| 1322 | if (src != GL_BACK) |
| 1323 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1324 | context->handleError( |
| 1325 | InvalidOperation() |
| 1326 | << "'src' must be GL_NONE or GL_BACK when reading from the default framebuffer."); |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 1327 | return false; |
| 1328 | } |
| 1329 | } |
| 1330 | else |
| 1331 | { |
| 1332 | GLuint drawBuffer = static_cast<GLuint>(src - GL_COLOR_ATTACHMENT0); |
| 1333 | |
| 1334 | if (drawBuffer >= context->getCaps().maxDrawBuffers) |
| 1335 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1336 | context->handleError(InvalidOperation() << "'src' is greater than MAX_DRAW_BUFFERS."); |
Jamie Madill | b885e57 | 2015-02-03 16:16:04 -0500 | [diff] [blame] | 1337 | return false; |
| 1338 | } |
| 1339 | } |
| 1340 | |
| 1341 | return true; |
| 1342 | } |
| 1343 | |
Jamie Madill | 86af3d2 | 2015-07-21 15:14:07 -0400 | [diff] [blame] | 1344 | bool ValidateCompressedTexImage3D(Context *context, |
| 1345 | GLenum target, |
| 1346 | GLint level, |
| 1347 | GLenum internalformat, |
| 1348 | GLsizei width, |
| 1349 | GLsizei height, |
| 1350 | GLsizei depth, |
| 1351 | GLint border, |
| 1352 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1353 | const void *data) |
Jamie Madill | 86af3d2 | 2015-07-21 15:14:07 -0400 | [diff] [blame] | 1354 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1355 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 86af3d2 | 2015-07-21 15:14:07 -0400 | [diff] [blame] | 1356 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1357 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | 86af3d2 | 2015-07-21 15:14:07 -0400 | [diff] [blame] | 1358 | return false; |
| 1359 | } |
| 1360 | |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1361 | if (!ValidTextureTarget(context, target)) |
| 1362 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1363 | context->handleError(InvalidEnum()); |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1364 | return false; |
| 1365 | } |
| 1366 | |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 1367 | // Validate image size |
| 1368 | if (!ValidImageSizeParameters(context, target, level, width, height, depth, false)) |
| 1369 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1370 | context->handleError(InvalidValue()); |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 1371 | return false; |
| 1372 | } |
| 1373 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1374 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(internalformat); |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1375 | if (!formatInfo.compressed) |
| 1376 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1377 | context->handleError(InvalidEnum() << "Not a valid compressed texture format"); |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1378 | return false; |
| 1379 | } |
| 1380 | |
Jamie Madill | 513558d | 2016-06-02 13:04:11 -0400 | [diff] [blame] | 1381 | auto blockSizeOrErr = |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1382 | formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, depth)); |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 1383 | if (blockSizeOrErr.isError()) |
| 1384 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1385 | context->handleError(InvalidValue()); |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 1386 | return false; |
| 1387 | } |
| 1388 | if (imageSize < 0 || static_cast<GLuint>(imageSize) != blockSizeOrErr.getResult()) |
Jamie Madill | 86af3d2 | 2015-07-21 15:14:07 -0400 | [diff] [blame] | 1389 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1390 | context->handleError(InvalidValue()); |
Jamie Madill | 86af3d2 | 2015-07-21 15:14:07 -0400 | [diff] [blame] | 1391 | return false; |
| 1392 | } |
| 1393 | |
| 1394 | // 3D texture target validation |
| 1395 | if (target != GL_TEXTURE_3D && target != GL_TEXTURE_2D_ARRAY) |
| 1396 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1397 | context->handleError(InvalidEnum() << "Must specify a valid 3D texture destination target"); |
Jamie Madill | 86af3d2 | 2015-07-21 15:14:07 -0400 | [diff] [blame] | 1398 | return false; |
| 1399 | } |
| 1400 | |
| 1401 | // validateES3TexImageFormat sets the error code if there is an error |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 1402 | if (!ValidateES3TexImage3DParameters(context, target, level, internalformat, true, false, 0, 0, |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 1403 | 0, width, height, depth, border, GL_NONE, GL_NONE, -1, |
| 1404 | data)) |
Jamie Madill | 86af3d2 | 2015-07-21 15:14:07 -0400 | [diff] [blame] | 1405 | { |
| 1406 | return false; |
| 1407 | } |
| 1408 | |
| 1409 | return true; |
| 1410 | } |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 1411 | |
Corentin Wallez | b293160 | 2017-04-11 15:58:57 -0400 | [diff] [blame] | 1412 | bool ValidateCompressedTexImage3DRobustANGLE(Context *context, |
| 1413 | GLenum target, |
| 1414 | GLint level, |
| 1415 | GLenum internalformat, |
| 1416 | GLsizei width, |
| 1417 | GLsizei height, |
| 1418 | GLsizei depth, |
| 1419 | GLint border, |
| 1420 | GLsizei imageSize, |
| 1421 | GLsizei dataSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1422 | const void *data) |
Corentin Wallez | b293160 | 2017-04-11 15:58:57 -0400 | [diff] [blame] | 1423 | { |
| 1424 | if (!ValidateRobustCompressedTexImageBase(context, imageSize, dataSize)) |
| 1425 | { |
| 1426 | return false; |
| 1427 | } |
| 1428 | |
| 1429 | return ValidateCompressedTexImage3D(context, target, level, internalformat, width, height, |
| 1430 | depth, border, imageSize, data); |
| 1431 | } |
| 1432 | |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 1433 | bool ValidateBindVertexArray(Context *context, GLuint array) |
| 1434 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1435 | if (context->getClientMajorVersion() < 3) |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 1436 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1437 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 1438 | return false; |
| 1439 | } |
| 1440 | |
| 1441 | return ValidateBindVertexArrayBase(context, array); |
| 1442 | } |
| 1443 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 1444 | bool ValidateIsVertexArray(Context *context, GLuint array) |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 1445 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1446 | if (context->getClientMajorVersion() < 3) |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 1447 | { |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 1448 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 1449 | return false; |
| 1450 | } |
| 1451 | |
| 1452 | return true; |
| 1453 | } |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1454 | |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1455 | static bool ValidateBindBufferCommon(Context *context, |
| 1456 | GLenum target, |
| 1457 | GLuint index, |
| 1458 | GLuint buffer, |
| 1459 | GLintptr offset, |
| 1460 | GLsizeiptr size) |
| 1461 | { |
| 1462 | if (context->getClientMajorVersion() < 3) |
| 1463 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1464 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1465 | return false; |
| 1466 | } |
| 1467 | |
| 1468 | if (buffer != 0 && offset < 0) |
| 1469 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1470 | context->handleError(InvalidValue() << "buffer is non-zero and offset is negative."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1471 | return false; |
| 1472 | } |
| 1473 | |
| 1474 | if (!context->getGLState().isBindGeneratesResourceEnabled() && |
| 1475 | !context->isBufferGenerated(buffer)) |
| 1476 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1477 | context->handleError(InvalidOperation() << "Buffer was not generated."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1478 | return false; |
| 1479 | } |
| 1480 | |
| 1481 | const Caps &caps = context->getCaps(); |
| 1482 | switch (target) |
| 1483 | { |
| 1484 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 1485 | { |
| 1486 | if (index >= caps.maxTransformFeedbackSeparateAttributes) |
| 1487 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1488 | context->handleError(InvalidValue() << "index is greater than or equal to the " |
| 1489 | "number of TRANSFORM_FEEDBACK_BUFFER " |
| 1490 | "indexed binding points."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1491 | return false; |
| 1492 | } |
| 1493 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 1494 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1495 | context->handleError(InvalidValue() << "offset and size must be multiple of 4."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1496 | return false; |
| 1497 | } |
| 1498 | |
| 1499 | TransformFeedback *curTransformFeedback = |
| 1500 | context->getGLState().getCurrentTransformFeedback(); |
| 1501 | if (curTransformFeedback && curTransformFeedback->isActive()) |
| 1502 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1503 | context->handleError(InvalidOperation() |
| 1504 | << "target is TRANSFORM_FEEDBACK_BUFFER and transform " |
| 1505 | "feedback is currently active."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1506 | return false; |
| 1507 | } |
| 1508 | break; |
| 1509 | } |
| 1510 | case GL_UNIFORM_BUFFER: |
| 1511 | { |
| 1512 | if (index >= caps.maxUniformBufferBindings) |
| 1513 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1514 | context->handleError(InvalidValue() << "index is greater than or equal to the " |
| 1515 | "number of UNIFORM_BUFFER indexed " |
| 1516 | "binding points."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1517 | return false; |
| 1518 | } |
| 1519 | |
| 1520 | if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0) |
| 1521 | { |
| 1522 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1523 | InvalidValue() |
| 1524 | << "offset must be multiple of value of UNIFORM_BUFFER_OFFSET_ALIGNMENT."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1525 | return false; |
| 1526 | } |
| 1527 | break; |
| 1528 | } |
| 1529 | case GL_ATOMIC_COUNTER_BUFFER: |
| 1530 | { |
| 1531 | if (context->getClientVersion() < ES_3_1) |
| 1532 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1533 | context->handleError(InvalidEnum() |
| 1534 | << "ATOMIC_COUNTER_BUFFER is not supported before GLES 3.1"); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1535 | return false; |
| 1536 | } |
| 1537 | if (index >= caps.maxAtomicCounterBufferBindings) |
| 1538 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1539 | context->handleError(InvalidValue() << "index is greater than or equal to the " |
| 1540 | "number of ATOMIC_COUNTER_BUFFER " |
| 1541 | "indexed binding points."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1542 | return false; |
| 1543 | } |
| 1544 | if (buffer != 0 && (offset % 4) != 0) |
| 1545 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1546 | context->handleError(InvalidValue() << "offset must be a multiple of 4."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1547 | return false; |
| 1548 | } |
| 1549 | break; |
| 1550 | } |
| 1551 | case GL_SHADER_STORAGE_BUFFER: |
| 1552 | { |
| 1553 | if (context->getClientVersion() < ES_3_1) |
| 1554 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1555 | context->handleError(InvalidEnum() |
| 1556 | << "SHADER_STORAGE_BUFFER is not supported in GLES3."); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1557 | return false; |
| 1558 | } |
| 1559 | if (index >= caps.maxShaderStorageBufferBindings) |
| 1560 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1561 | context->handleError(InvalidValue() << "index is greater than or equal to the " |
| 1562 | "number of SHADER_STORAGE_BUFFER " |
| 1563 | "indexed binding points."); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1564 | return false; |
| 1565 | } |
| 1566 | if (buffer != 0 && (offset % caps.shaderStorageBufferOffsetAlignment) != 0) |
| 1567 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1568 | context->handleError(InvalidValue() << "offset must be multiple of value of " |
| 1569 | "SHADER_STORAGE_BUFFER_OFFSET_" |
| 1570 | "ALIGNMENT."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1571 | return false; |
| 1572 | } |
| 1573 | break; |
| 1574 | } |
| 1575 | default: |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1576 | context->handleError(InvalidEnum() << "the target is not supported."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1577 | return false; |
| 1578 | } |
| 1579 | |
| 1580 | return true; |
| 1581 | } |
| 1582 | |
| 1583 | bool ValidateBindBufferBase(Context *context, GLenum target, GLuint index, GLuint buffer) |
| 1584 | { |
| 1585 | return ValidateBindBufferCommon(context, target, index, buffer, 0, 0); |
| 1586 | } |
| 1587 | |
| 1588 | bool ValidateBindBufferRange(Context *context, |
| 1589 | GLenum target, |
| 1590 | GLuint index, |
| 1591 | GLuint buffer, |
| 1592 | GLintptr offset, |
| 1593 | GLsizeiptr size) |
| 1594 | { |
| 1595 | if (buffer != 0 && size <= 0) |
| 1596 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1597 | context->handleError(InvalidValue() |
| 1598 | << "buffer is non-zero and size is less than or equal to zero."); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1599 | return false; |
| 1600 | } |
| 1601 | return ValidateBindBufferCommon(context, target, index, buffer, offset, size); |
| 1602 | } |
| 1603 | |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1604 | bool ValidateProgramBinary(Context *context, |
| 1605 | GLuint program, |
| 1606 | GLenum binaryFormat, |
| 1607 | const void *binary, |
| 1608 | GLint length) |
| 1609 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1610 | if (context->getClientMajorVersion() < 3) |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1611 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1612 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1613 | return false; |
| 1614 | } |
| 1615 | |
| 1616 | return ValidateProgramBinaryBase(context, program, binaryFormat, binary, length); |
| 1617 | } |
| 1618 | |
| 1619 | bool ValidateGetProgramBinary(Context *context, |
| 1620 | GLuint program, |
| 1621 | GLsizei bufSize, |
| 1622 | GLsizei *length, |
| 1623 | GLenum *binaryFormat, |
| 1624 | void *binary) |
| 1625 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1626 | if (context->getClientMajorVersion() < 3) |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1627 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1628 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1629 | return false; |
| 1630 | } |
| 1631 | |
| 1632 | return ValidateGetProgramBinaryBase(context, program, bufSize, length, binaryFormat, binary); |
| 1633 | } |
| 1634 | |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 1635 | bool ValidateProgramParameteri(Context *context, GLuint program, GLenum pname, GLint value) |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1636 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1637 | if (context->getClientMajorVersion() < 3) |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1638 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 1639 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1640 | return false; |
| 1641 | } |
| 1642 | |
| 1643 | if (GetValidProgram(context, program) == nullptr) |
| 1644 | { |
| 1645 | return false; |
| 1646 | } |
| 1647 | |
| 1648 | switch (pname) |
| 1649 | { |
| 1650 | case GL_PROGRAM_BINARY_RETRIEVABLE_HINT: |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 1651 | if (value != GL_FALSE && value != GL_TRUE) |
| 1652 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1653 | context->handleError(InvalidValue() |
| 1654 | << "Invalid value, expected GL_FALSE or GL_TRUE: " << value); |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 1655 | return false; |
| 1656 | } |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1657 | break; |
| 1658 | |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 1659 | case GL_PROGRAM_SEPARABLE: |
| 1660 | if (context->getClientVersion() < ES_3_1) |
| 1661 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1662 | context->handleError(InvalidEnum() |
| 1663 | << "PROGRAM_SEPARABLE is not supported before GLES 3.1"); |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 1664 | return false; |
| 1665 | } |
| 1666 | |
| 1667 | if (value != GL_FALSE && value != GL_TRUE) |
| 1668 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1669 | context->handleError(InvalidValue() |
| 1670 | << "Invalid value, expected GL_FALSE or GL_TRUE: " << value); |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 1671 | return false; |
| 1672 | } |
| 1673 | break; |
| 1674 | |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1675 | default: |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1676 | context->handleError(InvalidEnum() |
| 1677 | << "Invalid pname: 0x" << std::hex << std::uppercase << pname); |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 1678 | return false; |
| 1679 | } |
| 1680 | |
| 1681 | return true; |
| 1682 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1683 | |
| 1684 | bool ValidateBlitFramebuffer(Context *context, |
| 1685 | GLint srcX0, |
| 1686 | GLint srcY0, |
| 1687 | GLint srcX1, |
| 1688 | GLint srcY1, |
| 1689 | GLint dstX0, |
| 1690 | GLint dstY0, |
| 1691 | GLint dstX1, |
| 1692 | GLint dstY1, |
| 1693 | GLbitfield mask, |
| 1694 | GLenum filter) |
| 1695 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1696 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1697 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1698 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1699 | return false; |
| 1700 | } |
| 1701 | |
| 1702 | return ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, |
| 1703 | dstX1, dstY1, mask, filter); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1704 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1705 | |
| 1706 | bool ValidateClearBufferiv(ValidationContext *context, |
| 1707 | GLenum buffer, |
| 1708 | GLint drawbuffer, |
| 1709 | const GLint *value) |
| 1710 | { |
| 1711 | switch (buffer) |
| 1712 | { |
| 1713 | case GL_COLOR: |
| 1714 | if (drawbuffer < 0 || |
| 1715 | static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) |
| 1716 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1717 | context->handleError(InvalidValue()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1718 | return false; |
| 1719 | } |
Geoff Lang | 76e6565 | 2017-03-27 14:58:02 -0400 | [diff] [blame] | 1720 | if (context->getExtensions().webglCompatibility) |
| 1721 | { |
| 1722 | constexpr GLenum validComponentTypes[] = {GL_INT}; |
Geoff Lang | 0fb0864 | 2017-07-04 15:07:23 -0400 | [diff] [blame] | 1723 | if (!ValidateWebGLFramebufferAttachmentClearType( |
Geoff Lang | 76e6565 | 2017-03-27 14:58:02 -0400 | [diff] [blame] | 1724 | context, drawbuffer, validComponentTypes, ArraySize(validComponentTypes))) |
| 1725 | { |
| 1726 | return false; |
| 1727 | } |
| 1728 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1729 | break; |
| 1730 | |
| 1731 | case GL_STENCIL: |
| 1732 | if (drawbuffer != 0) |
| 1733 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1734 | context->handleError(InvalidValue()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1735 | return false; |
| 1736 | } |
| 1737 | break; |
| 1738 | |
| 1739 | default: |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1740 | context->handleError(InvalidEnum()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1741 | return false; |
| 1742 | } |
| 1743 | |
| 1744 | return ValidateClearBuffer(context); |
| 1745 | } |
| 1746 | |
| 1747 | bool ValidateClearBufferuiv(ValidationContext *context, |
| 1748 | GLenum buffer, |
| 1749 | GLint drawbuffer, |
| 1750 | const GLuint *value) |
| 1751 | { |
| 1752 | switch (buffer) |
| 1753 | { |
| 1754 | case GL_COLOR: |
| 1755 | if (drawbuffer < 0 || |
| 1756 | static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) |
| 1757 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1758 | context->handleError(InvalidValue()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1759 | return false; |
| 1760 | } |
Geoff Lang | 76e6565 | 2017-03-27 14:58:02 -0400 | [diff] [blame] | 1761 | if (context->getExtensions().webglCompatibility) |
| 1762 | { |
| 1763 | constexpr GLenum validComponentTypes[] = {GL_UNSIGNED_INT}; |
Geoff Lang | 0fb0864 | 2017-07-04 15:07:23 -0400 | [diff] [blame] | 1764 | if (!ValidateWebGLFramebufferAttachmentClearType( |
Geoff Lang | 76e6565 | 2017-03-27 14:58:02 -0400 | [diff] [blame] | 1765 | context, drawbuffer, validComponentTypes, ArraySize(validComponentTypes))) |
| 1766 | { |
| 1767 | return false; |
| 1768 | } |
| 1769 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1770 | break; |
| 1771 | |
| 1772 | default: |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1773 | context->handleError(InvalidEnum()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1774 | return false; |
| 1775 | } |
| 1776 | |
| 1777 | return ValidateClearBuffer(context); |
| 1778 | } |
| 1779 | |
| 1780 | bool ValidateClearBufferfv(ValidationContext *context, |
| 1781 | GLenum buffer, |
| 1782 | GLint drawbuffer, |
| 1783 | const GLfloat *value) |
| 1784 | { |
| 1785 | switch (buffer) |
| 1786 | { |
| 1787 | case GL_COLOR: |
| 1788 | if (drawbuffer < 0 || |
| 1789 | static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) |
| 1790 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1791 | context->handleError(InvalidValue()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1792 | return false; |
| 1793 | } |
Geoff Lang | 76e6565 | 2017-03-27 14:58:02 -0400 | [diff] [blame] | 1794 | if (context->getExtensions().webglCompatibility) |
| 1795 | { |
| 1796 | constexpr GLenum validComponentTypes[] = {GL_FLOAT, GL_UNSIGNED_NORMALIZED, |
| 1797 | GL_SIGNED_NORMALIZED}; |
Geoff Lang | 0fb0864 | 2017-07-04 15:07:23 -0400 | [diff] [blame] | 1798 | if (!ValidateWebGLFramebufferAttachmentClearType( |
Geoff Lang | 76e6565 | 2017-03-27 14:58:02 -0400 | [diff] [blame] | 1799 | context, drawbuffer, validComponentTypes, ArraySize(validComponentTypes))) |
| 1800 | { |
| 1801 | return false; |
| 1802 | } |
| 1803 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1804 | break; |
| 1805 | |
| 1806 | case GL_DEPTH: |
| 1807 | if (drawbuffer != 0) |
| 1808 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1809 | context->handleError(InvalidValue()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1810 | return false; |
| 1811 | } |
| 1812 | break; |
| 1813 | |
| 1814 | default: |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1815 | context->handleError(InvalidEnum()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1816 | return false; |
| 1817 | } |
| 1818 | |
| 1819 | return ValidateClearBuffer(context); |
| 1820 | } |
| 1821 | |
| 1822 | bool ValidateClearBufferfi(ValidationContext *context, |
| 1823 | GLenum buffer, |
| 1824 | GLint drawbuffer, |
| 1825 | GLfloat depth, |
| 1826 | GLint stencil) |
| 1827 | { |
| 1828 | switch (buffer) |
| 1829 | { |
| 1830 | case GL_DEPTH_STENCIL: |
| 1831 | if (drawbuffer != 0) |
| 1832 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1833 | context->handleError(InvalidValue()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1834 | return false; |
| 1835 | } |
| 1836 | break; |
| 1837 | |
| 1838 | default: |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 1839 | context->handleError(InvalidEnum()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1840 | return false; |
| 1841 | } |
| 1842 | |
| 1843 | return ValidateClearBuffer(context); |
| 1844 | } |
| 1845 | |
| 1846 | bool ValidateDrawBuffers(ValidationContext *context, GLsizei n, const GLenum *bufs) |
| 1847 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1848 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1849 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 1850 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1851 | return false; |
| 1852 | } |
| 1853 | |
| 1854 | return ValidateDrawBuffersBase(context, n, bufs); |
| 1855 | } |
| 1856 | |
| 1857 | bool ValidateCopyTexSubImage3D(Context *context, |
| 1858 | GLenum target, |
| 1859 | GLint level, |
| 1860 | GLint xoffset, |
| 1861 | GLint yoffset, |
| 1862 | GLint zoffset, |
| 1863 | GLint x, |
| 1864 | GLint y, |
| 1865 | GLsizei width, |
| 1866 | GLsizei height) |
| 1867 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1868 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1869 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1870 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1871 | return false; |
| 1872 | } |
| 1873 | |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 1874 | return ValidateES3CopyTexImage3DParameters(context, target, level, GL_NONE, true, xoffset, |
| 1875 | yoffset, zoffset, x, y, width, height, 0); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1876 | } |
| 1877 | |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1878 | bool ValidateTexImage3D(Context *context, |
| 1879 | GLenum target, |
| 1880 | GLint level, |
| 1881 | GLint internalformat, |
| 1882 | GLsizei width, |
| 1883 | GLsizei height, |
| 1884 | GLsizei depth, |
| 1885 | GLint border, |
| 1886 | GLenum format, |
| 1887 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1888 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1889 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1890 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1891 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1892 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1893 | return false; |
| 1894 | } |
| 1895 | |
| 1896 | return ValidateES3TexImage3DParameters(context, target, level, internalformat, false, false, 0, |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 1897 | 0, 0, width, height, depth, border, format, type, -1, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1898 | pixels); |
| 1899 | } |
| 1900 | |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 1901 | bool ValidateTexImage3DRobustANGLE(Context *context, |
| 1902 | GLenum target, |
| 1903 | GLint level, |
| 1904 | GLint internalformat, |
| 1905 | GLsizei width, |
| 1906 | GLsizei height, |
| 1907 | GLsizei depth, |
| 1908 | GLint border, |
| 1909 | GLenum format, |
| 1910 | GLenum type, |
| 1911 | GLsizei bufSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1912 | const void *pixels) |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 1913 | { |
| 1914 | if (context->getClientMajorVersion() < 3) |
| 1915 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1916 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 1917 | return false; |
| 1918 | } |
| 1919 | |
| 1920 | if (!ValidateRobustEntryPoint(context, bufSize)) |
| 1921 | { |
| 1922 | return false; |
| 1923 | } |
| 1924 | |
| 1925 | return ValidateES3TexImage3DParameters(context, target, level, internalformat, false, false, 0, |
| 1926 | 0, 0, width, height, depth, border, format, type, |
| 1927 | bufSize, pixels); |
| 1928 | } |
| 1929 | |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1930 | bool ValidateTexSubImage3D(Context *context, |
| 1931 | GLenum target, |
| 1932 | GLint level, |
| 1933 | GLint xoffset, |
| 1934 | GLint yoffset, |
| 1935 | GLint zoffset, |
| 1936 | GLsizei width, |
| 1937 | GLsizei height, |
| 1938 | GLsizei depth, |
| 1939 | GLenum format, |
| 1940 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1941 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1942 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1943 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1944 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1945 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1946 | return false; |
| 1947 | } |
| 1948 | |
| 1949 | return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, false, true, xoffset, |
| 1950 | yoffset, zoffset, width, height, depth, 0, format, type, |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 1951 | -1, pixels); |
| 1952 | } |
| 1953 | |
| 1954 | bool ValidateTexSubImage3DRobustANGLE(Context *context, |
| 1955 | GLenum target, |
| 1956 | GLint level, |
| 1957 | GLint xoffset, |
| 1958 | GLint yoffset, |
| 1959 | GLint zoffset, |
| 1960 | GLsizei width, |
| 1961 | GLsizei height, |
| 1962 | GLsizei depth, |
| 1963 | GLenum format, |
| 1964 | GLenum type, |
| 1965 | GLsizei bufSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1966 | const void *pixels) |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 1967 | { |
| 1968 | if (context->getClientMajorVersion() < 3) |
| 1969 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1970 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | c52f6f1 | 2016-10-14 10:18:00 -0400 | [diff] [blame] | 1971 | return false; |
| 1972 | } |
| 1973 | |
| 1974 | if (!ValidateRobustEntryPoint(context, bufSize)) |
| 1975 | { |
| 1976 | return false; |
| 1977 | } |
| 1978 | |
| 1979 | return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, false, true, xoffset, |
| 1980 | yoffset, zoffset, width, height, depth, 0, format, type, |
| 1981 | bufSize, pixels); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1982 | } |
| 1983 | |
| 1984 | bool ValidateCompressedTexSubImage3D(Context *context, |
| 1985 | GLenum target, |
| 1986 | GLint level, |
| 1987 | GLint xoffset, |
| 1988 | GLint yoffset, |
| 1989 | GLint zoffset, |
| 1990 | GLsizei width, |
| 1991 | GLsizei height, |
| 1992 | GLsizei depth, |
| 1993 | GLenum format, |
| 1994 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1995 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1996 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1997 | if (context->getClientMajorVersion() < 3) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 1998 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 1999 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2000 | return false; |
| 2001 | } |
| 2002 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 2003 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(format); |
Geoff Lang | c5508d6 | 2017-02-10 14:58:38 -0500 | [diff] [blame] | 2004 | if (!formatInfo.compressed) |
| 2005 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2006 | context->handleError(InvalidEnum() << "Not a valid compressed texture format"); |
Geoff Lang | c5508d6 | 2017-02-10 14:58:38 -0500 | [diff] [blame] | 2007 | return false; |
| 2008 | } |
| 2009 | |
Jamie Madill | 513558d | 2016-06-02 13:04:11 -0400 | [diff] [blame] | 2010 | auto blockSizeOrErr = |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 2011 | formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, depth)); |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 2012 | if (blockSizeOrErr.isError()) |
| 2013 | { |
| 2014 | context->handleError(blockSizeOrErr.getError()); |
| 2015 | return false; |
| 2016 | } |
| 2017 | if (imageSize < 0 || static_cast<GLuint>(imageSize) != blockSizeOrErr.getResult()) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2018 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2019 | context->handleError(InvalidValue()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2020 | return false; |
| 2021 | } |
| 2022 | |
| 2023 | if (!data) |
| 2024 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2025 | context->handleError(InvalidValue()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2026 | return false; |
| 2027 | } |
| 2028 | |
| 2029 | return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, true, true, 0, 0, 0, |
Geoff Lang | 966c940 | 2017-04-18 12:38:27 -0400 | [diff] [blame] | 2030 | width, height, depth, 0, format, GL_NONE, -1, data); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2031 | } |
Corentin Wallez | b293160 | 2017-04-11 15:58:57 -0400 | [diff] [blame] | 2032 | bool ValidateCompressedTexSubImage3DRobustANGLE(Context *context, |
| 2033 | GLenum target, |
| 2034 | GLint level, |
| 2035 | GLint xoffset, |
| 2036 | GLint yoffset, |
| 2037 | GLint zoffset, |
| 2038 | GLsizei width, |
| 2039 | GLsizei height, |
| 2040 | GLsizei depth, |
| 2041 | GLenum format, |
| 2042 | GLsizei imageSize, |
| 2043 | GLsizei dataSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2044 | const void *data) |
Corentin Wallez | b293160 | 2017-04-11 15:58:57 -0400 | [diff] [blame] | 2045 | { |
| 2046 | if (!ValidateRobustCompressedTexImageBase(context, imageSize, dataSize)) |
| 2047 | { |
| 2048 | return false; |
| 2049 | } |
| 2050 | |
| 2051 | return ValidateCompressedTexSubImage3D(context, target, level, xoffset, yoffset, zoffset, width, |
| 2052 | height, depth, format, imageSize, data); |
| 2053 | } |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2054 | |
Olli Etuaho | 41997e7 | 2016-03-10 13:38:39 +0200 | [diff] [blame] | 2055 | bool ValidateGenQueries(Context *context, GLint n, GLuint *) |
| 2056 | { |
| 2057 | return ValidateGenOrDeleteES3(context, n); |
| 2058 | } |
| 2059 | |
| 2060 | bool ValidateDeleteQueries(Context *context, GLint n, const GLuint *) |
| 2061 | { |
| 2062 | return ValidateGenOrDeleteES3(context, n); |
| 2063 | } |
| 2064 | |
| 2065 | bool ValidateGenSamplers(Context *context, GLint count, GLuint *) |
| 2066 | { |
| 2067 | return ValidateGenOrDeleteCountES3(context, count); |
| 2068 | } |
| 2069 | |
| 2070 | bool ValidateDeleteSamplers(Context *context, GLint count, const GLuint *) |
| 2071 | { |
| 2072 | return ValidateGenOrDeleteCountES3(context, count); |
| 2073 | } |
| 2074 | |
| 2075 | bool ValidateGenTransformFeedbacks(Context *context, GLint n, GLuint *) |
| 2076 | { |
| 2077 | return ValidateGenOrDeleteES3(context, n); |
| 2078 | } |
| 2079 | |
| 2080 | bool ValidateDeleteTransformFeedbacks(Context *context, GLint n, const GLuint *ids) |
| 2081 | { |
| 2082 | if (!ValidateGenOrDeleteES3(context, n)) |
| 2083 | { |
| 2084 | return false; |
| 2085 | } |
| 2086 | for (GLint i = 0; i < n; ++i) |
| 2087 | { |
| 2088 | auto *transformFeedback = context->getTransformFeedback(ids[i]); |
| 2089 | if (transformFeedback != nullptr && transformFeedback->isActive()) |
| 2090 | { |
| 2091 | // ES 3.0.4 section 2.15.1 page 86 |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2092 | context->handleError(InvalidOperation() |
| 2093 | << "Attempt to delete active transform feedback."); |
Olli Etuaho | 41997e7 | 2016-03-10 13:38:39 +0200 | [diff] [blame] | 2094 | return false; |
| 2095 | } |
| 2096 | } |
| 2097 | return true; |
| 2098 | } |
| 2099 | |
| 2100 | bool ValidateGenVertexArrays(Context *context, GLint n, GLuint *) |
| 2101 | { |
| 2102 | return ValidateGenOrDeleteES3(context, n); |
| 2103 | } |
| 2104 | |
| 2105 | bool ValidateDeleteVertexArrays(Context *context, GLint n, const GLuint *) |
| 2106 | { |
| 2107 | return ValidateGenOrDeleteES3(context, n); |
| 2108 | } |
| 2109 | |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2110 | bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode) |
| 2111 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2112 | if (context->getClientMajorVersion() < 3) |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2113 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2114 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2115 | return false; |
| 2116 | } |
| 2117 | switch (primitiveMode) |
| 2118 | { |
| 2119 | case GL_TRIANGLES: |
| 2120 | case GL_LINES: |
| 2121 | case GL_POINTS: |
| 2122 | break; |
| 2123 | |
| 2124 | default: |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2125 | context->handleError(InvalidEnum() << "Invalid primitive mode."); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2126 | return false; |
| 2127 | } |
| 2128 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2129 | TransformFeedback *transformFeedback = context->getGLState().getCurrentTransformFeedback(); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2130 | ASSERT(transformFeedback != nullptr); |
| 2131 | |
| 2132 | if (transformFeedback->isActive()) |
| 2133 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2134 | context->handleError(InvalidOperation() << "Transform feedback is already active."); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2135 | return false; |
| 2136 | } |
Geoff Lang | 79f7104 | 2017-08-14 16:43:43 -0400 | [diff] [blame] | 2137 | |
| 2138 | for (size_t i = 0; i < transformFeedback->getIndexedBufferCount(); i++) |
| 2139 | { |
| 2140 | const auto &buffer = transformFeedback->getIndexedBuffer(i); |
| 2141 | if (buffer.get() && buffer->isMapped()) |
| 2142 | { |
| 2143 | context->handleError(InvalidOperation() << "Transform feedback has a mapped buffer."); |
| 2144 | return false; |
| 2145 | } |
| 2146 | } |
| 2147 | |
Olli Etuaho | 02032bd | 2017-10-13 18:10:17 +0300 | [diff] [blame] | 2148 | auto program = context->getGLState().getProgram(); |
| 2149 | |
| 2150 | if (!program) |
| 2151 | { |
| 2152 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotBound); |
| 2153 | return false; |
| 2154 | } |
| 2155 | |
| 2156 | if (program->getTransformFeedbackVaryingCount() == 0) |
| 2157 | { |
| 2158 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), NoTransformFeedbackOutputVariables); |
| 2159 | return false; |
| 2160 | } |
| 2161 | |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2162 | return true; |
| 2163 | } |
| 2164 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2165 | bool ValidateGetBufferPointerv(Context *context, GLenum target, GLenum pname, void **params) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2166 | { |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 2167 | return ValidateGetBufferPointervBase(context, target, pname, nullptr, params); |
| 2168 | } |
| 2169 | |
| 2170 | bool ValidateGetBufferPointervRobustANGLE(Context *context, |
| 2171 | GLenum target, |
| 2172 | GLenum pname, |
| 2173 | GLsizei bufSize, |
| 2174 | GLsizei *length, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2175 | void **params) |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 2176 | { |
| 2177 | if (!ValidateRobustEntryPoint(context, bufSize)) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2178 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2179 | return false; |
| 2180 | } |
| 2181 | |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 2182 | if (!ValidateGetBufferPointervBase(context, target, pname, length, params)) |
| 2183 | { |
| 2184 | return false; |
| 2185 | } |
| 2186 | |
| 2187 | if (!ValidateRobustBufferSize(context, bufSize, *length)) |
| 2188 | { |
| 2189 | return false; |
| 2190 | } |
| 2191 | |
| 2192 | return true; |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2193 | } |
| 2194 | |
| 2195 | bool ValidateUnmapBuffer(Context *context, GLenum target) |
| 2196 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2197 | if (context->getClientMajorVersion() < 3) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2198 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 2199 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2200 | return false; |
| 2201 | } |
| 2202 | |
| 2203 | return ValidateUnmapBufferBase(context, target); |
| 2204 | } |
| 2205 | |
| 2206 | bool ValidateMapBufferRange(Context *context, |
| 2207 | GLenum target, |
| 2208 | GLintptr offset, |
| 2209 | GLsizeiptr length, |
| 2210 | GLbitfield access) |
| 2211 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2212 | if (context->getClientMajorVersion() < 3) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2213 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2214 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2215 | return false; |
| 2216 | } |
| 2217 | |
| 2218 | return ValidateMapBufferRangeBase(context, target, offset, length, access); |
| 2219 | } |
| 2220 | |
| 2221 | bool ValidateFlushMappedBufferRange(Context *context, |
| 2222 | GLenum target, |
| 2223 | GLintptr offset, |
| 2224 | GLsizeiptr length) |
| 2225 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2226 | if (context->getClientMajorVersion() < 3) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2227 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2228 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2229 | return false; |
| 2230 | } |
| 2231 | |
| 2232 | return ValidateFlushMappedBufferRangeBase(context, target, offset, length); |
| 2233 | } |
| 2234 | |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 2235 | bool ValidateIndexedStateQuery(ValidationContext *context, |
| 2236 | GLenum pname, |
| 2237 | GLuint index, |
| 2238 | GLsizei *length) |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2239 | { |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 2240 | if (length) |
| 2241 | { |
| 2242 | *length = 0; |
| 2243 | } |
| 2244 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2245 | GLenum nativeType; |
| 2246 | unsigned int numParams; |
| 2247 | if (!context->getIndexedQueryParameterInfo(pname, &nativeType, &numParams)) |
| 2248 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2249 | context->handleError(InvalidEnum()); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2250 | return false; |
| 2251 | } |
| 2252 | |
| 2253 | const Caps &caps = context->getCaps(); |
| 2254 | switch (pname) |
| 2255 | { |
| 2256 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 2257 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 2258 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 2259 | if (index >= caps.maxTransformFeedbackSeparateAttributes) |
| 2260 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2261 | context->handleError(InvalidValue()); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2262 | return false; |
| 2263 | } |
| 2264 | break; |
| 2265 | |
| 2266 | case GL_UNIFORM_BUFFER_START: |
| 2267 | case GL_UNIFORM_BUFFER_SIZE: |
| 2268 | case GL_UNIFORM_BUFFER_BINDING: |
| 2269 | if (index >= caps.maxUniformBufferBindings) |
| 2270 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2271 | context->handleError(InvalidValue()); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2272 | return false; |
| 2273 | } |
| 2274 | break; |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2275 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2276 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 2277 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 2278 | if (index >= 3u) |
| 2279 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2280 | context->handleError(InvalidValue()); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2281 | return false; |
| 2282 | } |
| 2283 | break; |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2284 | |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 2285 | case GL_ATOMIC_COUNTER_BUFFER_START: |
| 2286 | case GL_ATOMIC_COUNTER_BUFFER_SIZE: |
| 2287 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 2288 | if (context->getClientVersion() < ES_3_1) |
| 2289 | { |
| 2290 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2291 | InvalidEnum() |
| 2292 | << "Atomic Counter buffers are not supported in this version of GL"); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 2293 | return false; |
| 2294 | } |
| 2295 | if (index >= caps.maxAtomicCounterBufferBindings) |
| 2296 | { |
| 2297 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2298 | InvalidValue() |
| 2299 | << "index is outside the valid range for GL_ATOMIC_COUNTER_BUFFER_BINDING"); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 2300 | return false; |
| 2301 | } |
| 2302 | break; |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2303 | |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 2304 | case GL_SHADER_STORAGE_BUFFER_START: |
| 2305 | case GL_SHADER_STORAGE_BUFFER_SIZE: |
| 2306 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 2307 | if (context->getClientVersion() < ES_3_1) |
| 2308 | { |
| 2309 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2310 | InvalidEnum() |
| 2311 | << "Shader storage buffers are not supported in this version of GL"); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 2312 | return false; |
| 2313 | } |
| 2314 | if (index >= caps.maxShaderStorageBufferBindings) |
| 2315 | { |
| 2316 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2317 | InvalidValue() |
| 2318 | << "index is outside the valid range for GL_SHADER_STORAGE_BUFFER_BINDING"); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 2319 | return false; |
| 2320 | } |
| 2321 | break; |
| 2322 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2323 | case GL_VERTEX_BINDING_BUFFER: |
| 2324 | case GL_VERTEX_BINDING_DIVISOR: |
| 2325 | case GL_VERTEX_BINDING_OFFSET: |
| 2326 | case GL_VERTEX_BINDING_STRIDE: |
| 2327 | if (context->getClientVersion() < ES_3_1) |
| 2328 | { |
| 2329 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2330 | InvalidEnum() |
| 2331 | << "Vertex Attrib Bindings are not supported in this version of GL"); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2332 | return false; |
| 2333 | } |
| 2334 | if (index >= caps.maxVertexAttribBindings) |
| 2335 | { |
| 2336 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2337 | InvalidValue() |
| 2338 | << "bindingindex must be smaller than MAX_VERTEX_ATTRIB_BINDINGS."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2339 | return false; |
| 2340 | } |
| 2341 | break; |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 2342 | case GL_SAMPLE_MASK_VALUE: |
| 2343 | if (context->getClientVersion() < ES_3_1) |
| 2344 | { |
| 2345 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), EnumRequiresGLES31); |
| 2346 | return false; |
| 2347 | } |
| 2348 | if (index >= caps.maxSampleMaskWords) |
| 2349 | { |
| 2350 | ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidSampleMaskNumber); |
| 2351 | return false; |
| 2352 | } |
| 2353 | break; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2354 | default: |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2355 | context->handleError(InvalidEnum()); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2356 | return false; |
| 2357 | } |
| 2358 | |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 2359 | if (length) |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2360 | { |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 2361 | *length = 1; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2362 | } |
| 2363 | |
| 2364 | return true; |
| 2365 | } |
| 2366 | |
| 2367 | bool ValidateGetIntegeri_v(ValidationContext *context, GLenum target, GLuint index, GLint *data) |
| 2368 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 2369 | if (context->getClientVersion() < ES_3_0) |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2370 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2371 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2372 | return false; |
| 2373 | } |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 2374 | return ValidateIndexedStateQuery(context, target, index, nullptr); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2375 | } |
| 2376 | |
Geoff Lang | cf255ea | 2016-10-20 11:39:09 -0700 | [diff] [blame] | 2377 | bool ValidateGetIntegeri_vRobustANGLE(ValidationContext *context, |
| 2378 | GLenum target, |
| 2379 | GLuint index, |
| 2380 | GLsizei bufSize, |
| 2381 | GLsizei *length, |
| 2382 | GLint *data) |
| 2383 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 2384 | if (context->getClientVersion() < ES_3_0) |
Geoff Lang | cf255ea | 2016-10-20 11:39:09 -0700 | [diff] [blame] | 2385 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2386 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | cf255ea | 2016-10-20 11:39:09 -0700 | [diff] [blame] | 2387 | return false; |
| 2388 | } |
| 2389 | |
| 2390 | if (!ValidateRobustEntryPoint(context, bufSize)) |
| 2391 | { |
| 2392 | return false; |
| 2393 | } |
| 2394 | |
| 2395 | if (!ValidateIndexedStateQuery(context, target, index, length)) |
| 2396 | { |
| 2397 | return false; |
| 2398 | } |
| 2399 | |
| 2400 | if (!ValidateRobustBufferSize(context, bufSize, *length)) |
| 2401 | { |
| 2402 | return false; |
| 2403 | } |
| 2404 | |
| 2405 | return true; |
| 2406 | } |
| 2407 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2408 | bool ValidateGetInteger64i_v(ValidationContext *context, GLenum target, GLuint index, GLint64 *data) |
| 2409 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 2410 | if (context->getClientVersion() < ES_3_0) |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2411 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2412 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2413 | return false; |
| 2414 | } |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 2415 | return ValidateIndexedStateQuery(context, target, index, nullptr); |
| 2416 | } |
| 2417 | |
| 2418 | bool ValidateGetInteger64i_vRobustANGLE(ValidationContext *context, |
| 2419 | GLenum target, |
| 2420 | GLuint index, |
| 2421 | GLsizei bufSize, |
| 2422 | GLsizei *length, |
| 2423 | GLint64 *data) |
| 2424 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 2425 | if (context->getClientVersion() < ES_3_0) |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 2426 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2427 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | 2e43dbb | 2016-10-14 12:27:35 -0400 | [diff] [blame] | 2428 | return false; |
| 2429 | } |
| 2430 | |
| 2431 | if (!ValidateRobustEntryPoint(context, bufSize)) |
| 2432 | { |
| 2433 | return false; |
| 2434 | } |
| 2435 | |
| 2436 | if (!ValidateIndexedStateQuery(context, target, index, length)) |
| 2437 | { |
| 2438 | return false; |
| 2439 | } |
| 2440 | |
| 2441 | if (!ValidateRobustBufferSize(context, bufSize, *length)) |
| 2442 | { |
| 2443 | return false; |
| 2444 | } |
| 2445 | |
| 2446 | return true; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2447 | } |
| 2448 | |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 2449 | bool ValidateCopyBufferSubData(ValidationContext *context, |
| 2450 | GLenum readTarget, |
| 2451 | GLenum writeTarget, |
| 2452 | GLintptr readOffset, |
| 2453 | GLintptr writeOffset, |
| 2454 | GLsizeiptr size) |
| 2455 | { |
| 2456 | if (context->getClientMajorVersion() < 3) |
| 2457 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2458 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 2459 | return false; |
| 2460 | } |
| 2461 | |
| 2462 | if (!ValidBufferTarget(context, readTarget) || !ValidBufferTarget(context, writeTarget)) |
| 2463 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2464 | context->handleError(InvalidEnum() << "Invalid buffer target"); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 2465 | return false; |
| 2466 | } |
| 2467 | |
| 2468 | Buffer *readBuffer = context->getGLState().getTargetBuffer(readTarget); |
| 2469 | Buffer *writeBuffer = context->getGLState().getTargetBuffer(writeTarget); |
| 2470 | |
| 2471 | if (!readBuffer || !writeBuffer) |
| 2472 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2473 | context->handleError(InvalidOperation() << "No buffer bound to target"); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 2474 | return false; |
| 2475 | } |
| 2476 | |
| 2477 | // Verify that readBuffer and writeBuffer are not currently mapped |
| 2478 | if (readBuffer->isMapped() || writeBuffer->isMapped()) |
| 2479 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2480 | context->handleError(InvalidOperation() |
| 2481 | << "Cannot call CopyBufferSubData on a mapped buffer"); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 2482 | return false; |
| 2483 | } |
| 2484 | |
Jamie Madill | d2f0c74 | 2016-11-02 10:34:41 -0400 | [diff] [blame] | 2485 | CheckedNumeric<GLintptr> checkedReadOffset(readOffset); |
| 2486 | CheckedNumeric<GLintptr> checkedWriteOffset(writeOffset); |
| 2487 | CheckedNumeric<GLintptr> checkedSize(size); |
| 2488 | |
| 2489 | auto checkedReadSum = checkedReadOffset + checkedSize; |
| 2490 | auto checkedWriteSum = checkedWriteOffset + checkedSize; |
| 2491 | |
| 2492 | if (!checkedReadSum.IsValid() || !checkedWriteSum.IsValid() || |
| 2493 | !IsValueInRangeForNumericType<GLintptr>(readBuffer->getSize()) || |
| 2494 | !IsValueInRangeForNumericType<GLintptr>(writeBuffer->getSize())) |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 2495 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2496 | context->handleError(InvalidValue() << "Integer overflow when validating copy offsets."); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 2497 | return false; |
| 2498 | } |
| 2499 | |
Jamie Madill | d2f0c74 | 2016-11-02 10:34:41 -0400 | [diff] [blame] | 2500 | if (readOffset < 0 || writeOffset < 0 || size < 0) |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 2501 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2502 | context->handleError(InvalidValue() |
| 2503 | << "readOffset, writeOffset and size must all be non-negative"); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 2504 | return false; |
| 2505 | } |
| 2506 | |
Jamie Madill | d2f0c74 | 2016-11-02 10:34:41 -0400 | [diff] [blame] | 2507 | if (checkedReadSum.ValueOrDie() > readBuffer->getSize() || |
| 2508 | checkedWriteSum.ValueOrDie() > writeBuffer->getSize()) |
| 2509 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2510 | context->handleError(InvalidValue() << "Buffer offset overflow in CopyBufferSubData"); |
Jamie Madill | d2f0c74 | 2016-11-02 10:34:41 -0400 | [diff] [blame] | 2511 | return false; |
| 2512 | } |
| 2513 | |
| 2514 | if (readBuffer == writeBuffer) |
| 2515 | { |
| 2516 | auto checkedOffsetDiff = (checkedReadOffset - checkedWriteOffset).Abs(); |
| 2517 | if (!checkedOffsetDiff.IsValid()) |
| 2518 | { |
| 2519 | // This shold not be possible. |
| 2520 | UNREACHABLE(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2521 | context->handleError(InvalidValue() |
| 2522 | << "Integer overflow when validating same buffer copy."); |
Jamie Madill | d2f0c74 | 2016-11-02 10:34:41 -0400 | [diff] [blame] | 2523 | return false; |
| 2524 | } |
| 2525 | |
| 2526 | if (checkedOffsetDiff.ValueOrDie() < size) |
| 2527 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2528 | context->handleError(InvalidValue()); |
Jamie Madill | d2f0c74 | 2016-11-02 10:34:41 -0400 | [diff] [blame] | 2529 | return false; |
| 2530 | } |
| 2531 | } |
| 2532 | |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 2533 | return true; |
| 2534 | } |
| 2535 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2536 | bool ValidateGetStringi(Context *context, GLenum name, GLuint index) |
| 2537 | { |
| 2538 | if (context->getClientMajorVersion() < 3) |
| 2539 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2540 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2541 | return false; |
| 2542 | } |
| 2543 | |
| 2544 | switch (name) |
| 2545 | { |
| 2546 | case GL_EXTENSIONS: |
| 2547 | if (index >= context->getExtensionStringCount()) |
| 2548 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2549 | context->handleError(InvalidValue() |
| 2550 | << "index must be less than the number of extension strings."); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2551 | return false; |
| 2552 | } |
| 2553 | break; |
| 2554 | |
| 2555 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 2556 | if (!context->getExtensions().requestExtension) |
| 2557 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2558 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidName); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2559 | return false; |
| 2560 | } |
| 2561 | if (index >= context->getRequestableExtensionStringCount()) |
| 2562 | { |
| 2563 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2564 | InvalidValue() |
| 2565 | << "index must be less than the number of requestable extension strings."); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2566 | return false; |
| 2567 | } |
| 2568 | break; |
| 2569 | |
| 2570 | default: |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2571 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidName); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2572 | return false; |
| 2573 | } |
| 2574 | |
| 2575 | return true; |
| 2576 | } |
| 2577 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 2578 | bool ValidateRenderbufferStorageMultisample(ValidationContext *context, |
| 2579 | GLenum target, |
| 2580 | GLsizei samples, |
| 2581 | GLenum internalformat, |
| 2582 | GLsizei width, |
| 2583 | GLsizei height) |
| 2584 | { |
| 2585 | if (context->getClientMajorVersion() < 3) |
| 2586 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 2587 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 2588 | return false; |
| 2589 | } |
| 2590 | |
| 2591 | if (!ValidateRenderbufferStorageParametersBase(context, target, samples, internalformat, width, |
| 2592 | height)) |
| 2593 | { |
| 2594 | return false; |
| 2595 | } |
| 2596 | |
| 2597 | // The ES3 spec(section 4.4.2) states that the internal format must be sized and not an integer |
| 2598 | // format if samples is greater than zero. |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 2599 | const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalformat); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 2600 | if ((formatInfo.componentType == GL_UNSIGNED_INT || formatInfo.componentType == GL_INT) && |
| 2601 | samples > 0) |
| 2602 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2603 | context->handleError(InvalidOperation()); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 2604 | return false; |
| 2605 | } |
| 2606 | |
| 2607 | // The behavior is different than the ANGLE version, which would generate a GL_OUT_OF_MEMORY. |
| 2608 | const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); |
| 2609 | if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples()) |
| 2610 | { |
| 2611 | context->handleError( |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2612 | InvalidOperation() |
| 2613 | << "Samples must not be greater than maximum supported value for the format."); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 2614 | return false; |
| 2615 | } |
| 2616 | |
| 2617 | return true; |
| 2618 | } |
| 2619 | |
Geoff Lang | aa086d6 | 2017-03-23 16:47:21 -0400 | [diff] [blame] | 2620 | bool ValidateVertexAttribIPointer(ValidationContext *context, |
| 2621 | GLuint index, |
| 2622 | GLint size, |
| 2623 | GLenum type, |
| 2624 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2625 | const void *pointer) |
Geoff Lang | aa086d6 | 2017-03-23 16:47:21 -0400 | [diff] [blame] | 2626 | { |
| 2627 | if (context->getClientMajorVersion() < 3) |
| 2628 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2629 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | aa086d6 | 2017-03-23 16:47:21 -0400 | [diff] [blame] | 2630 | return false; |
| 2631 | } |
| 2632 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2633 | if (!ValidateVertexFormatBase(context, index, size, type, true)) |
Geoff Lang | aa086d6 | 2017-03-23 16:47:21 -0400 | [diff] [blame] | 2634 | { |
Geoff Lang | aa086d6 | 2017-03-23 16:47:21 -0400 | [diff] [blame] | 2635 | return false; |
| 2636 | } |
| 2637 | |
Geoff Lang | aa086d6 | 2017-03-23 16:47:21 -0400 | [diff] [blame] | 2638 | if (stride < 0) |
| 2639 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2640 | ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeStride); |
Geoff Lang | aa086d6 | 2017-03-23 16:47:21 -0400 | [diff] [blame] | 2641 | return false; |
| 2642 | } |
| 2643 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2644 | const Caps &caps = context->getCaps(); |
| 2645 | if (context->getClientVersion() >= ES_3_1) |
| 2646 | { |
| 2647 | if (stride > caps.maxVertexAttribStride) |
| 2648 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2649 | context->handleError(InvalidValue() |
| 2650 | << "stride cannot be greater than MAX_VERTEX_ATTRIB_STRIDE."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2651 | return false; |
| 2652 | } |
| 2653 | |
| 2654 | // [OpenGL ES 3.1] Section 10.3.1 page 245: |
| 2655 | // glVertexAttribBinding is part of the equivalent code of VertexAttribIPointer, so its |
| 2656 | // validation should be inherited. |
| 2657 | if (index >= caps.maxVertexAttribBindings) |
| 2658 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2659 | context->handleError(InvalidValue() |
| 2660 | << "index must be smaller than MAX_VERTEX_ATTRIB_BINDINGS."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2661 | return false; |
| 2662 | } |
| 2663 | } |
| 2664 | |
Geoff Lang | aa086d6 | 2017-03-23 16:47:21 -0400 | [diff] [blame] | 2665 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 2666 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 2667 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 2668 | // and the pointer argument is not NULL. |
| 2669 | if (context->getGLState().getVertexArrayId() != 0 && |
| 2670 | context->getGLState().getArrayBufferId() == 0 && pointer != nullptr) |
| 2671 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2672 | context |
| 2673 | ->handleError(InvalidOperation() |
| 2674 | << "Client data cannot be used with a non-default vertex array object."); |
Geoff Lang | aa086d6 | 2017-03-23 16:47:21 -0400 | [diff] [blame] | 2675 | return false; |
| 2676 | } |
| 2677 | |
Geoff Lang | 2d62ab7 | 2017-03-23 16:54:40 -0400 | [diff] [blame] | 2678 | if (context->getExtensions().webglCompatibility) |
| 2679 | { |
| 2680 | if (!ValidateWebGLVertexAttribPointer(context, type, false, stride, pointer, true)) |
| 2681 | { |
| 2682 | return false; |
| 2683 | } |
| 2684 | } |
| 2685 | |
Geoff Lang | aa086d6 | 2017-03-23 16:47:21 -0400 | [diff] [blame] | 2686 | return true; |
| 2687 | } |
| 2688 | |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 2689 | bool ValidateGetSynciv(Context *context, |
| 2690 | GLsync sync, |
| 2691 | GLenum pname, |
| 2692 | GLsizei bufSize, |
| 2693 | GLsizei *length, |
| 2694 | GLint *values) |
| 2695 | { |
| 2696 | if (context->getClientMajorVersion() < 3) |
| 2697 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2698 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 2699 | return false; |
| 2700 | } |
| 2701 | |
| 2702 | if (bufSize < 0) |
| 2703 | { |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2704 | ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 2705 | return false; |
| 2706 | } |
| 2707 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 2708 | Sync *syncObject = context->getSync(sync); |
| 2709 | if (!syncObject) |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 2710 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 2711 | context->handleError(InvalidValue() << "Invalid sync object."); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 2712 | return false; |
| 2713 | } |
| 2714 | |
| 2715 | switch (pname) |
| 2716 | { |
| 2717 | case GL_OBJECT_TYPE: |
| 2718 | case GL_SYNC_CONDITION: |
| 2719 | case GL_SYNC_FLAGS: |
| 2720 | case GL_SYNC_STATUS: |
| 2721 | break; |
| 2722 | |
| 2723 | default: |
Brandon Jones | afa7515 | 2017-07-21 13:11:29 -0700 | [diff] [blame] | 2724 | ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPname); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 2725 | return false; |
| 2726 | } |
| 2727 | |
| 2728 | return true; |
| 2729 | } |
| 2730 | |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 2731 | bool ValidateDrawElementsInstanced(ValidationContext *context, |
| 2732 | GLenum mode, |
| 2733 | GLsizei count, |
| 2734 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2735 | const void *indices, |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 2736 | GLsizei instanceCount) |
| 2737 | { |
| 2738 | if (context->getClientMajorVersion() < 3) |
| 2739 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 2740 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 2741 | return false; |
| 2742 | } |
| 2743 | |
| 2744 | return ValidateDrawElementsInstancedCommon(context, mode, count, type, indices, instanceCount); |
| 2745 | } |
| 2746 | |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 2747 | bool ValidateFramebufferTextureMultiviewLayeredANGLE(Context *context, |
| 2748 | GLenum target, |
| 2749 | GLenum attachment, |
| 2750 | GLuint texture, |
| 2751 | GLint level, |
| 2752 | GLint baseViewIndex, |
| 2753 | GLsizei numViews) |
| 2754 | { |
| 2755 | |
| 2756 | if (!ValidateFramebufferTextureMultiviewBaseANGLE(context, target, attachment, texture, level, |
| 2757 | numViews)) |
| 2758 | { |
| 2759 | return false; |
| 2760 | } |
| 2761 | |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 2762 | if (texture != 0) |
| 2763 | { |
Martin Radev | 14b2126 | 2017-08-25 13:54:37 +0300 | [diff] [blame] | 2764 | if (baseViewIndex < 0) |
| 2765 | { |
| 2766 | context->handleError(InvalidValue() << "baseViewIndex cannot be less than 0."); |
| 2767 | return false; |
| 2768 | } |
| 2769 | |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 2770 | Texture *tex = context->getTexture(texture); |
| 2771 | ASSERT(tex); |
| 2772 | |
| 2773 | switch (tex->getTarget()) |
| 2774 | { |
| 2775 | case GL_TEXTURE_2D_ARRAY: |
| 2776 | { |
| 2777 | const Caps &caps = context->getCaps(); |
| 2778 | if (static_cast<GLuint>(baseViewIndex + numViews) > caps.maxArrayTextureLayers) |
| 2779 | { |
| 2780 | context->handleError(InvalidValue() << "baseViewIndex+numViews cannot be " |
| 2781 | "greater than " |
| 2782 | "GL_MAX_ARRAY_TEXTURE_LAYERS."); |
| 2783 | return false; |
| 2784 | } |
| 2785 | } |
| 2786 | break; |
| 2787 | default: |
| 2788 | context->handleError(InvalidOperation() |
| 2789 | << "Texture's target must be GL_TEXTURE_2D_ARRAY."); |
| 2790 | return false; |
| 2791 | } |
| 2792 | |
| 2793 | if (!ValidateFramebufferTextureMultiviewLevelAndFormat(context, tex, level)) |
| 2794 | { |
| 2795 | return false; |
| 2796 | } |
| 2797 | } |
| 2798 | |
| 2799 | return true; |
| 2800 | } |
| 2801 | |
| 2802 | bool ValidateFramebufferTextureMultiviewSideBySideANGLE(Context *context, |
| 2803 | GLenum target, |
| 2804 | GLenum attachment, |
| 2805 | GLuint texture, |
| 2806 | GLint level, |
| 2807 | GLsizei numViews, |
| 2808 | const GLint *viewportOffsets) |
| 2809 | { |
| 2810 | if (!ValidateFramebufferTextureMultiviewBaseANGLE(context, target, attachment, texture, level, |
| 2811 | numViews)) |
| 2812 | { |
| 2813 | return false; |
| 2814 | } |
| 2815 | |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 2816 | if (texture != 0) |
| 2817 | { |
Martin Radev | 14b2126 | 2017-08-25 13:54:37 +0300 | [diff] [blame] | 2818 | const GLsizei numViewportOffsetValues = numViews * 2; |
| 2819 | for (GLsizei i = 0; i < numViewportOffsetValues; ++i) |
| 2820 | { |
| 2821 | if (viewportOffsets[i] < 0) |
| 2822 | { |
| 2823 | context->handleError(InvalidValue() |
| 2824 | << "viewportOffsets cannot contain negative values."); |
| 2825 | return false; |
| 2826 | } |
| 2827 | } |
| 2828 | |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 2829 | Texture *tex = context->getTexture(texture); |
| 2830 | ASSERT(tex); |
| 2831 | |
| 2832 | switch (tex->getTarget()) |
| 2833 | { |
| 2834 | case GL_TEXTURE_2D: |
| 2835 | break; |
| 2836 | default: |
| 2837 | context->handleError(InvalidOperation() |
| 2838 | << "Texture's target must be GL_TEXTURE_2D."); |
| 2839 | return false; |
| 2840 | } |
| 2841 | |
| 2842 | if (!ValidateFramebufferTextureMultiviewLevelAndFormat(context, tex, level)) |
| 2843 | { |
| 2844 | return false; |
| 2845 | } |
| 2846 | } |
| 2847 | |
| 2848 | return true; |
| 2849 | } |
| 2850 | |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 2851 | bool ValidateUniform1ui(Context *context, GLint location, GLuint v0) |
| 2852 | { |
| 2853 | return ValidateUniformES3(context, GL_UNSIGNED_INT, location, 1); |
| 2854 | } |
| 2855 | |
| 2856 | bool ValidateUniform2ui(Context *context, GLint location, GLuint v0, GLuint v1) |
| 2857 | { |
| 2858 | return ValidateUniformES3(context, GL_UNSIGNED_INT_VEC2, location, 1); |
| 2859 | } |
| 2860 | |
| 2861 | bool ValidateUniform3ui(Context *context, GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 2862 | { |
| 2863 | return ValidateUniformES3(context, GL_UNSIGNED_INT_VEC3, location, 1); |
| 2864 | } |
| 2865 | |
| 2866 | bool ValidateUniform4ui(Context *context, |
| 2867 | GLint location, |
| 2868 | GLuint v0, |
| 2869 | GLuint v1, |
| 2870 | GLuint v2, |
| 2871 | GLuint v3) |
| 2872 | { |
| 2873 | return ValidateUniformES3(context, GL_UNSIGNED_INT_VEC4, location, 1); |
| 2874 | } |
| 2875 | |
| 2876 | bool ValidateUniform1uiv(Context *context, GLint location, GLsizei count, const GLuint *value) |
| 2877 | { |
| 2878 | return ValidateUniformES3(context, GL_UNSIGNED_INT, location, count); |
| 2879 | } |
| 2880 | |
| 2881 | bool ValidateUniform2uiv(Context *context, GLint location, GLsizei count, const GLuint *value) |
| 2882 | { |
| 2883 | return ValidateUniformES3(context, GL_UNSIGNED_INT_VEC2, location, count); |
| 2884 | } |
| 2885 | |
| 2886 | bool ValidateUniform3uiv(Context *context, GLint location, GLsizei count, const GLuint *value) |
| 2887 | { |
| 2888 | return ValidateUniformES3(context, GL_UNSIGNED_INT_VEC3, location, count); |
| 2889 | } |
| 2890 | |
| 2891 | bool ValidateUniform4uiv(Context *context, GLint location, GLsizei count, const GLuint *value) |
| 2892 | { |
| 2893 | return ValidateUniformES3(context, GL_UNSIGNED_INT_VEC4, location, count); |
| 2894 | } |
| 2895 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 2896 | bool ValidateIsQuery(Context *context, GLuint id) |
| 2897 | { |
| 2898 | if (context->getClientMajorVersion() < 3) |
| 2899 | { |
| 2900 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 2901 | return false; |
| 2902 | } |
| 2903 | |
| 2904 | return true; |
| 2905 | } |
| 2906 | |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 2907 | bool ValidateUniformMatrix2x3fv(Context *context, |
| 2908 | GLint location, |
| 2909 | GLsizei count, |
| 2910 | GLboolean transpose, |
| 2911 | const GLfloat *value) |
| 2912 | { |
| 2913 | return ValidateUniformMatrixES3(context, GL_FLOAT_MAT2x3, location, count, transpose); |
| 2914 | } |
| 2915 | |
| 2916 | bool ValidateUniformMatrix3x2fv(Context *context, |
| 2917 | GLint location, |
| 2918 | GLsizei count, |
| 2919 | GLboolean transpose, |
| 2920 | const GLfloat *value) |
| 2921 | { |
| 2922 | return ValidateUniformMatrixES3(context, GL_FLOAT_MAT3x2, location, count, transpose); |
| 2923 | } |
| 2924 | |
| 2925 | bool ValidateUniformMatrix2x4fv(Context *context, |
| 2926 | GLint location, |
| 2927 | GLsizei count, |
| 2928 | GLboolean transpose, |
| 2929 | const GLfloat *value) |
| 2930 | { |
| 2931 | return ValidateUniformMatrixES3(context, GL_FLOAT_MAT2x4, location, count, transpose); |
| 2932 | } |
| 2933 | |
| 2934 | bool ValidateUniformMatrix4x2fv(Context *context, |
| 2935 | GLint location, |
| 2936 | GLsizei count, |
| 2937 | GLboolean transpose, |
| 2938 | const GLfloat *value) |
| 2939 | { |
| 2940 | return ValidateUniformMatrixES3(context, GL_FLOAT_MAT4x2, location, count, transpose); |
| 2941 | } |
| 2942 | |
| 2943 | bool ValidateUniformMatrix3x4fv(Context *context, |
| 2944 | GLint location, |
| 2945 | GLsizei count, |
| 2946 | GLboolean transpose, |
| 2947 | const GLfloat *value) |
| 2948 | { |
| 2949 | return ValidateUniformMatrixES3(context, GL_FLOAT_MAT3x4, location, count, transpose); |
| 2950 | } |
| 2951 | |
| 2952 | bool ValidateUniformMatrix4x3fv(Context *context, |
| 2953 | GLint location, |
| 2954 | GLsizei count, |
| 2955 | GLboolean transpose, |
| 2956 | const GLfloat *value) |
| 2957 | { |
| 2958 | return ValidateUniformMatrixES3(context, GL_FLOAT_MAT4x3, location, count, transpose); |
| 2959 | } |
| 2960 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 2961 | bool ValidateEndTransformFeedback(Context *context) |
| 2962 | { |
| 2963 | if (context->getClientMajorVersion() < 3) |
| 2964 | { |
| 2965 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 2966 | return false; |
| 2967 | } |
| 2968 | |
| 2969 | TransformFeedback *transformFeedback = context->getGLState().getCurrentTransformFeedback(); |
| 2970 | ASSERT(transformFeedback != nullptr); |
| 2971 | |
| 2972 | if (!transformFeedback->isActive()) |
| 2973 | { |
| 2974 | context->handleError(InvalidOperation()); |
| 2975 | return false; |
| 2976 | } |
| 2977 | |
| 2978 | return true; |
| 2979 | } |
| 2980 | |
| 2981 | bool ValidateTransformFeedbackVaryings(Context *context, |
| 2982 | GLuint program, |
| 2983 | GLsizei count, |
| 2984 | const GLchar *const *varyings, |
| 2985 | GLenum bufferMode) |
| 2986 | { |
| 2987 | if (context->getClientMajorVersion() < 3) |
| 2988 | { |
| 2989 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 2990 | return false; |
| 2991 | } |
| 2992 | |
| 2993 | if (count < 0) |
| 2994 | { |
| 2995 | ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeCount); |
| 2996 | return false; |
| 2997 | } |
| 2998 | |
| 2999 | switch (bufferMode) |
| 3000 | { |
| 3001 | case GL_INTERLEAVED_ATTRIBS: |
| 3002 | break; |
| 3003 | case GL_SEPARATE_ATTRIBS: |
| 3004 | { |
| 3005 | const Caps &caps = context->getCaps(); |
| 3006 | if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes) |
| 3007 | { |
| 3008 | context->handleError(InvalidValue()); |
| 3009 | return false; |
| 3010 | } |
| 3011 | break; |
| 3012 | } |
| 3013 | default: |
| 3014 | context->handleError(InvalidEnum()); |
| 3015 | return false; |
| 3016 | } |
| 3017 | |
| 3018 | Program *programObject = GetValidProgram(context, program); |
| 3019 | if (!programObject) |
| 3020 | { |
| 3021 | return false; |
| 3022 | } |
| 3023 | |
| 3024 | return true; |
| 3025 | } |
| 3026 | |
| 3027 | bool ValidateGetTransformFeedbackVarying(Context *context, |
| 3028 | GLuint program, |
| 3029 | GLuint index, |
| 3030 | GLsizei bufSize, |
| 3031 | GLsizei *length, |
| 3032 | GLsizei *size, |
| 3033 | GLenum *type, |
| 3034 | GLchar *name) |
| 3035 | { |
| 3036 | if (context->getClientMajorVersion() < 3) |
| 3037 | { |
| 3038 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3039 | return false; |
| 3040 | } |
| 3041 | |
| 3042 | if (bufSize < 0) |
| 3043 | { |
| 3044 | ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize); |
| 3045 | return false; |
| 3046 | } |
| 3047 | |
| 3048 | Program *programObject = GetValidProgram(context, program); |
| 3049 | if (!programObject) |
| 3050 | { |
| 3051 | return false; |
| 3052 | } |
| 3053 | |
| 3054 | if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount())) |
| 3055 | { |
| 3056 | context->handleError(InvalidValue()); |
| 3057 | return false; |
| 3058 | } |
| 3059 | |
| 3060 | return true; |
| 3061 | } |
| 3062 | |
| 3063 | bool ValidateBindTransformFeedback(Context *context, GLenum target, GLuint id) |
| 3064 | { |
| 3065 | if (context->getClientMajorVersion() < 3) |
| 3066 | { |
| 3067 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3068 | return false; |
| 3069 | } |
| 3070 | |
| 3071 | switch (target) |
| 3072 | { |
| 3073 | case GL_TRANSFORM_FEEDBACK: |
| 3074 | { |
| 3075 | // Cannot bind a transform feedback object if the current one is started and not |
| 3076 | // paused (3.0.2 pg 85 section 2.14.1) |
| 3077 | TransformFeedback *curTransformFeedback = |
| 3078 | context->getGLState().getCurrentTransformFeedback(); |
| 3079 | if (curTransformFeedback && curTransformFeedback->isActive() && |
| 3080 | !curTransformFeedback->isPaused()) |
| 3081 | { |
| 3082 | context->handleError(InvalidOperation()); |
| 3083 | return false; |
| 3084 | } |
| 3085 | |
| 3086 | // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section |
| 3087 | // 2.14.1) |
| 3088 | if (!context->isTransformFeedbackGenerated(id)) |
| 3089 | { |
| 3090 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), TransformFeedbackDoesNotExist); |
| 3091 | return false; |
| 3092 | } |
| 3093 | } |
| 3094 | break; |
| 3095 | |
| 3096 | default: |
| 3097 | context->handleError(InvalidEnum()); |
| 3098 | return false; |
| 3099 | } |
| 3100 | |
| 3101 | return true; |
| 3102 | } |
| 3103 | |
| 3104 | bool ValidateIsTransformFeedback(Context *context, GLuint id) |
| 3105 | { |
| 3106 | if (context->getClientMajorVersion() < 3) |
| 3107 | { |
| 3108 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3109 | return false; |
| 3110 | } |
| 3111 | |
| 3112 | return true; |
| 3113 | } |
| 3114 | |
| 3115 | bool ValidatePauseTransformFeedback(Context *context) |
| 3116 | { |
| 3117 | if (context->getClientMajorVersion() < 3) |
| 3118 | { |
| 3119 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3120 | return false; |
| 3121 | } |
| 3122 | |
| 3123 | TransformFeedback *transformFeedback = context->getGLState().getCurrentTransformFeedback(); |
| 3124 | ASSERT(transformFeedback != nullptr); |
| 3125 | |
| 3126 | // Current transform feedback must be active and not paused in order to pause (3.0.2 pg 86) |
| 3127 | if (!transformFeedback->isActive() || transformFeedback->isPaused()) |
| 3128 | { |
| 3129 | context->handleError(InvalidOperation()); |
| 3130 | return false; |
| 3131 | } |
| 3132 | |
| 3133 | return true; |
| 3134 | } |
| 3135 | |
| 3136 | bool ValidateResumeTransformFeedback(Context *context) |
| 3137 | { |
| 3138 | if (context->getClientMajorVersion() < 3) |
| 3139 | { |
| 3140 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3141 | return false; |
| 3142 | } |
| 3143 | |
| 3144 | TransformFeedback *transformFeedback = context->getGLState().getCurrentTransformFeedback(); |
| 3145 | ASSERT(transformFeedback != nullptr); |
| 3146 | |
| 3147 | // Current transform feedback must be active and paused in order to resume (3.0.2 pg 86) |
| 3148 | if (!transformFeedback->isActive() || !transformFeedback->isPaused()) |
| 3149 | { |
| 3150 | context->handleError(InvalidOperation()); |
| 3151 | return false; |
| 3152 | } |
| 3153 | |
| 3154 | return true; |
| 3155 | } |
| 3156 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 3157 | bool ValidateVertexAttribI4i(Context *context, GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 3158 | { |
| 3159 | if (context->getClientMajorVersion() < 3) |
| 3160 | { |
| 3161 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3162 | return false; |
| 3163 | } |
| 3164 | |
| 3165 | return ValidateVertexAttribIndex(context, index); |
| 3166 | } |
| 3167 | |
| 3168 | bool ValidateVertexAttribI4ui(Context *context, |
| 3169 | GLuint index, |
| 3170 | GLuint x, |
| 3171 | GLuint y, |
| 3172 | GLuint z, |
| 3173 | GLuint w) |
| 3174 | { |
| 3175 | if (context->getClientMajorVersion() < 3) |
| 3176 | { |
| 3177 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3178 | return false; |
| 3179 | } |
| 3180 | |
| 3181 | return ValidateVertexAttribIndex(context, index); |
| 3182 | } |
| 3183 | |
| 3184 | bool ValidateVertexAttribI4iv(Context *context, GLuint index, const GLint *v) |
| 3185 | { |
| 3186 | if (context->getClientMajorVersion() < 3) |
| 3187 | { |
| 3188 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3189 | return false; |
| 3190 | } |
| 3191 | |
| 3192 | return ValidateVertexAttribIndex(context, index); |
| 3193 | } |
| 3194 | |
| 3195 | bool ValidateVertexAttribI4uiv(Context *context, GLuint index, const GLuint *v) |
| 3196 | { |
| 3197 | if (context->getClientMajorVersion() < 3) |
| 3198 | { |
| 3199 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3200 | return false; |
| 3201 | } |
| 3202 | |
| 3203 | return ValidateVertexAttribIndex(context, index); |
| 3204 | } |
| 3205 | |
| 3206 | bool ValidateGetFragDataLocation(Context *context, GLuint program, const GLchar *name) |
| 3207 | { |
| 3208 | if (context->getClientMajorVersion() < 3) |
| 3209 | { |
| 3210 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3211 | return false; |
| 3212 | } |
| 3213 | |
| 3214 | Program *programObject = GetValidProgram(context, program); |
| 3215 | if (!programObject) |
| 3216 | { |
| 3217 | return false; |
| 3218 | } |
| 3219 | |
| 3220 | if (!programObject->isLinked()) |
| 3221 | { |
| 3222 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotLinked); |
| 3223 | return false; |
| 3224 | } |
| 3225 | |
| 3226 | return true; |
| 3227 | } |
| 3228 | |
| 3229 | bool ValidateGetUniformIndices(Context *context, |
| 3230 | GLuint program, |
| 3231 | GLsizei uniformCount, |
| 3232 | const GLchar *const *uniformNames, |
| 3233 | GLuint *uniformIndices) |
| 3234 | { |
| 3235 | if (context->getClientMajorVersion() < 3) |
| 3236 | { |
| 3237 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3238 | return false; |
| 3239 | } |
| 3240 | |
| 3241 | if (uniformCount < 0) |
| 3242 | { |
| 3243 | context->handleError(InvalidValue()); |
| 3244 | return false; |
| 3245 | } |
| 3246 | |
| 3247 | Program *programObject = GetValidProgram(context, program); |
| 3248 | if (!programObject) |
| 3249 | { |
| 3250 | return false; |
| 3251 | } |
| 3252 | |
| 3253 | return true; |
| 3254 | } |
| 3255 | |
| 3256 | bool ValidateGetActiveUniformsiv(Context *context, |
| 3257 | GLuint program, |
| 3258 | GLsizei uniformCount, |
| 3259 | const GLuint *uniformIndices, |
| 3260 | GLenum pname, |
| 3261 | GLint *params) |
| 3262 | { |
| 3263 | if (context->getClientMajorVersion() < 3) |
| 3264 | { |
| 3265 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3266 | return false; |
| 3267 | } |
| 3268 | |
| 3269 | if (uniformCount < 0) |
| 3270 | { |
| 3271 | context->handleError(InvalidValue()); |
| 3272 | return false; |
| 3273 | } |
| 3274 | |
| 3275 | Program *programObject = GetValidProgram(context, program); |
| 3276 | if (!programObject) |
| 3277 | { |
| 3278 | return false; |
| 3279 | } |
| 3280 | |
| 3281 | switch (pname) |
| 3282 | { |
| 3283 | case GL_UNIFORM_TYPE: |
| 3284 | case GL_UNIFORM_SIZE: |
| 3285 | case GL_UNIFORM_NAME_LENGTH: |
| 3286 | case GL_UNIFORM_BLOCK_INDEX: |
| 3287 | case GL_UNIFORM_OFFSET: |
| 3288 | case GL_UNIFORM_ARRAY_STRIDE: |
| 3289 | case GL_UNIFORM_MATRIX_STRIDE: |
| 3290 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 3291 | break; |
| 3292 | |
| 3293 | default: |
| 3294 | context->handleError(InvalidEnum()); |
| 3295 | return false; |
| 3296 | } |
| 3297 | |
| 3298 | if (uniformCount > programObject->getActiveUniformCount()) |
| 3299 | { |
| 3300 | context->handleError(InvalidValue()); |
| 3301 | return false; |
| 3302 | } |
| 3303 | |
| 3304 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 3305 | { |
| 3306 | const GLuint index = uniformIndices[uniformId]; |
| 3307 | |
| 3308 | if (index >= static_cast<GLuint>(programObject->getActiveUniformCount())) |
| 3309 | { |
| 3310 | context->handleError(InvalidValue()); |
| 3311 | return false; |
| 3312 | } |
| 3313 | } |
| 3314 | |
| 3315 | return true; |
| 3316 | } |
| 3317 | |
| 3318 | bool ValidateGetUniformBlockIndex(Context *context, GLuint program, const GLchar *uniformBlockName) |
| 3319 | { |
| 3320 | if (context->getClientMajorVersion() < 3) |
| 3321 | { |
| 3322 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3323 | return false; |
| 3324 | } |
| 3325 | |
| 3326 | Program *programObject = GetValidProgram(context, program); |
| 3327 | if (!programObject) |
| 3328 | { |
| 3329 | return false; |
| 3330 | } |
| 3331 | |
| 3332 | return true; |
| 3333 | } |
| 3334 | |
| 3335 | bool ValidateGetActiveUniformBlockiv(Context *context, |
| 3336 | GLuint program, |
| 3337 | GLuint uniformBlockIndex, |
| 3338 | GLenum pname, |
| 3339 | GLint *params) |
| 3340 | { |
| 3341 | return ValidateGetActiveUniformBlockivBase(context, program, uniformBlockIndex, pname, nullptr); |
| 3342 | } |
| 3343 | |
| 3344 | bool ValidateGetActiveUniformBlockName(Context *context, |
| 3345 | GLuint program, |
| 3346 | GLuint uniformBlockIndex, |
| 3347 | GLsizei bufSize, |
| 3348 | GLsizei *length, |
| 3349 | GLchar *uniformBlockName) |
| 3350 | { |
| 3351 | if (context->getClientMajorVersion() < 3) |
| 3352 | { |
| 3353 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3354 | return false; |
| 3355 | } |
| 3356 | |
| 3357 | Program *programObject = GetValidProgram(context, program); |
| 3358 | if (!programObject) |
| 3359 | { |
| 3360 | return false; |
| 3361 | } |
| 3362 | |
| 3363 | if (uniformBlockIndex >= programObject->getActiveUniformBlockCount()) |
| 3364 | { |
| 3365 | context->handleError(InvalidValue()); |
| 3366 | return false; |
| 3367 | } |
| 3368 | |
| 3369 | return true; |
| 3370 | } |
| 3371 | |
| 3372 | bool ValidateUniformBlockBinding(Context *context, |
| 3373 | GLuint program, |
| 3374 | GLuint uniformBlockIndex, |
| 3375 | GLuint uniformBlockBinding) |
| 3376 | { |
| 3377 | if (context->getClientMajorVersion() < 3) |
| 3378 | { |
| 3379 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3380 | return false; |
| 3381 | } |
| 3382 | |
| 3383 | if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings) |
| 3384 | { |
| 3385 | context->handleError(InvalidValue()); |
| 3386 | return false; |
| 3387 | } |
| 3388 | |
| 3389 | Program *programObject = GetValidProgram(context, program); |
| 3390 | if (!programObject) |
| 3391 | { |
| 3392 | return false; |
| 3393 | } |
| 3394 | |
| 3395 | // if never linked, there won't be any uniform blocks |
| 3396 | if (uniformBlockIndex >= programObject->getActiveUniformBlockCount()) |
| 3397 | { |
| 3398 | context->handleError(InvalidValue()); |
| 3399 | return false; |
| 3400 | } |
| 3401 | |
| 3402 | return true; |
| 3403 | } |
| 3404 | |
| 3405 | bool ValidateDrawArraysInstanced(Context *context, |
| 3406 | GLenum mode, |
| 3407 | GLint first, |
| 3408 | GLsizei count, |
| 3409 | GLsizei primcount) |
| 3410 | { |
| 3411 | if (context->getClientMajorVersion() < 3) |
| 3412 | { |
| 3413 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3414 | return false; |
| 3415 | } |
| 3416 | |
| 3417 | return ValidateDrawArraysInstancedBase(context, mode, first, count, primcount); |
| 3418 | } |
| 3419 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 3420 | bool ValidateFenceSync(Context *context, GLenum condition, GLbitfield flags) |
| 3421 | { |
| 3422 | if (context->getClientMajorVersion() < 3) |
| 3423 | { |
| 3424 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3425 | return false; |
| 3426 | } |
| 3427 | |
| 3428 | if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) |
| 3429 | { |
| 3430 | context->handleError(InvalidEnum()); |
| 3431 | return false; |
| 3432 | } |
| 3433 | |
| 3434 | if (flags != 0) |
| 3435 | { |
| 3436 | context->handleError(InvalidValue()); |
| 3437 | return false; |
| 3438 | } |
| 3439 | |
| 3440 | return true; |
| 3441 | } |
| 3442 | |
| 3443 | bool ValidateIsSync(Context *context, GLsync sync) |
| 3444 | { |
| 3445 | if (context->getClientMajorVersion() < 3) |
| 3446 | { |
| 3447 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3448 | return false; |
| 3449 | } |
| 3450 | |
| 3451 | return true; |
| 3452 | } |
| 3453 | |
| 3454 | bool ValidateDeleteSync(Context *context, GLsync sync) |
| 3455 | { |
| 3456 | if (context->getClientMajorVersion() < 3) |
| 3457 | { |
| 3458 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3459 | return false; |
| 3460 | } |
| 3461 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 3462 | if (sync != static_cast<GLsync>(0) && !context->getSync(sync)) |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 3463 | { |
| 3464 | context->handleError(InvalidValue()); |
| 3465 | return false; |
| 3466 | } |
| 3467 | |
| 3468 | return true; |
| 3469 | } |
| 3470 | |
| 3471 | bool ValidateClientWaitSync(Context *context, GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 3472 | { |
| 3473 | if (context->getClientMajorVersion() < 3) |
| 3474 | { |
| 3475 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3476 | return false; |
| 3477 | } |
| 3478 | |
| 3479 | if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0) |
| 3480 | { |
| 3481 | context->handleError(InvalidValue()); |
| 3482 | return false; |
| 3483 | } |
| 3484 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 3485 | Sync *clientWaitSync = context->getSync(sync); |
| 3486 | if (!clientWaitSync) |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 3487 | { |
| 3488 | context->handleError(InvalidValue()); |
| 3489 | return false; |
| 3490 | } |
| 3491 | |
| 3492 | return true; |
| 3493 | } |
| 3494 | |
| 3495 | bool ValidateWaitSync(Context *context, GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 3496 | { |
| 3497 | if (context->getClientMajorVersion() < 3) |
| 3498 | { |
| 3499 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3500 | return false; |
| 3501 | } |
| 3502 | |
| 3503 | if (flags != 0) |
| 3504 | { |
| 3505 | context->handleError(InvalidValue()); |
| 3506 | return false; |
| 3507 | } |
| 3508 | |
| 3509 | if (timeout != GL_TIMEOUT_IGNORED) |
| 3510 | { |
| 3511 | context->handleError(InvalidValue()); |
| 3512 | return false; |
| 3513 | } |
| 3514 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 3515 | Sync *waitSync = context->getSync(sync); |
| 3516 | if (!waitSync) |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 3517 | { |
| 3518 | context->handleError(InvalidValue()); |
| 3519 | return false; |
| 3520 | } |
| 3521 | |
| 3522 | return true; |
| 3523 | } |
| 3524 | |
| 3525 | bool ValidateGetInteger64v(Context *context, GLenum pname, GLint64 *params) |
| 3526 | { |
| 3527 | if (context->getClientMajorVersion() < 3) |
| 3528 | { |
| 3529 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3530 | return false; |
| 3531 | } |
| 3532 | |
| 3533 | GLenum nativeType = GL_NONE; |
| 3534 | unsigned int numParams = 0; |
| 3535 | if (!ValidateStateQuery(context, pname, &nativeType, &numParams)) |
| 3536 | { |
| 3537 | return false; |
| 3538 | } |
| 3539 | |
| 3540 | return true; |
| 3541 | } |
| 3542 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 3543 | bool ValidateIsSampler(Context *context, GLuint sampler) |
| 3544 | { |
| 3545 | if (context->getClientMajorVersion() < 3) |
| 3546 | { |
Yunchao He | f0fd87d | 2017-09-12 04:55:05 +0800 | [diff] [blame] | 3547 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 3548 | return false; |
| 3549 | } |
| 3550 | |
| 3551 | return true; |
| 3552 | } |
| 3553 | |
| 3554 | bool ValidateBindSampler(Context *context, GLuint unit, GLuint sampler) |
| 3555 | { |
| 3556 | if (context->getClientMajorVersion() < 3) |
| 3557 | { |
| 3558 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3559 | return false; |
| 3560 | } |
| 3561 | |
| 3562 | if (sampler != 0 && !context->isSampler(sampler)) |
| 3563 | { |
| 3564 | context->handleError(InvalidOperation()); |
| 3565 | return false; |
| 3566 | } |
| 3567 | |
| 3568 | if (unit >= context->getCaps().maxCombinedTextureImageUnits) |
| 3569 | { |
| 3570 | context->handleError(InvalidValue()); |
| 3571 | return false; |
| 3572 | } |
| 3573 | |
| 3574 | return true; |
| 3575 | } |
| 3576 | |
| 3577 | bool ValidateVertexAttribDivisor(Context *context, GLuint index, GLuint divisor) |
| 3578 | { |
| 3579 | if (context->getClientMajorVersion() < 3) |
| 3580 | { |
| 3581 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3582 | return false; |
| 3583 | } |
| 3584 | |
| 3585 | return ValidateVertexAttribIndex(context, index); |
| 3586 | } |
| 3587 | |
| 3588 | bool ValidateTexStorage2D(Context *context, |
| 3589 | GLenum target, |
| 3590 | GLsizei levels, |
| 3591 | GLenum internalformat, |
| 3592 | GLsizei width, |
| 3593 | GLsizei height) |
| 3594 | { |
| 3595 | if (context->getClientMajorVersion() < 3) |
| 3596 | { |
| 3597 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3598 | return false; |
| 3599 | } |
| 3600 | |
| 3601 | if (!ValidateES3TexStorage2DParameters(context, target, levels, internalformat, width, height, |
| 3602 | 1)) |
| 3603 | { |
| 3604 | return false; |
| 3605 | } |
| 3606 | |
| 3607 | return true; |
| 3608 | } |
| 3609 | |
| 3610 | bool ValidateTexStorage3D(Context *context, |
| 3611 | GLenum target, |
| 3612 | GLsizei levels, |
| 3613 | GLenum internalformat, |
| 3614 | GLsizei width, |
| 3615 | GLsizei height, |
| 3616 | GLsizei depth) |
| 3617 | { |
| 3618 | if (context->getClientMajorVersion() < 3) |
| 3619 | { |
| 3620 | ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required); |
| 3621 | return false; |
| 3622 | } |
| 3623 | |
| 3624 | if (!ValidateES3TexStorage3DParameters(context, target, levels, internalformat, width, height, |
| 3625 | depth)) |
| 3626 | { |
| 3627 | return false; |
| 3628 | } |
| 3629 | |
| 3630 | return true; |
| 3631 | } |
| 3632 | |
Jamie Madill | 9696d07 | 2017-08-26 23:19:57 -0400 | [diff] [blame] | 3633 | bool ValidateGetBufferParameteri64v(ValidationContext *context, |
| 3634 | GLenum target, |
| 3635 | GLenum pname, |
| 3636 | GLint64 *params) |
| 3637 | { |
| 3638 | return ValidateGetBufferParameterBase(context, target, pname, false, nullptr); |
| 3639 | } |
| 3640 | |
| 3641 | bool ValidateGetSamplerParameterfv(Context *context, GLuint sampler, GLenum pname, GLfloat *params) |
| 3642 | { |
| 3643 | return ValidateGetSamplerParameterBase(context, sampler, pname, nullptr); |
| 3644 | } |
| 3645 | |
| 3646 | bool ValidateGetSamplerParameteriv(Context *context, GLuint sampler, GLenum pname, GLint *params) |
| 3647 | { |
| 3648 | return ValidateGetSamplerParameterBase(context, sampler, pname, nullptr); |
| 3649 | } |
| 3650 | |
| 3651 | bool ValidateSamplerParameterf(Context *context, GLuint sampler, GLenum pname, GLfloat param) |
| 3652 | { |
| 3653 | return ValidateSamplerParameterBase(context, sampler, pname, -1, ¶m); |
| 3654 | } |
| 3655 | |
| 3656 | bool ValidateSamplerParameterfv(Context *context, |
| 3657 | GLuint sampler, |
| 3658 | GLenum pname, |
| 3659 | const GLfloat *params) |
| 3660 | { |
| 3661 | return ValidateSamplerParameterBase(context, sampler, pname, -1, params); |
| 3662 | } |
| 3663 | |
| 3664 | bool ValidateSamplerParameteri(Context *context, GLuint sampler, GLenum pname, GLint param) |
| 3665 | { |
| 3666 | return ValidateSamplerParameterBase(context, sampler, pname, -1, ¶m); |
| 3667 | } |
| 3668 | |
| 3669 | bool ValidateSamplerParameteriv(Context *context, GLuint sampler, GLenum pname, const GLint *params) |
| 3670 | { |
| 3671 | return ValidateSamplerParameterBase(context, sampler, pname, -1, params); |
| 3672 | } |
| 3673 | |
| 3674 | bool ValidateGetVertexAttribIiv(Context *context, GLuint index, GLenum pname, GLint *params) |
| 3675 | { |
| 3676 | return ValidateGetVertexAttribBase(context, index, pname, nullptr, false, true); |
| 3677 | } |
| 3678 | |
| 3679 | bool ValidateGetVertexAttribIuiv(Context *context, GLuint index, GLenum pname, GLuint *params) |
| 3680 | { |
| 3681 | return ValidateGetVertexAttribBase(context, index, pname, nullptr, false, true); |
| 3682 | } |
| 3683 | |
| 3684 | bool ValidateGetInternalformativ(Context *context, |
| 3685 | GLenum target, |
| 3686 | GLenum internalformat, |
| 3687 | GLenum pname, |
| 3688 | GLsizei bufSize, |
| 3689 | GLint *params) |
| 3690 | { |
| 3691 | return ValidateGetInternalFormativBase(context, target, internalformat, pname, bufSize, |
| 3692 | nullptr); |
| 3693 | } |
| 3694 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3695 | } // namespace gl |