Jamie Madill | 1e9ae07 | 2014-11-06 15:27:21 -0500 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. |
| 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 | // Data.cpp: Container class for all GL relevant state, caps and objects |
| 8 | |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 9 | #include "libANGLE/ContextState.h" |
Jamie Madill | 51f40ec | 2016-06-15 14:06:00 -0400 | [diff] [blame] | 10 | |
| 11 | #include "libANGLE/Framebuffer.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 12 | #include "libANGLE/ResourceManager.h" |
Jamie Madill | 1e9ae07 | 2014-11-06 15:27:21 -0500 | [diff] [blame] | 13 | |
| 14 | namespace gl |
| 15 | { |
| 16 | |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 17 | namespace |
| 18 | { |
| 19 | |
| 20 | template <typename T> |
| 21 | using ContextStateMember = T *(ContextState::*); |
| 22 | |
| 23 | template <typename T> |
| 24 | T *AllocateOrGetSharedResourceManager(const ContextState *shareContextState, |
| 25 | ContextStateMember<T> member) |
| 26 | { |
| 27 | if (shareContextState) |
| 28 | { |
| 29 | T *resourceManager = (*shareContextState).*member; |
| 30 | resourceManager->addRef(); |
| 31 | return resourceManager; |
| 32 | } |
| 33 | else |
| 34 | { |
| 35 | return new T(); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | } // anonymous namespace |
| 40 | |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 41 | ContextState::ContextState(uintptr_t contextIn, |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 42 | const ContextState *shareContextState, |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 43 | const Version &clientVersion, |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 44 | State *stateIn, |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 45 | const Caps &capsIn, |
| 46 | const TextureCapsMap &textureCapsIn, |
| 47 | const Extensions &extensionsIn, |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 48 | const Limitations &limitationsIn, |
| 49 | const ResourceMap<Framebuffer> &framebufferMap) |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 50 | : mClientVersion(clientVersion), |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 51 | mContext(contextIn), |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 52 | mState(stateIn), |
| 53 | mCaps(capsIn), |
| 54 | mTextureCaps(textureCapsIn), |
| 55 | mExtensions(extensionsIn), |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 56 | mLimitations(limitationsIn), |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 57 | mFramebufferMap(framebufferMap), |
| 58 | mBuffers(AllocateOrGetSharedResourceManager(shareContextState, &ContextState::mBuffers)), |
| 59 | mShaderPrograms( |
| 60 | AllocateOrGetSharedResourceManager(shareContextState, &ContextState::mShaderPrograms)), |
| 61 | mTextures(AllocateOrGetSharedResourceManager(shareContextState, &ContextState::mTextures)), |
| 62 | mRenderbuffers( |
| 63 | AllocateOrGetSharedResourceManager(shareContextState, &ContextState::mRenderbuffers)), |
| 64 | mSamplers(AllocateOrGetSharedResourceManager(shareContextState, &ContextState::mSamplers)), |
| 65 | mFenceSyncs( |
| 66 | AllocateOrGetSharedResourceManager(shareContextState, &ContextState::mFenceSyncs)), |
| 67 | mPaths(AllocateOrGetSharedResourceManager(shareContextState, &ContextState::mPaths)) |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 68 | { |
| 69 | } |
Jamie Madill | 1e9ae07 | 2014-11-06 15:27:21 -0500 | [diff] [blame] | 70 | |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 71 | ContextState::~ContextState() |
Jamie Madill | 1e9ae07 | 2014-11-06 15:27:21 -0500 | [diff] [blame] | 72 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 73 | mBuffers->release(); |
| 74 | mShaderPrograms->release(); |
| 75 | mTextures->release(); |
| 76 | mRenderbuffers->release(); |
| 77 | mSamplers->release(); |
| 78 | mFenceSyncs->release(); |
| 79 | mPaths->release(); |
Jamie Madill | 1e9ae07 | 2014-11-06 15:27:21 -0500 | [diff] [blame] | 80 | } |
| 81 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 82 | const TextureCaps &ContextState::getTextureCap(GLenum internalFormat) const |
| 83 | { |
| 84 | return mTextureCaps.get(internalFormat); |
| 85 | } |
| 86 | |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 87 | ValidationContext::ValidationContext(const ValidationContext *shareContext, |
| 88 | const Version &clientVersion, |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 89 | State *state, |
Jamie Madill | f25855c | 2015-11-03 11:06:18 -0500 | [diff] [blame] | 90 | const Caps &caps, |
| 91 | const TextureCapsMap &textureCaps, |
| 92 | const Extensions &extensions, |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 93 | const Limitations &limitations, |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 94 | const ResourceMap<Framebuffer> &framebufferMap, |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 95 | bool skipValidation) |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 96 | : mState(reinterpret_cast<uintptr_t>(this), |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 97 | shareContext ? &shareContext->mState : nullptr, |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 98 | clientVersion, |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 99 | state, |
| 100 | caps, |
| 101 | textureCaps, |
| 102 | extensions, |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 103 | limitations, |
| 104 | framebufferMap), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 105 | mSkipValidation(skipValidation) |
Jamie Madill | f25855c | 2015-11-03 11:06:18 -0500 | [diff] [blame] | 106 | { |
| 107 | } |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 108 | |
| 109 | bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) |
| 110 | { |
| 111 | if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT) |
| 112 | { |
| 113 | *type = GL_INT; |
| 114 | *numParams = 1; |
| 115 | return true; |
| 116 | } |
| 117 | |
| 118 | // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation |
| 119 | // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due |
| 120 | // to the fact that it is stored internally as a float, and so would require conversion |
| 121 | // if returned from Context::getIntegerv. Since this conversion is already implemented |
| 122 | // in the case that one calls glGetIntegerv to retrieve a float-typed state variable, we |
| 123 | // place DEPTH_CLEAR_VALUE with the floats. This should make no difference to the calling |
| 124 | // application. |
| 125 | switch (pname) |
| 126 | { |
| 127 | case GL_COMPRESSED_TEXTURE_FORMATS: |
| 128 | { |
| 129 | *type = GL_INT; |
| 130 | *numParams = static_cast<unsigned int>(getCaps().compressedTextureFormats.size()); |
| 131 | return true; |
| 132 | } |
| 133 | case GL_PROGRAM_BINARY_FORMATS_OES: |
| 134 | { |
| 135 | *type = GL_INT; |
| 136 | *numParams = static_cast<unsigned int>(getCaps().programBinaryFormats.size()); |
| 137 | return true; |
| 138 | } |
| 139 | case GL_SHADER_BINARY_FORMATS: |
| 140 | { |
| 141 | *type = GL_INT; |
| 142 | *numParams = static_cast<unsigned int>(getCaps().shaderBinaryFormats.size()); |
| 143 | return true; |
| 144 | } |
| 145 | |
| 146 | case GL_MAX_VERTEX_ATTRIBS: |
| 147 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 148 | case GL_MAX_VARYING_VECTORS: |
| 149 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 150 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 151 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
| 152 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 153 | case GL_MAX_RENDERBUFFER_SIZE: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 154 | case GL_NUM_SHADER_BINARY_FORMATS: |
| 155 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 156 | case GL_ARRAY_BUFFER_BINDING: |
| 157 | // case GL_FRAMEBUFFER_BINDING: // equivalent to DRAW_FRAMEBUFFER_BINDING_ANGLE |
| 158 | case GL_DRAW_FRAMEBUFFER_BINDING_ANGLE: |
| 159 | case GL_READ_FRAMEBUFFER_BINDING_ANGLE: |
| 160 | case GL_RENDERBUFFER_BINDING: |
| 161 | case GL_CURRENT_PROGRAM: |
| 162 | case GL_PACK_ALIGNMENT: |
| 163 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 164 | case GL_UNPACK_ALIGNMENT: |
| 165 | case GL_GENERATE_MIPMAP_HINT: |
| 166 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 167 | case GL_RED_BITS: |
| 168 | case GL_GREEN_BITS: |
| 169 | case GL_BLUE_BITS: |
| 170 | case GL_ALPHA_BITS: |
| 171 | case GL_DEPTH_BITS: |
| 172 | case GL_STENCIL_BITS: |
| 173 | case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 174 | case GL_CULL_FACE_MODE: |
| 175 | case GL_FRONT_FACE: |
| 176 | case GL_ACTIVE_TEXTURE: |
| 177 | case GL_STENCIL_FUNC: |
| 178 | case GL_STENCIL_VALUE_MASK: |
| 179 | case GL_STENCIL_REF: |
| 180 | case GL_STENCIL_FAIL: |
| 181 | case GL_STENCIL_PASS_DEPTH_FAIL: |
| 182 | case GL_STENCIL_PASS_DEPTH_PASS: |
| 183 | case GL_STENCIL_BACK_FUNC: |
| 184 | case GL_STENCIL_BACK_VALUE_MASK: |
| 185 | case GL_STENCIL_BACK_REF: |
| 186 | case GL_STENCIL_BACK_FAIL: |
| 187 | case GL_STENCIL_BACK_PASS_DEPTH_FAIL: |
| 188 | case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
| 189 | case GL_DEPTH_FUNC: |
| 190 | case GL_BLEND_SRC_RGB: |
| 191 | case GL_BLEND_SRC_ALPHA: |
| 192 | case GL_BLEND_DST_RGB: |
| 193 | case GL_BLEND_DST_ALPHA: |
| 194 | case GL_BLEND_EQUATION_RGB: |
| 195 | case GL_BLEND_EQUATION_ALPHA: |
| 196 | case GL_STENCIL_WRITEMASK: |
| 197 | case GL_STENCIL_BACK_WRITEMASK: |
| 198 | case GL_STENCIL_CLEAR_VALUE: |
| 199 | case GL_SUBPIXEL_BITS: |
| 200 | case GL_MAX_TEXTURE_SIZE: |
| 201 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 202 | case GL_SAMPLE_BUFFERS: |
| 203 | case GL_SAMPLES: |
| 204 | case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 205 | case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 206 | case GL_TEXTURE_BINDING_2D: |
| 207 | case GL_TEXTURE_BINDING_CUBE_MAP: |
| 208 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 209 | case GL_NUM_PROGRAM_BINARY_FORMATS_OES: |
| 210 | { |
| 211 | *type = GL_INT; |
| 212 | *numParams = 1; |
| 213 | return true; |
| 214 | } |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 215 | case GL_MAX_DRAW_BUFFERS_EXT: |
| 216 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
| 217 | { |
| 218 | if ((getClientMajorVersion() < 3) && !getExtensions().drawBuffers) |
| 219 | { |
| 220 | return false; |
| 221 | } |
| 222 | *type = GL_INT; |
| 223 | *numParams = 1; |
| 224 | return true; |
| 225 | } |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 226 | case GL_MAX_SAMPLES_ANGLE: |
| 227 | { |
| 228 | if (!getExtensions().framebufferMultisample) |
| 229 | { |
| 230 | return false; |
| 231 | } |
| 232 | *type = GL_INT; |
| 233 | *numParams = 1; |
| 234 | return true; |
| 235 | } |
| 236 | case GL_MAX_VIEWPORT_DIMS: |
| 237 | { |
| 238 | *type = GL_INT; |
| 239 | *numParams = 2; |
| 240 | return true; |
| 241 | } |
| 242 | case GL_VIEWPORT: |
| 243 | case GL_SCISSOR_BOX: |
| 244 | { |
| 245 | *type = GL_INT; |
| 246 | *numParams = 4; |
| 247 | return true; |
| 248 | } |
| 249 | case GL_SHADER_COMPILER: |
| 250 | case GL_SAMPLE_COVERAGE_INVERT: |
| 251 | case GL_DEPTH_WRITEMASK: |
| 252 | case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled, |
| 253 | case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries. |
| 254 | case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as |
| 255 | // bool-natural |
| 256 | case GL_SAMPLE_COVERAGE: |
| 257 | case GL_SCISSOR_TEST: |
| 258 | case GL_STENCIL_TEST: |
| 259 | case GL_DEPTH_TEST: |
| 260 | case GL_BLEND: |
| 261 | case GL_DITHER: |
| 262 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 263 | { |
| 264 | *type = GL_BOOL; |
| 265 | *numParams = 1; |
| 266 | return true; |
| 267 | } |
| 268 | case GL_COLOR_WRITEMASK: |
| 269 | { |
| 270 | *type = GL_BOOL; |
| 271 | *numParams = 4; |
| 272 | return true; |
| 273 | } |
| 274 | case GL_POLYGON_OFFSET_FACTOR: |
| 275 | case GL_POLYGON_OFFSET_UNITS: |
| 276 | case GL_SAMPLE_COVERAGE_VALUE: |
| 277 | case GL_DEPTH_CLEAR_VALUE: |
| 278 | case GL_LINE_WIDTH: |
| 279 | { |
| 280 | *type = GL_FLOAT; |
| 281 | *numParams = 1; |
| 282 | return true; |
| 283 | } |
| 284 | case GL_ALIASED_LINE_WIDTH_RANGE: |
| 285 | case GL_ALIASED_POINT_SIZE_RANGE: |
| 286 | case GL_DEPTH_RANGE: |
| 287 | { |
| 288 | *type = GL_FLOAT; |
| 289 | *numParams = 2; |
| 290 | return true; |
| 291 | } |
| 292 | case GL_COLOR_CLEAR_VALUE: |
| 293 | case GL_BLEND_COLOR: |
| 294 | { |
| 295 | *type = GL_FLOAT; |
| 296 | *numParams = 4; |
| 297 | return true; |
| 298 | } |
| 299 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
| 300 | if (!getExtensions().maxTextureAnisotropy) |
| 301 | { |
| 302 | return false; |
| 303 | } |
| 304 | *type = GL_FLOAT; |
| 305 | *numParams = 1; |
| 306 | return true; |
| 307 | case GL_TIMESTAMP_EXT: |
| 308 | if (!getExtensions().disjointTimerQuery) |
| 309 | { |
| 310 | return false; |
| 311 | } |
| 312 | *type = GL_INT_64_ANGLEX; |
| 313 | *numParams = 1; |
| 314 | return true; |
| 315 | case GL_GPU_DISJOINT_EXT: |
| 316 | if (!getExtensions().disjointTimerQuery) |
| 317 | { |
| 318 | return false; |
| 319 | } |
| 320 | *type = GL_INT; |
| 321 | *numParams = 1; |
| 322 | return true; |
| 323 | case GL_COVERAGE_MODULATION_CHROMIUM: |
| 324 | if (!getExtensions().framebufferMixedSamples) |
| 325 | { |
| 326 | return false; |
| 327 | } |
| 328 | *type = GL_INT; |
| 329 | *numParams = 1; |
| 330 | return true; |
John Bauman | 1831918 | 2016-09-28 14:22:27 -0700 | [diff] [blame] | 331 | case GL_TEXTURE_BINDING_EXTERNAL_OES: |
| 332 | if (!getExtensions().eglStreamConsumerExternal && !getExtensions().eglImageExternal) |
| 333 | { |
| 334 | return false; |
| 335 | } |
| 336 | *type = GL_INT; |
| 337 | *numParams = 1; |
| 338 | return true; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | if (getExtensions().debug) |
| 342 | { |
| 343 | switch (pname) |
| 344 | { |
| 345 | case GL_DEBUG_LOGGED_MESSAGES: |
| 346 | case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: |
| 347 | case GL_DEBUG_GROUP_STACK_DEPTH: |
| 348 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 349 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 350 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 351 | case GL_MAX_LABEL_LENGTH: |
| 352 | *type = GL_INT; |
| 353 | *numParams = 1; |
| 354 | return true; |
| 355 | |
| 356 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 357 | case GL_DEBUG_OUTPUT: |
| 358 | *type = GL_BOOL; |
| 359 | *numParams = 1; |
| 360 | return true; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | if (getExtensions().multisampleCompatibility) |
| 365 | { |
| 366 | switch (pname) |
| 367 | { |
| 368 | case GL_MULTISAMPLE_EXT: |
| 369 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 370 | *type = GL_BOOL; |
| 371 | *numParams = 1; |
| 372 | return true; |
| 373 | } |
| 374 | } |
| 375 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 376 | if (getExtensions().pathRendering) |
| 377 | { |
| 378 | switch (pname) |
| 379 | { |
| 380 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 381 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 382 | *type = GL_FLOAT; |
| 383 | *numParams = 16; |
| 384 | return true; |
| 385 | } |
| 386 | } |
| 387 | |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 388 | if (getExtensions().bindGeneratesResource) |
| 389 | { |
| 390 | switch (pname) |
| 391 | { |
| 392 | case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 393 | *type = GL_BOOL; |
| 394 | *numParams = 1; |
| 395 | return true; |
| 396 | } |
| 397 | } |
| 398 | |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 399 | if (getExtensions().sRGBWriteControl) |
| 400 | { |
| 401 | switch (pname) |
| 402 | { |
| 403 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 404 | *type = GL_BOOL; |
| 405 | *numParams = 1; |
| 406 | return true; |
| 407 | } |
| 408 | } |
| 409 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 410 | // Check for ES3.0+ parameter names which are also exposed as ES2 extensions |
| 411 | switch (pname) |
| 412 | { |
| 413 | case GL_PACK_ROW_LENGTH: |
| 414 | case GL_PACK_SKIP_ROWS: |
| 415 | case GL_PACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 416 | if ((getClientMajorVersion() < 3) && !getExtensions().packSubimage) |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 417 | { |
| 418 | return false; |
| 419 | } |
| 420 | *type = GL_INT; |
| 421 | *numParams = 1; |
| 422 | return true; |
| 423 | case GL_UNPACK_ROW_LENGTH: |
| 424 | case GL_UNPACK_SKIP_ROWS: |
| 425 | case GL_UNPACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 426 | if ((getClientMajorVersion() < 3) && !getExtensions().unpackSubimage) |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 427 | { |
| 428 | return false; |
| 429 | } |
| 430 | *type = GL_INT; |
| 431 | *numParams = 1; |
| 432 | return true; |
| 433 | case GL_VERTEX_ARRAY_BINDING: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 434 | if ((getClientMajorVersion() < 3) && !getExtensions().vertexArrayObject) |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 435 | { |
| 436 | return false; |
| 437 | } |
| 438 | *type = GL_INT; |
| 439 | *numParams = 1; |
| 440 | return true; |
| 441 | case GL_PIXEL_PACK_BUFFER_BINDING: |
| 442 | case GL_PIXEL_UNPACK_BUFFER_BINDING: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 443 | if ((getClientMajorVersion() < 3) && !getExtensions().pixelBufferObject) |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 444 | { |
| 445 | return false; |
| 446 | } |
| 447 | *type = GL_INT; |
| 448 | *numParams = 1; |
| 449 | return true; |
| 450 | } |
| 451 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 452 | if (getClientVersion() < Version(3, 0)) |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 453 | { |
| 454 | return false; |
| 455 | } |
| 456 | |
| 457 | // Check for ES3.0+ parameter names |
| 458 | switch (pname) |
| 459 | { |
| 460 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 461 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 462 | case GL_UNIFORM_BUFFER_BINDING: |
| 463 | case GL_TRANSFORM_FEEDBACK_BINDING: |
| 464 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 465 | case GL_COPY_READ_BUFFER_BINDING: |
| 466 | case GL_COPY_WRITE_BUFFER_BINDING: |
| 467 | case GL_SAMPLER_BINDING: |
| 468 | case GL_READ_BUFFER: |
| 469 | case GL_TEXTURE_BINDING_3D: |
| 470 | case GL_TEXTURE_BINDING_2D_ARRAY: |
| 471 | case GL_MAX_3D_TEXTURE_SIZE: |
| 472 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 473 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
| 474 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
| 475 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 476 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 477 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 478 | case GL_MAX_VARYING_COMPONENTS: |
| 479 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
| 480 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
| 481 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 482 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 483 | case GL_NUM_EXTENSIONS: |
| 484 | case GL_MAJOR_VERSION: |
| 485 | case GL_MINOR_VERSION: |
| 486 | case GL_MAX_ELEMENTS_INDICES: |
| 487 | case GL_MAX_ELEMENTS_VERTICES: |
| 488 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 489 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 490 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 491 | case GL_UNPACK_IMAGE_HEIGHT: |
| 492 | case GL_UNPACK_SKIP_IMAGES: |
| 493 | { |
| 494 | *type = GL_INT; |
| 495 | *numParams = 1; |
| 496 | return true; |
| 497 | } |
| 498 | |
| 499 | case GL_MAX_ELEMENT_INDEX: |
| 500 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 501 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
| 502 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
| 503 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 504 | { |
| 505 | *type = GL_INT_64_ANGLEX; |
| 506 | *numParams = 1; |
| 507 | return true; |
| 508 | } |
| 509 | |
| 510 | case GL_TRANSFORM_FEEDBACK_ACTIVE: |
| 511 | case GL_TRANSFORM_FEEDBACK_PAUSED: |
| 512 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 513 | case GL_RASTERIZER_DISCARD: |
| 514 | { |
| 515 | *type = GL_BOOL; |
| 516 | *numParams = 1; |
| 517 | return true; |
| 518 | } |
| 519 | |
| 520 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 521 | { |
| 522 | *type = GL_FLOAT; |
| 523 | *numParams = 1; |
| 524 | return true; |
| 525 | } |
| 526 | } |
| 527 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 528 | if (getExtensions().requestExtension) |
| 529 | { |
| 530 | switch (pname) |
| 531 | { |
| 532 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 533 | *type = GL_INT; |
| 534 | *numParams = 1; |
| 535 | return true; |
| 536 | } |
| 537 | } |
| 538 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 539 | if (getClientVersion() < Version(3, 1)) |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 540 | { |
| 541 | return false; |
| 542 | } |
| 543 | |
| 544 | switch (pname) |
| 545 | { |
Jiajia Qin | 9d7d0b1 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 546 | case GL_DRAW_INDIRECT_BUFFER_BINDING: |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 547 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 548 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 549 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 550 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 551 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 552 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 553 | case GL_MAX_INTEGER_SAMPLES: |
| 554 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 555 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 556 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 557 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
| 558 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
| 559 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
| 560 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
| 561 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
| 562 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
| 563 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
| 564 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
| 565 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 566 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 567 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 568 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
| 569 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
| 570 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 571 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
| 572 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
| 573 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
| 574 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
| 575 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
| 576 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
| 577 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 578 | case GL_MAX_UNIFORM_LOCATIONS: |
| 579 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 580 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 581 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 582 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 583 | case GL_MAX_IMAGE_UNITS: |
| 584 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 585 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 586 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 587 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 588 | *type = GL_INT; |
| 589 | *numParams = 1; |
| 590 | return true; |
| 591 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 592 | *type = GL_INT_64_ANGLEX; |
| 593 | *numParams = 1; |
| 594 | return true; |
| 595 | } |
| 596 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 597 | return false; |
| 598 | } |
| 599 | |
| 600 | bool ValidationContext::getIndexedQueryParameterInfo(GLenum target, |
| 601 | GLenum *type, |
| 602 | unsigned int *numParams) |
| 603 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 604 | if (getClientVersion() < Version(3, 0)) |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 605 | { |
| 606 | return false; |
| 607 | } |
| 608 | |
| 609 | switch (target) |
| 610 | { |
| 611 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 612 | case GL_UNIFORM_BUFFER_BINDING: |
| 613 | { |
| 614 | *type = GL_INT; |
| 615 | *numParams = 1; |
| 616 | return true; |
| 617 | } |
| 618 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 619 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 620 | case GL_UNIFORM_BUFFER_START: |
| 621 | case GL_UNIFORM_BUFFER_SIZE: |
| 622 | { |
| 623 | *type = GL_INT_64_ANGLEX; |
| 624 | *numParams = 1; |
| 625 | return true; |
| 626 | } |
| 627 | } |
| 628 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 629 | if (getClientVersion() < Version(3, 1)) |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 630 | { |
| 631 | return false; |
| 632 | } |
| 633 | |
| 634 | switch (target) |
| 635 | { |
| 636 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 637 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 638 | { |
| 639 | *type = GL_INT; |
| 640 | *numParams = 1; |
| 641 | return true; |
| 642 | } |
| 643 | } |
| 644 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 645 | return false; |
| 646 | } |
| 647 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 648 | Program *ValidationContext::getProgram(GLuint handle) const |
| 649 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 650 | return mState.mShaderPrograms->getProgram(handle); |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | Shader *ValidationContext::getShader(GLuint handle) const |
| 654 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 655 | return mState.mShaderPrograms->getShader(handle); |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 656 | } |
| 657 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 658 | bool ValidationContext::isTextureGenerated(GLuint texture) const |
| 659 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 660 | return mState.mTextures->isTextureGenerated(texture); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | bool ValidationContext::isBufferGenerated(GLuint buffer) const |
| 664 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 665 | return mState.mBuffers->isBufferGenerated(buffer); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | bool ValidationContext::isRenderbufferGenerated(GLuint renderbuffer) const |
| 669 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 670 | return mState.mRenderbuffers->isRenderbufferGenerated(renderbuffer); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | bool ValidationContext::isFramebufferGenerated(GLuint framebuffer) const |
| 674 | { |
| 675 | ASSERT(mState.mFramebufferMap.find(0) != mState.mFramebufferMap.end()); |
| 676 | return mState.mFramebufferMap.find(framebuffer) != mState.mFramebufferMap.end(); |
| 677 | } |
| 678 | |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 679 | } // namespace gl |