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 | // validationES.h: Validation functions for generic OpenGL ES entry point parameters |
| 8 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 9 | #include "libANGLE/validationES.h" |
| 10 | #include "libANGLE/validationES2.h" |
| 11 | #include "libANGLE/validationES3.h" |
| 12 | #include "libANGLE/Context.h" |
Geoff Lang | a840617 | 2015-07-21 16:53:39 -0400 | [diff] [blame] | 13 | #include "libANGLE/Display.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 14 | #include "libANGLE/Texture.h" |
| 15 | #include "libANGLE/Framebuffer.h" |
| 16 | #include "libANGLE/FramebufferAttachment.h" |
| 17 | #include "libANGLE/formatutils.h" |
Geoff Lang | a840617 | 2015-07-21 16:53:39 -0400 | [diff] [blame] | 18 | #include "libANGLE/Image.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 19 | #include "libANGLE/Query.h" |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 20 | #include "libANGLE/Program.h" |
| 21 | #include "libANGLE/Uniform.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 22 | #include "libANGLE/TransformFeedback.h" |
| 23 | #include "libANGLE/VertexArray.h" |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 24 | |
| 25 | #include "common/mathutil.h" |
| 26 | #include "common/utilities.h" |
| 27 | |
| 28 | namespace gl |
| 29 | { |
Jamie Madill | e79b1e1 | 2015-11-04 16:36:37 -0500 | [diff] [blame] | 30 | const char *g_ExceedsMaxElementErrorMessage = "Element value exceeds maximum element index."; |
| 31 | |
Jamie Madill | 1ca7467 | 2015-07-21 15:14:11 -0400 | [diff] [blame] | 32 | namespace |
| 33 | { |
Jamie Madill | f25855c | 2015-11-03 11:06:18 -0500 | [diff] [blame] | 34 | bool ValidateDrawAttribs(ValidationContext *context, GLint primcount, GLint maxVertex) |
Jamie Madill | 1ca7467 | 2015-07-21 15:14:11 -0400 | [diff] [blame] | 35 | { |
| 36 | const gl::State &state = context->getState(); |
| 37 | const gl::Program *program = state.getProgram(); |
| 38 | |
| 39 | const VertexArray *vao = state.getVertexArray(); |
| 40 | const auto &vertexAttribs = vao->getVertexAttributes(); |
Jamie Madill | 1ca7467 | 2015-07-21 15:14:11 -0400 | [diff] [blame] | 41 | size_t maxEnabledAttrib = vao->getMaxEnabledAttribute(); |
| 42 | for (size_t attributeIndex = 0; attributeIndex < maxEnabledAttrib; ++attributeIndex) |
| 43 | { |
| 44 | const VertexAttribute &attrib = vertexAttribs[attributeIndex]; |
Jamie Madill | 63805b4 | 2015-08-25 13:17:39 -0400 | [diff] [blame] | 45 | if (program->isAttribLocationActive(attributeIndex) && attrib.enabled) |
Jamie Madill | 1ca7467 | 2015-07-21 15:14:11 -0400 | [diff] [blame] | 46 | { |
| 47 | gl::Buffer *buffer = attrib.buffer.get(); |
| 48 | |
| 49 | if (buffer) |
| 50 | { |
| 51 | GLint64 attribStride = static_cast<GLint64>(ComputeVertexAttributeStride(attrib)); |
| 52 | GLint64 maxVertexElement = 0; |
| 53 | |
| 54 | if (attrib.divisor > 0) |
| 55 | { |
| 56 | maxVertexElement = |
| 57 | static_cast<GLint64>(primcount) / static_cast<GLint64>(attrib.divisor); |
| 58 | } |
| 59 | else |
| 60 | { |
| 61 | maxVertexElement = static_cast<GLint64>(maxVertex); |
| 62 | } |
| 63 | |
| 64 | // If we're drawing zero vertices, we have enough data. |
| 65 | if (maxVertexElement > 0) |
| 66 | { |
| 67 | // Note: Last vertex element does not take the full stride! |
| 68 | GLint64 attribSize = |
| 69 | static_cast<GLint64>(ComputeVertexAttributeTypeSize(attrib)); |
| 70 | GLint64 attribDataSize = (maxVertexElement - 1) * attribStride + attribSize; |
Jamie Madill | bc4c4bc | 2016-03-23 21:04:43 -0400 | [diff] [blame] | 71 | GLint64 attribOffset = static_cast<GLint64>(attrib.offset); |
Jamie Madill | 1ca7467 | 2015-07-21 15:14:11 -0400 | [diff] [blame] | 72 | |
| 73 | // [OpenGL ES 3.0.2] section 2.9.4 page 40: |
| 74 | // We can return INVALID_OPERATION if our vertex attribute does not have |
| 75 | // enough backing data. |
Jamie Madill | bc4c4bc | 2016-03-23 21:04:43 -0400 | [diff] [blame] | 76 | if (attribDataSize + attribOffset > buffer->getSize()) |
Jamie Madill | 1ca7467 | 2015-07-21 15:14:11 -0400 | [diff] [blame] | 77 | { |
Jamie Madill | bc4c4bc | 2016-03-23 21:04:43 -0400 | [diff] [blame] | 78 | context->recordError( |
| 79 | Error(GL_INVALID_OPERATION, |
| 80 | "Vertex buffer is not big enough for the draw call")); |
Jamie Madill | 1ca7467 | 2015-07-21 15:14:11 -0400 | [diff] [blame] | 81 | return false; |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | else if (attrib.pointer == NULL) |
| 86 | { |
| 87 | // This is an application error that would normally result in a crash, |
| 88 | // but we catch it and return an error |
| 89 | context->recordError(Error( |
| 90 | GL_INVALID_OPERATION, "An enabled vertex array has no buffer and no pointer.")); |
| 91 | return false; |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | return true; |
| 97 | } |
| 98 | |
| 99 | } // anonymous namespace |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 100 | |
Geoff Lang | 0550d03 | 2014-01-30 11:29:07 -0500 | [diff] [blame] | 101 | bool ValidCap(const Context *context, GLenum cap) |
| 102 | { |
| 103 | switch (cap) |
| 104 | { |
| 105 | case GL_CULL_FACE: |
| 106 | case GL_POLYGON_OFFSET_FILL: |
| 107 | case GL_SAMPLE_ALPHA_TO_COVERAGE: |
| 108 | case GL_SAMPLE_COVERAGE: |
| 109 | case GL_SCISSOR_TEST: |
| 110 | case GL_STENCIL_TEST: |
| 111 | case GL_DEPTH_TEST: |
| 112 | case GL_BLEND: |
| 113 | case GL_DITHER: |
| 114 | return true; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 115 | |
Geoff Lang | 0550d03 | 2014-01-30 11:29:07 -0500 | [diff] [blame] | 116 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 117 | case GL_RASTERIZER_DISCARD: |
| 118 | return (context->getClientVersion() >= 3); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 119 | |
| 120 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 121 | case GL_DEBUG_OUTPUT: |
| 122 | return context->getExtensions().debug; |
| 123 | |
Geoff Lang | 0550d03 | 2014-01-30 11:29:07 -0500 | [diff] [blame] | 124 | default: |
| 125 | return false; |
| 126 | } |
| 127 | } |
| 128 | |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 129 | bool ValidTextureTarget(const ValidationContext *context, GLenum target) |
Jamie Madill | 35d1501 | 2013-10-07 10:46:37 -0400 | [diff] [blame] | 130 | { |
Jamie Madill | d7460c7 | 2014-01-21 16:38:14 -0500 | [diff] [blame] | 131 | switch (target) |
Jamie Madill | 35d1501 | 2013-10-07 10:46:37 -0400 | [diff] [blame] | 132 | { |
Jamie Madill | d7460c7 | 2014-01-21 16:38:14 -0500 | [diff] [blame] | 133 | case GL_TEXTURE_2D: |
| 134 | case GL_TEXTURE_CUBE_MAP: |
| 135 | return true; |
Jamie Madill | 35d1501 | 2013-10-07 10:46:37 -0400 | [diff] [blame] | 136 | |
Jamie Madill | d7460c7 | 2014-01-21 16:38:14 -0500 | [diff] [blame] | 137 | case GL_TEXTURE_3D: |
| 138 | case GL_TEXTURE_2D_ARRAY: |
| 139 | return (context->getClientVersion() >= 3); |
| 140 | |
| 141 | default: |
| 142 | return false; |
| 143 | } |
Jamie Madill | 35d1501 | 2013-10-07 10:46:37 -0400 | [diff] [blame] | 144 | } |
| 145 | |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 146 | bool ValidTexture2DTarget(const ValidationContext *context, GLenum target) |
| 147 | { |
| 148 | switch (target) |
| 149 | { |
| 150 | case GL_TEXTURE_2D: |
| 151 | case GL_TEXTURE_CUBE_MAP: |
| 152 | return true; |
| 153 | |
| 154 | default: |
| 155 | return false; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | bool ValidTexture3DTarget(const ValidationContext *context, GLenum target) |
| 160 | { |
| 161 | switch (target) |
| 162 | { |
| 163 | case GL_TEXTURE_3D: |
| 164 | case GL_TEXTURE_2D_ARRAY: |
| 165 | return (context->getClientVersion() >= 3); |
| 166 | |
| 167 | default: |
| 168 | return false; |
| 169 | } |
| 170 | } |
| 171 | |
Shannon Woods | 4dfed83 | 2014-03-17 20:03:39 -0400 | [diff] [blame] | 172 | // This function differs from ValidTextureTarget in that the target must be |
| 173 | // usable as the destination of a 2D operation-- so a cube face is valid, but |
| 174 | // GL_TEXTURE_CUBE_MAP is not. |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 175 | // Note: duplicate of IsInternalTextureTarget |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 176 | bool ValidTexture2DDestinationTarget(const ValidationContext *context, GLenum target) |
Shannon Woods | 4dfed83 | 2014-03-17 20:03:39 -0400 | [diff] [blame] | 177 | { |
| 178 | switch (target) |
| 179 | { |
| 180 | case GL_TEXTURE_2D: |
| 181 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 182 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 183 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 184 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 185 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 186 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 187 | return true; |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 188 | default: |
| 189 | return false; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | bool ValidTexture3DDestinationTarget(const ValidationContext *context, GLenum target) |
| 194 | { |
| 195 | switch (target) |
| 196 | { |
Shannon Woods | 4dfed83 | 2014-03-17 20:03:39 -0400 | [diff] [blame] | 197 | case GL_TEXTURE_3D: |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 198 | case GL_TEXTURE_2D_ARRAY: |
| 199 | return true; |
Shannon Woods | 4dfed83 | 2014-03-17 20:03:39 -0400 | [diff] [blame] | 200 | default: |
| 201 | return false; |
| 202 | } |
| 203 | } |
| 204 | |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 205 | bool ValidFramebufferTarget(GLenum target) |
| 206 | { |
Geoff Lang | d447581 | 2015-03-18 10:53:05 -0400 | [diff] [blame] | 207 | static_assert(GL_DRAW_FRAMEBUFFER_ANGLE == GL_DRAW_FRAMEBUFFER && GL_READ_FRAMEBUFFER_ANGLE == GL_READ_FRAMEBUFFER, |
| 208 | "ANGLE framebuffer enums must equal the ES3 framebuffer enums."); |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 209 | |
| 210 | switch (target) |
| 211 | { |
| 212 | case GL_FRAMEBUFFER: return true; |
| 213 | case GL_READ_FRAMEBUFFER: return true; |
| 214 | case GL_DRAW_FRAMEBUFFER: return true; |
| 215 | default: return false; |
| 216 | } |
| 217 | } |
| 218 | |
Jamie Madill | 8c96d58 | 2014-03-05 15:01:23 -0500 | [diff] [blame] | 219 | bool ValidBufferTarget(const Context *context, GLenum target) |
| 220 | { |
| 221 | switch (target) |
| 222 | { |
| 223 | case GL_ARRAY_BUFFER: |
| 224 | case GL_ELEMENT_ARRAY_BUFFER: |
| 225 | return true; |
| 226 | |
Jamie Madill | 8c96d58 | 2014-03-05 15:01:23 -0500 | [diff] [blame] | 227 | case GL_PIXEL_PACK_BUFFER: |
| 228 | case GL_PIXEL_UNPACK_BUFFER: |
Geoff Lang | e4de307 | 2015-09-02 11:01:32 -0400 | [diff] [blame] | 229 | return (context->getExtensions().pixelBufferObject || context->getClientVersion() >= 3); |
Shannon Woods | 158c438 | 2014-05-06 13:00:07 -0400 | [diff] [blame] | 230 | |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 231 | case GL_COPY_READ_BUFFER: |
| 232 | case GL_COPY_WRITE_BUFFER: |
Jamie Madill | 8c96d58 | 2014-03-05 15:01:23 -0500 | [diff] [blame] | 233 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 234 | case GL_UNIFORM_BUFFER: |
| 235 | return (context->getClientVersion() >= 3); |
| 236 | |
| 237 | default: |
| 238 | return false; |
| 239 | } |
| 240 | } |
| 241 | |
Jamie Madill | 70656a6 | 2014-03-05 15:01:26 -0500 | [diff] [blame] | 242 | bool ValidBufferParameter(const Context *context, GLenum pname) |
| 243 | { |
Geoff Lang | cc6f55d | 2015-03-20 13:01:02 -0400 | [diff] [blame] | 244 | const Extensions &extensions = context->getExtensions(); |
| 245 | |
Jamie Madill | 70656a6 | 2014-03-05 15:01:26 -0500 | [diff] [blame] | 246 | switch (pname) |
| 247 | { |
| 248 | case GL_BUFFER_USAGE: |
| 249 | case GL_BUFFER_SIZE: |
| 250 | return true; |
| 251 | |
Geoff Lang | cc6f55d | 2015-03-20 13:01:02 -0400 | [diff] [blame] | 252 | case GL_BUFFER_ACCESS_OES: |
| 253 | return extensions.mapBuffer; |
| 254 | |
| 255 | case GL_BUFFER_MAPPED: |
| 256 | static_assert(GL_BUFFER_MAPPED == GL_BUFFER_MAPPED_OES, "GL enums should be equal."); |
| 257 | return (context->getClientVersion() >= 3) || extensions.mapBuffer || extensions.mapBufferRange; |
| 258 | |
Jamie Madill | 70656a6 | 2014-03-05 15:01:26 -0500 | [diff] [blame] | 259 | // GL_BUFFER_MAP_POINTER is a special case, and may only be |
| 260 | // queried with GetBufferPointerv |
| 261 | case GL_BUFFER_ACCESS_FLAGS: |
Jamie Madill | 70656a6 | 2014-03-05 15:01:26 -0500 | [diff] [blame] | 262 | case GL_BUFFER_MAP_OFFSET: |
| 263 | case GL_BUFFER_MAP_LENGTH: |
Geoff Lang | cc6f55d | 2015-03-20 13:01:02 -0400 | [diff] [blame] | 264 | return (context->getClientVersion() >= 3) || extensions.mapBufferRange; |
Jamie Madill | 70656a6 | 2014-03-05 15:01:26 -0500 | [diff] [blame] | 265 | |
| 266 | default: |
| 267 | return false; |
| 268 | } |
| 269 | } |
| 270 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 271 | bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level) |
Geoff Lang | ce63569 | 2013-09-24 13:56:32 -0400 | [diff] [blame] | 272 | { |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 273 | const auto &caps = context->getCaps(); |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 274 | size_t maxDimension = 0; |
Geoff Lang | ce63569 | 2013-09-24 13:56:32 -0400 | [diff] [blame] | 275 | switch (target) |
| 276 | { |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 277 | case GL_TEXTURE_2D: |
| 278 | maxDimension = caps.max2DTextureSize; |
| 279 | break; |
Geoff Lang | ce63569 | 2013-09-24 13:56:32 -0400 | [diff] [blame] | 280 | case GL_TEXTURE_CUBE_MAP: |
| 281 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 282 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 283 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 284 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 285 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 286 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 287 | maxDimension = caps.maxCubeMapTextureSize; |
| 288 | break; |
| 289 | case GL_TEXTURE_3D: |
| 290 | maxDimension = caps.max3DTextureSize; |
| 291 | break; |
| 292 | case GL_TEXTURE_2D_ARRAY: |
| 293 | maxDimension = caps.max2DTextureSize; |
| 294 | break; |
Geoff Lang | ce63569 | 2013-09-24 13:56:32 -0400 | [diff] [blame] | 295 | default: UNREACHABLE(); |
| 296 | } |
| 297 | |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 298 | return level <= gl::log2(static_cast<int>(maxDimension)); |
Geoff Lang | ce63569 | 2013-09-24 13:56:32 -0400 | [diff] [blame] | 299 | } |
| 300 | |
Austin Kinross | 08528e1 | 2015-10-07 16:24:40 -0700 | [diff] [blame] | 301 | bool ValidImageSizeParameters(const Context *context, |
| 302 | GLenum target, |
| 303 | GLint level, |
| 304 | GLsizei width, |
| 305 | GLsizei height, |
| 306 | GLsizei depth, |
| 307 | bool isSubImage) |
Geoff Lang | ce63569 | 2013-09-24 13:56:32 -0400 | [diff] [blame] | 308 | { |
| 309 | if (level < 0 || width < 0 || height < 0 || depth < 0) |
| 310 | { |
| 311 | return false; |
| 312 | } |
| 313 | |
Austin Kinross | 08528e1 | 2015-10-07 16:24:40 -0700 | [diff] [blame] | 314 | // TexSubImage parameters can be NPOT without textureNPOT extension, |
| 315 | // as long as the destination texture is POT. |
| 316 | if (!isSubImage && !context->getExtensions().textureNPOT && |
Jamie Madill | 4fd75c1 | 2014-06-23 10:53:54 -0400 | [diff] [blame] | 317 | (level != 0 && (!gl::isPow2(width) || !gl::isPow2(height) || !gl::isPow2(depth)))) |
Geoff Lang | ce63569 | 2013-09-24 13:56:32 -0400 | [diff] [blame] | 318 | { |
| 319 | return false; |
| 320 | } |
| 321 | |
| 322 | if (!ValidMipLevel(context, target, level)) |
| 323 | { |
| 324 | return false; |
| 325 | } |
| 326 | |
| 327 | return true; |
| 328 | } |
| 329 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 330 | bool CompressedTextureFormatRequiresExactSize(GLenum internalFormat) |
| 331 | { |
| 332 | // List of compressed format that require that the texture size is smaller than or a multiple of |
| 333 | // the compressed block size. |
| 334 | switch (internalFormat) |
| 335 | { |
| 336 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 337 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 338 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 339 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
Minmin Gong | e3939b9 | 2015-12-01 15:36:51 -0800 | [diff] [blame] | 340 | case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE: |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 341 | return true; |
| 342 | |
| 343 | default: |
| 344 | return false; |
| 345 | } |
| 346 | } |
| 347 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 348 | bool ValidCompressedImageSize(const ValidationContext *context, |
| 349 | GLenum internalFormat, |
| 350 | GLsizei width, |
| 351 | GLsizei height) |
Geoff Lang | d4f180b | 2013-09-24 13:57:44 -0400 | [diff] [blame] | 352 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 353 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat); |
| 354 | if (!formatInfo.compressed) |
Geoff Lang | d4f180b | 2013-09-24 13:57:44 -0400 | [diff] [blame] | 355 | { |
| 356 | return false; |
| 357 | } |
| 358 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 359 | if (width < 0 || height < 0) |
Geoff Lang | d4f180b | 2013-09-24 13:57:44 -0400 | [diff] [blame] | 360 | { |
| 361 | return false; |
| 362 | } |
| 363 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 364 | if (CompressedTextureFormatRequiresExactSize(internalFormat)) |
| 365 | { |
| 366 | if ((static_cast<GLuint>(width) > formatInfo.compressedBlockWidth && |
| 367 | width % formatInfo.compressedBlockWidth != 0) || |
| 368 | (static_cast<GLuint>(height) > formatInfo.compressedBlockHeight && |
| 369 | height % formatInfo.compressedBlockHeight != 0)) |
| 370 | { |
| 371 | return false; |
| 372 | } |
| 373 | } |
| 374 | |
Geoff Lang | d4f180b | 2013-09-24 13:57:44 -0400 | [diff] [blame] | 375 | return true; |
| 376 | } |
| 377 | |
Geoff Lang | 37dde69 | 2014-01-31 16:34:54 -0500 | [diff] [blame] | 378 | bool ValidQueryType(const Context *context, GLenum queryType) |
| 379 | { |
Geoff Lang | d447581 | 2015-03-18 10:53:05 -0400 | [diff] [blame] | 380 | static_assert(GL_ANY_SAMPLES_PASSED == GL_ANY_SAMPLES_PASSED_EXT, "GL extension enums not equal."); |
| 381 | static_assert(GL_ANY_SAMPLES_PASSED_CONSERVATIVE == GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, "GL extension enums not equal."); |
Geoff Lang | 37dde69 | 2014-01-31 16:34:54 -0500 | [diff] [blame] | 382 | |
| 383 | switch (queryType) |
| 384 | { |
| 385 | case GL_ANY_SAMPLES_PASSED: |
| 386 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: |
| 387 | return true; |
| 388 | case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: |
| 389 | return (context->getClientVersion() >= 3); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 390 | case GL_TIME_ELAPSED_EXT: |
| 391 | return context->getExtensions().disjointTimerQuery; |
Geoff Lang | 37dde69 | 2014-01-31 16:34:54 -0500 | [diff] [blame] | 392 | default: |
| 393 | return false; |
| 394 | } |
| 395 | } |
| 396 | |
Dian Xiang | 769769a | 2015-09-09 15:20:08 -0700 | [diff] [blame] | 397 | Program *GetValidProgram(Context *context, GLuint id) |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 398 | { |
| 399 | // ES3 spec (section 2.11.1) -- "Commands that accept shader or program object names will generate the |
| 400 | // error INVALID_VALUE if the provided name is not the name of either a shader or program object and |
| 401 | // INVALID_OPERATION if the provided name identifies an object that is not the expected type." |
| 402 | |
Dian Xiang | 769769a | 2015-09-09 15:20:08 -0700 | [diff] [blame] | 403 | Program *validProgram = context->getProgram(id); |
| 404 | |
| 405 | if (!validProgram) |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 406 | { |
Dian Xiang | 769769a | 2015-09-09 15:20:08 -0700 | [diff] [blame] | 407 | if (context->getShader(id)) |
| 408 | { |
| 409 | context->recordError( |
| 410 | Error(GL_INVALID_OPERATION, "Expected a program name, but found a shader name")); |
| 411 | } |
| 412 | else |
| 413 | { |
| 414 | context->recordError(Error(GL_INVALID_VALUE, "Program name is not valid")); |
| 415 | } |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 416 | } |
Dian Xiang | 769769a | 2015-09-09 15:20:08 -0700 | [diff] [blame] | 417 | |
| 418 | return validProgram; |
| 419 | } |
| 420 | |
| 421 | Shader *GetValidShader(Context *context, GLuint id) |
| 422 | { |
| 423 | // See ValidProgram for spec details. |
| 424 | |
| 425 | Shader *validShader = context->getShader(id); |
| 426 | |
| 427 | if (!validShader) |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 428 | { |
Dian Xiang | 769769a | 2015-09-09 15:20:08 -0700 | [diff] [blame] | 429 | if (context->getProgram(id)) |
| 430 | { |
| 431 | context->recordError( |
| 432 | Error(GL_INVALID_OPERATION, "Expected a shader name, but found a program name")); |
| 433 | } |
| 434 | else |
| 435 | { |
| 436 | context->recordError(Error(GL_INVALID_VALUE, "Shader name is invalid")); |
| 437 | } |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 438 | } |
Dian Xiang | 769769a | 2015-09-09 15:20:08 -0700 | [diff] [blame] | 439 | |
| 440 | return validShader; |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 441 | } |
| 442 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 443 | bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment) |
Jamie Madill | b447227 | 2014-07-03 10:38:55 -0400 | [diff] [blame] | 444 | { |
| 445 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 446 | { |
| 447 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 448 | |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 449 | if (colorAttachment >= context->getCaps().maxColorAttachments) |
Jamie Madill | b447227 | 2014-07-03 10:38:55 -0400 | [diff] [blame] | 450 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 451 | context->recordError(Error(GL_INVALID_VALUE)); |
| 452 | return false; |
Jamie Madill | b447227 | 2014-07-03 10:38:55 -0400 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | else |
| 456 | { |
| 457 | switch (attachment) |
| 458 | { |
| 459 | case GL_DEPTH_ATTACHMENT: |
| 460 | case GL_STENCIL_ATTACHMENT: |
| 461 | break; |
| 462 | |
| 463 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 464 | if (context->getClientVersion() < 3) |
| 465 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 466 | context->recordError(Error(GL_INVALID_ENUM)); |
| 467 | return false; |
Jamie Madill | b447227 | 2014-07-03 10:38:55 -0400 | [diff] [blame] | 468 | } |
| 469 | break; |
| 470 | |
| 471 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 472 | context->recordError(Error(GL_INVALID_ENUM)); |
| 473 | return false; |
Jamie Madill | b447227 | 2014-07-03 10:38:55 -0400 | [diff] [blame] | 474 | } |
| 475 | } |
| 476 | |
| 477 | return true; |
| 478 | } |
| 479 | |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 480 | bool ValidateRenderbufferStorageParametersBase(gl::Context *context, GLenum target, GLsizei samples, |
| 481 | GLenum internalformat, GLsizei width, GLsizei height) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 482 | { |
| 483 | switch (target) |
| 484 | { |
| 485 | case GL_RENDERBUFFER: |
| 486 | break; |
| 487 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 488 | context->recordError(Error(GL_INVALID_ENUM)); |
| 489 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | if (width < 0 || height < 0 || samples < 0) |
| 493 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 494 | context->recordError(Error(GL_INVALID_VALUE)); |
| 495 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 496 | } |
| 497 | |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 498 | const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); |
| 499 | if (!formatCaps.renderable) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 500 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 501 | context->recordError(Error(GL_INVALID_ENUM)); |
| 502 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be |
| 506 | // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 507 | // only sized internal formats. |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 508 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 509 | if (formatInfo.pixelBytes == 0) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 510 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 511 | context->recordError(Error(GL_INVALID_ENUM)); |
| 512 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 513 | } |
| 514 | |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 515 | if (static_cast<GLuint>(std::max(width, height)) > context->getCaps().maxRenderbufferSize) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 516 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 517 | context->recordError(Error(GL_INVALID_VALUE)); |
| 518 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 519 | } |
| 520 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 521 | GLuint handle = context->getState().getRenderbufferId(); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 522 | if (handle == 0) |
| 523 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 524 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 525 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | return true; |
| 529 | } |
| 530 | |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 531 | bool ValidateRenderbufferStorageParametersANGLE(gl::Context *context, GLenum target, GLsizei samples, |
| 532 | GLenum internalformat, GLsizei width, GLsizei height) |
| 533 | { |
Austin Kinross | d2cf3ad | 2015-01-07 14:00:30 -0800 | [diff] [blame] | 534 | ASSERT(samples == 0 || context->getExtensions().framebufferMultisample); |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 535 | |
| 536 | // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal |
Geoff Lang | def624b | 2015-04-13 10:46:56 -0400 | [diff] [blame] | 537 | // to MAX_SAMPLES_ANGLE (Context::getCaps().maxSamples) otherwise GL_INVALID_VALUE is |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 538 | // generated. |
Geoff Lang | def624b | 2015-04-13 10:46:56 -0400 | [diff] [blame] | 539 | if (static_cast<GLuint>(samples) > context->getCaps().maxSamples) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 540 | { |
| 541 | context->recordError(Error(GL_INVALID_VALUE)); |
| 542 | return false; |
| 543 | } |
| 544 | |
| 545 | // ANGLE_framebuffer_multisample states GL_OUT_OF_MEMORY is generated on a failure to create |
| 546 | // the specified storage. This is different than ES 3.0 in which a sample number higher |
| 547 | // than the maximum sample number supported by this format generates a GL_INVALID_VALUE. |
Geoff Lang | a4903b7 | 2015-03-02 16:02:48 -0800 | [diff] [blame] | 548 | // The TextureCaps::getMaxSamples method is only guarenteed to be valid when the context is ES3. |
| 549 | if (context->getClientVersion() >= 3) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 550 | { |
Geoff Lang | a4903b7 | 2015-03-02 16:02:48 -0800 | [diff] [blame] | 551 | const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); |
| 552 | if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples()) |
| 553 | { |
| 554 | context->recordError(Error(GL_OUT_OF_MEMORY)); |
| 555 | return false; |
| 556 | } |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | return ValidateRenderbufferStorageParametersBase(context, target, samples, internalformat, width, height); |
| 560 | } |
| 561 | |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 562 | bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum target, GLenum attachment, |
| 563 | GLenum renderbuffertarget, GLuint renderbuffer) |
| 564 | { |
Shannon Woods | 1da3cf6 | 2014-06-27 15:32:23 -0400 | [diff] [blame] | 565 | if (!ValidFramebufferTarget(target)) |
| 566 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 567 | context->recordError(Error(GL_INVALID_ENUM)); |
| 568 | return false; |
Shannon Woods | 1da3cf6 | 2014-06-27 15:32:23 -0400 | [diff] [blame] | 569 | } |
| 570 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 571 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 572 | |
Jamie Madill | 84115c9 | 2015-04-23 15:00:07 -0400 | [diff] [blame] | 573 | ASSERT(framebuffer); |
| 574 | if (framebuffer->id() == 0) |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 575 | { |
Jamie Madill | 84115c9 | 2015-04-23 15:00:07 -0400 | [diff] [blame] | 576 | context->recordError(Error(GL_INVALID_OPERATION, "Cannot change default FBO's attachments")); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 577 | return false; |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 578 | } |
| 579 | |
Jamie Madill | b447227 | 2014-07-03 10:38:55 -0400 | [diff] [blame] | 580 | if (!ValidateAttachmentTarget(context, attachment)) |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 581 | { |
Jamie Madill | b447227 | 2014-07-03 10:38:55 -0400 | [diff] [blame] | 582 | return false; |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 583 | } |
| 584 | |
Jamie Madill | ab9d82c | 2014-01-21 16:38:14 -0500 | [diff] [blame] | 585 | // [OpenGL ES 2.0.25] Section 4.4.3 page 112 |
| 586 | // [OpenGL ES 3.0.2] Section 4.4.2 page 201 |
| 587 | // 'renderbuffer' must be either zero or the name of an existing renderbuffer object of |
| 588 | // type 'renderbuffertarget', otherwise an INVALID_OPERATION error is generated. |
| 589 | if (renderbuffer != 0) |
| 590 | { |
| 591 | if (!context->getRenderbuffer(renderbuffer)) |
| 592 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 593 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 594 | return false; |
Jamie Madill | ab9d82c | 2014-01-21 16:38:14 -0500 | [diff] [blame] | 595 | } |
| 596 | } |
| 597 | |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 598 | return true; |
| 599 | } |
| 600 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 601 | bool ValidateBlitFramebufferParameters(gl::Context *context, |
| 602 | GLint srcX0, |
| 603 | GLint srcY0, |
| 604 | GLint srcX1, |
| 605 | GLint srcY1, |
| 606 | GLint dstX0, |
| 607 | GLint dstY0, |
| 608 | GLint dstX1, |
| 609 | GLint dstY1, |
| 610 | GLbitfield mask, |
| 611 | GLenum filter) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 612 | { |
| 613 | switch (filter) |
| 614 | { |
| 615 | case GL_NEAREST: |
| 616 | break; |
| 617 | case GL_LINEAR: |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 618 | break; |
| 619 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 620 | context->recordError(Error(GL_INVALID_ENUM)); |
| 621 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) |
| 625 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 626 | context->recordError(Error(GL_INVALID_VALUE)); |
| 627 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | if (mask == 0) |
| 631 | { |
| 632 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 633 | // buffers are copied. |
| 634 | return false; |
| 635 | } |
| 636 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 637 | // ES3.0 spec, section 4.3.2 states that linear filtering is only available for the |
| 638 | // color buffer, leaving only nearest being unfiltered from above |
| 639 | if ((mask & ~GL_COLOR_BUFFER_BIT) != 0 && filter != GL_NEAREST) |
| 640 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 641 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 642 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 643 | } |
| 644 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 645 | if (context->getState().getReadFramebuffer()->id() == context->getState().getDrawFramebuffer()->id()) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 646 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 647 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 648 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 649 | } |
| 650 | |
Jamie Madill | e3ef715 | 2015-04-28 16:55:17 +0000 | [diff] [blame] | 651 | const gl::Framebuffer *readFramebuffer = context->getState().getReadFramebuffer(); |
| 652 | const gl::Framebuffer *drawFramebuffer = context->getState().getDrawFramebuffer(); |
Jamie Madill | 48faf80 | 2014-11-06 15:27:22 -0500 | [diff] [blame] | 653 | |
| 654 | if (!readFramebuffer || !drawFramebuffer) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 655 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 656 | context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); |
| 657 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 658 | } |
| 659 | |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 660 | if (!readFramebuffer->checkStatus(context->getData())) |
Jamie Madill | 48faf80 | 2014-11-06 15:27:22 -0500 | [diff] [blame] | 661 | { |
| 662 | context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); |
| 663 | return false; |
| 664 | } |
| 665 | |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 666 | if (!drawFramebuffer->checkStatus(context->getData())) |
Jamie Madill | 48faf80 | 2014-11-06 15:27:22 -0500 | [diff] [blame] | 667 | { |
| 668 | context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); |
| 669 | return false; |
| 670 | } |
| 671 | |
| 672 | if (drawFramebuffer->getSamples(context->getData()) != 0) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 673 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 674 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 675 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 676 | } |
| 677 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 678 | bool sameBounds = srcX0 == dstX0 && srcY0 == dstY0 && srcX1 == dstX1 && srcY1 == dstY1; |
| 679 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 680 | if (mask & GL_COLOR_BUFFER_BIT) |
| 681 | { |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 682 | const gl::FramebufferAttachment *readColorBuffer = readFramebuffer->getReadColorbuffer(); |
| 683 | const gl::FramebufferAttachment *drawColorBuffer = drawFramebuffer->getFirstColorbuffer(); |
Jamie Madill | 6163c75 | 2015-12-07 16:32:59 -0500 | [diff] [blame] | 684 | const Extensions &extensions = context->getExtensions(); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 685 | |
| 686 | if (readColorBuffer && drawColorBuffer) |
| 687 | { |
Geoff Lang | d8a2258 | 2014-12-17 15:28:23 -0500 | [diff] [blame] | 688 | GLenum readInternalFormat = readColorBuffer->getInternalFormat(); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 689 | const InternalFormat &readFormatInfo = GetInternalFormatInfo(readInternalFormat); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 690 | |
Geoff Lang | a15472a | 2015-08-11 11:48:03 -0400 | [diff] [blame] | 691 | for (size_t drawbufferIdx = 0; |
| 692 | drawbufferIdx < drawFramebuffer->getDrawbufferStateCount(); ++drawbufferIdx) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 693 | { |
Geoff Lang | a15472a | 2015-08-11 11:48:03 -0400 | [diff] [blame] | 694 | const FramebufferAttachment *attachment = |
| 695 | drawFramebuffer->getDrawBuffer(drawbufferIdx); |
| 696 | if (attachment) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 697 | { |
Geoff Lang | a15472a | 2015-08-11 11:48:03 -0400 | [diff] [blame] | 698 | GLenum drawInternalFormat = attachment->getInternalFormat(); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 699 | const InternalFormat &drawFormatInfo = GetInternalFormatInfo(drawInternalFormat); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 700 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 701 | // The GL ES 3.0.2 spec (pg 193) states that: |
| 702 | // 1) If the read buffer is fixed point format, the draw buffer must be as well |
| 703 | // 2) If the read buffer is an unsigned integer format, the draw buffer must be as well |
| 704 | // 3) If the read buffer is a signed integer format, the draw buffer must be as well |
Jamie Madill | 6163c75 | 2015-12-07 16:32:59 -0500 | [diff] [blame] | 705 | // Changes with EXT_color_buffer_float: |
| 706 | // Case 1) is changed to fixed point OR floating point |
| 707 | GLenum readComponentType = readFormatInfo.componentType; |
| 708 | GLenum drawComponentType = drawFormatInfo.componentType; |
| 709 | bool readFixedPoint = (readComponentType == GL_UNSIGNED_NORMALIZED || |
| 710 | readComponentType == GL_SIGNED_NORMALIZED); |
| 711 | bool drawFixedPoint = (drawComponentType == GL_UNSIGNED_NORMALIZED || |
| 712 | drawComponentType == GL_SIGNED_NORMALIZED); |
| 713 | |
| 714 | if (extensions.colorBufferFloat) |
| 715 | { |
| 716 | bool readFixedOrFloat = (readFixedPoint || readComponentType == GL_FLOAT); |
| 717 | bool drawFixedOrFloat = (drawFixedPoint || drawComponentType == GL_FLOAT); |
| 718 | |
| 719 | if (readFixedOrFloat != drawFixedOrFloat) |
| 720 | { |
| 721 | context->recordError(Error(GL_INVALID_OPERATION, |
| 722 | "If the read buffer contains fixed-point or " |
| 723 | "floating-point values, the draw buffer " |
| 724 | "must as well.")); |
| 725 | return false; |
| 726 | } |
| 727 | } |
| 728 | else if (readFixedPoint != drawFixedPoint) |
| 729 | { |
| 730 | context->recordError(Error(GL_INVALID_OPERATION, |
| 731 | "If the read buffer contains fixed-point " |
| 732 | "values, the draw buffer must as well.")); |
| 733 | return false; |
| 734 | } |
| 735 | |
| 736 | if (readComponentType == GL_UNSIGNED_INT && |
| 737 | drawComponentType != GL_UNSIGNED_INT) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 738 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 739 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 740 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 741 | } |
| 742 | |
Jamie Madill | 6163c75 | 2015-12-07 16:32:59 -0500 | [diff] [blame] | 743 | if (readComponentType == GL_INT && drawComponentType != GL_INT) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 744 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 745 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 746 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 747 | } |
| 748 | |
Geoff Lang | b2f3d05 | 2013-08-13 12:49:27 -0400 | [diff] [blame] | 749 | if (readColorBuffer->getSamples() > 0 && (readInternalFormat != drawInternalFormat || !sameBounds)) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 750 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 751 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 752 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 753 | } |
| 754 | } |
| 755 | } |
| 756 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 757 | if ((readFormatInfo.componentType == GL_INT || readFormatInfo.componentType == GL_UNSIGNED_INT) && filter == GL_LINEAR) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 758 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 759 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 760 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 761 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 762 | } |
| 763 | } |
| 764 | |
Dongseong Hwang | 44b422c | 2014-12-09 15:42:01 +0200 | [diff] [blame] | 765 | GLenum masks[] = {GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT}; |
| 766 | GLenum attachments[] = {GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT}; |
| 767 | for (size_t i = 0; i < 2; i++) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 768 | { |
Dongseong Hwang | 44b422c | 2014-12-09 15:42:01 +0200 | [diff] [blame] | 769 | if (mask & masks[i]) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 770 | { |
Jamie Madill | 2d06b73 | 2015-04-20 12:53:28 -0400 | [diff] [blame] | 771 | const gl::FramebufferAttachment *readBuffer = readFramebuffer->getAttachment(attachments[i]); |
| 772 | const gl::FramebufferAttachment *drawBuffer = drawFramebuffer->getAttachment(attachments[i]); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 773 | |
Dongseong Hwang | 44b422c | 2014-12-09 15:42:01 +0200 | [diff] [blame] | 774 | if (readBuffer && drawBuffer) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 775 | { |
Geoff Lang | d8a2258 | 2014-12-17 15:28:23 -0500 | [diff] [blame] | 776 | if (readBuffer->getInternalFormat() != drawBuffer->getInternalFormat()) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 777 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 778 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 779 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 780 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 781 | |
Dongseong Hwang | 44b422c | 2014-12-09 15:42:01 +0200 | [diff] [blame] | 782 | if (readBuffer->getSamples() > 0 && !sameBounds) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 783 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 784 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 785 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 786 | } |
| 787 | } |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | return true; |
| 792 | } |
| 793 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 794 | bool ValidateGetVertexAttribParameters(Context *context, GLenum pname) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 795 | { |
| 796 | switch (pname) |
| 797 | { |
| 798 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
| 799 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
| 800 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
| 801 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
| 802 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
| 803 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
| 804 | case GL_CURRENT_VERTEX_ATTRIB: |
| 805 | return true; |
| 806 | |
| 807 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 808 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 809 | // the same constant. |
Geoff Lang | d447581 | 2015-03-18 10:53:05 -0400 | [diff] [blame] | 810 | static_assert(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE, |
| 811 | "ANGLE extension enums not equal to GL enums."); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 812 | return true; |
| 813 | |
| 814 | case GL_VERTEX_ATTRIB_ARRAY_INTEGER: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 815 | if (context->getClientVersion() < 3) |
| 816 | { |
| 817 | context->recordError(Error(GL_INVALID_ENUM)); |
| 818 | return false; |
| 819 | } |
| 820 | return true; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 821 | |
| 822 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 823 | context->recordError(Error(GL_INVALID_ENUM)); |
| 824 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 825 | } |
| 826 | } |
| 827 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 828 | bool ValidateTexParamParameters(gl::Context *context, GLenum pname, GLint param) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 829 | { |
| 830 | switch (pname) |
| 831 | { |
| 832 | case GL_TEXTURE_WRAP_R: |
| 833 | case GL_TEXTURE_SWIZZLE_R: |
| 834 | case GL_TEXTURE_SWIZZLE_G: |
| 835 | case GL_TEXTURE_SWIZZLE_B: |
| 836 | case GL_TEXTURE_SWIZZLE_A: |
| 837 | case GL_TEXTURE_BASE_LEVEL: |
| 838 | case GL_TEXTURE_MAX_LEVEL: |
| 839 | case GL_TEXTURE_COMPARE_MODE: |
| 840 | case GL_TEXTURE_COMPARE_FUNC: |
| 841 | case GL_TEXTURE_MIN_LOD: |
| 842 | case GL_TEXTURE_MAX_LOD: |
| 843 | if (context->getClientVersion() < 3) |
| 844 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 845 | context->recordError(Error(GL_INVALID_ENUM)); |
| 846 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 847 | } |
| 848 | break; |
| 849 | |
| 850 | default: break; |
| 851 | } |
| 852 | |
| 853 | switch (pname) |
| 854 | { |
| 855 | case GL_TEXTURE_WRAP_S: |
| 856 | case GL_TEXTURE_WRAP_T: |
| 857 | case GL_TEXTURE_WRAP_R: |
| 858 | switch (param) |
| 859 | { |
| 860 | case GL_REPEAT: |
| 861 | case GL_CLAMP_TO_EDGE: |
| 862 | case GL_MIRRORED_REPEAT: |
| 863 | return true; |
| 864 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 865 | context->recordError(Error(GL_INVALID_ENUM)); |
| 866 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 867 | } |
| 868 | |
| 869 | case GL_TEXTURE_MIN_FILTER: |
| 870 | switch (param) |
| 871 | { |
| 872 | case GL_NEAREST: |
| 873 | case GL_LINEAR: |
| 874 | case GL_NEAREST_MIPMAP_NEAREST: |
| 875 | case GL_LINEAR_MIPMAP_NEAREST: |
| 876 | case GL_NEAREST_MIPMAP_LINEAR: |
| 877 | case GL_LINEAR_MIPMAP_LINEAR: |
| 878 | return true; |
| 879 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 880 | context->recordError(Error(GL_INVALID_ENUM)); |
| 881 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 882 | } |
| 883 | break; |
| 884 | |
| 885 | case GL_TEXTURE_MAG_FILTER: |
| 886 | switch (param) |
| 887 | { |
| 888 | case GL_NEAREST: |
| 889 | case GL_LINEAR: |
| 890 | return true; |
| 891 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 892 | context->recordError(Error(GL_INVALID_ENUM)); |
| 893 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 894 | } |
| 895 | break; |
| 896 | |
| 897 | case GL_TEXTURE_USAGE_ANGLE: |
| 898 | switch (param) |
| 899 | { |
| 900 | case GL_NONE: |
| 901 | case GL_FRAMEBUFFER_ATTACHMENT_ANGLE: |
| 902 | return true; |
| 903 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 904 | context->recordError(Error(GL_INVALID_ENUM)); |
| 905 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 906 | } |
| 907 | break; |
| 908 | |
| 909 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 910 | if (!context->getExtensions().textureFilterAnisotropic) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 911 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 912 | context->recordError(Error(GL_INVALID_ENUM)); |
| 913 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | // we assume the parameter passed to this validation method is truncated, not rounded |
| 917 | if (param < 1) |
| 918 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 919 | context->recordError(Error(GL_INVALID_VALUE)); |
| 920 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 921 | } |
| 922 | return true; |
| 923 | |
| 924 | case GL_TEXTURE_MIN_LOD: |
| 925 | case GL_TEXTURE_MAX_LOD: |
| 926 | // any value is permissible |
| 927 | return true; |
| 928 | |
| 929 | case GL_TEXTURE_COMPARE_MODE: |
Geoff Lang | 63b5f1f | 2013-09-23 14:52:14 -0400 | [diff] [blame] | 930 | // Acceptable mode parameters from GLES 3.0.2 spec, table 3.17 |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 931 | switch (param) |
| 932 | { |
| 933 | case GL_NONE: |
| 934 | case GL_COMPARE_REF_TO_TEXTURE: |
| 935 | return true; |
| 936 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 937 | context->recordError(Error(GL_INVALID_ENUM)); |
| 938 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 939 | } |
| 940 | break; |
| 941 | |
| 942 | case GL_TEXTURE_COMPARE_FUNC: |
Geoff Lang | 63b5f1f | 2013-09-23 14:52:14 -0400 | [diff] [blame] | 943 | // Acceptable function parameters from GLES 3.0.2 spec, table 3.17 |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 944 | switch (param) |
| 945 | { |
| 946 | case GL_LEQUAL: |
| 947 | case GL_GEQUAL: |
| 948 | case GL_LESS: |
| 949 | case GL_GREATER: |
| 950 | case GL_EQUAL: |
| 951 | case GL_NOTEQUAL: |
| 952 | case GL_ALWAYS: |
| 953 | case GL_NEVER: |
| 954 | return true; |
| 955 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 956 | context->recordError(Error(GL_INVALID_ENUM)); |
| 957 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 958 | } |
| 959 | break; |
| 960 | |
| 961 | case GL_TEXTURE_SWIZZLE_R: |
| 962 | case GL_TEXTURE_SWIZZLE_G: |
| 963 | case GL_TEXTURE_SWIZZLE_B: |
| 964 | case GL_TEXTURE_SWIZZLE_A: |
Geoff Lang | bc90a48 | 2013-09-17 16:51:27 -0400 | [diff] [blame] | 965 | switch (param) |
| 966 | { |
| 967 | case GL_RED: |
| 968 | case GL_GREEN: |
| 969 | case GL_BLUE: |
| 970 | case GL_ALPHA: |
| 971 | case GL_ZERO: |
| 972 | case GL_ONE: |
| 973 | return true; |
| 974 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 975 | context->recordError(Error(GL_INVALID_ENUM)); |
| 976 | return false; |
Geoff Lang | bc90a48 | 2013-09-17 16:51:27 -0400 | [diff] [blame] | 977 | } |
| 978 | break; |
| 979 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 980 | case GL_TEXTURE_BASE_LEVEL: |
| 981 | case GL_TEXTURE_MAX_LEVEL: |
Nicolas Capens | 8de6828 | 2014-04-04 11:10:27 -0400 | [diff] [blame] | 982 | if (param < 0) |
| 983 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 984 | context->recordError(Error(GL_INVALID_VALUE)); |
| 985 | return false; |
Nicolas Capens | 8de6828 | 2014-04-04 11:10:27 -0400 | [diff] [blame] | 986 | } |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 987 | return true; |
| 988 | |
| 989 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 990 | context->recordError(Error(GL_INVALID_ENUM)); |
| 991 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 992 | } |
| 993 | } |
| 994 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 995 | bool ValidateSamplerObjectParameter(gl::Context *context, GLenum pname) |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 996 | { |
| 997 | switch (pname) |
| 998 | { |
| 999 | case GL_TEXTURE_MIN_FILTER: |
| 1000 | case GL_TEXTURE_MAG_FILTER: |
| 1001 | case GL_TEXTURE_WRAP_S: |
| 1002 | case GL_TEXTURE_WRAP_T: |
| 1003 | case GL_TEXTURE_WRAP_R: |
| 1004 | case GL_TEXTURE_MIN_LOD: |
| 1005 | case GL_TEXTURE_MAX_LOD: |
| 1006 | case GL_TEXTURE_COMPARE_MODE: |
| 1007 | case GL_TEXTURE_COMPARE_FUNC: |
| 1008 | return true; |
| 1009 | |
| 1010 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1011 | context->recordError(Error(GL_INVALID_ENUM)); |
| 1012 | return false; |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 1013 | } |
| 1014 | } |
| 1015 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1016 | bool ValidateReadPixels(Context *context, |
| 1017 | GLint x, |
| 1018 | GLint y, |
| 1019 | GLsizei width, |
| 1020 | GLsizei height, |
| 1021 | GLenum format, |
| 1022 | GLenum type, |
| 1023 | GLvoid *pixels) |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1024 | { |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1025 | if (width < 0 || height < 0) |
| 1026 | { |
| 1027 | context->recordError(Error(GL_INVALID_VALUE, "width and height must be positive")); |
| 1028 | return false; |
| 1029 | } |
| 1030 | |
| 1031 | Framebuffer *framebuffer = context->getState().getReadFramebuffer(); |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1032 | ASSERT(framebuffer); |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1033 | |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 1034 | if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1035 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1036 | context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); |
| 1037 | return false; |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1038 | } |
| 1039 | |
Jamie Madill | 48faf80 | 2014-11-06 15:27:22 -0500 | [diff] [blame] | 1040 | if (context->getState().getReadFramebuffer()->id() != 0 && |
| 1041 | framebuffer->getSamples(context->getData()) != 0) |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1042 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1043 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1044 | return false; |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1045 | } |
| 1046 | |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 1047 | const FramebufferAttachment *readBuffer = framebuffer->getReadColorbuffer(); |
| 1048 | if (!readBuffer) |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1049 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1050 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1051 | return false; |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1052 | } |
| 1053 | |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 1054 | GLenum currentFormat = framebuffer->getImplementationColorReadFormat(); |
| 1055 | GLenum currentType = framebuffer->getImplementationColorReadType(); |
Geoff Lang | d8a2258 | 2014-12-17 15:28:23 -0500 | [diff] [blame] | 1056 | GLenum currentInternalFormat = readBuffer->getInternalFormat(); |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 1057 | GLuint clientVersion = context->getClientVersion(); |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1058 | |
Geoff Lang | bdc9b2f | 2014-04-16 14:41:54 -0400 | [diff] [blame] | 1059 | bool validReadFormat = (clientVersion < 3) ? ValidES2ReadFormatType(context, format, type) : |
| 1060 | ValidES3ReadFormatType(context, currentInternalFormat, format, type); |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1061 | |
| 1062 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
| 1063 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1064 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1065 | return false; |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1066 | } |
| 1067 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1068 | return true; |
| 1069 | } |
| 1070 | |
| 1071 | bool ValidateReadnPixelsEXT(Context *context, |
| 1072 | GLint x, |
| 1073 | GLint y, |
| 1074 | GLsizei width, |
| 1075 | GLsizei height, |
| 1076 | GLenum format, |
| 1077 | GLenum type, |
| 1078 | GLsizei bufSize, |
| 1079 | GLvoid *pixels) |
| 1080 | { |
| 1081 | if (bufSize < 0) |
| 1082 | { |
| 1083 | context->recordError(Error(GL_INVALID_VALUE, "bufSize must be a positive number")); |
| 1084 | return false; |
| 1085 | } |
| 1086 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1087 | GLenum sizedInternalFormat = GetSizedInternalFormat(format, type); |
| 1088 | const InternalFormat &sizedFormatInfo = GetInternalFormatInfo(sizedInternalFormat); |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1089 | |
Minmin Gong | adff67b | 2015-10-14 10:34:45 -0400 | [diff] [blame] | 1090 | GLsizei outputPitch = |
| 1091 | sizedFormatInfo.computeRowPitch(type, width, context->getState().getPackAlignment(), |
| 1092 | context->getState().getPackRowLength()); |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1093 | // sized query sanity check |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1094 | int requiredSize = outputPitch * height; |
| 1095 | if (requiredSize > bufSize) |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1096 | { |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1097 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1098 | return false; |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1099 | } |
| 1100 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1101 | return ValidateReadPixels(context, x, y, width, height, format, type, pixels); |
Jamie Madill | 26e9195 | 2014-03-05 15:01:27 -0500 | [diff] [blame] | 1102 | } |
| 1103 | |
Olli Etuaho | 41997e7 | 2016-03-10 13:38:39 +0200 | [diff] [blame] | 1104 | bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1105 | { |
| 1106 | if (!context->getExtensions().occlusionQueryBoolean && |
| 1107 | !context->getExtensions().disjointTimerQuery) |
| 1108 | { |
| 1109 | context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); |
| 1110 | return false; |
| 1111 | } |
| 1112 | |
Olli Etuaho | 41997e7 | 2016-03-10 13:38:39 +0200 | [diff] [blame] | 1113 | return ValidateGenOrDelete(context, n); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1114 | } |
| 1115 | |
Olli Etuaho | 41997e7 | 2016-03-10 13:38:39 +0200 | [diff] [blame] | 1116 | bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1117 | { |
| 1118 | if (!context->getExtensions().occlusionQueryBoolean && |
| 1119 | !context->getExtensions().disjointTimerQuery) |
| 1120 | { |
| 1121 | context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); |
| 1122 | return false; |
| 1123 | } |
| 1124 | |
Olli Etuaho | 41997e7 | 2016-03-10 13:38:39 +0200 | [diff] [blame] | 1125 | return ValidateGenOrDelete(context, n); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1126 | } |
| 1127 | |
| 1128 | bool ValidateBeginQueryBase(gl::Context *context, GLenum target, GLuint id) |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1129 | { |
| 1130 | if (!ValidQueryType(context, target)) |
| 1131 | { |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1132 | context->recordError(Error(GL_INVALID_ENUM, "Invalid query target")); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1133 | return false; |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | if (id == 0) |
| 1137 | { |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1138 | context->recordError(Error(GL_INVALID_OPERATION, "Query id is 0")); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1139 | return false; |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1140 | } |
| 1141 | |
| 1142 | // From EXT_occlusion_query_boolean: If BeginQueryEXT is called with an <id> |
| 1143 | // of zero, if the active query object name for <target> is non-zero (for the |
| 1144 | // targets ANY_SAMPLES_PASSED_EXT and ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, if |
| 1145 | // the active query for either target is non-zero), if <id> is the name of an |
| 1146 | // existing query object whose type does not match <target>, or if <id> is the |
| 1147 | // active query object name for any query type, the error INVALID_OPERATION is |
| 1148 | // generated. |
| 1149 | |
| 1150 | // Ensure no other queries are active |
| 1151 | // NOTE: If other queries than occlusion are supported, we will need to check |
| 1152 | // separately that: |
| 1153 | // a) The query ID passed is not the current active query for any target/type |
| 1154 | // b) There are no active queries for the requested target (and in the case |
| 1155 | // of GL_ANY_SAMPLES_PASSED_EXT and GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, |
| 1156 | // no query may be active for either if glBeginQuery targets either. |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1157 | |
| 1158 | // TODO(ewell): I think this needs to be changed for timer and occlusion queries to work at the |
| 1159 | // same time |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1160 | if (context->getState().isQueryActive()) |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1161 | { |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1162 | context->recordError(Error(GL_INVALID_OPERATION, "Other query is active")); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1163 | return false; |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1164 | } |
| 1165 | |
| 1166 | Query *queryObject = context->getQuery(id, true, target); |
| 1167 | |
| 1168 | // check that name was obtained with glGenQueries |
| 1169 | if (!queryObject) |
| 1170 | { |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1171 | context->recordError(Error(GL_INVALID_OPERATION, "Invalid query id")); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1172 | return false; |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1173 | } |
| 1174 | |
| 1175 | // check for type mismatch |
| 1176 | if (queryObject->getType() != target) |
| 1177 | { |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1178 | context->recordError(Error(GL_INVALID_OPERATION, "Query type does not match target")); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1179 | return false; |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1180 | } |
| 1181 | |
| 1182 | return true; |
| 1183 | } |
| 1184 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1185 | bool ValidateBeginQueryEXT(gl::Context *context, GLenum target, GLuint id) |
| 1186 | { |
| 1187 | if (!context->getExtensions().occlusionQueryBoolean && |
| 1188 | !context->getExtensions().disjointTimerQuery) |
| 1189 | { |
| 1190 | context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); |
| 1191 | return false; |
| 1192 | } |
| 1193 | |
| 1194 | return ValidateBeginQueryBase(context, target, id); |
| 1195 | } |
| 1196 | |
| 1197 | bool ValidateEndQueryBase(gl::Context *context, GLenum target) |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1198 | { |
| 1199 | if (!ValidQueryType(context, target)) |
| 1200 | { |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1201 | context->recordError(Error(GL_INVALID_ENUM, "Invalid query target")); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1202 | return false; |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1203 | } |
| 1204 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1205 | const Query *queryObject = context->getState().getActiveQuery(target); |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1206 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1207 | if (queryObject == nullptr) |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1208 | { |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1209 | context->recordError(Error(GL_INVALID_OPERATION, "Query target not active")); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1210 | return false; |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1211 | } |
| 1212 | |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1213 | return true; |
| 1214 | } |
| 1215 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1216 | bool ValidateEndQueryEXT(gl::Context *context, GLenum target) |
| 1217 | { |
| 1218 | if (!context->getExtensions().occlusionQueryBoolean && |
| 1219 | !context->getExtensions().disjointTimerQuery) |
| 1220 | { |
| 1221 | context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); |
| 1222 | return false; |
| 1223 | } |
| 1224 | |
| 1225 | return ValidateEndQueryBase(context, target); |
| 1226 | } |
| 1227 | |
| 1228 | bool ValidateQueryCounterEXT(Context *context, GLuint id, GLenum target) |
| 1229 | { |
| 1230 | if (!context->getExtensions().disjointTimerQuery) |
| 1231 | { |
| 1232 | context->recordError(Error(GL_INVALID_OPERATION, "Disjoint timer query not enabled")); |
| 1233 | return false; |
| 1234 | } |
| 1235 | |
| 1236 | if (target != GL_TIMESTAMP_EXT) |
| 1237 | { |
| 1238 | context->recordError(Error(GL_INVALID_ENUM, "Invalid query target")); |
| 1239 | return false; |
| 1240 | } |
| 1241 | |
| 1242 | Query *queryObject = context->getQuery(id, true, target); |
| 1243 | if (queryObject == nullptr) |
| 1244 | { |
| 1245 | context->recordError(Error(GL_INVALID_OPERATION, "Invalid query id")); |
| 1246 | return false; |
| 1247 | } |
| 1248 | |
| 1249 | if (context->getState().isQueryActive(queryObject)) |
| 1250 | { |
| 1251 | context->recordError(Error(GL_INVALID_OPERATION, "Query is active")); |
| 1252 | return false; |
| 1253 | } |
| 1254 | |
| 1255 | return true; |
| 1256 | } |
| 1257 | |
| 1258 | bool ValidateGetQueryivBase(Context *context, GLenum target, GLenum pname) |
| 1259 | { |
| 1260 | if (!ValidQueryType(context, target) && target != GL_TIMESTAMP_EXT) |
| 1261 | { |
| 1262 | context->recordError(Error(GL_INVALID_ENUM, "Invalid query type")); |
| 1263 | return false; |
| 1264 | } |
| 1265 | |
| 1266 | switch (pname) |
| 1267 | { |
| 1268 | case GL_CURRENT_QUERY_EXT: |
| 1269 | if (target == GL_TIMESTAMP_EXT) |
| 1270 | { |
| 1271 | context->recordError( |
| 1272 | Error(GL_INVALID_ENUM, "Cannot use current query for timestamp")); |
| 1273 | return false; |
| 1274 | } |
| 1275 | break; |
| 1276 | case GL_QUERY_COUNTER_BITS_EXT: |
| 1277 | if (!context->getExtensions().disjointTimerQuery || |
| 1278 | (target != GL_TIMESTAMP_EXT && target != GL_TIME_ELAPSED_EXT)) |
| 1279 | { |
| 1280 | context->recordError(Error(GL_INVALID_ENUM, "Invalid pname")); |
| 1281 | return false; |
| 1282 | } |
| 1283 | break; |
| 1284 | default: |
| 1285 | context->recordError(Error(GL_INVALID_ENUM, "Invalid pname")); |
| 1286 | return false; |
| 1287 | } |
| 1288 | |
| 1289 | return true; |
| 1290 | } |
| 1291 | |
| 1292 | bool ValidateGetQueryivEXT(Context *context, GLenum target, GLenum pname, GLint *params) |
| 1293 | { |
| 1294 | if (!context->getExtensions().occlusionQueryBoolean && |
| 1295 | !context->getExtensions().disjointTimerQuery) |
| 1296 | { |
| 1297 | context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); |
| 1298 | return false; |
| 1299 | } |
| 1300 | |
| 1301 | return ValidateGetQueryivBase(context, target, pname); |
| 1302 | } |
| 1303 | |
| 1304 | bool ValidateGetQueryObjectValueBase(Context *context, GLuint id, GLenum pname) |
| 1305 | { |
| 1306 | Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 1307 | |
| 1308 | if (!queryObject) |
| 1309 | { |
| 1310 | context->recordError(Error(GL_INVALID_OPERATION, "Query does not exist")); |
| 1311 | return false; |
| 1312 | } |
| 1313 | |
| 1314 | if (context->getState().isQueryActive(queryObject)) |
| 1315 | { |
| 1316 | context->recordError(Error(GL_INVALID_OPERATION, "Query currently active")); |
| 1317 | return false; |
| 1318 | } |
| 1319 | |
| 1320 | switch (pname) |
| 1321 | { |
| 1322 | case GL_QUERY_RESULT_EXT: |
| 1323 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 1324 | break; |
| 1325 | |
| 1326 | default: |
| 1327 | context->recordError(Error(GL_INVALID_ENUM, "Invalid pname enum")); |
| 1328 | return false; |
| 1329 | } |
| 1330 | |
| 1331 | return true; |
| 1332 | } |
| 1333 | |
| 1334 | bool ValidateGetQueryObjectivEXT(Context *context, GLuint id, GLenum pname, GLint *params) |
| 1335 | { |
| 1336 | if (!context->getExtensions().disjointTimerQuery) |
| 1337 | { |
| 1338 | context->recordError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); |
| 1339 | return false; |
| 1340 | } |
| 1341 | return ValidateGetQueryObjectValueBase(context, id, pname); |
| 1342 | } |
| 1343 | |
| 1344 | bool ValidateGetQueryObjectuivEXT(Context *context, GLuint id, GLenum pname, GLuint *params) |
| 1345 | { |
| 1346 | if (!context->getExtensions().disjointTimerQuery && |
| 1347 | !context->getExtensions().occlusionQueryBoolean) |
| 1348 | { |
| 1349 | context->recordError(Error(GL_INVALID_OPERATION, "Query extension not enabled")); |
| 1350 | return false; |
| 1351 | } |
| 1352 | return ValidateGetQueryObjectValueBase(context, id, pname); |
| 1353 | } |
| 1354 | |
| 1355 | bool ValidateGetQueryObjecti64vEXT(Context *context, GLuint id, GLenum pname, GLint64 *params) |
| 1356 | { |
| 1357 | if (!context->getExtensions().disjointTimerQuery) |
| 1358 | { |
| 1359 | context->recordError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); |
| 1360 | return false; |
| 1361 | } |
| 1362 | return ValidateGetQueryObjectValueBase(context, id, pname); |
| 1363 | } |
| 1364 | |
| 1365 | bool ValidateGetQueryObjectui64vEXT(Context *context, GLuint id, GLenum pname, GLuint64 *params) |
| 1366 | { |
| 1367 | if (!context->getExtensions().disjointTimerQuery) |
| 1368 | { |
| 1369 | context->recordError(Error(GL_INVALID_OPERATION, "Timer query extension not enabled")); |
| 1370 | return false; |
| 1371 | } |
| 1372 | return ValidateGetQueryObjectValueBase(context, id, pname); |
| 1373 | } |
| 1374 | |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 1375 | static bool ValidateUniformCommonBase(gl::Context *context, |
| 1376 | GLenum targetUniformType, |
| 1377 | GLint location, |
| 1378 | GLsizei count, |
| 1379 | const LinkedUniform **uniformOut) |
Jamie Madill | d7c7bb2 | 2014-05-20 10:55:54 -0400 | [diff] [blame] | 1380 | { |
| 1381 | if (count < 0) |
| 1382 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1383 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1384 | return false; |
Jamie Madill | d7c7bb2 | 2014-05-20 10:55:54 -0400 | [diff] [blame] | 1385 | } |
| 1386 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1387 | gl::Program *program = context->getState().getProgram(); |
| 1388 | if (!program) |
Jamie Madill | d7c7bb2 | 2014-05-20 10:55:54 -0400 | [diff] [blame] | 1389 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1390 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1391 | return false; |
Jamie Madill | d7c7bb2 | 2014-05-20 10:55:54 -0400 | [diff] [blame] | 1392 | } |
| 1393 | |
| 1394 | if (location == -1) |
| 1395 | { |
| 1396 | // Silently ignore the uniform command |
| 1397 | return false; |
| 1398 | } |
| 1399 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1400 | if (!program->isValidUniformLocation(location)) |
Jamie Madill | 3639892 | 2014-05-20 14:51:53 -0400 | [diff] [blame] | 1401 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1402 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1403 | return false; |
Jamie Madill | 3639892 | 2014-05-20 14:51:53 -0400 | [diff] [blame] | 1404 | } |
| 1405 | |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 1406 | const LinkedUniform &uniform = program->getUniformByLocation(location); |
Jamie Madill | 3639892 | 2014-05-20 14:51:53 -0400 | [diff] [blame] | 1407 | |
| 1408 | // attempting to write an array to a non-array uniform is an INVALID_OPERATION |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 1409 | if (!uniform.isArray() && count > 1) |
Jamie Madill | 3639892 | 2014-05-20 14:51:53 -0400 | [diff] [blame] | 1410 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1411 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1412 | return false; |
Jamie Madill | 3639892 | 2014-05-20 14:51:53 -0400 | [diff] [blame] | 1413 | } |
| 1414 | |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 1415 | *uniformOut = &uniform; |
Jamie Madill | d7c7bb2 | 2014-05-20 10:55:54 -0400 | [diff] [blame] | 1416 | return true; |
| 1417 | } |
| 1418 | |
Jamie Madill | aa981bd | 2014-05-20 10:55:55 -0400 | [diff] [blame] | 1419 | bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, GLsizei count) |
| 1420 | { |
| 1421 | // Check for ES3 uniform entry points |
Jamie Madill | f257598 | 2014-06-25 16:04:54 -0400 | [diff] [blame] | 1422 | if (VariableComponentType(uniformType) == GL_UNSIGNED_INT && context->getClientVersion() < 3) |
Jamie Madill | aa981bd | 2014-05-20 10:55:55 -0400 | [diff] [blame] | 1423 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1424 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1425 | return false; |
Jamie Madill | aa981bd | 2014-05-20 10:55:55 -0400 | [diff] [blame] | 1426 | } |
| 1427 | |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 1428 | const LinkedUniform *uniform = nullptr; |
Jamie Madill | 3639892 | 2014-05-20 14:51:53 -0400 | [diff] [blame] | 1429 | if (!ValidateUniformCommonBase(context, uniformType, location, count, &uniform)) |
| 1430 | { |
| 1431 | return false; |
| 1432 | } |
| 1433 | |
Jamie Madill | f257598 | 2014-06-25 16:04:54 -0400 | [diff] [blame] | 1434 | GLenum targetBoolType = VariableBoolVectorType(uniformType); |
Geoff Lang | 2ec386b | 2014-12-03 14:44:38 -0500 | [diff] [blame] | 1435 | bool samplerUniformCheck = (IsSamplerType(uniform->type) && uniformType == GL_INT); |
Jamie Madill | 3639892 | 2014-05-20 14:51:53 -0400 | [diff] [blame] | 1436 | if (!samplerUniformCheck && uniformType != uniform->type && targetBoolType != uniform->type) |
| 1437 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1438 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1439 | return false; |
Jamie Madill | 3639892 | 2014-05-20 14:51:53 -0400 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | return true; |
Jamie Madill | aa981bd | 2014-05-20 10:55:55 -0400 | [diff] [blame] | 1443 | } |
| 1444 | |
| 1445 | bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint location, GLsizei count, |
| 1446 | GLboolean transpose) |
| 1447 | { |
| 1448 | // Check for ES3 uniform entry points |
| 1449 | int rows = VariableRowCount(matrixType); |
| 1450 | int cols = VariableColumnCount(matrixType); |
| 1451 | if (rows != cols && context->getClientVersion() < 3) |
| 1452 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1453 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1454 | return false; |
Jamie Madill | aa981bd | 2014-05-20 10:55:55 -0400 | [diff] [blame] | 1455 | } |
| 1456 | |
| 1457 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 1458 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1459 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1460 | return false; |
Jamie Madill | aa981bd | 2014-05-20 10:55:55 -0400 | [diff] [blame] | 1461 | } |
| 1462 | |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 1463 | const LinkedUniform *uniform = nullptr; |
Jamie Madill | 3639892 | 2014-05-20 14:51:53 -0400 | [diff] [blame] | 1464 | if (!ValidateUniformCommonBase(context, matrixType, location, count, &uniform)) |
| 1465 | { |
| 1466 | return false; |
| 1467 | } |
| 1468 | |
| 1469 | if (uniform->type != matrixType) |
| 1470 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1471 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1472 | return false; |
Jamie Madill | 3639892 | 2014-05-20 14:51:53 -0400 | [diff] [blame] | 1473 | } |
| 1474 | |
| 1475 | return true; |
Jamie Madill | aa981bd | 2014-05-20 10:55:55 -0400 | [diff] [blame] | 1476 | } |
| 1477 | |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1478 | bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, unsigned int *numParams) |
| 1479 | { |
| 1480 | if (!context->getQueryParameterInfo(pname, nativeType, numParams)) |
| 1481 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1482 | context->recordError(Error(GL_INVALID_ENUM)); |
| 1483 | return false; |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1484 | } |
| 1485 | |
Jamie Madill | 0af26e1 | 2015-03-05 19:54:33 -0500 | [diff] [blame] | 1486 | const Caps &caps = context->getCaps(); |
| 1487 | |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1488 | if (pname >= GL_DRAW_BUFFER0 && pname <= GL_DRAW_BUFFER15) |
| 1489 | { |
| 1490 | unsigned int colorAttachment = (pname - GL_DRAW_BUFFER0); |
| 1491 | |
Jamie Madill | 0af26e1 | 2015-03-05 19:54:33 -0500 | [diff] [blame] | 1492 | if (colorAttachment >= caps.maxDrawBuffers) |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1493 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1494 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1495 | return false; |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1496 | } |
| 1497 | } |
| 1498 | |
| 1499 | switch (pname) |
| 1500 | { |
| 1501 | case GL_TEXTURE_BINDING_2D: |
| 1502 | case GL_TEXTURE_BINDING_CUBE_MAP: |
| 1503 | case GL_TEXTURE_BINDING_3D: |
| 1504 | case GL_TEXTURE_BINDING_2D_ARRAY: |
Jamie Madill | 0af26e1 | 2015-03-05 19:54:33 -0500 | [diff] [blame] | 1505 | if (context->getState().getActiveSampler() >= caps.maxCombinedTextureImageUnits) |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1506 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1507 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1508 | return false; |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1509 | } |
| 1510 | break; |
| 1511 | |
| 1512 | case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 1513 | case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 1514 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1515 | Framebuffer *framebuffer = context->getState().getReadFramebuffer(); |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1516 | ASSERT(framebuffer); |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 1517 | if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1518 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1519 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1520 | return false; |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1521 | } |
| 1522 | |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 1523 | const FramebufferAttachment *attachment = framebuffer->getReadColorbuffer(); |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 1524 | if (!attachment) |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1525 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1526 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1527 | return false; |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1528 | } |
| 1529 | } |
| 1530 | break; |
| 1531 | |
| 1532 | default: |
| 1533 | break; |
| 1534 | } |
| 1535 | |
| 1536 | // pname is valid, but there are no parameters to return |
| 1537 | if (numParams == 0) |
| 1538 | { |
| 1539 | return false; |
| 1540 | } |
| 1541 | |
| 1542 | return true; |
| 1543 | } |
| 1544 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1545 | bool ValidateCopyTexImageParametersBase(ValidationContext *context, |
| 1546 | GLenum target, |
| 1547 | GLint level, |
| 1548 | GLenum internalformat, |
| 1549 | bool isSubImage, |
| 1550 | GLint xoffset, |
| 1551 | GLint yoffset, |
| 1552 | GLint zoffset, |
| 1553 | GLint x, |
| 1554 | GLint y, |
| 1555 | GLsizei width, |
| 1556 | GLsizei height, |
| 1557 | GLint border, |
| 1558 | GLenum *textureFormatOut) |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1559 | { |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1560 | if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0) |
| 1561 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1562 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1563 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1564 | } |
| 1565 | |
| 1566 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 1567 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1568 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1569 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1570 | } |
| 1571 | |
| 1572 | if (border != 0) |
| 1573 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1574 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1575 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1576 | } |
| 1577 | |
| 1578 | if (!ValidMipLevel(context, target, level)) |
| 1579 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1580 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1581 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1582 | } |
| 1583 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1584 | const gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 1585 | if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1586 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1587 | context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); |
| 1588 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1589 | } |
| 1590 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1591 | const auto &state = context->getState(); |
| 1592 | if (state.getReadFramebuffer()->id() != 0 && framebuffer->getSamples(context->getData()) != 0) |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1593 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1594 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1595 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1596 | } |
| 1597 | |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 1598 | const gl::Caps &caps = context->getCaps(); |
| 1599 | |
Geoff Lang | aae65a4 | 2014-05-26 12:43:44 -0400 | [diff] [blame] | 1600 | GLuint maxDimension = 0; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1601 | switch (target) |
| 1602 | { |
| 1603 | case GL_TEXTURE_2D: |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1604 | maxDimension = caps.max2DTextureSize; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1605 | break; |
| 1606 | |
| 1607 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1608 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1609 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1610 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1611 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1612 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1613 | maxDimension = caps.maxCubeMapTextureSize; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1614 | break; |
| 1615 | |
| 1616 | case GL_TEXTURE_2D_ARRAY: |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1617 | maxDimension = caps.max2DTextureSize; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1618 | break; |
| 1619 | |
| 1620 | case GL_TEXTURE_3D: |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1621 | maxDimension = caps.max3DTextureSize; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1622 | break; |
| 1623 | |
| 1624 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1625 | context->recordError(Error(GL_INVALID_ENUM)); |
| 1626 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1627 | } |
| 1628 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 1629 | gl::Texture *texture = |
| 1630 | state.getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1631 | if (!texture) |
| 1632 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1633 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1634 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1635 | } |
| 1636 | |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 1637 | if (texture->getImmutableFormat() && !isSubImage) |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1638 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1639 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1640 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1641 | } |
| 1642 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1643 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); |
| 1644 | |
| 1645 | if (formatInfo.depthBits > 0) |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1646 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1647 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1648 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1649 | } |
| 1650 | |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1651 | if (formatInfo.compressed && !ValidCompressedImageSize(context, internalformat, width, height)) |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1652 | { |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1653 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1654 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1655 | } |
| 1656 | |
| 1657 | if (isSubImage) |
| 1658 | { |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1659 | if (static_cast<size_t>(xoffset + width) > texture->getWidth(target, level) || |
| 1660 | static_cast<size_t>(yoffset + height) > texture->getHeight(target, level) || |
| 1661 | static_cast<size_t>(zoffset) >= texture->getDepth(target, level)) |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1662 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1663 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1664 | return false; |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1665 | } |
| 1666 | } |
Jamie Madill | 6f38f82 | 2014-06-06 17:12:20 -0400 | [diff] [blame] | 1667 | else |
| 1668 | { |
Geoff Lang | 691e58c | 2014-12-19 17:03:25 -0500 | [diff] [blame] | 1669 | if (IsCubeMapTextureTarget(target) && width != height) |
Jamie Madill | 6f38f82 | 2014-06-06 17:12:20 -0400 | [diff] [blame] | 1670 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1671 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1672 | return false; |
Jamie Madill | 6f38f82 | 2014-06-06 17:12:20 -0400 | [diff] [blame] | 1673 | } |
| 1674 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1675 | if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions())) |
Jamie Madill | 6f38f82 | 2014-06-06 17:12:20 -0400 | [diff] [blame] | 1676 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1677 | context->recordError(Error(GL_INVALID_ENUM)); |
| 1678 | return false; |
Jamie Madill | 6f38f82 | 2014-06-06 17:12:20 -0400 | [diff] [blame] | 1679 | } |
| 1680 | |
| 1681 | int maxLevelDimension = (maxDimension >> level); |
| 1682 | if (static_cast<int>(width) > maxLevelDimension || static_cast<int>(height) > maxLevelDimension) |
| 1683 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1684 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1685 | return false; |
Jamie Madill | 6f38f82 | 2014-06-06 17:12:20 -0400 | [diff] [blame] | 1686 | } |
| 1687 | } |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1688 | |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 1689 | *textureFormatOut = texture->getInternalFormat(target, level); |
Jamie Madill | 560a8d8 | 2014-05-21 13:06:20 -0400 | [diff] [blame] | 1690 | return true; |
| 1691 | } |
| 1692 | |
Jamie Madill | f25855c | 2015-11-03 11:06:18 -0500 | [diff] [blame] | 1693 | static bool ValidateDrawBase(ValidationContext *context, |
| 1694 | GLenum mode, |
| 1695 | GLsizei count, |
| 1696 | GLsizei primcount) |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1697 | { |
Jamie Madill | 1aeb131 | 2014-06-20 13:21:25 -0400 | [diff] [blame] | 1698 | switch (mode) |
| 1699 | { |
| 1700 | case GL_POINTS: |
| 1701 | case GL_LINES: |
| 1702 | case GL_LINE_LOOP: |
| 1703 | case GL_LINE_STRIP: |
| 1704 | case GL_TRIANGLES: |
| 1705 | case GL_TRIANGLE_STRIP: |
| 1706 | case GL_TRIANGLE_FAN: |
| 1707 | break; |
| 1708 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1709 | context->recordError(Error(GL_INVALID_ENUM)); |
| 1710 | return false; |
Jamie Madill | 1aeb131 | 2014-06-20 13:21:25 -0400 | [diff] [blame] | 1711 | } |
| 1712 | |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1713 | if (count < 0) |
| 1714 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1715 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1716 | return false; |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1717 | } |
| 1718 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1719 | const State &state = context->getState(); |
| 1720 | |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1721 | // Check for mapped buffers |
Jamie Madill | d9ba4f7 | 2014-08-04 10:47:59 -0400 | [diff] [blame] | 1722 | if (state.hasMappedBuffer(GL_ARRAY_BUFFER)) |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1723 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1724 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1725 | return false; |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1726 | } |
| 1727 | |
Geoff Lang | 3a86ad3 | 2015-09-01 11:47:05 -0400 | [diff] [blame] | 1728 | if (context->getLimitations().noSeparateStencilRefsAndMasks) |
Jamie Madill | ac52801 | 2014-06-20 13:21:23 -0400 | [diff] [blame] | 1729 | { |
Jinyoung Hur | 85769f0 | 2015-10-20 17:08:44 -0400 | [diff] [blame] | 1730 | const Framebuffer *framebuffer = context->getState().getDrawFramebuffer(); |
| 1731 | const FramebufferAttachment *stencilBuffer = framebuffer->getStencilbuffer(); |
| 1732 | GLuint stencilBits = stencilBuffer ? stencilBuffer->getStencilSize() : 0; |
| 1733 | GLuint minimumRequiredStencilMask = (1 << stencilBits) - 1; |
| 1734 | const DepthStencilState &depthStencilState = state.getDepthStencilState(); |
| 1735 | if ((depthStencilState.stencilWritemask & minimumRequiredStencilMask) != |
| 1736 | (depthStencilState.stencilBackWritemask & minimumRequiredStencilMask) || |
Geoff Lang | 3a86ad3 | 2015-09-01 11:47:05 -0400 | [diff] [blame] | 1737 | state.getStencilRef() != state.getStencilBackRef() || |
Jinyoung Hur | 85769f0 | 2015-10-20 17:08:44 -0400 | [diff] [blame] | 1738 | (depthStencilState.stencilMask & minimumRequiredStencilMask) != |
| 1739 | (depthStencilState.stencilBackMask & minimumRequiredStencilMask)) |
Geoff Lang | 3a86ad3 | 2015-09-01 11:47:05 -0400 | [diff] [blame] | 1740 | { |
| 1741 | // Note: these separate values are not supported in WebGL, due to D3D's limitations. See |
| 1742 | // Section 6.10 of the WebGL 1.0 spec |
| 1743 | ERR( |
| 1744 | "This ANGLE implementation does not support separate front/back stencil " |
| 1745 | "writemasks, reference values, or stencil mask values."); |
| 1746 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1747 | return false; |
| 1748 | } |
Jamie Madill | ac52801 | 2014-06-20 13:21:23 -0400 | [diff] [blame] | 1749 | } |
| 1750 | |
Jamie Madill | d9ba4f7 | 2014-08-04 10:47:59 -0400 | [diff] [blame] | 1751 | const gl::Framebuffer *fbo = state.getDrawFramebuffer(); |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 1752 | if (!fbo || fbo->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE) |
Jamie Madill | 13f7d7d | 2014-06-20 13:21:27 -0400 | [diff] [blame] | 1753 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1754 | context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); |
| 1755 | return false; |
Jamie Madill | 13f7d7d | 2014-06-20 13:21:27 -0400 | [diff] [blame] | 1756 | } |
| 1757 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1758 | gl::Program *program = state.getProgram(); |
| 1759 | if (!program) |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 1760 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1761 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1762 | return false; |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 1763 | } |
| 1764 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1765 | if (!program->validateSamplers(NULL, context->getCaps())) |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 1766 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1767 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1768 | return false; |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 1769 | } |
| 1770 | |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 1771 | // Uniform buffer validation |
| 1772 | for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < program->getActiveUniformBlockCount(); uniformBlockIndex++) |
| 1773 | { |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 1774 | const gl::UniformBlock &uniformBlock = program->getUniformBlockByIndex(uniformBlockIndex); |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 1775 | GLuint blockBinding = program->getUniformBlockBinding(uniformBlockIndex); |
Geoff Lang | 5d124a6 | 2015-09-15 13:03:27 -0400 | [diff] [blame] | 1776 | const OffsetBindingPointer<Buffer> &uniformBuffer = |
| 1777 | state.getIndexedUniformBuffer(blockBinding); |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 1778 | |
Geoff Lang | 5d124a6 | 2015-09-15 13:03:27 -0400 | [diff] [blame] | 1779 | if (uniformBuffer.get() == nullptr) |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 1780 | { |
| 1781 | // undefined behaviour |
| 1782 | context->recordError(Error(GL_INVALID_OPERATION, "It is undefined behaviour to have a used but unbound uniform buffer.")); |
| 1783 | return false; |
| 1784 | } |
| 1785 | |
Geoff Lang | 5d124a6 | 2015-09-15 13:03:27 -0400 | [diff] [blame] | 1786 | size_t uniformBufferSize = uniformBuffer.getSize(); |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 1787 | if (uniformBufferSize == 0) |
| 1788 | { |
| 1789 | // Bind the whole buffer. |
Minmin Gong | 794e000 | 2015-04-07 18:31:54 -0700 | [diff] [blame] | 1790 | uniformBufferSize = static_cast<size_t>(uniformBuffer->getSize()); |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 1791 | } |
| 1792 | |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 1793 | if (uniformBufferSize < uniformBlock.dataSize) |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 1794 | { |
| 1795 | // undefined behaviour |
| 1796 | context->recordError(Error(GL_INVALID_OPERATION, "It is undefined behaviour to use a uniform buffer that is too small.")); |
| 1797 | return false; |
| 1798 | } |
| 1799 | } |
| 1800 | |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1801 | // No-op if zero count |
| 1802 | return (count > 0); |
| 1803 | } |
| 1804 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1805 | bool ValidateDrawArrays(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1806 | { |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 1807 | if (first < 0) |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1808 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1809 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1810 | return false; |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1811 | } |
| 1812 | |
Jamie Madill | d9ba4f7 | 2014-08-04 10:47:59 -0400 | [diff] [blame] | 1813 | const State &state = context->getState(); |
| 1814 | gl::TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback(); |
Geoff Lang | bb0a0bb | 2015-03-27 12:16:57 -0400 | [diff] [blame] | 1815 | if (curTransformFeedback && curTransformFeedback->isActive() && !curTransformFeedback->isPaused() && |
| 1816 | curTransformFeedback->getPrimitiveMode() != mode) |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 1817 | { |
| 1818 | // It is an invalid operation to call DrawArrays or DrawArraysInstanced with a draw mode |
| 1819 | // that does not match the current transform feedback object's draw mode (if transform feedback |
| 1820 | // is active), (3.0.2, section 2.14, pg 86) |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1821 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1822 | return false; |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 1823 | } |
| 1824 | |
Corentin Wallez | 18a2fb3 | 2015-08-10 12:58:14 -0700 | [diff] [blame] | 1825 | if (!ValidateDrawBase(context, mode, count, primcount)) |
| 1826 | { |
| 1827 | return false; |
| 1828 | } |
| 1829 | |
| 1830 | if (!ValidateDrawAttribs(context, primcount, count)) |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 1831 | { |
| 1832 | return false; |
| 1833 | } |
| 1834 | |
| 1835 | return true; |
| 1836 | } |
| 1837 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1838 | bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 1839 | { |
| 1840 | if (primcount < 0) |
| 1841 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1842 | context->recordError(Error(GL_INVALID_VALUE)); |
| 1843 | return false; |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 1844 | } |
| 1845 | |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1846 | if (!ValidateDrawArrays(context, mode, first, count, primcount)) |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 1847 | { |
| 1848 | return false; |
| 1849 | } |
| 1850 | |
| 1851 | // No-op if zero primitive count |
| 1852 | return (primcount > 0); |
| 1853 | } |
| 1854 | |
Geoff Lang | 87a9330 | 2014-09-16 13:29:43 -0400 | [diff] [blame] | 1855 | static bool ValidateDrawInstancedANGLE(Context *context) |
| 1856 | { |
| 1857 | // Verify there is at least one active attribute with a divisor of zero |
| 1858 | const gl::State& state = context->getState(); |
| 1859 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1860 | gl::Program *program = state.getProgram(); |
Geoff Lang | 87a9330 | 2014-09-16 13:29:43 -0400 | [diff] [blame] | 1861 | |
| 1862 | const VertexArray *vao = state.getVertexArray(); |
Jamie Madill | 63805b4 | 2015-08-25 13:17:39 -0400 | [diff] [blame] | 1863 | for (size_t attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++) |
Geoff Lang | 87a9330 | 2014-09-16 13:29:43 -0400 | [diff] [blame] | 1864 | { |
| 1865 | const VertexAttribute &attrib = vao->getVertexAttribute(attributeIndex); |
Jamie Madill | 63805b4 | 2015-08-25 13:17:39 -0400 | [diff] [blame] | 1866 | if (program->isAttribLocationActive(attributeIndex) && attrib.divisor == 0) |
Geoff Lang | 87a9330 | 2014-09-16 13:29:43 -0400 | [diff] [blame] | 1867 | { |
| 1868 | return true; |
| 1869 | } |
| 1870 | } |
| 1871 | |
| 1872 | context->recordError(Error(GL_INVALID_OPERATION, "ANGLE_instanced_arrays requires that at least one active attribute" |
| 1873 | "has a divisor of zero.")); |
| 1874 | return false; |
| 1875 | } |
| 1876 | |
| 1877 | bool ValidateDrawArraysInstancedANGLE(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 1878 | { |
| 1879 | if (!ValidateDrawInstancedANGLE(context)) |
| 1880 | { |
| 1881 | return false; |
| 1882 | } |
| 1883 | |
| 1884 | return ValidateDrawArraysInstanced(context, mode, first, count, primcount); |
| 1885 | } |
| 1886 | |
Jamie Madill | f25855c | 2015-11-03 11:06:18 -0500 | [diff] [blame] | 1887 | bool ValidateDrawElements(ValidationContext *context, |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 1888 | GLenum mode, |
| 1889 | GLsizei count, |
| 1890 | GLenum type, |
| 1891 | const GLvoid *indices, |
| 1892 | GLsizei primcount, |
| 1893 | IndexRange *indexRangeOut) |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 1894 | { |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1895 | switch (type) |
| 1896 | { |
| 1897 | case GL_UNSIGNED_BYTE: |
| 1898 | case GL_UNSIGNED_SHORT: |
| 1899 | break; |
| 1900 | case GL_UNSIGNED_INT: |
Jamie Madill | e79b1e1 | 2015-11-04 16:36:37 -0500 | [diff] [blame] | 1901 | if (context->getClientVersion() < 3 && !context->getExtensions().elementIndexUint) |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1902 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1903 | context->recordError(Error(GL_INVALID_ENUM)); |
| 1904 | return false; |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1905 | } |
| 1906 | break; |
| 1907 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1908 | context->recordError(Error(GL_INVALID_ENUM)); |
| 1909 | return false; |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1910 | } |
| 1911 | |
Jamie Madill | d9ba4f7 | 2014-08-04 10:47:59 -0400 | [diff] [blame] | 1912 | const State &state = context->getState(); |
| 1913 | |
| 1914 | gl::TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback(); |
Geoff Lang | bb0a0bb | 2015-03-27 12:16:57 -0400 | [diff] [blame] | 1915 | if (curTransformFeedback && curTransformFeedback->isActive() && !curTransformFeedback->isPaused()) |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1916 | { |
| 1917 | // It is an invalid operation to call DrawElements, DrawRangeElements or DrawElementsInstanced |
| 1918 | // while transform feedback is active, (3.0.2, section 2.14, pg 86) |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1919 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1920 | return false; |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1921 | } |
| 1922 | |
| 1923 | // Check for mapped buffers |
Jamie Madill | d9ba4f7 | 2014-08-04 10:47:59 -0400 | [diff] [blame] | 1924 | if (state.hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER)) |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1925 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1926 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1927 | return false; |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 1928 | } |
| 1929 | |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1930 | const gl::VertexArray *vao = state.getVertexArray(); |
Jamie Madill | 8e34494 | 2015-07-09 14:22:07 -0400 | [diff] [blame] | 1931 | gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer().get(); |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1932 | if (!indices && !elementArrayBuffer) |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 1933 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1934 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1935 | return false; |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 1936 | } |
| 1937 | |
Jamie Madill | ae3000b | 2014-08-25 15:47:51 -0400 | [diff] [blame] | 1938 | if (elementArrayBuffer) |
| 1939 | { |
| 1940 | const gl::Type &typeInfo = gl::GetTypeInfo(type); |
| 1941 | |
| 1942 | GLint64 offset = reinterpret_cast<GLint64>(indices); |
| 1943 | GLint64 byteCount = static_cast<GLint64>(typeInfo.bytes) * static_cast<GLint64>(count)+offset; |
| 1944 | |
| 1945 | // check for integer overflows |
| 1946 | if (static_cast<GLuint>(count) > (std::numeric_limits<GLuint>::max() / typeInfo.bytes) || |
| 1947 | byteCount > static_cast<GLint64>(std::numeric_limits<GLuint>::max())) |
| 1948 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1949 | context->recordError(Error(GL_OUT_OF_MEMORY)); |
| 1950 | return false; |
Jamie Madill | ae3000b | 2014-08-25 15:47:51 -0400 | [diff] [blame] | 1951 | } |
| 1952 | |
| 1953 | // Check for reading past the end of the bound buffer object |
| 1954 | if (byteCount > elementArrayBuffer->getSize()) |
| 1955 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1956 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1957 | return false; |
Jamie Madill | ae3000b | 2014-08-25 15:47:51 -0400 | [diff] [blame] | 1958 | } |
| 1959 | } |
| 1960 | else if (!indices) |
| 1961 | { |
| 1962 | // Catch this programming error here |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1963 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 1964 | return false; |
Jamie Madill | ae3000b | 2014-08-25 15:47:51 -0400 | [diff] [blame] | 1965 | } |
| 1966 | |
Corentin Wallez | 18a2fb3 | 2015-08-10 12:58:14 -0700 | [diff] [blame] | 1967 | if (!ValidateDrawBase(context, mode, count, primcount)) |
| 1968 | { |
| 1969 | return false; |
| 1970 | } |
| 1971 | |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1972 | // Use max index to validate if our vertex buffers are large enough for the pull. |
| 1973 | // TODO: offer fast path, with disabled index validation. |
| 1974 | // TODO: also disable index checking on back-ends that are robust to out-of-range accesses. |
| 1975 | if (elementArrayBuffer) |
| 1976 | { |
Jacek Caban | a5521de | 2014-10-01 17:23:46 +0200 | [diff] [blame] | 1977 | uintptr_t offset = reinterpret_cast<uintptr_t>(indices); |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 1978 | Error error = |
| 1979 | elementArrayBuffer->getIndexRange(type, static_cast<size_t>(offset), count, |
| 1980 | state.isPrimitiveRestartEnabled(), indexRangeOut); |
Geoff Lang | 520c4ae | 2015-05-05 13:12:36 -0400 | [diff] [blame] | 1981 | if (error.isError()) |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1982 | { |
Geoff Lang | 520c4ae | 2015-05-05 13:12:36 -0400 | [diff] [blame] | 1983 | context->recordError(error); |
| 1984 | return false; |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1985 | } |
| 1986 | } |
| 1987 | else |
| 1988 | { |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 1989 | *indexRangeOut = ComputeIndexRange(type, indices, count, state.isPrimitiveRestartEnabled()); |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1990 | } |
| 1991 | |
Jamie Madill | e79b1e1 | 2015-11-04 16:36:37 -0500 | [diff] [blame] | 1992 | // If we use an index greater than our maximum supported index range, return an error. |
| 1993 | // The ES3 spec does not specify behaviour here, it is undefined, but ANGLE should always |
| 1994 | // return an error if possible here. |
| 1995 | if (static_cast<GLuint64>(indexRangeOut->end) >= context->getCaps().maxElementIndex) |
| 1996 | { |
| 1997 | context->recordError(Error(GL_INVALID_OPERATION, g_ExceedsMaxElementErrorMessage)); |
| 1998 | return false; |
| 1999 | } |
| 2000 | |
Jamie Madill | bc4c4bc | 2016-03-23 21:04:43 -0400 | [diff] [blame] | 2001 | if (!ValidateDrawAttribs(context, primcount, static_cast<GLint>(indexRangeOut->vertexCount()))) |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 2002 | { |
| 2003 | return false; |
| 2004 | } |
| 2005 | |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 2006 | // No op if there are no real indices in the index data (all are primitive restart). |
| 2007 | return (indexRangeOut->vertexIndexCount > 0); |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 2008 | } |
| 2009 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2010 | bool ValidateDrawElementsInstanced(Context *context, |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 2011 | GLenum mode, |
| 2012 | GLsizei count, |
| 2013 | GLenum type, |
| 2014 | const GLvoid *indices, |
| 2015 | GLsizei primcount, |
| 2016 | IndexRange *indexRangeOut) |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 2017 | { |
| 2018 | if (primcount < 0) |
| 2019 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2020 | context->recordError(Error(GL_INVALID_VALUE)); |
| 2021 | return false; |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 2022 | } |
| 2023 | |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 2024 | if (!ValidateDrawElements(context, mode, count, type, indices, primcount, indexRangeOut)) |
Jamie Madill | fd71658 | 2014-06-06 17:09:04 -0400 | [diff] [blame] | 2025 | { |
| 2026 | return false; |
| 2027 | } |
| 2028 | |
| 2029 | // No-op zero primitive count |
| 2030 | return (primcount > 0); |
Jamie Madill | 250d33f | 2014-06-06 17:09:03 -0400 | [diff] [blame] | 2031 | } |
| 2032 | |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 2033 | bool ValidateDrawElementsInstancedANGLE(Context *context, |
| 2034 | GLenum mode, |
| 2035 | GLsizei count, |
| 2036 | GLenum type, |
| 2037 | const GLvoid *indices, |
| 2038 | GLsizei primcount, |
| 2039 | IndexRange *indexRangeOut) |
Geoff Lang | 87a9330 | 2014-09-16 13:29:43 -0400 | [diff] [blame] | 2040 | { |
| 2041 | if (!ValidateDrawInstancedANGLE(context)) |
| 2042 | { |
| 2043 | return false; |
| 2044 | } |
| 2045 | |
| 2046 | return ValidateDrawElementsInstanced(context, mode, count, type, indices, primcount, indexRangeOut); |
| 2047 | } |
| 2048 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2049 | bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum attachment, |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2050 | GLuint texture, GLint level) |
Jamie Madill | 570f7c8 | 2014-07-03 10:38:54 -0400 | [diff] [blame] | 2051 | { |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2052 | if (!ValidFramebufferTarget(target)) |
| 2053 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2054 | context->recordError(Error(GL_INVALID_ENUM)); |
| 2055 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2056 | } |
| 2057 | |
| 2058 | if (!ValidateAttachmentTarget(context, attachment)) |
Jamie Madill | 570f7c8 | 2014-07-03 10:38:54 -0400 | [diff] [blame] | 2059 | { |
| 2060 | return false; |
| 2061 | } |
| 2062 | |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2063 | if (texture != 0) |
| 2064 | { |
| 2065 | gl::Texture *tex = context->getTexture(texture); |
| 2066 | |
| 2067 | if (tex == NULL) |
| 2068 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2069 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 2070 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2071 | } |
| 2072 | |
| 2073 | if (level < 0) |
| 2074 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2075 | context->recordError(Error(GL_INVALID_VALUE)); |
| 2076 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2077 | } |
| 2078 | } |
| 2079 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2080 | const gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
Jamie Madill | 84115c9 | 2015-04-23 15:00:07 -0400 | [diff] [blame] | 2081 | ASSERT(framebuffer); |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2082 | |
Jamie Madill | 84115c9 | 2015-04-23 15:00:07 -0400 | [diff] [blame] | 2083 | if (framebuffer->id() == 0) |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2084 | { |
Jamie Madill | 84115c9 | 2015-04-23 15:00:07 -0400 | [diff] [blame] | 2085 | context->recordError(Error(GL_INVALID_OPERATION, "Cannot change default FBO's attachments")); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2086 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2087 | } |
| 2088 | |
| 2089 | return true; |
| 2090 | } |
| 2091 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2092 | bool ValidateFramebufferTexture2D(Context *context, GLenum target, GLenum attachment, |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2093 | GLenum textarget, GLuint texture, GLint level) |
| 2094 | { |
Geoff Lang | 9566391 | 2015-04-02 15:54:45 -0400 | [diff] [blame] | 2095 | // Attachments are required to be bound to level 0 without ES3 or the GL_OES_fbo_render_mipmap extension |
| 2096 | if (context->getClientVersion() < 3 && !context->getExtensions().fboRenderMipmap && level != 0) |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2097 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2098 | context->recordError(Error(GL_INVALID_VALUE)); |
| 2099 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2100 | } |
| 2101 | |
| 2102 | if (!ValidateFramebufferTextureBase(context, target, attachment, texture, level)) |
Jamie Madill | 570f7c8 | 2014-07-03 10:38:54 -0400 | [diff] [blame] | 2103 | { |
| 2104 | return false; |
| 2105 | } |
| 2106 | |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2107 | if (texture != 0) |
| 2108 | { |
| 2109 | gl::Texture *tex = context->getTexture(texture); |
| 2110 | ASSERT(tex); |
| 2111 | |
Jamie Madill | 2a6564e | 2014-07-11 09:53:19 -0400 | [diff] [blame] | 2112 | const gl::Caps &caps = context->getCaps(); |
| 2113 | |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2114 | switch (textarget) |
| 2115 | { |
| 2116 | case GL_TEXTURE_2D: |
| 2117 | { |
Jamie Madill | 2a6564e | 2014-07-11 09:53:19 -0400 | [diff] [blame] | 2118 | if (level > gl::log2(caps.max2DTextureSize)) |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2119 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2120 | context->recordError(Error(GL_INVALID_VALUE)); |
| 2121 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2122 | } |
| 2123 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 2124 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2125 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 2126 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2127 | } |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2128 | } |
| 2129 | break; |
| 2130 | |
| 2131 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2132 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2133 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2134 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2135 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2136 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 2137 | { |
Jamie Madill | 2a6564e | 2014-07-11 09:53:19 -0400 | [diff] [blame] | 2138 | if (level > gl::log2(caps.maxCubeMapTextureSize)) |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2139 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2140 | context->recordError(Error(GL_INVALID_VALUE)); |
| 2141 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2142 | } |
| 2143 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 2144 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2145 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 2146 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2147 | } |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2148 | } |
| 2149 | break; |
| 2150 | |
| 2151 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2152 | context->recordError(Error(GL_INVALID_ENUM)); |
| 2153 | return false; |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2154 | } |
Geoff Lang | a9be0dc | 2014-12-17 12:34:40 -0500 | [diff] [blame] | 2155 | |
| 2156 | const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(tex->getInternalFormat(textarget, level)); |
| 2157 | if (internalFormatInfo.compressed) |
| 2158 | { |
| 2159 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 2160 | return false; |
| 2161 | } |
Jamie Madill | 55ec3b1 | 2014-07-03 10:38:57 -0400 | [diff] [blame] | 2162 | } |
| 2163 | |
Jamie Madill | 570f7c8 | 2014-07-03 10:38:54 -0400 | [diff] [blame] | 2164 | return true; |
| 2165 | } |
| 2166 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2167 | bool ValidateGetUniformBase(Context *context, GLuint program, GLint location) |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2168 | { |
| 2169 | if (program == 0) |
| 2170 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2171 | context->recordError(Error(GL_INVALID_VALUE)); |
| 2172 | return false; |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2173 | } |
| 2174 | |
Dian Xiang | 769769a | 2015-09-09 15:20:08 -0700 | [diff] [blame] | 2175 | gl::Program *programObject = GetValidProgram(context, program); |
| 2176 | if (!programObject) |
Shannon Woods | 4de4fd6 | 2014-11-07 16:22:02 -0500 | [diff] [blame] | 2177 | { |
| 2178 | return false; |
| 2179 | } |
| 2180 | |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2181 | if (!programObject || !programObject->isLinked()) |
| 2182 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2183 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 2184 | return false; |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2185 | } |
| 2186 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 2187 | if (!programObject->isValidUniformLocation(location)) |
Jamie Madill | 549c7fd | 2014-08-25 15:47:56 -0400 | [diff] [blame] | 2188 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2189 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 2190 | return false; |
Jamie Madill | 549c7fd | 2014-08-25 15:47:56 -0400 | [diff] [blame] | 2191 | } |
| 2192 | |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2193 | return true; |
| 2194 | } |
| 2195 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2196 | bool ValidateGetUniformfv(Context *context, GLuint program, GLint location, GLfloat* params) |
Jamie Madill | 78f4180 | 2014-08-25 15:47:55 -0400 | [diff] [blame] | 2197 | { |
| 2198 | return ValidateGetUniformBase(context, program, location); |
| 2199 | } |
| 2200 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2201 | bool ValidateGetUniformiv(Context *context, GLuint program, GLint location, GLint* params) |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2202 | { |
Jamie Madill | 78f4180 | 2014-08-25 15:47:55 -0400 | [diff] [blame] | 2203 | return ValidateGetUniformBase(context, program, location); |
| 2204 | } |
| 2205 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2206 | static bool ValidateSizedGetUniform(Context *context, GLuint program, GLint location, GLsizei bufSize) |
Jamie Madill | 78f4180 | 2014-08-25 15:47:55 -0400 | [diff] [blame] | 2207 | { |
| 2208 | if (!ValidateGetUniformBase(context, program, location)) |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2209 | { |
Jamie Madill | 78f4180 | 2014-08-25 15:47:55 -0400 | [diff] [blame] | 2210 | return false; |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2211 | } |
| 2212 | |
Jamie Madill | a502c74 | 2014-08-28 17:19:13 -0400 | [diff] [blame] | 2213 | gl::Program *programObject = context->getProgram(program); |
| 2214 | ASSERT(programObject); |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2215 | |
Jamie Madill | 78f4180 | 2014-08-25 15:47:55 -0400 | [diff] [blame] | 2216 | // sized queries -- ensure the provided buffer is large enough |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 2217 | const LinkedUniform &uniform = programObject->getUniformByLocation(location); |
| 2218 | size_t requiredBytes = VariableExternalSize(uniform.type); |
Jamie Madill | 78f4180 | 2014-08-25 15:47:55 -0400 | [diff] [blame] | 2219 | if (static_cast<size_t>(bufSize) < requiredBytes) |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2220 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2221 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 2222 | return false; |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2223 | } |
| 2224 | |
| 2225 | return true; |
| 2226 | } |
| 2227 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2228 | bool ValidateGetnUniformfvEXT(Context *context, GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2229 | { |
Jamie Madill | 78f4180 | 2014-08-25 15:47:55 -0400 | [diff] [blame] | 2230 | return ValidateSizedGetUniform(context, program, location, bufSize); |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2231 | } |
| 2232 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2233 | bool ValidateGetnUniformivEXT(Context *context, GLuint program, GLint location, GLsizei bufSize, GLint* params) |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2234 | { |
Jamie Madill | 78f4180 | 2014-08-25 15:47:55 -0400 | [diff] [blame] | 2235 | return ValidateSizedGetUniform(context, program, location, bufSize); |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 2236 | } |
| 2237 | |
Austin Kinross | 0833263 | 2015-05-05 13:35:47 -0700 | [diff] [blame] | 2238 | bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei numAttachments, |
| 2239 | const GLenum *attachments, bool defaultFramebuffer) |
| 2240 | { |
| 2241 | if (numAttachments < 0) |
| 2242 | { |
| 2243 | context->recordError(Error(GL_INVALID_VALUE, "numAttachments must not be less than zero")); |
| 2244 | return false; |
| 2245 | } |
| 2246 | |
| 2247 | for (GLsizei i = 0; i < numAttachments; ++i) |
| 2248 | { |
Olli Etuaho | 84c9f59 | 2016-03-09 14:37:25 +0200 | [diff] [blame] | 2249 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT31) |
Austin Kinross | 0833263 | 2015-05-05 13:35:47 -0700 | [diff] [blame] | 2250 | { |
| 2251 | if (defaultFramebuffer) |
| 2252 | { |
| 2253 | context->recordError(Error(GL_INVALID_ENUM, "Invalid attachment when the default framebuffer is bound")); |
| 2254 | return false; |
| 2255 | } |
| 2256 | |
| 2257 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getCaps().maxColorAttachments) |
| 2258 | { |
| 2259 | context->recordError(Error(GL_INVALID_OPERATION, |
| 2260 | "Requested color attachment is greater than the maximum supported color attachments")); |
| 2261 | return false; |
| 2262 | } |
| 2263 | } |
| 2264 | else |
| 2265 | { |
| 2266 | switch (attachments[i]) |
| 2267 | { |
| 2268 | case GL_DEPTH_ATTACHMENT: |
| 2269 | case GL_STENCIL_ATTACHMENT: |
| 2270 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 2271 | if (defaultFramebuffer) |
| 2272 | { |
| 2273 | context->recordError(Error(GL_INVALID_ENUM, "Invalid attachment when the default framebuffer is bound")); |
| 2274 | return false; |
| 2275 | } |
| 2276 | break; |
| 2277 | case GL_COLOR: |
| 2278 | case GL_DEPTH: |
| 2279 | case GL_STENCIL: |
| 2280 | if (!defaultFramebuffer) |
| 2281 | { |
| 2282 | context->recordError(Error(GL_INVALID_ENUM, "Invalid attachment when the default framebuffer is not bound")); |
| 2283 | return false; |
| 2284 | } |
| 2285 | break; |
| 2286 | default: |
| 2287 | context->recordError(Error(GL_INVALID_ENUM, "Invalid attachment")); |
| 2288 | return false; |
| 2289 | } |
| 2290 | } |
| 2291 | } |
| 2292 | |
| 2293 | return true; |
| 2294 | } |
| 2295 | |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2296 | bool ValidateInsertEventMarkerEXT(Context *context, GLsizei length, const char *marker) |
| 2297 | { |
| 2298 | // Note that debug marker calls must not set error state |
| 2299 | |
| 2300 | if (length < 0) |
| 2301 | { |
| 2302 | return false; |
| 2303 | } |
| 2304 | |
| 2305 | if (marker == nullptr) |
| 2306 | { |
| 2307 | return false; |
| 2308 | } |
| 2309 | |
| 2310 | return true; |
| 2311 | } |
| 2312 | |
| 2313 | bool ValidatePushGroupMarkerEXT(Context *context, GLsizei length, const char *marker) |
| 2314 | { |
| 2315 | // Note that debug marker calls must not set error state |
| 2316 | |
| 2317 | if (length < 0) |
| 2318 | { |
| 2319 | return false; |
| 2320 | } |
| 2321 | |
| 2322 | if (length > 0 && marker == nullptr) |
| 2323 | { |
| 2324 | return false; |
| 2325 | } |
| 2326 | |
| 2327 | return true; |
| 2328 | } |
| 2329 | |
Geoff Lang | dcab33b | 2015-07-21 13:03:16 -0400 | [diff] [blame] | 2330 | bool ValidateEGLImageTargetTexture2DOES(Context *context, |
| 2331 | egl::Display *display, |
| 2332 | GLenum target, |
| 2333 | egl::Image *image) |
| 2334 | { |
Geoff Lang | a840617 | 2015-07-21 16:53:39 -0400 | [diff] [blame] | 2335 | if (!context->getExtensions().eglImage && !context->getExtensions().eglImageExternal) |
| 2336 | { |
| 2337 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 2338 | return false; |
| 2339 | } |
| 2340 | |
| 2341 | switch (target) |
| 2342 | { |
| 2343 | case GL_TEXTURE_2D: |
| 2344 | break; |
| 2345 | |
| 2346 | default: |
| 2347 | context->recordError(Error(GL_INVALID_ENUM, "invalid texture target.")); |
| 2348 | return false; |
| 2349 | } |
| 2350 | |
| 2351 | if (!display->isValidImage(image)) |
| 2352 | { |
| 2353 | context->recordError(Error(GL_INVALID_VALUE, "EGL image is not valid.")); |
| 2354 | return false; |
| 2355 | } |
| 2356 | |
| 2357 | if (image->getSamples() > 0) |
| 2358 | { |
| 2359 | context->recordError(Error(GL_INVALID_OPERATION, |
| 2360 | "cannot create a 2D texture from a multisampled EGL image.")); |
| 2361 | return false; |
| 2362 | } |
| 2363 | |
| 2364 | const TextureCaps &textureCaps = context->getTextureCaps().get(image->getInternalFormat()); |
| 2365 | if (!textureCaps.texturable) |
| 2366 | { |
| 2367 | context->recordError(Error(GL_INVALID_OPERATION, |
| 2368 | "EGL image internal format is not supported as a texture.")); |
| 2369 | return false; |
| 2370 | } |
| 2371 | |
Geoff Lang | dcab33b | 2015-07-21 13:03:16 -0400 | [diff] [blame] | 2372 | return true; |
| 2373 | } |
| 2374 | |
| 2375 | bool ValidateEGLImageTargetRenderbufferStorageOES(Context *context, |
| 2376 | egl::Display *display, |
| 2377 | GLenum target, |
| 2378 | egl::Image *image) |
| 2379 | { |
Geoff Lang | a840617 | 2015-07-21 16:53:39 -0400 | [diff] [blame] | 2380 | if (!context->getExtensions().eglImage) |
| 2381 | { |
| 2382 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 2383 | return false; |
| 2384 | } |
| 2385 | |
| 2386 | switch (target) |
| 2387 | { |
| 2388 | case GL_RENDERBUFFER: |
| 2389 | break; |
| 2390 | |
| 2391 | default: |
| 2392 | context->recordError(Error(GL_INVALID_ENUM, "invalid renderbuffer target.")); |
| 2393 | return false; |
| 2394 | } |
| 2395 | |
| 2396 | if (!display->isValidImage(image)) |
| 2397 | { |
| 2398 | context->recordError(Error(GL_INVALID_VALUE, "EGL image is not valid.")); |
| 2399 | return false; |
| 2400 | } |
| 2401 | |
| 2402 | const TextureCaps &textureCaps = context->getTextureCaps().get(image->getInternalFormat()); |
| 2403 | if (!textureCaps.renderable) |
| 2404 | { |
| 2405 | context->recordError(Error( |
| 2406 | GL_INVALID_OPERATION, "EGL image internal format is not supported as a renderbuffer.")); |
| 2407 | return false; |
| 2408 | } |
| 2409 | |
Geoff Lang | dcab33b | 2015-07-21 13:03:16 -0400 | [diff] [blame] | 2410 | return true; |
| 2411 | } |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2412 | |
| 2413 | bool ValidateBindVertexArrayBase(Context *context, GLuint array) |
| 2414 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2415 | if (!context->isVertexArrayGenerated(array)) |
Austin Kinross | bc781f3 | 2015-10-26 09:27:38 -0700 | [diff] [blame] | 2416 | { |
| 2417 | // The default VAO should always exist |
| 2418 | ASSERT(array != 0); |
| 2419 | context->recordError(Error(GL_INVALID_OPERATION)); |
| 2420 | return false; |
| 2421 | } |
| 2422 | |
| 2423 | return true; |
| 2424 | } |
| 2425 | |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame^] | 2426 | bool ValidateLinkProgram(Context *context, GLuint program) |
| 2427 | { |
| 2428 | if (context->hasActiveTransformFeedback(program)) |
| 2429 | { |
| 2430 | // ES 3.0.4 section 2.15 page 91 |
| 2431 | context->recordError(Error(GL_INVALID_OPERATION, |
| 2432 | "Cannot link program while program is associated with an active " |
| 2433 | "transform feedback object.")); |
| 2434 | return false; |
| 2435 | } |
| 2436 | return true; |
| 2437 | } |
| 2438 | |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 2439 | bool ValidateProgramBinaryBase(Context *context, |
| 2440 | GLuint program, |
| 2441 | GLenum binaryFormat, |
| 2442 | const void *binary, |
| 2443 | GLint length) |
| 2444 | { |
| 2445 | Program *programObject = GetValidProgram(context, program); |
| 2446 | if (programObject == nullptr) |
| 2447 | { |
| 2448 | return false; |
| 2449 | } |
| 2450 | |
| 2451 | const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats; |
| 2452 | if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == |
| 2453 | programBinaryFormats.end()) |
| 2454 | { |
| 2455 | context->recordError(Error(GL_INVALID_ENUM, "Program binary format is not valid.")); |
| 2456 | return false; |
| 2457 | } |
| 2458 | |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame^] | 2459 | if (context->hasActiveTransformFeedback(program)) |
| 2460 | { |
| 2461 | // ES 3.0.4 section 2.15 page 91 |
| 2462 | context->recordError(Error(GL_INVALID_OPERATION, |
| 2463 | "Cannot change program binary while program is associated with " |
| 2464 | "an active transform feedback object.")); |
| 2465 | return false; |
| 2466 | } |
| 2467 | |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 2468 | return true; |
| 2469 | } |
| 2470 | |
| 2471 | bool ValidateGetProgramBinaryBase(Context *context, |
| 2472 | GLuint program, |
| 2473 | GLsizei bufSize, |
| 2474 | GLsizei *length, |
| 2475 | GLenum *binaryFormat, |
| 2476 | void *binary) |
| 2477 | { |
| 2478 | Program *programObject = GetValidProgram(context, program); |
| 2479 | if (programObject == nullptr) |
| 2480 | { |
| 2481 | return false; |
| 2482 | } |
| 2483 | |
| 2484 | if (!programObject->isLinked()) |
| 2485 | { |
| 2486 | context->recordError(Error(GL_INVALID_OPERATION, "Program is not linked.")); |
| 2487 | return false; |
| 2488 | } |
| 2489 | |
| 2490 | return true; |
| 2491 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2492 | |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame^] | 2493 | bool ValidateUseProgram(Context *context, GLuint program) |
| 2494 | { |
| 2495 | if (program != 0) |
| 2496 | { |
| 2497 | Program *programObject = context->getProgram(program); |
| 2498 | if (!programObject) |
| 2499 | { |
| 2500 | // ES 3.1.0 section 7.3 page 72 |
| 2501 | if (context->getShader(program)) |
| 2502 | { |
| 2503 | context->recordError( |
| 2504 | Error(GL_INVALID_OPERATION, |
| 2505 | "Attempted to use a single shader instead of a shader program.")); |
| 2506 | return false; |
| 2507 | } |
| 2508 | else |
| 2509 | { |
| 2510 | context->recordError(Error(GL_INVALID_VALUE, "Program invalid.")); |
| 2511 | return false; |
| 2512 | } |
| 2513 | } |
| 2514 | if (!programObject->isLinked()) |
| 2515 | { |
| 2516 | context->recordError(Error(GL_INVALID_OPERATION, "Program not linked.")); |
| 2517 | return false; |
| 2518 | } |
| 2519 | } |
| 2520 | if (context->getState().isTransformFeedbackActiveUnpaused()) |
| 2521 | { |
| 2522 | // ES 3.0.4 section 2.15 page 91 |
| 2523 | context->recordError( |
| 2524 | Error(GL_INVALID_OPERATION, |
| 2525 | "Cannot change active program while transform feedback is unpaused.")); |
| 2526 | return false; |
| 2527 | } |
| 2528 | |
| 2529 | return true; |
| 2530 | } |
| 2531 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2532 | bool ValidateCopyTexImage2D(ValidationContext *context, |
| 2533 | GLenum target, |
| 2534 | GLint level, |
| 2535 | GLenum internalformat, |
| 2536 | GLint x, |
| 2537 | GLint y, |
| 2538 | GLsizei width, |
| 2539 | GLsizei height, |
| 2540 | GLint border) |
| 2541 | { |
| 2542 | if (context->getClientVersion() < 3) |
| 2543 | { |
| 2544 | return ValidateES2CopyTexImageParameters(context, target, level, internalformat, false, 0, |
| 2545 | 0, x, y, width, height, border); |
| 2546 | } |
| 2547 | |
| 2548 | ASSERT(context->getClientVersion() == 3); |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 2549 | return ValidateES3CopyTexImage2DParameters(context, target, level, internalformat, false, 0, 0, |
| 2550 | 0, x, y, width, height, border); |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 2551 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2552 | |
| 2553 | bool ValidateFramebufferRenderbuffer(Context *context, |
| 2554 | GLenum target, |
| 2555 | GLenum attachment, |
| 2556 | GLenum renderbuffertarget, |
| 2557 | GLuint renderbuffer) |
| 2558 | { |
| 2559 | if (!ValidFramebufferTarget(target) || |
| 2560 | (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
| 2561 | { |
| 2562 | context->recordError(Error(GL_INVALID_ENUM)); |
| 2563 | return false; |
| 2564 | } |
| 2565 | |
| 2566 | return ValidateFramebufferRenderbufferParameters(context, target, attachment, |
| 2567 | renderbuffertarget, renderbuffer); |
| 2568 | } |
| 2569 | |
| 2570 | bool ValidateDrawBuffersBase(ValidationContext *context, GLsizei n, const GLenum *bufs) |
| 2571 | { |
| 2572 | // INVALID_VALUE is generated if n is negative or greater than value of MAX_DRAW_BUFFERS |
| 2573 | if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers) |
| 2574 | { |
| 2575 | context->recordError( |
| 2576 | Error(GL_INVALID_VALUE, "n must be non-negative and no greater than MAX_DRAW_BUFFERS")); |
| 2577 | return false; |
| 2578 | } |
| 2579 | |
| 2580 | ASSERT(context->getState().getDrawFramebuffer()); |
| 2581 | GLuint frameBufferId = context->getState().getDrawFramebuffer()->id(); |
| 2582 | GLuint maxColorAttachment = GL_COLOR_ATTACHMENT0_EXT + context->getCaps().maxColorAttachments; |
| 2583 | |
| 2584 | // This should come first before the check for the default frame buffer |
| 2585 | // because when we switch to ES3.1+, invalid enums will return INVALID_ENUM |
| 2586 | // rather than INVALID_OPERATION |
| 2587 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 2588 | { |
| 2589 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 2590 | |
| 2591 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != GL_BACK && |
Olli Etuaho | 84c9f59 | 2016-03-09 14:37:25 +0200 | [diff] [blame] | 2592 | (bufs[colorAttachment] < GL_COLOR_ATTACHMENT0 || |
| 2593 | bufs[colorAttachment] > GL_COLOR_ATTACHMENT31)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2594 | { |
| 2595 | // Value in bufs is not NONE, BACK, or GL_COLOR_ATTACHMENTi |
Olli Etuaho | 84c9f59 | 2016-03-09 14:37:25 +0200 | [diff] [blame] | 2596 | // The 3.0.4 spec says to generate GL_INVALID_OPERATION here, but this |
| 2597 | // was changed to GL_INVALID_ENUM in 3.1, which dEQP also expects. |
| 2598 | // 3.1 is still a bit ambiguous about the error, but future specs are |
| 2599 | // expected to clarify that GL_INVALID_ENUM is the correct error. |
| 2600 | context->recordError(Error(GL_INVALID_ENUM, "Invalid buffer value")); |
| 2601 | return false; |
| 2602 | } |
| 2603 | else if (bufs[colorAttachment] >= maxColorAttachment) |
| 2604 | { |
| 2605 | context->recordError( |
| 2606 | Error(GL_INVALID_OPERATION, "Buffer value is greater than MAX_DRAW_BUFFERS")); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2607 | return false; |
| 2608 | } |
| 2609 | else if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment && |
| 2610 | frameBufferId != 0) |
| 2611 | { |
| 2612 | // INVALID_OPERATION-GL is bound to buffer and ith argument |
| 2613 | // is not COLOR_ATTACHMENTi or NONE |
| 2614 | context->recordError( |
| 2615 | Error(GL_INVALID_OPERATION, "Ith value does not match COLOR_ATTACHMENTi or NONE")); |
| 2616 | return false; |
| 2617 | } |
| 2618 | } |
| 2619 | |
| 2620 | // INVALID_OPERATION is generated if GL is bound to the default framebuffer |
| 2621 | // and n is not 1 or bufs is bound to value other than BACK and NONE |
| 2622 | if (frameBufferId == 0) |
| 2623 | { |
| 2624 | if (n != 1) |
| 2625 | { |
| 2626 | context->recordError(Error(GL_INVALID_OPERATION, |
| 2627 | "n must be 1 when GL is bound to the default framebuffer")); |
| 2628 | return false; |
| 2629 | } |
| 2630 | |
| 2631 | if (bufs[0] != GL_NONE && bufs[0] != GL_BACK) |
| 2632 | { |
| 2633 | context->recordError(Error( |
| 2634 | GL_INVALID_OPERATION, |
| 2635 | "Only NONE or BACK are valid values when drawing to the default framebuffer")); |
| 2636 | return false; |
| 2637 | } |
| 2638 | } |
| 2639 | |
| 2640 | return true; |
| 2641 | } |
| 2642 | |
| 2643 | bool ValidateCopyTexSubImage2D(Context *context, |
| 2644 | GLenum target, |
| 2645 | GLint level, |
| 2646 | GLint xoffset, |
| 2647 | GLint yoffset, |
| 2648 | GLint x, |
| 2649 | GLint y, |
| 2650 | GLsizei width, |
| 2651 | GLsizei height) |
| 2652 | { |
| 2653 | if (context->getClientVersion() < 3) |
| 2654 | { |
| 2655 | return ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, |
| 2656 | yoffset, x, y, width, height, 0); |
| 2657 | } |
| 2658 | |
Ian Ewell | fc7cf8e | 2016-01-20 15:57:46 -0500 | [diff] [blame] | 2659 | return ValidateES3CopyTexImage2DParameters(context, target, level, GL_NONE, true, xoffset, |
| 2660 | yoffset, 0, x, y, width, height, 0); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2661 | } |
| 2662 | |
Olli Etuaho | 41997e7 | 2016-03-10 13:38:39 +0200 | [diff] [blame] | 2663 | bool ValidateGenBuffers(Context *context, GLint n, GLuint *) |
| 2664 | { |
| 2665 | return ValidateGenOrDelete(context, n); |
| 2666 | } |
| 2667 | |
| 2668 | bool ValidateDeleteBuffers(Context *context, GLint n, const GLuint *) |
| 2669 | { |
| 2670 | return ValidateGenOrDelete(context, n); |
| 2671 | } |
| 2672 | |
| 2673 | bool ValidateGenFramebuffers(Context *context, GLint n, GLuint *) |
| 2674 | { |
| 2675 | return ValidateGenOrDelete(context, n); |
| 2676 | } |
| 2677 | |
| 2678 | bool ValidateDeleteFramebuffers(Context *context, GLint n, const GLuint *) |
| 2679 | { |
| 2680 | return ValidateGenOrDelete(context, n); |
| 2681 | } |
| 2682 | |
| 2683 | bool ValidateGenRenderbuffers(Context *context, GLint n, GLuint *) |
| 2684 | { |
| 2685 | return ValidateGenOrDelete(context, n); |
| 2686 | } |
| 2687 | |
| 2688 | bool ValidateDeleteRenderbuffers(Context *context, GLint n, const GLuint *) |
| 2689 | { |
| 2690 | return ValidateGenOrDelete(context, n); |
| 2691 | } |
| 2692 | |
| 2693 | bool ValidateGenTextures(Context *context, GLint n, GLuint *) |
| 2694 | { |
| 2695 | return ValidateGenOrDelete(context, n); |
| 2696 | } |
| 2697 | |
| 2698 | bool ValidateDeleteTextures(Context *context, GLint n, const GLuint *) |
| 2699 | { |
| 2700 | return ValidateGenOrDelete(context, n); |
| 2701 | } |
| 2702 | |
| 2703 | bool ValidateGenOrDelete(Context *context, GLint n) |
| 2704 | { |
| 2705 | if (n < 0) |
| 2706 | { |
| 2707 | context->recordError(Error(GL_INVALID_VALUE, "n < 0")); |
| 2708 | return false; |
| 2709 | } |
| 2710 | return true; |
| 2711 | } |
| 2712 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2713 | } // namespace gl |