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