apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1 | // |
Geoff Lang | eeba6e1 | 2014-02-03 13:12:30 -0500 | [diff] [blame] | 2 | // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [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 | // Context.cpp: Implements the gl::Context class, managing all GL state and performing |
| 8 | // rendering operations. It is the GLES2 specific implementation of EGLContext. |
| 9 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 10 | #include "libANGLE/Context.h" |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 11 | |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 12 | #include <iterator> |
| 13 | #include <sstream> |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 14 | #include <string.h> |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 15 | #include <vector> |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 16 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 17 | #include "common/matrix_utils.h" |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 18 | #include "common/platform.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 19 | #include "common/utilities.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 20 | #include "libANGLE/Buffer.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 21 | #include "libANGLE/Compiler.h" |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 22 | #include "libANGLE/Display.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 23 | #include "libANGLE/Fence.h" |
| 24 | #include "libANGLE/Framebuffer.h" |
| 25 | #include "libANGLE/FramebufferAttachment.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 26 | #include "libANGLE/Path.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 27 | #include "libANGLE/Program.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 28 | #include "libANGLE/Query.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 29 | #include "libANGLE/Renderbuffer.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 30 | #include "libANGLE/ResourceManager.h" |
| 31 | #include "libANGLE/Sampler.h" |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 32 | #include "libANGLE/Surface.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 33 | #include "libANGLE/Texture.h" |
| 34 | #include "libANGLE/TransformFeedback.h" |
| 35 | #include "libANGLE/VertexArray.h" |
| 36 | #include "libANGLE/formatutils.h" |
| 37 | #include "libANGLE/validationES.h" |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 38 | #include "libANGLE/renderer/ContextImpl.h" |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 39 | #include "libANGLE/renderer/EGLImplFactory.h" |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame^] | 40 | #include "libANGLE/queryconversions.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 41 | |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 42 | namespace |
| 43 | { |
| 44 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 45 | template <typename T> |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 46 | std::vector<gl::Path *> GatherPaths(gl::ResourceManager &resourceManager, |
| 47 | GLsizei numPaths, |
| 48 | const void *paths, |
| 49 | GLuint pathBase) |
| 50 | { |
| 51 | std::vector<gl::Path *> ret; |
| 52 | ret.reserve(numPaths); |
| 53 | |
| 54 | const auto *nameArray = static_cast<const T *>(paths); |
| 55 | |
| 56 | for (GLsizei i = 0; i < numPaths; ++i) |
| 57 | { |
| 58 | const GLuint pathName = nameArray[i] + pathBase; |
| 59 | |
| 60 | ret.push_back(resourceManager.getPath(pathName)); |
| 61 | } |
| 62 | |
| 63 | return ret; |
| 64 | } |
| 65 | |
| 66 | std::vector<gl::Path *> GatherPaths(gl::ResourceManager &resourceManager, |
| 67 | GLsizei numPaths, |
| 68 | GLenum pathNameType, |
| 69 | const void *paths, |
| 70 | GLuint pathBase) |
| 71 | { |
| 72 | switch (pathNameType) |
| 73 | { |
| 74 | case GL_UNSIGNED_BYTE: |
| 75 | return GatherPaths<GLubyte>(resourceManager, numPaths, paths, pathBase); |
| 76 | |
| 77 | case GL_BYTE: |
| 78 | return GatherPaths<GLbyte>(resourceManager, numPaths, paths, pathBase); |
| 79 | |
| 80 | case GL_UNSIGNED_SHORT: |
| 81 | return GatherPaths<GLushort>(resourceManager, numPaths, paths, pathBase); |
| 82 | |
| 83 | case GL_SHORT: |
| 84 | return GatherPaths<GLshort>(resourceManager, numPaths, paths, pathBase); |
| 85 | |
| 86 | case GL_UNSIGNED_INT: |
| 87 | return GatherPaths<GLuint>(resourceManager, numPaths, paths, pathBase); |
| 88 | |
| 89 | case GL_INT: |
| 90 | return GatherPaths<GLint>(resourceManager, numPaths, paths, pathBase); |
| 91 | } |
| 92 | |
| 93 | UNREACHABLE(); |
| 94 | return std::vector<gl::Path *>(); |
| 95 | } |
| 96 | |
| 97 | template <typename T> |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 98 | gl::Error GetQueryObjectParameter(gl::Context *context, GLuint id, GLenum pname, T *params) |
| 99 | { |
| 100 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 101 | ASSERT(queryObject != nullptr); |
| 102 | |
| 103 | switch (pname) |
| 104 | { |
| 105 | case GL_QUERY_RESULT_EXT: |
| 106 | return queryObject->getResult(params); |
| 107 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 108 | { |
| 109 | bool available; |
| 110 | gl::Error error = queryObject->isResultAvailable(&available); |
| 111 | if (!error.isError()) |
| 112 | { |
| 113 | *params = static_cast<T>(available ? GL_TRUE : GL_FALSE); |
| 114 | } |
| 115 | return error; |
| 116 | } |
| 117 | default: |
| 118 | UNREACHABLE(); |
| 119 | return gl::Error(GL_INVALID_OPERATION, "Unreachable Error"); |
| 120 | } |
| 121 | } |
| 122 | |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 123 | void MarkTransformFeedbackBufferUsage(gl::TransformFeedback *transformFeedback) |
| 124 | { |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 125 | if (transformFeedback && transformFeedback->isActive() && !transformFeedback->isPaused()) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 126 | { |
| 127 | for (size_t tfBufferIndex = 0; tfBufferIndex < transformFeedback->getIndexedBufferCount(); |
| 128 | tfBufferIndex++) |
| 129 | { |
| 130 | const OffsetBindingPointer<gl::Buffer> &buffer = |
| 131 | transformFeedback->getIndexedBuffer(tfBufferIndex); |
| 132 | if (buffer.get() != nullptr) |
| 133 | { |
| 134 | buffer->onTransformFeedback(); |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | } |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 139 | |
| 140 | // Attribute map queries. |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 141 | EGLint GetClientMajorVersion(const egl::AttributeMap &attribs) |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 142 | { |
Ian Ewell | ec2c0c5 | 2016-04-05 13:46:26 -0400 | [diff] [blame] | 143 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1)); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 144 | } |
| 145 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 146 | EGLint GetClientMinorVersion(const egl::AttributeMap &attribs) |
| 147 | { |
| 148 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0)); |
| 149 | } |
| 150 | |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 151 | GLenum GetResetStrategy(const egl::AttributeMap &attribs) |
| 152 | { |
Ian Ewell | ec2c0c5 | 2016-04-05 13:46:26 -0400 | [diff] [blame] | 153 | EGLAttrib attrib = attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, |
| 154 | EGL_NO_RESET_NOTIFICATION_EXT); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 155 | switch (attrib) |
| 156 | { |
| 157 | case EGL_NO_RESET_NOTIFICATION: |
| 158 | return GL_NO_RESET_NOTIFICATION_EXT; |
| 159 | case EGL_LOSE_CONTEXT_ON_RESET: |
| 160 | return GL_LOSE_CONTEXT_ON_RESET_EXT; |
| 161 | default: |
| 162 | UNREACHABLE(); |
| 163 | return GL_NONE; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | bool GetRobustAccess(const egl::AttributeMap &attribs) |
| 168 | { |
| 169 | return (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE); |
| 170 | } |
| 171 | |
| 172 | bool GetDebug(const egl::AttributeMap &attribs) |
| 173 | { |
| 174 | return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE); |
| 175 | } |
| 176 | |
| 177 | bool GetNoError(const egl::AttributeMap &attribs) |
| 178 | { |
| 179 | return (attribs.get(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, EGL_FALSE) == EGL_TRUE); |
| 180 | } |
| 181 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 182 | std::string GetObjectLabelFromPointer(GLsizei length, const GLchar *label) |
| 183 | { |
| 184 | std::string labelName; |
| 185 | if (label != nullptr) |
| 186 | { |
| 187 | size_t labelLength = length < 0 ? strlen(label) : length; |
| 188 | labelName = std::string(label, labelLength); |
| 189 | } |
| 190 | return labelName; |
| 191 | } |
| 192 | |
| 193 | void GetObjectLabelBase(const std::string &objectLabel, |
| 194 | GLsizei bufSize, |
| 195 | GLsizei *length, |
| 196 | GLchar *label) |
| 197 | { |
| 198 | size_t writeLength = objectLabel.length(); |
| 199 | if (label != nullptr && bufSize > 0) |
| 200 | { |
| 201 | writeLength = std::min(static_cast<size_t>(bufSize) - 1, objectLabel.length()); |
| 202 | std::copy(objectLabel.begin(), objectLabel.begin() + writeLength, label); |
| 203 | label[writeLength] = '\0'; |
| 204 | } |
| 205 | |
| 206 | if (length != nullptr) |
| 207 | { |
| 208 | *length = static_cast<GLsizei>(writeLength); |
| 209 | } |
| 210 | } |
| 211 | |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 212 | } // anonymous namespace |
| 213 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 214 | namespace gl |
| 215 | { |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 216 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 217 | Context::Context(rx::EGLImplFactory *implFactory, |
| 218 | const egl::Config *config, |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 219 | const Context *shareContext, |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 220 | const egl::AttributeMap &attribs) |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 221 | |
| 222 | : ValidationContext(GetClientMajorVersion(attribs), |
| 223 | GetClientMinorVersion(attribs), |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 224 | &mGLState, |
Jamie Madill | f25855c | 2015-11-03 11:06:18 -0500 | [diff] [blame] | 225 | mCaps, |
| 226 | mTextureCaps, |
| 227 | mExtensions, |
| 228 | nullptr, |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 229 | mLimitations, |
| 230 | GetNoError(attribs)), |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 231 | mImplementation(implFactory->createContext(mState)), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 232 | mCompiler(nullptr), |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 233 | mClientMajorVersion(GetClientMajorVersion(attribs)), |
| 234 | mClientMinorVersion(GetClientMinorVersion(attribs)), |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 235 | mConfig(config), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 236 | mClientType(EGL_OPENGL_ES_API), |
| 237 | mHasBeenCurrent(false), |
| 238 | mContextLost(false), |
| 239 | mResetStatus(GL_NO_ERROR), |
| 240 | mResetStrategy(GetResetStrategy(attribs)), |
| 241 | mRobustAccess(GetRobustAccess(attribs)), |
| 242 | mCurrentSurface(nullptr), |
| 243 | mResourceManager(nullptr) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 244 | { |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 245 | ASSERT(!mRobustAccess); // Unimplemented |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 246 | |
Jamie Madill | 00ed7a1 | 2016-05-19 13:13:38 -0400 | [diff] [blame] | 247 | initCaps(); |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 248 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 249 | mGLState.initialize(mCaps, mExtensions, mClientMajorVersion, GetDebug(attribs)); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 250 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 251 | mFenceNVHandleAllocator.setBaseHandle(0); |
Geoff Lang | 7dca186 | 2013-07-30 16:30:46 -0400 | [diff] [blame] | 252 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 253 | if (shareContext != nullptr) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 254 | { |
| 255 | mResourceManager = shareContext->mResourceManager; |
| 256 | mResourceManager->addRef(); |
| 257 | } |
| 258 | else |
| 259 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 260 | mResourceManager = new ResourceManager(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 263 | mState.mResourceManager = mResourceManager; |
Jamie Madill | c185cb8 | 2015-04-28 12:39:08 -0400 | [diff] [blame] | 264 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 265 | // [OpenGL ES 2.0.24] section 3.7 page 83: |
| 266 | // In the initial state, TEXTURE_2D and TEXTURE_CUBE_MAP have twodimensional |
| 267 | // and cube map texture state vectors respectively associated with them. |
| 268 | // In order that access to these initial textures not be lost, they are treated as texture |
| 269 | // objects all of whose names are 0. |
| 270 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 271 | Texture *zeroTexture2D = new Texture(mImplementation.get(), 0, GL_TEXTURE_2D); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 272 | mZeroTextures[GL_TEXTURE_2D].set(zeroTexture2D); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 273 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 274 | Texture *zeroTextureCube = new Texture(mImplementation.get(), 0, GL_TEXTURE_CUBE_MAP); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 275 | mZeroTextures[GL_TEXTURE_CUBE_MAP].set(zeroTextureCube); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 276 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 277 | if (mClientMajorVersion >= 3) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 278 | { |
| 279 | // TODO: These could also be enabled via extension |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 280 | Texture *zeroTexture3D = new Texture(mImplementation.get(), 0, GL_TEXTURE_3D); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 281 | mZeroTextures[GL_TEXTURE_3D].set(zeroTexture3D); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 282 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 283 | Texture *zeroTexture2DArray = new Texture(mImplementation.get(), 0, GL_TEXTURE_2D_ARRAY); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 284 | mZeroTextures[GL_TEXTURE_2D_ARRAY].set(zeroTexture2DArray); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 285 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 286 | |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 287 | if (mExtensions.eglImageExternal || mExtensions.eglStreamConsumerExternal) |
| 288 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 289 | Texture *zeroTextureExternal = |
| 290 | new Texture(mImplementation.get(), 0, GL_TEXTURE_EXTERNAL_OES); |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 291 | mZeroTextures[GL_TEXTURE_EXTERNAL_OES].set(zeroTextureExternal); |
| 292 | } |
| 293 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 294 | mGLState.initializeZeroTextures(mZeroTextures); |
Jamie Madill | e6382c3 | 2014-11-07 15:05:26 -0500 | [diff] [blame] | 295 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 296 | bindVertexArray(0); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 297 | bindArrayBuffer(0); |
| 298 | bindElementArrayBuffer(0); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 299 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 300 | bindRenderbuffer(0); |
| 301 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 302 | bindGenericUniformBuffer(0); |
Shannon Woods | f3acaf9 | 2014-09-23 18:07:11 -0400 | [diff] [blame] | 303 | for (unsigned int i = 0; i < mCaps.maxCombinedUniformBlocks; i++) |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 304 | { |
| 305 | bindIndexedUniformBuffer(0, i, 0, -1); |
| 306 | } |
| 307 | |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 308 | bindCopyReadBuffer(0); |
| 309 | bindCopyWriteBuffer(0); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 310 | bindPixelPackBuffer(0); |
| 311 | bindPixelUnpackBuffer(0); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 312 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 313 | if (mClientMajorVersion >= 3) |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 314 | { |
| 315 | // [OpenGL ES 3.0.2] section 2.14.1 pg 85: |
| 316 | // In the initial state, a default transform feedback object is bound and treated as |
| 317 | // a transform feedback object with a name of zero. That object is bound any time |
| 318 | // BindTransformFeedback is called with id of zero |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 319 | bindTransformFeedback(0); |
| 320 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 321 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 322 | mCompiler = new Compiler(mImplementation.get(), mState); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 323 | |
| 324 | // Initialize dirty bit masks |
| 325 | // TODO(jmadill): additional ES3 state |
| 326 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_ALIGNMENT); |
| 327 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_ROW_LENGTH); |
| 328 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_IMAGE_HEIGHT); |
| 329 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_SKIP_IMAGES); |
| 330 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_SKIP_ROWS); |
| 331 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_SKIP_PIXELS); |
Corentin Wallez | bbd663a | 2016-04-20 17:49:17 -0400 | [diff] [blame] | 332 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_BUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 333 | // No dirty objects. |
| 334 | |
| 335 | // Readpixels uses the pack state and read FBO |
| 336 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_ALIGNMENT); |
| 337 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_REVERSE_ROW_ORDER); |
| 338 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_ROW_LENGTH); |
| 339 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_SKIP_ROWS); |
| 340 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_SKIP_PIXELS); |
Corentin Wallez | bbd663a | 2016-04-20 17:49:17 -0400 | [diff] [blame] | 341 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_BUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 342 | mReadPixelsDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 343 | |
| 344 | mClearDirtyBits.set(State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED); |
| 345 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 346 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
| 347 | mClearDirtyBits.set(State::DIRTY_BIT_VIEWPORT); |
| 348 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_COLOR); |
| 349 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_DEPTH); |
| 350 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_STENCIL); |
| 351 | mClearDirtyBits.set(State::DIRTY_BIT_COLOR_MASK); |
| 352 | mClearDirtyBits.set(State::DIRTY_BIT_DEPTH_MASK); |
| 353 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT); |
| 354 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_BACK); |
| 355 | mClearDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 356 | |
| 357 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 358 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
| 359 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 360 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 361 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 362 | handleError(mImplementation->initialize()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | Context::~Context() |
| 366 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 367 | mGLState.reset(); |
Geoff Lang | 2132941 | 2014-12-02 20:50:30 +0000 | [diff] [blame] | 368 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 369 | for (auto framebuffer : mFramebufferMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 370 | { |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 371 | // Default framebuffer are owned by their respective Surface |
Geoff Lang | f622792 | 2015-09-04 11:05:47 -0400 | [diff] [blame] | 372 | if (framebuffer.second != nullptr && framebuffer.second->id() != 0) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 373 | { |
| 374 | SafeDelete(framebuffer.second); |
| 375 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 376 | } |
| 377 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 378 | for (auto fence : mFenceNVMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 379 | { |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 380 | SafeDelete(fence.second); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 381 | } |
| 382 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 383 | for (auto query : mQueryMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 384 | { |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 385 | if (query.second != nullptr) |
| 386 | { |
| 387 | query.second->release(); |
| 388 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 389 | } |
| 390 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 391 | for (auto vertexArray : mVertexArrayMap) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 392 | { |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 393 | SafeDelete(vertexArray.second); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 394 | } |
| 395 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 396 | for (auto transformFeedback : mTransformFeedbackMap) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 397 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 398 | if (transformFeedback.second != nullptr) |
| 399 | { |
| 400 | transformFeedback.second->release(); |
| 401 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 402 | } |
| 403 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 404 | for (auto &zeroTexture : mZeroTextures) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 405 | { |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 406 | zeroTexture.second.set(NULL); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 407 | } |
| 408 | mZeroTextures.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 409 | |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 410 | if (mCurrentSurface != nullptr) |
| 411 | { |
| 412 | releaseSurface(); |
| 413 | } |
| 414 | |
Jamie Madill | 1e9ae07 | 2014-11-06 15:27:21 -0500 | [diff] [blame] | 415 | if (mResourceManager) |
| 416 | { |
| 417 | mResourceManager->release(); |
| 418 | } |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 419 | |
| 420 | SafeDelete(mCompiler); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 421 | } |
| 422 | |
daniel@transgaming.com | ad62987 | 2012-11-28 19:32:06 +0000 | [diff] [blame] | 423 | void Context::makeCurrent(egl::Surface *surface) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 424 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 425 | ASSERT(surface != nullptr); |
| 426 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 427 | if (!mHasBeenCurrent) |
| 428 | { |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 429 | initRendererString(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 430 | initExtensionStrings(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 431 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 432 | mGLState.setViewportParams(0, 0, surface->getWidth(), surface->getHeight()); |
| 433 | mGLState.setScissorParams(0, 0, surface->getWidth(), surface->getHeight()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 434 | |
| 435 | mHasBeenCurrent = true; |
| 436 | } |
| 437 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 438 | // TODO(jmadill): Rework this when we support ContextImpl |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 439 | mGLState.setAllDirtyBits(); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 440 | |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 441 | if (mCurrentSurface) |
| 442 | { |
| 443 | releaseSurface(); |
| 444 | } |
Jamie Madill | 18fdcbc | 2015-08-19 18:12:44 +0000 | [diff] [blame] | 445 | surface->setIsCurrent(true); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 446 | mCurrentSurface = surface; |
Jamie Madill | 18fdcbc | 2015-08-19 18:12:44 +0000 | [diff] [blame] | 447 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 448 | // Update default framebuffer, the binding of the previous default |
| 449 | // framebuffer (or lack of) will have a nullptr. |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 450 | { |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 451 | Framebuffer *newDefault = surface->getDefaultFramebuffer(); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 452 | if (mGLState.getReadFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 453 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 454 | mGLState.setReadFramebufferBinding(newDefault); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 455 | } |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 456 | if (mGLState.getDrawFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 457 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 458 | mGLState.setDrawFramebufferBinding(newDefault); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 459 | } |
| 460 | mFramebufferMap[0] = newDefault; |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 461 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 462 | |
| 463 | // Notify the renderer of a context switch |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 464 | mImplementation->onMakeCurrent(mState); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 465 | } |
| 466 | |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 467 | void Context::releaseSurface() |
| 468 | { |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 469 | ASSERT(mCurrentSurface != nullptr); |
| 470 | |
| 471 | // Remove the default framebuffer |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 472 | { |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 473 | Framebuffer *currentDefault = mCurrentSurface->getDefaultFramebuffer(); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 474 | if (mGLState.getReadFramebuffer() == currentDefault) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 475 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 476 | mGLState.setReadFramebufferBinding(nullptr); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 477 | } |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 478 | if (mGLState.getDrawFramebuffer() == currentDefault) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 479 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 480 | mGLState.setDrawFramebufferBinding(nullptr); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 481 | } |
| 482 | mFramebufferMap.erase(0); |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 483 | } |
| 484 | |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 485 | mCurrentSurface->setIsCurrent(false); |
| 486 | mCurrentSurface = nullptr; |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 487 | } |
| 488 | |
daniel@transgaming.com | f688c0d | 2012-10-31 17:52:57 +0000 | [diff] [blame] | 489 | // NOTE: this function should not assume that this context is current! |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 490 | void Context::markContextLost() |
| 491 | { |
| 492 | if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT) |
| 493 | mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT; |
| 494 | mContextLost = true; |
| 495 | } |
| 496 | |
| 497 | bool Context::isContextLost() |
| 498 | { |
| 499 | return mContextLost; |
| 500 | } |
| 501 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 502 | GLuint Context::createBuffer() |
| 503 | { |
| 504 | return mResourceManager->createBuffer(); |
| 505 | } |
| 506 | |
| 507 | GLuint Context::createProgram() |
| 508 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 509 | return mResourceManager->createProgram(mImplementation.get()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | GLuint Context::createShader(GLenum type) |
| 513 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 514 | return mResourceManager->createShader(mImplementation.get(), |
| 515 | mImplementation->getNativeLimitations(), type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | GLuint Context::createTexture() |
| 519 | { |
| 520 | return mResourceManager->createTexture(); |
| 521 | } |
| 522 | |
| 523 | GLuint Context::createRenderbuffer() |
| 524 | { |
| 525 | return mResourceManager->createRenderbuffer(); |
| 526 | } |
| 527 | |
Geoff Lang | 882033e | 2014-09-30 11:26:07 -0400 | [diff] [blame] | 528 | GLsync Context::createFenceSync() |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 529 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 530 | GLuint handle = mResourceManager->createFenceSync(mImplementation.get()); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 531 | |
Cooper Partin | d8e62a3 | 2015-01-29 15:21:25 -0800 | [diff] [blame] | 532 | return reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle)); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 533 | } |
| 534 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 535 | GLuint Context::createPaths(GLsizei range) |
| 536 | { |
| 537 | auto resultOrError = mResourceManager->createPaths(mImplementation.get(), range); |
| 538 | if (resultOrError.isError()) |
| 539 | { |
| 540 | handleError(resultOrError.getError()); |
| 541 | return 0; |
| 542 | } |
| 543 | return resultOrError.getResult(); |
| 544 | } |
| 545 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 546 | GLuint Context::createVertexArray() |
| 547 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 548 | GLuint vertexArray = mVertexArrayHandleAllocator.allocate(); |
| 549 | mVertexArrayMap[vertexArray] = nullptr; |
| 550 | return vertexArray; |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 551 | } |
| 552 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 553 | GLuint Context::createSampler() |
| 554 | { |
| 555 | return mResourceManager->createSampler(); |
| 556 | } |
| 557 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 558 | GLuint Context::createTransformFeedback() |
| 559 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 560 | GLuint transformFeedback = mTransformFeedbackAllocator.allocate(); |
| 561 | mTransformFeedbackMap[transformFeedback] = nullptr; |
| 562 | return transformFeedback; |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 563 | } |
| 564 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 565 | // Returns an unused framebuffer name |
| 566 | GLuint Context::createFramebuffer() |
| 567 | { |
| 568 | GLuint handle = mFramebufferHandleAllocator.allocate(); |
| 569 | |
| 570 | mFramebufferMap[handle] = NULL; |
| 571 | |
| 572 | return handle; |
| 573 | } |
| 574 | |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 575 | GLuint Context::createFenceNV() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 576 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 577 | GLuint handle = mFenceNVHandleAllocator.allocate(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 578 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 579 | mFenceNVMap[handle] = new FenceNV(mImplementation->createFenceNV()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 580 | |
| 581 | return handle; |
| 582 | } |
| 583 | |
| 584 | // Returns an unused query name |
| 585 | GLuint Context::createQuery() |
| 586 | { |
| 587 | GLuint handle = mQueryHandleAllocator.allocate(); |
| 588 | |
| 589 | mQueryMap[handle] = NULL; |
| 590 | |
| 591 | return handle; |
| 592 | } |
| 593 | |
| 594 | void Context::deleteBuffer(GLuint buffer) |
| 595 | { |
| 596 | if (mResourceManager->getBuffer(buffer)) |
| 597 | { |
| 598 | detachBuffer(buffer); |
| 599 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 600 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 601 | mResourceManager->deleteBuffer(buffer); |
| 602 | } |
| 603 | |
| 604 | void Context::deleteShader(GLuint shader) |
| 605 | { |
| 606 | mResourceManager->deleteShader(shader); |
| 607 | } |
| 608 | |
| 609 | void Context::deleteProgram(GLuint program) |
| 610 | { |
| 611 | mResourceManager->deleteProgram(program); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | void Context::deleteTexture(GLuint texture) |
| 615 | { |
| 616 | if (mResourceManager->getTexture(texture)) |
| 617 | { |
| 618 | detachTexture(texture); |
| 619 | } |
| 620 | |
| 621 | mResourceManager->deleteTexture(texture); |
| 622 | } |
| 623 | |
| 624 | void Context::deleteRenderbuffer(GLuint renderbuffer) |
| 625 | { |
| 626 | if (mResourceManager->getRenderbuffer(renderbuffer)) |
| 627 | { |
| 628 | detachRenderbuffer(renderbuffer); |
| 629 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 630 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 631 | mResourceManager->deleteRenderbuffer(renderbuffer); |
| 632 | } |
| 633 | |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 634 | void Context::deleteFenceSync(GLsync fenceSync) |
| 635 | { |
| 636 | // The spec specifies the underlying Fence object is not deleted until all current |
| 637 | // wait commands finish. However, since the name becomes invalid, we cannot query the fence, |
| 638 | // and since our API is currently designed for being called from a single thread, we can delete |
| 639 | // the fence immediately. |
Minmin Gong | 794e000 | 2015-04-07 18:31:54 -0700 | [diff] [blame] | 640 | mResourceManager->deleteFenceSync(static_cast<GLuint>(reinterpret_cast<uintptr_t>(fenceSync))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 641 | } |
| 642 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 643 | void Context::deletePaths(GLuint first, GLsizei range) |
| 644 | { |
| 645 | mResourceManager->deletePaths(first, range); |
| 646 | } |
| 647 | |
| 648 | bool Context::hasPathData(GLuint path) const |
| 649 | { |
| 650 | const auto *pathObj = mResourceManager->getPath(path); |
| 651 | if (pathObj == nullptr) |
| 652 | return false; |
| 653 | |
| 654 | return pathObj->hasPathData(); |
| 655 | } |
| 656 | |
| 657 | bool Context::hasPath(GLuint path) const |
| 658 | { |
| 659 | return mResourceManager->hasPath(path); |
| 660 | } |
| 661 | |
| 662 | void Context::setPathCommands(GLuint path, |
| 663 | GLsizei numCommands, |
| 664 | const GLubyte *commands, |
| 665 | GLsizei numCoords, |
| 666 | GLenum coordType, |
| 667 | const void *coords) |
| 668 | { |
| 669 | auto *pathObject = mResourceManager->getPath(path); |
| 670 | |
| 671 | handleError(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords)); |
| 672 | } |
| 673 | |
| 674 | void Context::setPathParameterf(GLuint path, GLenum pname, GLfloat value) |
| 675 | { |
| 676 | auto *pathObj = mResourceManager->getPath(path); |
| 677 | |
| 678 | switch (pname) |
| 679 | { |
| 680 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 681 | pathObj->setStrokeWidth(value); |
| 682 | break; |
| 683 | case GL_PATH_END_CAPS_CHROMIUM: |
| 684 | pathObj->setEndCaps(static_cast<GLenum>(value)); |
| 685 | break; |
| 686 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 687 | pathObj->setJoinStyle(static_cast<GLenum>(value)); |
| 688 | break; |
| 689 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 690 | pathObj->setMiterLimit(value); |
| 691 | break; |
| 692 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 693 | pathObj->setStrokeBound(value); |
| 694 | break; |
| 695 | default: |
| 696 | UNREACHABLE(); |
| 697 | break; |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | void Context::getPathParameterfv(GLuint path, GLenum pname, GLfloat *value) const |
| 702 | { |
| 703 | const auto *pathObj = mResourceManager->getPath(path); |
| 704 | |
| 705 | switch (pname) |
| 706 | { |
| 707 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 708 | *value = pathObj->getStrokeWidth(); |
| 709 | break; |
| 710 | case GL_PATH_END_CAPS_CHROMIUM: |
| 711 | *value = static_cast<GLfloat>(pathObj->getEndCaps()); |
| 712 | break; |
| 713 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 714 | *value = static_cast<GLfloat>(pathObj->getJoinStyle()); |
| 715 | break; |
| 716 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 717 | *value = pathObj->getMiterLimit(); |
| 718 | break; |
| 719 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 720 | *value = pathObj->getStrokeBound(); |
| 721 | break; |
| 722 | default: |
| 723 | UNREACHABLE(); |
| 724 | break; |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | void Context::setPathStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 729 | { |
| 730 | mGLState.setPathStencilFunc(func, ref, mask); |
| 731 | } |
| 732 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 733 | void Context::deleteVertexArray(GLuint vertexArray) |
| 734 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 735 | auto iter = mVertexArrayMap.find(vertexArray); |
| 736 | if (iter != mVertexArrayMap.end()) |
Geoff Lang | 50b3fe8 | 2015-12-08 14:49:12 +0000 | [diff] [blame] | 737 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 738 | VertexArray *vertexArrayObject = iter->second; |
| 739 | if (vertexArrayObject != nullptr) |
| 740 | { |
| 741 | detachVertexArray(vertexArray); |
| 742 | delete vertexArrayObject; |
| 743 | } |
Geoff Lang | 50b3fe8 | 2015-12-08 14:49:12 +0000 | [diff] [blame] | 744 | |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 745 | mVertexArrayMap.erase(iter); |
| 746 | mVertexArrayHandleAllocator.release(vertexArray); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 747 | } |
| 748 | } |
| 749 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 750 | void Context::deleteSampler(GLuint sampler) |
| 751 | { |
| 752 | if (mResourceManager->getSampler(sampler)) |
| 753 | { |
| 754 | detachSampler(sampler); |
| 755 | } |
| 756 | |
| 757 | mResourceManager->deleteSampler(sampler); |
| 758 | } |
| 759 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 760 | void Context::deleteTransformFeedback(GLuint transformFeedback) |
| 761 | { |
Jamie Madill | 5fd0b2d | 2015-01-05 13:38:44 -0500 | [diff] [blame] | 762 | auto iter = mTransformFeedbackMap.find(transformFeedback); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 763 | if (iter != mTransformFeedbackMap.end()) |
| 764 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 765 | TransformFeedback *transformFeedbackObject = iter->second; |
| 766 | if (transformFeedbackObject != nullptr) |
| 767 | { |
| 768 | detachTransformFeedback(transformFeedback); |
| 769 | transformFeedbackObject->release(); |
| 770 | } |
| 771 | |
Geoff Lang | 50b3fe8 | 2015-12-08 14:49:12 +0000 | [diff] [blame] | 772 | mTransformFeedbackMap.erase(iter); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 773 | mTransformFeedbackAllocator.release(transformFeedback); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 774 | } |
| 775 | } |
| 776 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 777 | void Context::deleteFramebuffer(GLuint framebuffer) |
| 778 | { |
Jamie Madill | 4e25a0d | 2016-03-08 13:53:03 -0500 | [diff] [blame] | 779 | auto framebufferObject = mFramebufferMap.find(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 780 | |
| 781 | if (framebufferObject != mFramebufferMap.end()) |
| 782 | { |
| 783 | detachFramebuffer(framebuffer); |
| 784 | |
| 785 | mFramebufferHandleAllocator.release(framebufferObject->first); |
| 786 | delete framebufferObject->second; |
| 787 | mFramebufferMap.erase(framebufferObject); |
| 788 | } |
| 789 | } |
| 790 | |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 791 | void Context::deleteFenceNV(GLuint fence) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 792 | { |
Jamie Madill | 4e25a0d | 2016-03-08 13:53:03 -0500 | [diff] [blame] | 793 | auto fenceObject = mFenceNVMap.find(fence); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 794 | |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 795 | if (fenceObject != mFenceNVMap.end()) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 796 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 797 | mFenceNVHandleAllocator.release(fenceObject->first); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 798 | delete fenceObject->second; |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 799 | mFenceNVMap.erase(fenceObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 800 | } |
| 801 | } |
| 802 | |
| 803 | void Context::deleteQuery(GLuint query) |
| 804 | { |
Jamie Madill | 4e25a0d | 2016-03-08 13:53:03 -0500 | [diff] [blame] | 805 | auto queryObject = mQueryMap.find(query); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 806 | if (queryObject != mQueryMap.end()) |
| 807 | { |
| 808 | mQueryHandleAllocator.release(queryObject->first); |
| 809 | if (queryObject->second) |
| 810 | { |
| 811 | queryObject->second->release(); |
| 812 | } |
| 813 | mQueryMap.erase(queryObject); |
| 814 | } |
| 815 | } |
| 816 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 817 | Buffer *Context::getBuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 818 | { |
| 819 | return mResourceManager->getBuffer(handle); |
| 820 | } |
| 821 | |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 822 | Shader *Context::getShader(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 823 | { |
| 824 | return mResourceManager->getShader(handle); |
| 825 | } |
| 826 | |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 827 | Program *Context::getProgram(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 828 | { |
| 829 | return mResourceManager->getProgram(handle); |
| 830 | } |
| 831 | |
Jamie Madill | 570f7c8 | 2014-07-03 10:38:54 -0400 | [diff] [blame] | 832 | Texture *Context::getTexture(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 833 | { |
| 834 | return mResourceManager->getTexture(handle); |
| 835 | } |
| 836 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 837 | Renderbuffer *Context::getRenderbuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 838 | { |
| 839 | return mResourceManager->getRenderbuffer(handle); |
| 840 | } |
| 841 | |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 842 | FenceSync *Context::getFenceSync(GLsync handle) const |
| 843 | { |
Minmin Gong | 794e000 | 2015-04-07 18:31:54 -0700 | [diff] [blame] | 844 | return mResourceManager->getFenceSync(static_cast<GLuint>(reinterpret_cast<uintptr_t>(handle))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 845 | } |
| 846 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 847 | VertexArray *Context::getVertexArray(GLuint handle) const |
| 848 | { |
| 849 | auto vertexArray = mVertexArrayMap.find(handle); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 850 | return (vertexArray != mVertexArrayMap.end()) ? vertexArray->second : nullptr; |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 851 | } |
| 852 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 853 | Sampler *Context::getSampler(GLuint handle) const |
| 854 | { |
| 855 | return mResourceManager->getSampler(handle); |
| 856 | } |
| 857 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 858 | TransformFeedback *Context::getTransformFeedback(GLuint handle) const |
| 859 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 860 | auto iter = mTransformFeedbackMap.find(handle); |
| 861 | return (iter != mTransformFeedbackMap.end()) ? iter->second : nullptr; |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 862 | } |
| 863 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 864 | LabeledObject *Context::getLabeledObject(GLenum identifier, GLuint name) const |
| 865 | { |
| 866 | switch (identifier) |
| 867 | { |
| 868 | case GL_BUFFER: |
| 869 | return getBuffer(name); |
| 870 | case GL_SHADER: |
| 871 | return getShader(name); |
| 872 | case GL_PROGRAM: |
| 873 | return getProgram(name); |
| 874 | case GL_VERTEX_ARRAY: |
| 875 | return getVertexArray(name); |
| 876 | case GL_QUERY: |
| 877 | return getQuery(name); |
| 878 | case GL_TRANSFORM_FEEDBACK: |
| 879 | return getTransformFeedback(name); |
| 880 | case GL_SAMPLER: |
| 881 | return getSampler(name); |
| 882 | case GL_TEXTURE: |
| 883 | return getTexture(name); |
| 884 | case GL_RENDERBUFFER: |
| 885 | return getRenderbuffer(name); |
| 886 | case GL_FRAMEBUFFER: |
| 887 | return getFramebuffer(name); |
| 888 | default: |
| 889 | UNREACHABLE(); |
| 890 | return nullptr; |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | LabeledObject *Context::getLabeledObjectFromPtr(const void *ptr) const |
| 895 | { |
| 896 | return getFenceSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr))); |
| 897 | } |
| 898 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 899 | void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label) |
| 900 | { |
| 901 | LabeledObject *object = getLabeledObject(identifier, name); |
| 902 | ASSERT(object != nullptr); |
| 903 | |
| 904 | std::string labelName = GetObjectLabelFromPointer(length, label); |
| 905 | object->setLabel(labelName); |
| 906 | } |
| 907 | |
| 908 | void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label) |
| 909 | { |
| 910 | LabeledObject *object = getLabeledObjectFromPtr(ptr); |
| 911 | ASSERT(object != nullptr); |
| 912 | |
| 913 | std::string labelName = GetObjectLabelFromPointer(length, label); |
| 914 | object->setLabel(labelName); |
| 915 | } |
| 916 | |
| 917 | void Context::getObjectLabel(GLenum identifier, |
| 918 | GLuint name, |
| 919 | GLsizei bufSize, |
| 920 | GLsizei *length, |
| 921 | GLchar *label) const |
| 922 | { |
| 923 | LabeledObject *object = getLabeledObject(identifier, name); |
| 924 | ASSERT(object != nullptr); |
| 925 | |
| 926 | const std::string &objectLabel = object->getLabel(); |
| 927 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 928 | } |
| 929 | |
| 930 | void Context::getObjectPtrLabel(const void *ptr, |
| 931 | GLsizei bufSize, |
| 932 | GLsizei *length, |
| 933 | GLchar *label) const |
| 934 | { |
| 935 | LabeledObject *object = getLabeledObjectFromPtr(ptr); |
| 936 | ASSERT(object != nullptr); |
| 937 | |
| 938 | const std::string &objectLabel = object->getLabel(); |
| 939 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 940 | } |
| 941 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 942 | bool Context::isSampler(GLuint samplerName) const |
| 943 | { |
| 944 | return mResourceManager->isSampler(samplerName); |
| 945 | } |
| 946 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 947 | void Context::bindArrayBuffer(GLuint bufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 948 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 949 | Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 950 | mGLState.setArrayBufferBinding(buffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 951 | } |
| 952 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 953 | void Context::bindElementArrayBuffer(GLuint bufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 954 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 955 | Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 956 | mGLState.getVertexArray()->setElementArrayBuffer(buffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 957 | } |
| 958 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 959 | void Context::bindTexture(GLenum target, GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 960 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 961 | Texture *texture = nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 962 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 963 | if (handle == 0) |
| 964 | { |
| 965 | texture = mZeroTextures[target].get(); |
| 966 | } |
| 967 | else |
| 968 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 969 | texture = mResourceManager->checkTextureAllocation(mImplementation.get(), handle, target); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 970 | } |
| 971 | |
| 972 | ASSERT(texture); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 973 | mGLState.setSamplerTexture(target, texture); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 974 | } |
| 975 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 976 | void Context::bindReadFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 977 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 978 | Framebuffer *framebuffer = checkFramebufferAllocation(framebufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 979 | mGLState.setReadFramebufferBinding(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 980 | } |
| 981 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 982 | void Context::bindDrawFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 983 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 984 | Framebuffer *framebuffer = checkFramebufferAllocation(framebufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 985 | mGLState.setDrawFramebufferBinding(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 986 | } |
| 987 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 988 | void Context::bindRenderbuffer(GLuint renderbufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 989 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 990 | Renderbuffer *renderbuffer = |
| 991 | mResourceManager->checkRenderbufferAllocation(mImplementation.get(), renderbufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 992 | mGLState.setRenderbufferBinding(renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 993 | } |
| 994 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 995 | void Context::bindVertexArray(GLuint vertexArrayHandle) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 996 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 997 | VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 998 | mGLState.setVertexArrayBinding(vertexArray); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 999 | } |
| 1000 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1001 | void Context::bindSampler(GLuint textureUnit, GLuint samplerHandle) |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1002 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 1003 | ASSERT(textureUnit < mCaps.maxCombinedTextureImageUnits); |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1004 | Sampler *sampler = |
| 1005 | mResourceManager->checkSamplerAllocation(mImplementation.get(), samplerHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1006 | mGLState.setSamplerBinding(textureUnit, sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1007 | } |
| 1008 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1009 | void Context::bindGenericUniformBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1010 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1011 | Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1012 | mGLState.setGenericUniformBufferBinding(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1013 | } |
| 1014 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1015 | void Context::bindIndexedUniformBuffer(GLuint bufferHandle, |
| 1016 | GLuint index, |
| 1017 | GLintptr offset, |
| 1018 | GLsizeiptr size) |
shannon.woods%transgaming.com@gtempaccount.com | 3408935 | 2013-04-13 03:36:57 +0000 | [diff] [blame] | 1019 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1020 | Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1021 | mGLState.setIndexedUniformBufferBinding(index, buffer, offset, size); |
shannon.woods%transgaming.com@gtempaccount.com | 3408935 | 2013-04-13 03:36:57 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1024 | void Context::bindGenericTransformFeedbackBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1025 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1026 | Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1027 | mGLState.getCurrentTransformFeedback()->bindGenericBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1028 | } |
| 1029 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1030 | void Context::bindIndexedTransformFeedbackBuffer(GLuint bufferHandle, |
| 1031 | GLuint index, |
| 1032 | GLintptr offset, |
| 1033 | GLsizeiptr size) |
shannon.woods%transgaming.com@gtempaccount.com | 3408935 | 2013-04-13 03:36:57 +0000 | [diff] [blame] | 1034 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1035 | Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1036 | mGLState.getCurrentTransformFeedback()->bindIndexedBuffer(index, buffer, offset, size); |
shannon.woods%transgaming.com@gtempaccount.com | 3408935 | 2013-04-13 03:36:57 +0000 | [diff] [blame] | 1037 | } |
| 1038 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1039 | void Context::bindCopyReadBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1040 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1041 | Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1042 | mGLState.setCopyReadBufferBinding(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1043 | } |
| 1044 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1045 | void Context::bindCopyWriteBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1046 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1047 | Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1048 | mGLState.setCopyWriteBufferBinding(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1049 | } |
| 1050 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1051 | void Context::bindPixelPackBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1052 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1053 | Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1054 | mGLState.setPixelPackBufferBinding(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1055 | } |
| 1056 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1057 | void Context::bindPixelUnpackBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1058 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1059 | Buffer *buffer = mResourceManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1060 | mGLState.setPixelUnpackBufferBinding(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1061 | } |
| 1062 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1063 | void Context::useProgram(GLuint program) |
| 1064 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1065 | mGLState.setProgram(getProgram(program)); |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1068 | void Context::bindTransformFeedback(GLuint transformFeedbackHandle) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1069 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1070 | TransformFeedback *transformFeedback = |
| 1071 | checkTransformFeedbackAllocation(transformFeedbackHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1072 | mGLState.setTransformFeedbackBinding(transformFeedback); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1073 | } |
| 1074 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1075 | Error Context::beginQuery(GLenum target, GLuint query) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1076 | { |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1077 | Query *queryObject = getQuery(query, true, target); |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1078 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1079 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1080 | // begin query |
| 1081 | Error error = queryObject->begin(); |
| 1082 | if (error.isError()) |
| 1083 | { |
| 1084 | return error; |
| 1085 | } |
| 1086 | |
| 1087 | // set query as active for specified target only if begin succeeded |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1088 | mGLState.setActiveQuery(target, queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1089 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1090 | return Error(GL_NO_ERROR); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1091 | } |
| 1092 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1093 | Error Context::endQuery(GLenum target) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1094 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1095 | Query *queryObject = mGLState.getActiveQuery(target); |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1096 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1097 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1098 | gl::Error error = queryObject->end(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1099 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1100 | // Always unbind the query, even if there was an error. This may delete the query object. |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1101 | mGLState.setActiveQuery(target, NULL); |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1102 | |
| 1103 | return error; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1104 | } |
| 1105 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1106 | Error Context::queryCounter(GLuint id, GLenum target) |
| 1107 | { |
| 1108 | ASSERT(target == GL_TIMESTAMP_EXT); |
| 1109 | |
| 1110 | Query *queryObject = getQuery(id, true, target); |
| 1111 | ASSERT(queryObject); |
| 1112 | |
| 1113 | return queryObject->queryCounter(); |
| 1114 | } |
| 1115 | |
| 1116 | void Context::getQueryiv(GLenum target, GLenum pname, GLint *params) |
| 1117 | { |
| 1118 | switch (pname) |
| 1119 | { |
| 1120 | case GL_CURRENT_QUERY_EXT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1121 | params[0] = mGLState.getActiveQueryId(target); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1122 | break; |
| 1123 | case GL_QUERY_COUNTER_BITS_EXT: |
| 1124 | switch (target) |
| 1125 | { |
| 1126 | case GL_TIME_ELAPSED_EXT: |
| 1127 | params[0] = getExtensions().queryCounterBitsTimeElapsed; |
| 1128 | break; |
| 1129 | case GL_TIMESTAMP_EXT: |
| 1130 | params[0] = getExtensions().queryCounterBitsTimestamp; |
| 1131 | break; |
| 1132 | default: |
| 1133 | UNREACHABLE(); |
| 1134 | params[0] = 0; |
| 1135 | break; |
| 1136 | } |
| 1137 | break; |
| 1138 | default: |
| 1139 | UNREACHABLE(); |
| 1140 | return; |
| 1141 | } |
| 1142 | } |
| 1143 | |
| 1144 | Error Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params) |
| 1145 | { |
| 1146 | return GetQueryObjectParameter(this, id, pname, params); |
| 1147 | } |
| 1148 | |
| 1149 | Error Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) |
| 1150 | { |
| 1151 | return GetQueryObjectParameter(this, id, pname, params); |
| 1152 | } |
| 1153 | |
| 1154 | Error Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) |
| 1155 | { |
| 1156 | return GetQueryObjectParameter(this, id, pname, params); |
| 1157 | } |
| 1158 | |
| 1159 | Error Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) |
| 1160 | { |
| 1161 | return GetQueryObjectParameter(this, id, pname, params); |
| 1162 | } |
| 1163 | |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 1164 | Framebuffer *Context::getFramebuffer(unsigned int handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1165 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1166 | auto framebufferIt = mFramebufferMap.find(handle); |
| 1167 | return ((framebufferIt == mFramebufferMap.end()) ? nullptr : framebufferIt->second); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 1170 | FenceNV *Context::getFenceNV(unsigned int handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1171 | { |
Jamie Madill | 4e25a0d | 2016-03-08 13:53:03 -0500 | [diff] [blame] | 1172 | auto fence = mFenceNVMap.find(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1173 | |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 1174 | if (fence == mFenceNVMap.end()) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1175 | { |
| 1176 | return NULL; |
| 1177 | } |
| 1178 | else |
| 1179 | { |
| 1180 | return fence->second; |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | Query *Context::getQuery(unsigned int handle, bool create, GLenum type) |
| 1185 | { |
Jamie Madill | 4e25a0d | 2016-03-08 13:53:03 -0500 | [diff] [blame] | 1186 | auto query = mQueryMap.find(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1187 | |
| 1188 | if (query == mQueryMap.end()) |
| 1189 | { |
| 1190 | return NULL; |
| 1191 | } |
| 1192 | else |
| 1193 | { |
| 1194 | if (!query->second && create) |
| 1195 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1196 | query->second = new Query(mImplementation->createQuery(type), handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1197 | query->second->addRef(); |
| 1198 | } |
| 1199 | return query->second; |
| 1200 | } |
| 1201 | } |
| 1202 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1203 | Query *Context::getQuery(GLuint handle) const |
| 1204 | { |
| 1205 | auto iter = mQueryMap.find(handle); |
| 1206 | return (iter != mQueryMap.end()) ? iter->second : nullptr; |
| 1207 | } |
| 1208 | |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 1209 | Texture *Context::getTargetTexture(GLenum target) const |
| 1210 | { |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 1211 | ASSERT(ValidTextureTarget(this, target) || ValidTextureExternalTarget(this, target)); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1212 | return mGLState.getTargetTexture(target); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1213 | } |
| 1214 | |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 1215 | Texture *Context::getSamplerTexture(unsigned int sampler, GLenum type) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1216 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1217 | return mGLState.getSamplerTexture(sampler, type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1218 | } |
| 1219 | |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1220 | Compiler *Context::getCompiler() const |
| 1221 | { |
| 1222 | return mCompiler; |
| 1223 | } |
| 1224 | |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1225 | void Context::getBooleanv(GLenum pname, GLboolean *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1226 | { |
| 1227 | switch (pname) |
| 1228 | { |
daniel@transgaming.com | f39967e | 2012-11-28 19:35:56 +0000 | [diff] [blame] | 1229 | case GL_SHADER_COMPILER: *params = GL_TRUE; break; |
daniel@transgaming.com | f39967e | 2012-11-28 19:35:56 +0000 | [diff] [blame] | 1230 | case GL_CONTEXT_ROBUST_ACCESS_EXT: *params = mRobustAccess ? GL_TRUE : GL_FALSE; break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1231 | default: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1232 | mGLState.getBooleanv(pname, params); |
| 1233 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1234 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1235 | } |
| 1236 | |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1237 | void Context::getFloatv(GLenum pname, GLfloat *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1238 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1239 | // Queries about context capabilities and maximums are answered by Context. |
| 1240 | // Queries about current GL state values are answered by State. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1241 | switch (pname) |
| 1242 | { |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1243 | case GL_ALIASED_LINE_WIDTH_RANGE: |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1244 | params[0] = mCaps.minAliasedLineWidth; |
| 1245 | params[1] = mCaps.maxAliasedLineWidth; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1246 | break; |
| 1247 | case GL_ALIASED_POINT_SIZE_RANGE: |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1248 | params[0] = mCaps.minAliasedPointSize; |
| 1249 | params[1] = mCaps.maxAliasedPointSize; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1250 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 1251 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1252 | ASSERT(mExtensions.textureFilterAnisotropic); |
| 1253 | *params = mExtensions.maxTextureAnisotropy; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 1254 | break; |
Geoff Lang | e6d4e12 | 2015-06-29 13:33:55 -0400 | [diff] [blame] | 1255 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 1256 | *params = mCaps.maxLODBias; |
| 1257 | break; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1258 | |
| 1259 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 1260 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 1261 | { |
| 1262 | ASSERT(mExtensions.pathRendering); |
| 1263 | const GLfloat *m = mGLState.getPathRenderingMatrix(pname); |
| 1264 | memcpy(params, m, 16 * sizeof(GLfloat)); |
| 1265 | } |
| 1266 | break; |
| 1267 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1268 | default: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1269 | mGLState.getFloatv(pname, params); |
| 1270 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1271 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1272 | } |
| 1273 | |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1274 | void Context::getIntegerv(GLenum pname, GLint *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1275 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1276 | // Queries about context capabilities and maximums are answered by Context. |
| 1277 | // Queries about current GL state values are answered by State. |
shannon.woods%transgaming.com@gtempaccount.com | bc373e5 | 2013-04-13 03:31:23 +0000 | [diff] [blame] | 1278 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1279 | switch (pname) |
| 1280 | { |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 1281 | case GL_MAX_VERTEX_ATTRIBS: *params = mCaps.maxVertexAttributes; break; |
| 1282 | case GL_MAX_VERTEX_UNIFORM_VECTORS: *params = mCaps.maxVertexUniformVectors; break; |
| 1283 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: *params = mCaps.maxVertexUniformComponents; break; |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 1284 | case GL_MAX_VARYING_VECTORS: *params = mCaps.maxVaryingVectors; break; |
| 1285 | case GL_MAX_VARYING_COMPONENTS: *params = mCaps.maxVertexOutputComponents; break; |
| 1286 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = mCaps.maxCombinedTextureImageUnits; break; |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 1287 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = mCaps.maxVertexTextureImageUnits; break; |
| 1288 | case GL_MAX_TEXTURE_IMAGE_UNITS: *params = mCaps.maxTextureImageUnits; break; |
| 1289 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: *params = mCaps.maxFragmentUniformVectors; break; |
Geoff Lang | e746890 | 2015-10-02 10:46:24 -0400 | [diff] [blame] | 1290 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: *params = mCaps.maxFragmentUniformComponents; break; |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1291 | case GL_MAX_RENDERBUFFER_SIZE: *params = mCaps.maxRenderbufferSize; break; |
| 1292 | case GL_MAX_COLOR_ATTACHMENTS_EXT: *params = mCaps.maxColorAttachments; break; |
| 1293 | case GL_MAX_DRAW_BUFFERS_EXT: *params = mCaps.maxDrawBuffers; break; |
Jamie Madill | 1caff07 | 2013-07-19 16:36:56 -0400 | [diff] [blame] | 1294 | //case GL_FRAMEBUFFER_BINDING: // now equivalent to GL_DRAW_FRAMEBUFFER_BINDING_ANGLE |
Jamie Madill | 1caff07 | 2013-07-19 16:36:56 -0400 | [diff] [blame] | 1295 | case GL_SUBPIXEL_BITS: *params = 4; break; |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1296 | case GL_MAX_TEXTURE_SIZE: *params = mCaps.max2DTextureSize; break; |
| 1297 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = mCaps.maxCubeMapTextureSize; break; |
| 1298 | case GL_MAX_3D_TEXTURE_SIZE: *params = mCaps.max3DTextureSize; break; |
| 1299 | case GL_MAX_ARRAY_TEXTURE_LAYERS: *params = mCaps.maxArrayTextureLayers; break; |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 1300 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: *params = mCaps.uniformBufferOffsetAlignment; break; |
| 1301 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: *params = mCaps.maxUniformBufferBindings; break; |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 1302 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: *params = mCaps.maxVertexUniformBlocks; break; |
| 1303 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: *params = mCaps.maxFragmentUniformBlocks; break; |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 1304 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: *params = mCaps.maxCombinedTextureImageUnits; break; |
Geoff Lang | e6d4e12 | 2015-06-29 13:33:55 -0400 | [diff] [blame] | 1305 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: *params = mCaps.maxVertexOutputComponents; break; |
| 1306 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: *params = mCaps.maxFragmentInputComponents; break; |
| 1307 | case GL_MIN_PROGRAM_TEXEL_OFFSET: *params = mCaps.minProgramTexelOffset; break; |
| 1308 | case GL_MAX_PROGRAM_TEXEL_OFFSET: *params = mCaps.maxProgramTexelOffset; break; |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 1309 | case GL_MAJOR_VERSION: |
| 1310 | *params = mClientMajorVersion; |
| 1311 | break; |
| 1312 | case GL_MINOR_VERSION: |
| 1313 | *params = mClientMinorVersion; |
| 1314 | break; |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 1315 | case GL_MAX_ELEMENTS_INDICES: *params = mCaps.maxElementsIndices; break; |
| 1316 | case GL_MAX_ELEMENTS_VERTICES: *params = mCaps.maxElementsVertices; break; |
Geoff Lang | 05881a0 | 2014-07-10 14:05:30 -0400 | [diff] [blame] | 1317 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: *params = mCaps.maxTransformFeedbackInterleavedComponents; break; |
| 1318 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: *params = mCaps.maxTransformFeedbackSeparateAttributes; break; |
| 1319 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: *params = mCaps.maxTransformFeedbackSeparateComponents; break; |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 1320 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 1321 | *params = static_cast<GLint>(mCaps.compressedTextureFormats.size()); |
| 1322 | break; |
Geoff Lang | def624b | 2015-04-13 10:46:56 -0400 | [diff] [blame] | 1323 | case GL_MAX_SAMPLES_ANGLE: *params = mCaps.maxSamples; break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1324 | case GL_MAX_VIEWPORT_DIMS: |
| 1325 | { |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1326 | params[0] = mCaps.maxViewportWidth; |
| 1327 | params[1] = mCaps.maxViewportHeight; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1328 | } |
| 1329 | break; |
| 1330 | case GL_COMPRESSED_TEXTURE_FORMATS: |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 1331 | std::copy(mCaps.compressedTextureFormats.begin(), mCaps.compressedTextureFormats.end(), params); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1332 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1333 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 1334 | *params = mResetStrategy; |
| 1335 | break; |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 1336 | case GL_NUM_SHADER_BINARY_FORMATS: |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 1337 | *params = static_cast<GLint>(mCaps.shaderBinaryFormats.size()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1338 | break; |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 1339 | case GL_SHADER_BINARY_FORMATS: |
| 1340 | std::copy(mCaps.shaderBinaryFormats.begin(), mCaps.shaderBinaryFormats.end(), params); |
| 1341 | break; |
| 1342 | case GL_NUM_PROGRAM_BINARY_FORMATS: |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 1343 | *params = static_cast<GLint>(mCaps.programBinaryFormats.size()); |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 1344 | break; |
| 1345 | case GL_PROGRAM_BINARY_FORMATS: |
| 1346 | std::copy(mCaps.programBinaryFormats.begin(), mCaps.programBinaryFormats.end(), params); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1347 | break; |
Geoff Lang | 23c8169 | 2013-08-12 10:46:58 -0400 | [diff] [blame] | 1348 | case GL_NUM_EXTENSIONS: |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 1349 | *params = static_cast<GLint>(mExtensionStrings.size()); |
Geoff Lang | 23c8169 | 2013-08-12 10:46:58 -0400 | [diff] [blame] | 1350 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1351 | |
| 1352 | // GL_KHR_debug |
| 1353 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 1354 | *params = mExtensions.maxDebugMessageLength; |
| 1355 | break; |
| 1356 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 1357 | *params = mExtensions.maxDebugLoggedMessages; |
| 1358 | break; |
| 1359 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 1360 | *params = mExtensions.maxDebugGroupStackDepth; |
| 1361 | break; |
| 1362 | case GL_MAX_LABEL_LENGTH: |
| 1363 | *params = mExtensions.maxLabelLength; |
| 1364 | break; |
| 1365 | |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 1366 | // GL_EXT_disjoint_timer_query |
| 1367 | case GL_GPU_DISJOINT_EXT: |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1368 | *params = mImplementation->getGPUDisjoint(); |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 1369 | break; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame^] | 1370 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 1371 | *params = mCaps.maxFramebufferWidth; |
| 1372 | break; |
| 1373 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 1374 | *params = mCaps.maxFramebufferHeight; |
| 1375 | break; |
| 1376 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 1377 | *params = mCaps.maxFramebufferSamples; |
| 1378 | break; |
| 1379 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 1380 | *params = mCaps.maxSampleMaskWords; |
| 1381 | break; |
| 1382 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 1383 | *params = mCaps.maxColorTextureSamples; |
| 1384 | break; |
| 1385 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 1386 | *params = mCaps.maxDepthTextureSamples; |
| 1387 | break; |
| 1388 | case GL_MAX_INTEGER_SAMPLES: |
| 1389 | *params = mCaps.maxIntegerSamples; |
| 1390 | break; |
| 1391 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 1392 | *params = mCaps.maxVertexAttribRelativeOffset; |
| 1393 | break; |
| 1394 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 1395 | *params = mCaps.maxVertexAttribBindings; |
| 1396 | break; |
| 1397 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 1398 | *params = mCaps.maxVertexAttribStride; |
| 1399 | break; |
| 1400 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
| 1401 | *params = mCaps.maxVertexAtomicCounterBuffers; |
| 1402 | break; |
| 1403 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
| 1404 | *params = mCaps.maxVertexAtomicCounters; |
| 1405 | break; |
| 1406 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
| 1407 | *params = mCaps.maxVertexImageUniforms; |
| 1408 | break; |
| 1409 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
| 1410 | *params = mCaps.maxVertexShaderStorageBlocks; |
| 1411 | break; |
| 1412 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
| 1413 | *params = mCaps.maxFragmentAtomicCounterBuffers; |
| 1414 | break; |
| 1415 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
| 1416 | *params = mCaps.maxFragmentAtomicCounters; |
| 1417 | break; |
| 1418 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
| 1419 | *params = mCaps.maxFragmentImageUniforms; |
| 1420 | break; |
| 1421 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
| 1422 | *params = mCaps.maxFragmentShaderStorageBlocks; |
| 1423 | break; |
| 1424 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 1425 | *params = mCaps.minProgramTextureGatherOffset; |
| 1426 | break; |
| 1427 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 1428 | *params = mCaps.maxProgramTextureGatherOffset; |
| 1429 | break; |
| 1430 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 1431 | *params = mCaps.maxComputeWorkGroupInvocations; |
| 1432 | break; |
| 1433 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
| 1434 | *params = mCaps.maxComputeUniformBlocks; |
| 1435 | break; |
| 1436 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
| 1437 | *params = mCaps.maxComputeTextureImageUnits; |
| 1438 | break; |
| 1439 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 1440 | *params = mCaps.maxComputeSharedMemorySize; |
| 1441 | break; |
| 1442 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
| 1443 | *params = mCaps.maxComputeUniformComponents; |
| 1444 | break; |
| 1445 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
| 1446 | *params = mCaps.maxComputeAtomicCounterBuffers; |
| 1447 | break; |
| 1448 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
| 1449 | *params = mCaps.maxComputeAtomicCounters; |
| 1450 | break; |
| 1451 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
| 1452 | *params = mCaps.maxComputeImageUniforms; |
| 1453 | break; |
| 1454 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
| 1455 | *params = mCaps.maxCombinedComputeUniformComponents; |
| 1456 | break; |
| 1457 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
| 1458 | *params = mCaps.maxComputeShaderStorageBlocks; |
| 1459 | break; |
| 1460 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 1461 | *params = mCaps.maxCombinedShaderOutputResources; |
| 1462 | break; |
| 1463 | case GL_MAX_UNIFORM_LOCATIONS: |
| 1464 | *params = mCaps.maxUniformLocations; |
| 1465 | break; |
| 1466 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 1467 | *params = mCaps.maxAtomicCounterBufferBindings; |
| 1468 | break; |
| 1469 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 1470 | *params = mCaps.maxAtomicCounterBufferSize; |
| 1471 | break; |
| 1472 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 1473 | *params = mCaps.maxCombinedAtomicCounterBuffers; |
| 1474 | break; |
| 1475 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 1476 | *params = mCaps.maxCombinedAtomicCounters; |
| 1477 | break; |
| 1478 | case GL_MAX_IMAGE_UNITS: |
| 1479 | *params = mCaps.maxImageUnits; |
| 1480 | break; |
| 1481 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 1482 | *params = mCaps.maxCombinedImageUniforms; |
| 1483 | break; |
| 1484 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 1485 | *params = mCaps.maxShaderStorageBufferBindings; |
| 1486 | break; |
| 1487 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 1488 | *params = mCaps.maxCombinedShaderStorageBlocks; |
| 1489 | break; |
| 1490 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 1491 | *params = mCaps.shaderStorageBufferOffsetAlignment; |
| 1492 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1493 | default: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1494 | mGLState.getIntegerv(mState, pname, params); |
| 1495 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1496 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1497 | } |
| 1498 | |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1499 | void Context::getInteger64v(GLenum pname, GLint64 *params) |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1500 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1501 | // Queries about context capabilities and maximums are answered by Context. |
| 1502 | // Queries about current GL state values are answered by State. |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1503 | switch (pname) |
| 1504 | { |
| 1505 | case GL_MAX_ELEMENT_INDEX: |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1506 | *params = mCaps.maxElementIndex; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1507 | break; |
| 1508 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 1509 | *params = mCaps.maxUniformBlockSize; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1510 | break; |
| 1511 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 1512 | *params = mCaps.maxCombinedVertexUniformComponents; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1513 | break; |
| 1514 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 1515 | *params = mCaps.maxCombinedFragmentUniformComponents; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1516 | break; |
| 1517 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 1518 | *params = mCaps.maxServerWaitTimeout; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1519 | break; |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 1520 | |
| 1521 | // GL_EXT_disjoint_timer_query |
| 1522 | case GL_TIMESTAMP_EXT: |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1523 | *params = mImplementation->getTimestamp(); |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 1524 | break; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame^] | 1525 | |
| 1526 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 1527 | *params = mCaps.maxShaderStorageBlockSize; |
| 1528 | break; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1529 | default: |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1530 | UNREACHABLE(); |
| 1531 | break; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1532 | } |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1533 | } |
| 1534 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1535 | void Context::getPointerv(GLenum pname, void **params) const |
| 1536 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1537 | mGLState.getPointerv(pname, params); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1538 | } |
| 1539 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame^] | 1540 | void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1541 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1542 | // Queries about context capabilities and maximums are answered by Context. |
| 1543 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame^] | 1544 | |
| 1545 | GLenum nativeType; |
| 1546 | unsigned int numParams; |
| 1547 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1548 | ASSERT(queryStatus); |
| 1549 | |
| 1550 | if (nativeType == GL_INT) |
| 1551 | { |
| 1552 | switch (target) |
| 1553 | { |
| 1554 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 1555 | ASSERT(index < 3u); |
| 1556 | *data = mCaps.maxComputeWorkGroupCount[index]; |
| 1557 | break; |
| 1558 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 1559 | ASSERT(index < 3u); |
| 1560 | *data = mCaps.maxComputeWorkGroupSize[index]; |
| 1561 | break; |
| 1562 | default: |
| 1563 | mGLState.getIntegeri_v(target, index, data); |
| 1564 | } |
| 1565 | } |
| 1566 | else |
| 1567 | { |
| 1568 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1569 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1570 | } |
| 1571 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame^] | 1572 | void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1573 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1574 | // Queries about context capabilities and maximums are answered by Context. |
| 1575 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame^] | 1576 | |
| 1577 | GLenum nativeType; |
| 1578 | unsigned int numParams; |
| 1579 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1580 | ASSERT(queryStatus); |
| 1581 | |
| 1582 | if (nativeType == GL_INT_64_ANGLEX) |
| 1583 | { |
| 1584 | mGLState.getInteger64i_v(target, index, data); |
| 1585 | } |
| 1586 | else |
| 1587 | { |
| 1588 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1589 | } |
| 1590 | } |
| 1591 | |
| 1592 | void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data) |
| 1593 | { |
| 1594 | // Queries about context capabilities and maximums are answered by Context. |
| 1595 | // Queries about current GL state values are answered by State. |
| 1596 | |
| 1597 | GLenum nativeType; |
| 1598 | unsigned int numParams; |
| 1599 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1600 | ASSERT(queryStatus); |
| 1601 | |
| 1602 | if (nativeType == GL_BOOL) |
| 1603 | { |
| 1604 | mGLState.getBooleani_v(target, index, data); |
| 1605 | } |
| 1606 | else |
| 1607 | { |
| 1608 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1609 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1610 | } |
| 1611 | |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1612 | Error Context::drawArrays(GLenum mode, GLint first, GLsizei count) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1613 | { |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 1614 | syncRendererState(); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1615 | ANGLE_TRY(mImplementation->drawArrays(mode, first, count)); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1616 | MarkTransformFeedbackBufferUsage(mGLState.getCurrentTransformFeedback()); |
Geoff Lang | 520c4ae | 2015-05-05 13:12:36 -0400 | [diff] [blame] | 1617 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1618 | return NoError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1619 | } |
| 1620 | |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1621 | Error Context::drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 1622 | { |
| 1623 | syncRendererState(); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1624 | ANGLE_TRY(mImplementation->drawArraysInstanced(mode, first, count, instanceCount)); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1625 | MarkTransformFeedbackBufferUsage(mGLState.getCurrentTransformFeedback()); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1626 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1627 | return NoError(); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1628 | } |
| 1629 | |
| 1630 | Error Context::drawElements(GLenum mode, |
| 1631 | GLsizei count, |
| 1632 | GLenum type, |
| 1633 | const GLvoid *indices, |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 1634 | const IndexRange &indexRange) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1635 | { |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 1636 | syncRendererState(); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1637 | return mImplementation->drawElements(mode, count, type, indices, indexRange); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1638 | } |
| 1639 | |
| 1640 | Error Context::drawElementsInstanced(GLenum mode, |
| 1641 | GLsizei count, |
| 1642 | GLenum type, |
| 1643 | const GLvoid *indices, |
| 1644 | GLsizei instances, |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 1645 | const IndexRange &indexRange) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1646 | { |
| 1647 | syncRendererState(); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1648 | return mImplementation->drawElementsInstanced(mode, count, type, indices, instances, |
| 1649 | indexRange); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1650 | } |
| 1651 | |
| 1652 | Error Context::drawRangeElements(GLenum mode, |
| 1653 | GLuint start, |
| 1654 | GLuint end, |
| 1655 | GLsizei count, |
| 1656 | GLenum type, |
| 1657 | const GLvoid *indices, |
Geoff Lang | 3edfe03 | 2015-09-04 16:38:24 -0400 | [diff] [blame] | 1658 | const IndexRange &indexRange) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1659 | { |
| 1660 | syncRendererState(); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1661 | return mImplementation->drawRangeElements(mode, start, end, count, type, indices, indexRange); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1662 | } |
| 1663 | |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 1664 | Error Context::flush() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1665 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1666 | return mImplementation->flush(); |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 1667 | } |
| 1668 | |
| 1669 | Error Context::finish() |
| 1670 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1671 | return mImplementation->finish(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1672 | } |
| 1673 | |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 1674 | void Context::insertEventMarker(GLsizei length, const char *marker) |
| 1675 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1676 | ASSERT(mImplementation); |
| 1677 | mImplementation->insertEventMarker(length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 1678 | } |
| 1679 | |
| 1680 | void Context::pushGroupMarker(GLsizei length, const char *marker) |
| 1681 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1682 | ASSERT(mImplementation); |
| 1683 | mImplementation->pushGroupMarker(length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 1684 | } |
| 1685 | |
| 1686 | void Context::popGroupMarker() |
| 1687 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1688 | ASSERT(mImplementation); |
| 1689 | mImplementation->popGroupMarker(); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 1690 | } |
| 1691 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 1692 | void Context::bindUniformLocation(GLuint program, GLint location, const GLchar *name) |
| 1693 | { |
| 1694 | Program *programObject = getProgram(program); |
| 1695 | ASSERT(programObject); |
| 1696 | |
| 1697 | programObject->bindUniformLocation(location, name); |
| 1698 | } |
| 1699 | |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 1700 | void Context::setCoverageModulation(GLenum components) |
| 1701 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1702 | mGLState.setCoverageModulation(components); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 1703 | } |
| 1704 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1705 | void Context::loadPathRenderingMatrix(GLenum matrixMode, const GLfloat *matrix) |
| 1706 | { |
| 1707 | mGLState.loadPathRenderingMatrix(matrixMode, matrix); |
| 1708 | } |
| 1709 | |
| 1710 | void Context::loadPathRenderingIdentityMatrix(GLenum matrixMode) |
| 1711 | { |
| 1712 | GLfloat I[16]; |
| 1713 | angle::Matrix<GLfloat>::setToIdentity(I); |
| 1714 | |
| 1715 | mGLState.loadPathRenderingMatrix(matrixMode, I); |
| 1716 | } |
| 1717 | |
| 1718 | void Context::stencilFillPath(GLuint path, GLenum fillMode, GLuint mask) |
| 1719 | { |
| 1720 | const auto *pathObj = mResourceManager->getPath(path); |
| 1721 | if (!pathObj) |
| 1722 | return; |
| 1723 | |
| 1724 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1725 | syncRendererState(); |
| 1726 | |
| 1727 | mImplementation->stencilFillPath(pathObj, fillMode, mask); |
| 1728 | } |
| 1729 | |
| 1730 | void Context::stencilStrokePath(GLuint path, GLint reference, GLuint mask) |
| 1731 | { |
| 1732 | const auto *pathObj = mResourceManager->getPath(path); |
| 1733 | if (!pathObj) |
| 1734 | return; |
| 1735 | |
| 1736 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1737 | syncRendererState(); |
| 1738 | |
| 1739 | mImplementation->stencilStrokePath(pathObj, reference, mask); |
| 1740 | } |
| 1741 | |
| 1742 | void Context::coverFillPath(GLuint path, GLenum coverMode) |
| 1743 | { |
| 1744 | const auto *pathObj = mResourceManager->getPath(path); |
| 1745 | if (!pathObj) |
| 1746 | return; |
| 1747 | |
| 1748 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1749 | syncRendererState(); |
| 1750 | |
| 1751 | mImplementation->coverFillPath(pathObj, coverMode); |
| 1752 | } |
| 1753 | |
| 1754 | void Context::coverStrokePath(GLuint path, GLenum coverMode) |
| 1755 | { |
| 1756 | const auto *pathObj = mResourceManager->getPath(path); |
| 1757 | if (!pathObj) |
| 1758 | return; |
| 1759 | |
| 1760 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1761 | syncRendererState(); |
| 1762 | |
| 1763 | mImplementation->coverStrokePath(pathObj, coverMode); |
| 1764 | } |
| 1765 | |
| 1766 | void Context::stencilThenCoverFillPath(GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode) |
| 1767 | { |
| 1768 | const auto *pathObj = mResourceManager->getPath(path); |
| 1769 | if (!pathObj) |
| 1770 | return; |
| 1771 | |
| 1772 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1773 | syncRendererState(); |
| 1774 | |
| 1775 | mImplementation->stencilThenCoverFillPath(pathObj, fillMode, mask, coverMode); |
| 1776 | } |
| 1777 | |
| 1778 | void Context::stencilThenCoverStrokePath(GLuint path, |
| 1779 | GLint reference, |
| 1780 | GLuint mask, |
| 1781 | GLenum coverMode) |
| 1782 | { |
| 1783 | const auto *pathObj = mResourceManager->getPath(path); |
| 1784 | if (!pathObj) |
| 1785 | return; |
| 1786 | |
| 1787 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1788 | syncRendererState(); |
| 1789 | |
| 1790 | mImplementation->stencilThenCoverStrokePath(pathObj, reference, mask, coverMode); |
| 1791 | } |
| 1792 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1793 | void Context::coverFillPathInstanced(GLsizei numPaths, |
| 1794 | GLenum pathNameType, |
| 1795 | const void *paths, |
| 1796 | GLuint pathBase, |
| 1797 | GLenum coverMode, |
| 1798 | GLenum transformType, |
| 1799 | const GLfloat *transformValues) |
| 1800 | { |
| 1801 | const auto &pathObjects = |
| 1802 | GatherPaths(*mResourceManager, numPaths, pathNameType, paths, pathBase); |
| 1803 | |
| 1804 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1805 | syncRendererState(); |
| 1806 | |
| 1807 | mImplementation->coverFillPathInstanced(pathObjects, coverMode, transformType, transformValues); |
| 1808 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 1809 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1810 | void Context::coverStrokePathInstanced(GLsizei numPaths, |
| 1811 | GLenum pathNameType, |
| 1812 | const void *paths, |
| 1813 | GLuint pathBase, |
| 1814 | GLenum coverMode, |
| 1815 | GLenum transformType, |
| 1816 | const GLfloat *transformValues) |
| 1817 | { |
| 1818 | const auto &pathObjects = |
| 1819 | GatherPaths(*mResourceManager, numPaths, pathNameType, paths, pathBase); |
| 1820 | |
| 1821 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1822 | syncRendererState(); |
| 1823 | |
| 1824 | mImplementation->coverStrokePathInstanced(pathObjects, coverMode, transformType, |
| 1825 | transformValues); |
| 1826 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 1827 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1828 | void Context::stencilFillPathInstanced(GLsizei numPaths, |
| 1829 | GLenum pathNameType, |
| 1830 | const void *paths, |
| 1831 | GLuint pathBase, |
| 1832 | GLenum fillMode, |
| 1833 | GLuint mask, |
| 1834 | GLenum transformType, |
| 1835 | const GLfloat *transformValues) |
| 1836 | { |
| 1837 | const auto &pathObjects = |
| 1838 | GatherPaths(*mResourceManager, numPaths, pathNameType, paths, pathBase); |
| 1839 | |
| 1840 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1841 | syncRendererState(); |
| 1842 | |
| 1843 | mImplementation->stencilFillPathInstanced(pathObjects, fillMode, mask, transformType, |
| 1844 | transformValues); |
| 1845 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 1846 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1847 | void Context::stencilStrokePathInstanced(GLsizei numPaths, |
| 1848 | GLenum pathNameType, |
| 1849 | const void *paths, |
| 1850 | GLuint pathBase, |
| 1851 | GLint reference, |
| 1852 | GLuint mask, |
| 1853 | GLenum transformType, |
| 1854 | const GLfloat *transformValues) |
| 1855 | { |
| 1856 | const auto &pathObjects = |
| 1857 | GatherPaths(*mResourceManager, numPaths, pathNameType, paths, pathBase); |
| 1858 | |
| 1859 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1860 | syncRendererState(); |
| 1861 | |
| 1862 | mImplementation->stencilStrokePathInstanced(pathObjects, reference, mask, transformType, |
| 1863 | transformValues); |
| 1864 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 1865 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1866 | void Context::stencilThenCoverFillPathInstanced(GLsizei numPaths, |
| 1867 | GLenum pathNameType, |
| 1868 | const void *paths, |
| 1869 | GLuint pathBase, |
| 1870 | GLenum fillMode, |
| 1871 | GLuint mask, |
| 1872 | GLenum coverMode, |
| 1873 | GLenum transformType, |
| 1874 | const GLfloat *transformValues) |
| 1875 | { |
| 1876 | const auto &pathObjects = |
| 1877 | GatherPaths(*mResourceManager, numPaths, pathNameType, paths, pathBase); |
| 1878 | |
| 1879 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1880 | syncRendererState(); |
| 1881 | |
| 1882 | mImplementation->stencilThenCoverFillPathInstanced(pathObjects, coverMode, fillMode, mask, |
| 1883 | transformType, transformValues); |
| 1884 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 1885 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1886 | void Context::stencilThenCoverStrokePathInstanced(GLsizei numPaths, |
| 1887 | GLenum pathNameType, |
| 1888 | const void *paths, |
| 1889 | GLuint pathBase, |
| 1890 | GLint reference, |
| 1891 | GLuint mask, |
| 1892 | GLenum coverMode, |
| 1893 | GLenum transformType, |
| 1894 | const GLfloat *transformValues) |
| 1895 | { |
| 1896 | const auto &pathObjects = |
| 1897 | GatherPaths(*mResourceManager, numPaths, pathNameType, paths, pathBase); |
| 1898 | |
| 1899 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1900 | syncRendererState(); |
| 1901 | |
| 1902 | mImplementation->stencilThenCoverStrokePathInstanced(pathObjects, coverMode, reference, mask, |
| 1903 | transformType, transformValues); |
| 1904 | } |
| 1905 | |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 1906 | void Context::bindFragmentInputLocation(GLuint program, GLint location, const GLchar *name) |
| 1907 | { |
| 1908 | auto *programObject = getProgram(program); |
| 1909 | |
| 1910 | programObject->bindFragmentInputLocation(location, name); |
| 1911 | } |
| 1912 | |
| 1913 | void Context::programPathFragmentInputGen(GLuint program, |
| 1914 | GLint location, |
| 1915 | GLenum genMode, |
| 1916 | GLint components, |
| 1917 | const GLfloat *coeffs) |
| 1918 | { |
| 1919 | auto *programObject = getProgram(program); |
| 1920 | |
| 1921 | programObject->pathFragmentInputGen(location, genMode, components, coeffs); |
| 1922 | } |
| 1923 | |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 1924 | void Context::handleError(const Error &error) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1925 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 1926 | if (error.isError()) |
| 1927 | { |
| 1928 | mErrors.insert(error.getCode()); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1929 | |
| 1930 | if (!error.getMessage().empty()) |
| 1931 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1932 | auto *debug = &mGLState.getDebug(); |
| 1933 | debug->insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, error.getID(), |
| 1934 | GL_DEBUG_SEVERITY_HIGH, error.getMessage()); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1935 | } |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 1936 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1937 | } |
| 1938 | |
| 1939 | // Get one of the recorded errors and clear its flag, if any. |
| 1940 | // [OpenGL ES 2.0.24] section 2.5 page 13. |
| 1941 | GLenum Context::getError() |
| 1942 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 1943 | if (mErrors.empty()) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1944 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 1945 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1946 | } |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 1947 | else |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1948 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 1949 | GLenum error = *mErrors.begin(); |
| 1950 | mErrors.erase(mErrors.begin()); |
| 1951 | return error; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1952 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1953 | } |
| 1954 | |
| 1955 | GLenum Context::getResetStatus() |
| 1956 | { |
Jamie Madill | 93e13fb | 2014-11-06 15:27:25 -0500 | [diff] [blame] | 1957 | //TODO(jmadill): needs MANGLE reworking |
shannon.woods@transgaming.com | ddd6c80 | 2013-02-28 23:05:14 +0000 | [diff] [blame] | 1958 | if (mResetStatus == GL_NO_ERROR && !mContextLost) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1959 | { |
daniel@transgaming.com | f688c0d | 2012-10-31 17:52:57 +0000 | [diff] [blame] | 1960 | // mResetStatus will be set by the markContextLost callback |
| 1961 | // in the case a notification is sent |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1962 | if (mImplementation->testDeviceLost()) |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 1963 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1964 | mImplementation->notifyDeviceLost(); |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 1965 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1966 | } |
| 1967 | |
| 1968 | GLenum status = mResetStatus; |
| 1969 | |
| 1970 | if (mResetStatus != GL_NO_ERROR) |
| 1971 | { |
shannon.woods@transgaming.com | ddd6c80 | 2013-02-28 23:05:14 +0000 | [diff] [blame] | 1972 | ASSERT(mContextLost); |
| 1973 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1974 | if (mImplementation->testDeviceResettable()) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1975 | { |
| 1976 | mResetStatus = GL_NO_ERROR; |
| 1977 | } |
| 1978 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1979 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1980 | return status; |
| 1981 | } |
| 1982 | |
| 1983 | bool Context::isResetNotificationEnabled() |
| 1984 | { |
| 1985 | return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
| 1986 | } |
| 1987 | |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 1988 | const egl::Config *Context::getConfig() const |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 1989 | { |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 1990 | return mConfig; |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 1991 | } |
| 1992 | |
| 1993 | EGLenum Context::getClientType() const |
| 1994 | { |
| 1995 | return mClientType; |
| 1996 | } |
| 1997 | |
| 1998 | EGLenum Context::getRenderBuffer() const |
| 1999 | { |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 2000 | auto framebufferIt = mFramebufferMap.find(0); |
| 2001 | if (framebufferIt != mFramebufferMap.end()) |
| 2002 | { |
| 2003 | const Framebuffer *framebuffer = framebufferIt->second; |
| 2004 | const FramebufferAttachment *backAttachment = framebuffer->getAttachment(GL_BACK); |
| 2005 | |
| 2006 | ASSERT(backAttachment != nullptr); |
| 2007 | return backAttachment->getSurface()->getRenderBuffer(); |
| 2008 | } |
| 2009 | else |
| 2010 | { |
| 2011 | return EGL_NONE; |
| 2012 | } |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2013 | } |
| 2014 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2015 | VertexArray *Context::checkVertexArrayAllocation(GLuint vertexArrayHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2016 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2017 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2018 | VertexArray *vertexArray = getVertexArray(vertexArrayHandle); |
| 2019 | if (!vertexArray) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2020 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2021 | vertexArray = new VertexArray(mImplementation.get(), vertexArrayHandle, MAX_VERTEX_ATTRIBS); |
| 2022 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2023 | mVertexArrayMap[vertexArrayHandle] = vertexArray; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2024 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2025 | |
| 2026 | return vertexArray; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2027 | } |
| 2028 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2029 | TransformFeedback *Context::checkTransformFeedbackAllocation(GLuint transformFeedbackHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2030 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2031 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2032 | TransformFeedback *transformFeedback = getTransformFeedback(transformFeedbackHandle); |
| 2033 | if (!transformFeedback) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2034 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2035 | transformFeedback = |
| 2036 | new TransformFeedback(mImplementation.get(), transformFeedbackHandle, mCaps); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2037 | transformFeedback->addRef(); |
| 2038 | mTransformFeedbackMap[transformFeedbackHandle] = transformFeedback; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2039 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2040 | |
| 2041 | return transformFeedback; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2042 | } |
| 2043 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2044 | Framebuffer *Context::checkFramebufferAllocation(GLuint framebuffer) |
| 2045 | { |
| 2046 | // Can be called from Bind without a prior call to Gen. |
| 2047 | auto framebufferIt = mFramebufferMap.find(framebuffer); |
| 2048 | bool neverCreated = framebufferIt == mFramebufferMap.end(); |
| 2049 | if (neverCreated || framebufferIt->second == nullptr) |
| 2050 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2051 | Framebuffer *newFBO = new Framebuffer(mCaps, mImplementation.get(), framebuffer); |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2052 | if (neverCreated) |
| 2053 | { |
| 2054 | mFramebufferHandleAllocator.reserve(framebuffer); |
| 2055 | mFramebufferMap[framebuffer] = newFBO; |
| 2056 | return newFBO; |
| 2057 | } |
| 2058 | |
| 2059 | framebufferIt->second = newFBO; |
| 2060 | } |
| 2061 | |
| 2062 | return framebufferIt->second; |
| 2063 | } |
| 2064 | |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2065 | bool Context::isVertexArrayGenerated(GLuint vertexArray) |
| 2066 | { |
| 2067 | return mVertexArrayMap.find(vertexArray) != mVertexArrayMap.end(); |
| 2068 | } |
| 2069 | |
| 2070 | bool Context::isTransformFeedbackGenerated(GLuint transformFeedback) |
| 2071 | { |
| 2072 | return mTransformFeedbackMap.find(transformFeedback) != mTransformFeedbackMap.end(); |
| 2073 | } |
| 2074 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2075 | void Context::detachTexture(GLuint texture) |
| 2076 | { |
| 2077 | // Simple pass-through to State's detachTexture method, as textures do not require |
| 2078 | // allocation map management either here or in the resource manager at detach time. |
| 2079 | // Zero textures are held by the Context, and we don't attempt to request them from |
| 2080 | // the State. |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2081 | mGLState.detachTexture(mZeroTextures, texture); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2082 | } |
| 2083 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2084 | void Context::detachBuffer(GLuint buffer) |
| 2085 | { |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2086 | // Simple pass-through to State's detachBuffer method, since |
| 2087 | // only buffer attachments to container objects that are bound to the current context |
| 2088 | // should be detached. And all those are available in State. |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2089 | |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2090 | // [OpenGL ES 3.2] section 5.1.2 page 45: |
| 2091 | // Attachments to unbound container objects, such as |
| 2092 | // deletion of a buffer attached to a vertex array object which is not bound to the context, |
| 2093 | // are not affected and continue to act as references on the deleted object |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2094 | mGLState.detachBuffer(buffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2095 | } |
| 2096 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2097 | void Context::detachFramebuffer(GLuint framebuffer) |
| 2098 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2099 | // Framebuffer detachment is handled by Context, because 0 is a valid |
| 2100 | // Framebuffer object, and a pointer to it must be passed from Context |
| 2101 | // to State at binding time. |
| 2102 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2103 | // [OpenGL ES 2.0.24] section 4.4 page 107: |
| 2104 | // If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as though |
| 2105 | // BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of zero. |
| 2106 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2107 | if (mGLState.removeReadFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2108 | { |
| 2109 | bindReadFramebuffer(0); |
| 2110 | } |
| 2111 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2112 | if (mGLState.removeDrawFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2113 | { |
| 2114 | bindDrawFramebuffer(0); |
| 2115 | } |
| 2116 | } |
| 2117 | |
| 2118 | void Context::detachRenderbuffer(GLuint renderbuffer) |
| 2119 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2120 | mGLState.detachRenderbuffer(renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2121 | } |
| 2122 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2123 | void Context::detachVertexArray(GLuint vertexArray) |
| 2124 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 2125 | // Vertex array detachment is handled by Context, because 0 is a valid |
| 2126 | // VAO, and a pointer to it must be passed from Context to State at |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2127 | // binding time. |
| 2128 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2129 | // [OpenGL ES 3.0.2] section 2.10 page 43: |
| 2130 | // If a vertex array object that is currently bound is deleted, the binding |
| 2131 | // for that object reverts to zero and the default vertex array becomes current. |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2132 | if (mGLState.removeVertexArrayBinding(vertexArray)) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2133 | { |
| 2134 | bindVertexArray(0); |
| 2135 | } |
| 2136 | } |
| 2137 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2138 | void Context::detachTransformFeedback(GLuint transformFeedback) |
| 2139 | { |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2140 | // Transform feedback detachment is handled by Context, because 0 is a valid |
| 2141 | // transform feedback, and a pointer to it must be passed from Context to State at |
| 2142 | // binding time. |
| 2143 | |
| 2144 | // The OpenGL specification doesn't mention what should happen when the currently bound |
| 2145 | // transform feedback object is deleted. Since it is a container object, we treat it like |
| 2146 | // VAOs and FBOs and set the current bound transform feedback back to 0. |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2147 | if (mGLState.removeTransformFeedbackBinding(transformFeedback)) |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2148 | { |
| 2149 | bindTransformFeedback(0); |
| 2150 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2151 | } |
| 2152 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2153 | void Context::detachSampler(GLuint sampler) |
| 2154 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2155 | mGLState.detachSampler(sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2156 | } |
| 2157 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2158 | void Context::setVertexAttribDivisor(GLuint index, GLuint divisor) |
| 2159 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2160 | mGLState.setVertexAttribDivisor(index, divisor); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2161 | } |
| 2162 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2163 | void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 2164 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 2165 | mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2166 | |
| 2167 | Sampler *samplerObject = getSampler(sampler); |
| 2168 | ASSERT(samplerObject); |
| 2169 | |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2170 | // clang-format off |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2171 | switch (pname) |
| 2172 | { |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2173 | case GL_TEXTURE_MIN_FILTER: samplerObject->setMinFilter(static_cast<GLenum>(param)); break; |
| 2174 | case GL_TEXTURE_MAG_FILTER: samplerObject->setMagFilter(static_cast<GLenum>(param)); break; |
| 2175 | case GL_TEXTURE_WRAP_S: samplerObject->setWrapS(static_cast<GLenum>(param)); break; |
| 2176 | case GL_TEXTURE_WRAP_T: samplerObject->setWrapT(static_cast<GLenum>(param)); break; |
| 2177 | case GL_TEXTURE_WRAP_R: samplerObject->setWrapR(static_cast<GLenum>(param)); break; |
| 2178 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: samplerObject->setMaxAnisotropy(std::min(static_cast<GLfloat>(param), getExtensions().maxTextureAnisotropy)); break; |
| 2179 | case GL_TEXTURE_MIN_LOD: samplerObject->setMinLod(static_cast<GLfloat>(param)); break; |
| 2180 | case GL_TEXTURE_MAX_LOD: samplerObject->setMaxLod(static_cast<GLfloat>(param)); break; |
| 2181 | case GL_TEXTURE_COMPARE_MODE: samplerObject->setCompareMode(static_cast<GLenum>(param)); break; |
| 2182 | case GL_TEXTURE_COMPARE_FUNC: samplerObject->setCompareFunc(static_cast<GLenum>(param)); break; |
| 2183 | default: UNREACHABLE(); break; |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2184 | } |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2185 | // clang-format on |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2186 | } |
| 2187 | |
| 2188 | void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 2189 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 2190 | mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2191 | |
| 2192 | Sampler *samplerObject = getSampler(sampler); |
| 2193 | ASSERT(samplerObject); |
| 2194 | |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2195 | // clang-format off |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2196 | switch (pname) |
| 2197 | { |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2198 | case GL_TEXTURE_MIN_FILTER: samplerObject->setMinFilter(uiround<GLenum>(param)); break; |
| 2199 | case GL_TEXTURE_MAG_FILTER: samplerObject->setMagFilter(uiround<GLenum>(param)); break; |
| 2200 | case GL_TEXTURE_WRAP_S: samplerObject->setWrapS(uiround<GLenum>(param)); break; |
| 2201 | case GL_TEXTURE_WRAP_T: samplerObject->setWrapT(uiround<GLenum>(param)); break; |
| 2202 | case GL_TEXTURE_WRAP_R: samplerObject->setWrapR(uiround<GLenum>(param)); break; |
| 2203 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: samplerObject->setMaxAnisotropy(std::min(param, getExtensions().maxTextureAnisotropy)); break; |
| 2204 | case GL_TEXTURE_MIN_LOD: samplerObject->setMinLod(param); break; |
| 2205 | case GL_TEXTURE_MAX_LOD: samplerObject->setMaxLod(param); break; |
| 2206 | case GL_TEXTURE_COMPARE_MODE: samplerObject->setCompareMode(uiround<GLenum>(param)); break; |
| 2207 | case GL_TEXTURE_COMPARE_FUNC: samplerObject->setCompareFunc(uiround<GLenum>(param)); break; |
| 2208 | default: UNREACHABLE(); break; |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2209 | } |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2210 | // clang-format on |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2211 | } |
| 2212 | |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2213 | GLint Context::getSamplerParameteri(GLuint sampler, GLenum pname) |
| 2214 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 2215 | mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2216 | |
| 2217 | Sampler *samplerObject = getSampler(sampler); |
| 2218 | ASSERT(samplerObject); |
| 2219 | |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2220 | // clang-format off |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2221 | switch (pname) |
| 2222 | { |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2223 | case GL_TEXTURE_MIN_FILTER: return static_cast<GLint>(samplerObject->getMinFilter()); |
| 2224 | case GL_TEXTURE_MAG_FILTER: return static_cast<GLint>(samplerObject->getMagFilter()); |
| 2225 | case GL_TEXTURE_WRAP_S: return static_cast<GLint>(samplerObject->getWrapS()); |
| 2226 | case GL_TEXTURE_WRAP_T: return static_cast<GLint>(samplerObject->getWrapT()); |
| 2227 | case GL_TEXTURE_WRAP_R: return static_cast<GLint>(samplerObject->getWrapR()); |
| 2228 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: return static_cast<GLint>(samplerObject->getMaxAnisotropy()); |
Olli Etuaho | 6ad0723 | 2016-03-03 17:15:49 +0200 | [diff] [blame] | 2229 | case GL_TEXTURE_MIN_LOD: return iround<GLint>(samplerObject->getMinLod()); |
| 2230 | case GL_TEXTURE_MAX_LOD: return iround<GLint>(samplerObject->getMaxLod()); |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2231 | case GL_TEXTURE_COMPARE_MODE: return static_cast<GLint>(samplerObject->getCompareMode()); |
| 2232 | case GL_TEXTURE_COMPARE_FUNC: return static_cast<GLint>(samplerObject->getCompareFunc()); |
| 2233 | default: UNREACHABLE(); return 0; |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2234 | } |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2235 | // clang-format on |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2236 | } |
| 2237 | |
| 2238 | GLfloat Context::getSamplerParameterf(GLuint sampler, GLenum pname) |
| 2239 | { |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 2240 | mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2241 | |
| 2242 | Sampler *samplerObject = getSampler(sampler); |
| 2243 | ASSERT(samplerObject); |
| 2244 | |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2245 | // clang-format off |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2246 | switch (pname) |
| 2247 | { |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2248 | case GL_TEXTURE_MIN_FILTER: return static_cast<GLfloat>(samplerObject->getMinFilter()); |
| 2249 | case GL_TEXTURE_MAG_FILTER: return static_cast<GLfloat>(samplerObject->getMagFilter()); |
| 2250 | case GL_TEXTURE_WRAP_S: return static_cast<GLfloat>(samplerObject->getWrapS()); |
| 2251 | case GL_TEXTURE_WRAP_T: return static_cast<GLfloat>(samplerObject->getWrapT()); |
| 2252 | case GL_TEXTURE_WRAP_R: return static_cast<GLfloat>(samplerObject->getWrapR()); |
| 2253 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: return samplerObject->getMaxAnisotropy(); |
| 2254 | case GL_TEXTURE_MIN_LOD: return samplerObject->getMinLod(); |
| 2255 | case GL_TEXTURE_MAX_LOD: return samplerObject->getMaxLod(); |
| 2256 | case GL_TEXTURE_COMPARE_MODE: return static_cast<GLfloat>(samplerObject->getCompareMode()); |
| 2257 | case GL_TEXTURE_COMPARE_FUNC: return static_cast<GLfloat>(samplerObject->getCompareFunc()); |
| 2258 | default: UNREACHABLE(); return 0; |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2259 | } |
Geoff Lang | 69cce58 | 2015-09-17 13:20:36 -0400 | [diff] [blame] | 2260 | // clang-format on |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2261 | } |
| 2262 | |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2263 | void Context::programParameteri(GLuint program, GLenum pname, GLint value) |
| 2264 | { |
| 2265 | gl::Program *programObject = getProgram(program); |
| 2266 | ASSERT(programObject != nullptr); |
| 2267 | |
| 2268 | ASSERT(pname == GL_PROGRAM_BINARY_RETRIEVABLE_HINT); |
| 2269 | programObject->setBinaryRetrievableHint(value != GL_FALSE); |
| 2270 | } |
| 2271 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2272 | void Context::initRendererString() |
| 2273 | { |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2274 | std::ostringstream rendererString; |
| 2275 | rendererString << "ANGLE ("; |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2276 | rendererString << mImplementation->getRendererDescription(); |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2277 | rendererString << ")"; |
| 2278 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2279 | mRendererString = MakeStaticString(rendererString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2280 | } |
| 2281 | |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 2282 | const std::string &Context::getRendererString() const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2283 | { |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2284 | return mRendererString; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2285 | } |
| 2286 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2287 | void Context::initExtensionStrings() |
| 2288 | { |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2289 | mExtensionStrings = mExtensions.getStrings(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2290 | |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 2291 | std::ostringstream combinedStringStream; |
| 2292 | std::copy(mExtensionStrings.begin(), mExtensionStrings.end(), std::ostream_iterator<std::string>(combinedStringStream, " ")); |
| 2293 | mExtensionString = combinedStringStream.str(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2294 | } |
| 2295 | |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 2296 | const std::string &Context::getExtensionString() const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2297 | { |
| 2298 | return mExtensionString; |
| 2299 | } |
| 2300 | |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 2301 | const std::string &Context::getExtensionString(size_t idx) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2302 | { |
| 2303 | return mExtensionStrings[idx]; |
| 2304 | } |
| 2305 | |
| 2306 | size_t Context::getExtensionStringCount() const |
| 2307 | { |
| 2308 | return mExtensionStrings.size(); |
| 2309 | } |
| 2310 | |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2311 | void Context::beginTransformFeedback(GLenum primitiveMode) |
| 2312 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2313 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2314 | ASSERT(transformFeedback != nullptr); |
| 2315 | ASSERT(!transformFeedback->isPaused()); |
| 2316 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2317 | transformFeedback->begin(primitiveMode, mGLState.getProgram()); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2318 | } |
| 2319 | |
| 2320 | bool Context::hasActiveTransformFeedback(GLuint program) const |
| 2321 | { |
| 2322 | for (auto pair : mTransformFeedbackMap) |
| 2323 | { |
| 2324 | if (pair.second != nullptr && pair.second->hasBoundProgram(program)) |
| 2325 | { |
| 2326 | return true; |
| 2327 | } |
| 2328 | } |
| 2329 | return false; |
| 2330 | } |
| 2331 | |
Jamie Madill | 00ed7a1 | 2016-05-19 13:13:38 -0400 | [diff] [blame] | 2332 | void Context::initCaps() |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2333 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2334 | mCaps = mImplementation->getNativeCaps(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2335 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2336 | mExtensions = mImplementation->getNativeExtensions(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2337 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2338 | mLimitations = mImplementation->getNativeLimitations(); |
Austin Kinross | 02df796 | 2015-07-01 10:03:42 -0700 | [diff] [blame] | 2339 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2340 | if (mClientMajorVersion < 3) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2341 | { |
| 2342 | // Disable ES3+ extensions |
| 2343 | mExtensions.colorBufferFloat = false; |
Geoff Lang | b66a909 | 2016-05-16 15:59:14 -0400 | [diff] [blame] | 2344 | mExtensions.eglImageExternalEssl3 = false; |
Vincent Lang | 25ab451 | 2016-05-13 18:13:59 +0200 | [diff] [blame] | 2345 | mExtensions.textureNorm16 = false; |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2346 | } |
| 2347 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2348 | if (mClientMajorVersion > 2) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2349 | { |
| 2350 | // FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts |
| 2351 | //mExtensions.sRGB = false; |
| 2352 | } |
| 2353 | |
Jamie Madill | 00ed7a1 | 2016-05-19 13:13:38 -0400 | [diff] [blame] | 2354 | // Some extensions are always available because they are implemented in the GL layer. |
| 2355 | mExtensions.bindUniformLocation = true; |
| 2356 | mExtensions.vertexArrayObject = true; |
| 2357 | |
| 2358 | // Enable the no error extension if the context was created with the flag. |
| 2359 | mExtensions.noError = mSkipValidation; |
| 2360 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2361 | // Explicitly enable GL_KHR_debug |
| 2362 | mExtensions.debug = true; |
| 2363 | mExtensions.maxDebugMessageLength = 1024; |
| 2364 | mExtensions.maxDebugLoggedMessages = 1024; |
| 2365 | mExtensions.maxDebugGroupStackDepth = 1024; |
| 2366 | mExtensions.maxLabelLength = 1024; |
| 2367 | |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 2368 | // Apply implementation limits |
| 2369 | mCaps.maxVertexAttributes = std::min<GLuint>(mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS); |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 2370 | mCaps.maxVertexUniformBlocks = std::min<GLuint>(mCaps.maxVertexUniformBlocks, IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS); |
| 2371 | mCaps.maxVertexOutputComponents = std::min<GLuint>(mCaps.maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
| 2372 | |
| 2373 | mCaps.maxFragmentInputComponents = std::min<GLuint>(mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 2374 | |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 2375 | mCaps.compressedTextureFormats.clear(); |
| 2376 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2377 | const TextureCapsMap &rendererFormats = mImplementation->getNativeTextureCaps(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2378 | for (TextureCapsMap::const_iterator i = rendererFormats.begin(); i != rendererFormats.end(); i++) |
| 2379 | { |
| 2380 | GLenum format = i->first; |
| 2381 | TextureCaps formatCaps = i->second; |
| 2382 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 2383 | const InternalFormat &formatInfo = GetInternalFormatInfo(format); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 2384 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 2385 | // Update the format caps based on the client version and extensions. |
| 2386 | // Caps are AND'd with the renderer caps because some core formats are still unsupported in |
| 2387 | // ES3. |
| 2388 | formatCaps.texturable = |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2389 | formatCaps.texturable && formatInfo.textureSupport(mClientMajorVersion, mExtensions); |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 2390 | formatCaps.renderable = |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2391 | formatCaps.renderable && formatInfo.renderSupport(mClientMajorVersion, mExtensions); |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 2392 | formatCaps.filterable = |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 2393 | formatCaps.filterable && formatInfo.filterSupport(mClientMajorVersion, mExtensions); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 2394 | |
| 2395 | // OpenGL ES does not support multisampling with integer formats |
| 2396 | if (!formatInfo.renderSupport || formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2397 | { |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 2398 | formatCaps.sampleCounts.clear(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2399 | } |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 2400 | |
| 2401 | if (formatCaps.texturable && formatInfo.compressed) |
| 2402 | { |
| 2403 | mCaps.compressedTextureFormats.push_back(format); |
| 2404 | } |
| 2405 | |
| 2406 | mTextureCaps.insert(format, formatCaps); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2407 | } |
| 2408 | } |
| 2409 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 2410 | void Context::syncRendererState() |
| 2411 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2412 | const State::DirtyBits &dirtyBits = mGLState.getDirtyBits(); |
| 2413 | mImplementation->syncState(mGLState, dirtyBits); |
| 2414 | mGLState.clearDirtyBits(); |
| 2415 | mGLState.syncDirtyObjects(); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 2416 | } |
| 2417 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2418 | void Context::syncRendererState(const State::DirtyBits &bitMask, |
| 2419 | const State::DirtyObjects &objectMask) |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 2420 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2421 | const State::DirtyBits &dirtyBits = (mGLState.getDirtyBits() & bitMask); |
| 2422 | mImplementation->syncState(mGLState, dirtyBits); |
| 2423 | mGLState.clearDirtyBits(dirtyBits); |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 2424 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2425 | mGLState.syncDirtyObjects(objectMask); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 2426 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2427 | |
| 2428 | void Context::blitFramebuffer(GLint srcX0, |
| 2429 | GLint srcY0, |
| 2430 | GLint srcX1, |
| 2431 | GLint srcY1, |
| 2432 | GLint dstX0, |
| 2433 | GLint dstY0, |
| 2434 | GLint dstX1, |
| 2435 | GLint dstY1, |
| 2436 | GLbitfield mask, |
| 2437 | GLenum filter) |
| 2438 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2439 | Framebuffer *drawFramebuffer = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2440 | ASSERT(drawFramebuffer); |
| 2441 | |
| 2442 | Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0); |
| 2443 | Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0); |
| 2444 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2445 | syncStateForBlit(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2446 | |
Jamie Madill | 8415b5f | 2016-04-26 13:41:39 -0400 | [diff] [blame] | 2447 | handleError(drawFramebuffer->blit(mImplementation.get(), srcArea, dstArea, mask, filter)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2448 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2449 | |
| 2450 | void Context::clear(GLbitfield mask) |
| 2451 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2452 | syncStateForClear(); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2453 | handleError(mGLState.getDrawFramebuffer()->clear(mImplementation.get(), mask)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2454 | } |
| 2455 | |
| 2456 | void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values) |
| 2457 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2458 | syncStateForClear(); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2459 | handleError(mGLState.getDrawFramebuffer()->clearBufferfv(mImplementation.get(), buffer, |
| 2460 | drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2461 | } |
| 2462 | |
| 2463 | void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values) |
| 2464 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2465 | syncStateForClear(); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2466 | handleError(mGLState.getDrawFramebuffer()->clearBufferuiv(mImplementation.get(), buffer, |
| 2467 | drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2468 | } |
| 2469 | |
| 2470 | void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values) |
| 2471 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2472 | syncStateForClear(); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2473 | handleError(mGLState.getDrawFramebuffer()->clearBufferiv(mImplementation.get(), buffer, |
| 2474 | drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2475 | } |
| 2476 | |
| 2477 | void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 2478 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2479 | Framebuffer *framebufferObject = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2480 | ASSERT(framebufferObject); |
| 2481 | |
| 2482 | // If a buffer is not present, the clear has no effect |
| 2483 | if (framebufferObject->getDepthbuffer() == nullptr && |
| 2484 | framebufferObject->getStencilbuffer() == nullptr) |
| 2485 | { |
| 2486 | return; |
| 2487 | } |
| 2488 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2489 | syncStateForClear(); |
Jamie Madill | 8415b5f | 2016-04-26 13:41:39 -0400 | [diff] [blame] | 2490 | handleError(framebufferObject->clearBufferfi(mImplementation.get(), buffer, drawbuffer, depth, |
| 2491 | stencil)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2492 | } |
| 2493 | |
| 2494 | void Context::readPixels(GLint x, |
| 2495 | GLint y, |
| 2496 | GLsizei width, |
| 2497 | GLsizei height, |
| 2498 | GLenum format, |
| 2499 | GLenum type, |
| 2500 | GLvoid *pixels) |
| 2501 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2502 | syncStateForReadPixels(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2503 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2504 | Framebuffer *framebufferObject = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2505 | ASSERT(framebufferObject); |
| 2506 | |
| 2507 | Rectangle area(x, y, width, height); |
Jamie Madill | 8415b5f | 2016-04-26 13:41:39 -0400 | [diff] [blame] | 2508 | handleError(framebufferObject->readPixels(mImplementation.get(), area, format, type, pixels)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2509 | } |
| 2510 | |
| 2511 | void Context::copyTexImage2D(GLenum target, |
| 2512 | GLint level, |
| 2513 | GLenum internalformat, |
| 2514 | GLint x, |
| 2515 | GLint y, |
| 2516 | GLsizei width, |
| 2517 | GLsizei height, |
| 2518 | GLint border) |
| 2519 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2520 | // Only sync the read FBO |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2521 | mGLState.syncDirtyObject(GL_READ_FRAMEBUFFER); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2522 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2523 | Rectangle sourceArea(x, y, width, height); |
| 2524 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2525 | const Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2526 | Texture *texture = |
| 2527 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2528 | handleError(texture->copyImage(target, level, sourceArea, internalformat, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2529 | } |
| 2530 | |
| 2531 | void Context::copyTexSubImage2D(GLenum target, |
| 2532 | GLint level, |
| 2533 | GLint xoffset, |
| 2534 | GLint yoffset, |
| 2535 | GLint x, |
| 2536 | GLint y, |
| 2537 | GLsizei width, |
| 2538 | GLsizei height) |
| 2539 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2540 | // Only sync the read FBO |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2541 | mGLState.syncDirtyObject(GL_READ_FRAMEBUFFER); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2542 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2543 | Offset destOffset(xoffset, yoffset, 0); |
| 2544 | Rectangle sourceArea(x, y, width, height); |
| 2545 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2546 | const Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2547 | Texture *texture = |
| 2548 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2549 | handleError(texture->copySubImage(target, level, destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2550 | } |
| 2551 | |
| 2552 | void Context::copyTexSubImage3D(GLenum target, |
| 2553 | GLint level, |
| 2554 | GLint xoffset, |
| 2555 | GLint yoffset, |
| 2556 | GLint zoffset, |
| 2557 | GLint x, |
| 2558 | GLint y, |
| 2559 | GLsizei width, |
| 2560 | GLsizei height) |
| 2561 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2562 | // Only sync the read FBO |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2563 | mGLState.syncDirtyObject(GL_READ_FRAMEBUFFER); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2564 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2565 | Offset destOffset(xoffset, yoffset, zoffset); |
| 2566 | Rectangle sourceArea(x, y, width, height); |
| 2567 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2568 | const Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2569 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2570 | handleError(texture->copySubImage(target, level, destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2571 | } |
| 2572 | |
| 2573 | void Context::framebufferTexture2D(GLenum target, |
| 2574 | GLenum attachment, |
| 2575 | GLenum textarget, |
| 2576 | GLuint texture, |
| 2577 | GLint level) |
| 2578 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2579 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2580 | ASSERT(framebuffer); |
| 2581 | |
| 2582 | if (texture != 0) |
| 2583 | { |
| 2584 | Texture *textureObj = getTexture(texture); |
| 2585 | |
| 2586 | ImageIndex index = ImageIndex::MakeInvalid(); |
| 2587 | |
| 2588 | if (textarget == GL_TEXTURE_2D) |
| 2589 | { |
| 2590 | index = ImageIndex::Make2D(level); |
| 2591 | } |
| 2592 | else |
| 2593 | { |
| 2594 | ASSERT(IsCubeMapTextureTarget(textarget)); |
| 2595 | index = ImageIndex::MakeCube(textarget, level); |
| 2596 | } |
| 2597 | |
| 2598 | framebuffer->setAttachment(GL_TEXTURE, attachment, index, textureObj); |
| 2599 | } |
| 2600 | else |
| 2601 | { |
| 2602 | framebuffer->resetAttachment(attachment); |
| 2603 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2604 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2605 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2606 | } |
| 2607 | |
| 2608 | void Context::framebufferRenderbuffer(GLenum target, |
| 2609 | GLenum attachment, |
| 2610 | GLenum renderbuffertarget, |
| 2611 | GLuint renderbuffer) |
| 2612 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2613 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2614 | ASSERT(framebuffer); |
| 2615 | |
| 2616 | if (renderbuffer != 0) |
| 2617 | { |
| 2618 | Renderbuffer *renderbufferObject = getRenderbuffer(renderbuffer); |
| 2619 | framebuffer->setAttachment(GL_RENDERBUFFER, attachment, gl::ImageIndex::MakeInvalid(), |
| 2620 | renderbufferObject); |
| 2621 | } |
| 2622 | else |
| 2623 | { |
| 2624 | framebuffer->resetAttachment(attachment); |
| 2625 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2626 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2627 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2628 | } |
| 2629 | |
| 2630 | void Context::framebufferTextureLayer(GLenum target, |
| 2631 | GLenum attachment, |
| 2632 | GLuint texture, |
| 2633 | GLint level, |
| 2634 | GLint layer) |
| 2635 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2636 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2637 | ASSERT(framebuffer); |
| 2638 | |
| 2639 | if (texture != 0) |
| 2640 | { |
| 2641 | Texture *textureObject = getTexture(texture); |
| 2642 | |
| 2643 | ImageIndex index = ImageIndex::MakeInvalid(); |
| 2644 | |
| 2645 | if (textureObject->getTarget() == GL_TEXTURE_3D) |
| 2646 | { |
| 2647 | index = ImageIndex::Make3D(level, layer); |
| 2648 | } |
| 2649 | else |
| 2650 | { |
| 2651 | ASSERT(textureObject->getTarget() == GL_TEXTURE_2D_ARRAY); |
| 2652 | index = ImageIndex::Make2DArray(level, layer); |
| 2653 | } |
| 2654 | |
| 2655 | framebuffer->setAttachment(GL_TEXTURE, attachment, index, textureObject); |
| 2656 | } |
| 2657 | else |
| 2658 | { |
| 2659 | framebuffer->resetAttachment(attachment); |
| 2660 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2661 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2662 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2663 | } |
| 2664 | |
| 2665 | void Context::drawBuffers(GLsizei n, const GLenum *bufs) |
| 2666 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2667 | Framebuffer *framebuffer = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2668 | ASSERT(framebuffer); |
| 2669 | framebuffer->setDrawBuffers(n, bufs); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2670 | mGLState.setObjectDirty(GL_DRAW_FRAMEBUFFER); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2671 | } |
| 2672 | |
| 2673 | void Context::readBuffer(GLenum mode) |
| 2674 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2675 | Framebuffer *readFBO = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2676 | readFBO->setReadBuffer(mode); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2677 | mGLState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2678 | } |
| 2679 | |
| 2680 | void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) |
| 2681 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2682 | // Only sync the FBO |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2683 | mGLState.syncDirtyObject(target); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2684 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2685 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2686 | ASSERT(framebuffer); |
| 2687 | |
| 2688 | // The specification isn't clear what should be done when the framebuffer isn't complete. |
| 2689 | // We leave it up to the framebuffer implementation to decide what to do. |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2690 | handleError(framebuffer->discard(numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2691 | } |
| 2692 | |
| 2693 | void Context::invalidateFramebuffer(GLenum target, |
| 2694 | GLsizei numAttachments, |
| 2695 | const GLenum *attachments) |
| 2696 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2697 | // Only sync the FBO |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2698 | mGLState.syncDirtyObject(target); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2699 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2700 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2701 | ASSERT(framebuffer); |
| 2702 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2703 | if (framebuffer->checkStatus(mState) != GL_FRAMEBUFFER_COMPLETE) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2704 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2705 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2706 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2707 | |
| 2708 | handleError(framebuffer->invalidate(numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2709 | } |
| 2710 | |
| 2711 | void Context::invalidateSubFramebuffer(GLenum target, |
| 2712 | GLsizei numAttachments, |
| 2713 | const GLenum *attachments, |
| 2714 | GLint x, |
| 2715 | GLint y, |
| 2716 | GLsizei width, |
| 2717 | GLsizei height) |
| 2718 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2719 | // Only sync the FBO |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2720 | mGLState.syncDirtyObject(target); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2721 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2722 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2723 | ASSERT(framebuffer); |
| 2724 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2725 | if (framebuffer->checkStatus(mState) != GL_FRAMEBUFFER_COMPLETE) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2726 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2727 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2728 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2729 | |
| 2730 | Rectangle area(x, y, width, height); |
| 2731 | handleError(framebuffer->invalidateSub(numAttachments, attachments, area)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2732 | } |
| 2733 | |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2734 | void Context::texImage2D(GLenum target, |
| 2735 | GLint level, |
| 2736 | GLint internalformat, |
| 2737 | GLsizei width, |
| 2738 | GLsizei height, |
| 2739 | GLint border, |
| 2740 | GLenum format, |
| 2741 | GLenum type, |
| 2742 | const GLvoid *pixels) |
| 2743 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2744 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2745 | |
| 2746 | Extents size(width, height, 1); |
| 2747 | Texture *texture = |
| 2748 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2749 | handleError(texture->setImage(mGLState.getUnpackState(), target, level, internalformat, size, |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2750 | format, type, reinterpret_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2751 | } |
| 2752 | |
| 2753 | void Context::texImage3D(GLenum target, |
| 2754 | GLint level, |
| 2755 | GLint internalformat, |
| 2756 | GLsizei width, |
| 2757 | GLsizei height, |
| 2758 | GLsizei depth, |
| 2759 | GLint border, |
| 2760 | GLenum format, |
| 2761 | GLenum type, |
| 2762 | const GLvoid *pixels) |
| 2763 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2764 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2765 | |
| 2766 | Extents size(width, height, depth); |
| 2767 | Texture *texture = getTargetTexture(target); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2768 | handleError(texture->setImage(mGLState.getUnpackState(), target, level, internalformat, size, |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2769 | format, type, reinterpret_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2770 | } |
| 2771 | |
| 2772 | void Context::texSubImage2D(GLenum target, |
| 2773 | GLint level, |
| 2774 | GLint xoffset, |
| 2775 | GLint yoffset, |
| 2776 | GLsizei width, |
| 2777 | GLsizei height, |
| 2778 | GLenum format, |
| 2779 | GLenum type, |
| 2780 | const GLvoid *pixels) |
| 2781 | { |
| 2782 | // Zero sized uploads are valid but no-ops |
| 2783 | if (width == 0 || height == 0) |
| 2784 | { |
| 2785 | return; |
| 2786 | } |
| 2787 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2788 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2789 | |
| 2790 | Box area(xoffset, yoffset, 0, width, height, 1); |
| 2791 | Texture *texture = |
| 2792 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2793 | handleError(texture->setSubImage(mGLState.getUnpackState(), target, level, area, format, type, |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2794 | reinterpret_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2795 | } |
| 2796 | |
| 2797 | void Context::texSubImage3D(GLenum target, |
| 2798 | GLint level, |
| 2799 | GLint xoffset, |
| 2800 | GLint yoffset, |
| 2801 | GLint zoffset, |
| 2802 | GLsizei width, |
| 2803 | GLsizei height, |
| 2804 | GLsizei depth, |
| 2805 | GLenum format, |
| 2806 | GLenum type, |
| 2807 | const GLvoid *pixels) |
| 2808 | { |
| 2809 | // Zero sized uploads are valid but no-ops |
| 2810 | if (width == 0 || height == 0 || depth == 0) |
| 2811 | { |
| 2812 | return; |
| 2813 | } |
| 2814 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2815 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2816 | |
| 2817 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 2818 | Texture *texture = getTargetTexture(target); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2819 | handleError(texture->setSubImage(mGLState.getUnpackState(), target, level, area, format, type, |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2820 | reinterpret_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2821 | } |
| 2822 | |
| 2823 | void Context::compressedTexImage2D(GLenum target, |
| 2824 | GLint level, |
| 2825 | GLenum internalformat, |
| 2826 | GLsizei width, |
| 2827 | GLsizei height, |
| 2828 | GLint border, |
| 2829 | GLsizei imageSize, |
| 2830 | const GLvoid *data) |
| 2831 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2832 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2833 | |
| 2834 | Extents size(width, height, 1); |
| 2835 | Texture *texture = |
| 2836 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2837 | handleError(texture->setCompressedImage(mGLState.getUnpackState(), target, level, |
| 2838 | internalformat, size, imageSize, |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2839 | reinterpret_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2840 | } |
| 2841 | |
| 2842 | void Context::compressedTexImage3D(GLenum target, |
| 2843 | GLint level, |
| 2844 | GLenum internalformat, |
| 2845 | GLsizei width, |
| 2846 | GLsizei height, |
| 2847 | GLsizei depth, |
| 2848 | GLint border, |
| 2849 | GLsizei imageSize, |
| 2850 | const GLvoid *data) |
| 2851 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2852 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2853 | |
| 2854 | Extents size(width, height, depth); |
| 2855 | Texture *texture = getTargetTexture(target); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2856 | handleError(texture->setCompressedImage(mGLState.getUnpackState(), target, level, |
| 2857 | internalformat, size, imageSize, |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2858 | reinterpret_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2859 | } |
| 2860 | |
| 2861 | void Context::compressedTexSubImage2D(GLenum target, |
| 2862 | GLint level, |
| 2863 | GLint xoffset, |
| 2864 | GLint yoffset, |
| 2865 | GLsizei width, |
| 2866 | GLsizei height, |
| 2867 | GLenum format, |
| 2868 | GLsizei imageSize, |
| 2869 | const GLvoid *data) |
| 2870 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2871 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2872 | |
| 2873 | Box area(xoffset, yoffset, 0, width, height, 1); |
| 2874 | Texture *texture = |
| 2875 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2876 | handleError(texture->setCompressedSubImage(mGLState.getUnpackState(), target, level, area, |
| 2877 | format, imageSize, |
| 2878 | reinterpret_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2879 | } |
| 2880 | |
| 2881 | void Context::compressedTexSubImage3D(GLenum target, |
| 2882 | GLint level, |
| 2883 | GLint xoffset, |
| 2884 | GLint yoffset, |
| 2885 | GLint zoffset, |
| 2886 | GLsizei width, |
| 2887 | GLsizei height, |
| 2888 | GLsizei depth, |
| 2889 | GLenum format, |
| 2890 | GLsizei imageSize, |
| 2891 | const GLvoid *data) |
| 2892 | { |
| 2893 | // Zero sized uploads are valid but no-ops |
| 2894 | if (width == 0 || height == 0) |
| 2895 | { |
| 2896 | return; |
| 2897 | } |
| 2898 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2899 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2900 | |
| 2901 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 2902 | Texture *texture = getTargetTexture(target); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2903 | handleError(texture->setCompressedSubImage(mGLState.getUnpackState(), target, level, area, |
| 2904 | format, imageSize, |
| 2905 | reinterpret_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 2906 | } |
| 2907 | |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 2908 | void Context::generateMipmap(GLenum target) |
| 2909 | { |
| 2910 | Texture *texture = getTargetTexture(target); |
| 2911 | handleError(texture->generateMipmap()); |
| 2912 | } |
| 2913 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 2914 | void Context::copyTextureCHROMIUM(GLuint sourceId, |
| 2915 | GLuint destId, |
| 2916 | GLint internalFormat, |
| 2917 | GLenum destType, |
| 2918 | GLboolean unpackFlipY, |
| 2919 | GLboolean unpackPremultiplyAlpha, |
| 2920 | GLboolean unpackUnmultiplyAlpha) |
| 2921 | { |
| 2922 | syncStateForTexImage(); |
| 2923 | |
| 2924 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 2925 | gl::Texture *destTexture = getTexture(destId); |
| 2926 | handleError(destTexture->copyTexture(internalFormat, destType, unpackFlipY == GL_TRUE, |
| 2927 | unpackPremultiplyAlpha == GL_TRUE, |
| 2928 | unpackUnmultiplyAlpha == GL_TRUE, sourceTexture)); |
| 2929 | } |
| 2930 | |
| 2931 | void Context::copySubTextureCHROMIUM(GLuint sourceId, |
| 2932 | GLuint destId, |
| 2933 | GLint xoffset, |
| 2934 | GLint yoffset, |
| 2935 | GLint x, |
| 2936 | GLint y, |
| 2937 | GLsizei width, |
| 2938 | GLsizei height, |
| 2939 | GLboolean unpackFlipY, |
| 2940 | GLboolean unpackPremultiplyAlpha, |
| 2941 | GLboolean unpackUnmultiplyAlpha) |
| 2942 | { |
| 2943 | // Zero sized copies are valid but no-ops |
| 2944 | if (width == 0 || height == 0) |
| 2945 | { |
| 2946 | return; |
| 2947 | } |
| 2948 | |
| 2949 | syncStateForTexImage(); |
| 2950 | |
| 2951 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 2952 | gl::Texture *destTexture = getTexture(destId); |
| 2953 | Offset offset(xoffset, yoffset, 0); |
| 2954 | Rectangle area(x, y, width, height); |
| 2955 | handleError(destTexture->copySubTexture(offset, area, unpackFlipY == GL_TRUE, |
| 2956 | unpackPremultiplyAlpha == GL_TRUE, |
| 2957 | unpackUnmultiplyAlpha == GL_TRUE, sourceTexture)); |
| 2958 | } |
| 2959 | |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2960 | void Context::getBufferPointerv(GLenum target, GLenum /*pname*/, void **params) |
| 2961 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2962 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2963 | ASSERT(buffer); |
| 2964 | |
| 2965 | if (!buffer->isMapped()) |
| 2966 | { |
| 2967 | *params = nullptr; |
| 2968 | } |
| 2969 | else |
| 2970 | { |
| 2971 | *params = buffer->getMapPointer(); |
| 2972 | } |
| 2973 | } |
| 2974 | |
| 2975 | GLvoid *Context::mapBuffer(GLenum target, GLenum access) |
| 2976 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2977 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2978 | ASSERT(buffer); |
| 2979 | |
| 2980 | Error error = buffer->map(access); |
| 2981 | if (error.isError()) |
| 2982 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2983 | handleError(error); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2984 | return nullptr; |
| 2985 | } |
| 2986 | |
| 2987 | return buffer->getMapPointer(); |
| 2988 | } |
| 2989 | |
| 2990 | GLboolean Context::unmapBuffer(GLenum target) |
| 2991 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2992 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 2993 | ASSERT(buffer); |
| 2994 | |
| 2995 | GLboolean result; |
| 2996 | Error error = buffer->unmap(&result); |
| 2997 | if (error.isError()) |
| 2998 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 2999 | handleError(error); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3000 | return GL_FALSE; |
| 3001 | } |
| 3002 | |
| 3003 | return result; |
| 3004 | } |
| 3005 | |
| 3006 | GLvoid *Context::mapBufferRange(GLenum target, |
| 3007 | GLintptr offset, |
| 3008 | GLsizeiptr length, |
| 3009 | GLbitfield access) |
| 3010 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3011 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3012 | ASSERT(buffer); |
| 3013 | |
| 3014 | Error error = buffer->mapRange(offset, length, access); |
| 3015 | if (error.isError()) |
| 3016 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3017 | handleError(error); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3018 | return nullptr; |
| 3019 | } |
| 3020 | |
| 3021 | return buffer->getMapPointer(); |
| 3022 | } |
| 3023 | |
| 3024 | void Context::flushMappedBufferRange(GLenum /*target*/, GLintptr /*offset*/, GLsizeiptr /*length*/) |
| 3025 | { |
| 3026 | // We do not currently support a non-trivial implementation of FlushMappedBufferRange |
| 3027 | } |
| 3028 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 3029 | void Context::syncStateForReadPixels() |
| 3030 | { |
| 3031 | syncRendererState(mReadPixelsDirtyBits, mReadPixelsDirtyObjects); |
| 3032 | } |
| 3033 | |
| 3034 | void Context::syncStateForTexImage() |
| 3035 | { |
| 3036 | syncRendererState(mTexImageDirtyBits, mTexImageDirtyObjects); |
| 3037 | } |
| 3038 | |
| 3039 | void Context::syncStateForClear() |
| 3040 | { |
| 3041 | syncRendererState(mClearDirtyBits, mClearDirtyObjects); |
| 3042 | } |
| 3043 | |
| 3044 | void Context::syncStateForBlit() |
| 3045 | { |
| 3046 | syncRendererState(mBlitDirtyBits, mBlitDirtyObjects); |
| 3047 | } |
| 3048 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3049 | void Context::activeTexture(GLenum texture) |
| 3050 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3051 | mGLState.setActiveSampler(texture - GL_TEXTURE0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3052 | } |
| 3053 | |
| 3054 | void Context::blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 3055 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3056 | mGLState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3057 | } |
| 3058 | |
| 3059 | void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 3060 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3061 | mGLState.setBlendEquation(modeRGB, modeAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3062 | } |
| 3063 | |
| 3064 | void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 3065 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3066 | mGLState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3067 | } |
| 3068 | |
| 3069 | void Context::clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 3070 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3071 | mGLState.setColorClearValue(red, green, blue, alpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3072 | } |
| 3073 | |
| 3074 | void Context::clearDepthf(GLclampf depth) |
| 3075 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3076 | mGLState.setDepthClearValue(depth); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3077 | } |
| 3078 | |
| 3079 | void Context::clearStencil(GLint s) |
| 3080 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3081 | mGLState.setStencilClearValue(s); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3082 | } |
| 3083 | |
| 3084 | void Context::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 3085 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3086 | mGLState.setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3087 | } |
| 3088 | |
| 3089 | void Context::cullFace(GLenum mode) |
| 3090 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3091 | mGLState.setCullMode(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3092 | } |
| 3093 | |
| 3094 | void Context::depthFunc(GLenum func) |
| 3095 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3096 | mGLState.setDepthFunc(func); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3097 | } |
| 3098 | |
| 3099 | void Context::depthMask(GLboolean flag) |
| 3100 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3101 | mGLState.setDepthMask(flag != GL_FALSE); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3102 | } |
| 3103 | |
| 3104 | void Context::depthRangef(GLclampf zNear, GLclampf zFar) |
| 3105 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3106 | mGLState.setDepthRange(zNear, zFar); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3107 | } |
| 3108 | |
| 3109 | void Context::disable(GLenum cap) |
| 3110 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3111 | mGLState.setEnableFeature(cap, false); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3112 | } |
| 3113 | |
| 3114 | void Context::disableVertexAttribArray(GLuint index) |
| 3115 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3116 | mGLState.setEnableVertexAttribArray(index, false); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3117 | } |
| 3118 | |
| 3119 | void Context::enable(GLenum cap) |
| 3120 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3121 | mGLState.setEnableFeature(cap, true); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3122 | } |
| 3123 | |
| 3124 | void Context::enableVertexAttribArray(GLuint index) |
| 3125 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3126 | mGLState.setEnableVertexAttribArray(index, true); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3127 | } |
| 3128 | |
| 3129 | void Context::frontFace(GLenum mode) |
| 3130 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3131 | mGLState.setFrontFace(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3132 | } |
| 3133 | |
| 3134 | void Context::hint(GLenum target, GLenum mode) |
| 3135 | { |
| 3136 | switch (target) |
| 3137 | { |
| 3138 | case GL_GENERATE_MIPMAP_HINT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3139 | mGLState.setGenerateMipmapHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3140 | break; |
| 3141 | |
| 3142 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3143 | mGLState.setFragmentShaderDerivativeHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3144 | break; |
| 3145 | |
| 3146 | default: |
| 3147 | UNREACHABLE(); |
| 3148 | return; |
| 3149 | } |
| 3150 | } |
| 3151 | |
| 3152 | void Context::lineWidth(GLfloat width) |
| 3153 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3154 | mGLState.setLineWidth(width); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3155 | } |
| 3156 | |
| 3157 | void Context::pixelStorei(GLenum pname, GLint param) |
| 3158 | { |
| 3159 | switch (pname) |
| 3160 | { |
| 3161 | case GL_UNPACK_ALIGNMENT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3162 | mGLState.setUnpackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3163 | break; |
| 3164 | |
| 3165 | case GL_PACK_ALIGNMENT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3166 | mGLState.setPackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3167 | break; |
| 3168 | |
| 3169 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3170 | mGLState.setPackReverseRowOrder(param != 0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3171 | break; |
| 3172 | |
| 3173 | case GL_UNPACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3174 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3175 | mGLState.setUnpackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3176 | break; |
| 3177 | |
| 3178 | case GL_UNPACK_IMAGE_HEIGHT: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3179 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3180 | mGLState.setUnpackImageHeight(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3181 | break; |
| 3182 | |
| 3183 | case GL_UNPACK_SKIP_IMAGES: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3184 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3185 | mGLState.setUnpackSkipImages(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3186 | break; |
| 3187 | |
| 3188 | case GL_UNPACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3189 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3190 | mGLState.setUnpackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3191 | break; |
| 3192 | |
| 3193 | case GL_UNPACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3194 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3195 | mGLState.setUnpackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3196 | break; |
| 3197 | |
| 3198 | case GL_PACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3199 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3200 | mGLState.setPackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3201 | break; |
| 3202 | |
| 3203 | case GL_PACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3204 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3205 | mGLState.setPackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3206 | break; |
| 3207 | |
| 3208 | case GL_PACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3209 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3210 | mGLState.setPackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3211 | break; |
| 3212 | |
| 3213 | default: |
| 3214 | UNREACHABLE(); |
| 3215 | return; |
| 3216 | } |
| 3217 | } |
| 3218 | |
| 3219 | void Context::polygonOffset(GLfloat factor, GLfloat units) |
| 3220 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3221 | mGLState.setPolygonOffsetParams(factor, units); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3222 | } |
| 3223 | |
| 3224 | void Context::sampleCoverage(GLclampf value, GLboolean invert) |
| 3225 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3226 | mGLState.setSampleCoverageParams(clamp01(value), invert == GL_TRUE); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3227 | } |
| 3228 | |
| 3229 | void Context::scissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 3230 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3231 | mGLState.setScissorParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3232 | } |
| 3233 | |
| 3234 | void Context::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 3235 | { |
| 3236 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 3237 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3238 | mGLState.setStencilParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3239 | } |
| 3240 | |
| 3241 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 3242 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3243 | mGLState.setStencilBackParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3244 | } |
| 3245 | } |
| 3246 | |
| 3247 | void Context::stencilMaskSeparate(GLenum face, GLuint mask) |
| 3248 | { |
| 3249 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 3250 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3251 | mGLState.setStencilWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3252 | } |
| 3253 | |
| 3254 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 3255 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3256 | mGLState.setStencilBackWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3257 | } |
| 3258 | } |
| 3259 | |
| 3260 | void Context::stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 3261 | { |
| 3262 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 3263 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3264 | mGLState.setStencilOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3265 | } |
| 3266 | |
| 3267 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 3268 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3269 | mGLState.setStencilBackOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3270 | } |
| 3271 | } |
| 3272 | |
| 3273 | void Context::vertexAttrib1f(GLuint index, GLfloat x) |
| 3274 | { |
| 3275 | GLfloat vals[4] = {x, 0, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3276 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3277 | } |
| 3278 | |
| 3279 | void Context::vertexAttrib1fv(GLuint index, const GLfloat *values) |
| 3280 | { |
| 3281 | GLfloat vals[4] = {values[0], 0, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3282 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3283 | } |
| 3284 | |
| 3285 | void Context::vertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 3286 | { |
| 3287 | GLfloat vals[4] = {x, y, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3288 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3289 | } |
| 3290 | |
| 3291 | void Context::vertexAttrib2fv(GLuint index, const GLfloat *values) |
| 3292 | { |
| 3293 | GLfloat vals[4] = {values[0], values[1], 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3294 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3295 | } |
| 3296 | |
| 3297 | void Context::vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 3298 | { |
| 3299 | GLfloat vals[4] = {x, y, z, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3300 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3301 | } |
| 3302 | |
| 3303 | void Context::vertexAttrib3fv(GLuint index, const GLfloat *values) |
| 3304 | { |
| 3305 | GLfloat vals[4] = {values[0], values[1], values[2], 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3306 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3307 | } |
| 3308 | |
| 3309 | void Context::vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 3310 | { |
| 3311 | GLfloat vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3312 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3313 | } |
| 3314 | |
| 3315 | void Context::vertexAttrib4fv(GLuint index, const GLfloat *values) |
| 3316 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3317 | mGLState.setVertexAttribf(index, values); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3318 | } |
| 3319 | |
| 3320 | void Context::vertexAttribPointer(GLuint index, |
| 3321 | GLint size, |
| 3322 | GLenum type, |
| 3323 | GLboolean normalized, |
| 3324 | GLsizei stride, |
| 3325 | const GLvoid *ptr) |
| 3326 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3327 | mGLState.setVertexAttribState(index, mGLState.getTargetBuffer(GL_ARRAY_BUFFER), size, type, |
| 3328 | normalized == GL_TRUE, false, stride, ptr); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3329 | } |
| 3330 | |
| 3331 | void Context::viewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 3332 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3333 | mGLState.setViewportParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3334 | } |
| 3335 | |
| 3336 | void Context::vertexAttribIPointer(GLuint index, |
| 3337 | GLint size, |
| 3338 | GLenum type, |
| 3339 | GLsizei stride, |
| 3340 | const GLvoid *pointer) |
| 3341 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3342 | mGLState.setVertexAttribState(index, mGLState.getTargetBuffer(GL_ARRAY_BUFFER), size, type, |
| 3343 | false, true, stride, pointer); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3344 | } |
| 3345 | |
| 3346 | void Context::vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 3347 | { |
| 3348 | GLint vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3349 | mGLState.setVertexAttribi(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3350 | } |
| 3351 | |
| 3352 | void Context::vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 3353 | { |
| 3354 | GLuint vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3355 | mGLState.setVertexAttribu(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3356 | } |
| 3357 | |
| 3358 | void Context::vertexAttribI4iv(GLuint index, const GLint *v) |
| 3359 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3360 | mGLState.setVertexAttribi(index, v); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3361 | } |
| 3362 | |
| 3363 | void Context::vertexAttribI4uiv(GLuint index, const GLuint *v) |
| 3364 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3365 | mGLState.setVertexAttribu(index, v); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3366 | } |
| 3367 | |
| 3368 | void Context::debugMessageControl(GLenum source, |
| 3369 | GLenum type, |
| 3370 | GLenum severity, |
| 3371 | GLsizei count, |
| 3372 | const GLuint *ids, |
| 3373 | GLboolean enabled) |
| 3374 | { |
| 3375 | std::vector<GLuint> idVector(ids, ids + count); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3376 | mGLState.getDebug().setMessageControl(source, type, severity, std::move(idVector), |
| 3377 | (enabled != GL_FALSE)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3378 | } |
| 3379 | |
| 3380 | void Context::debugMessageInsert(GLenum source, |
| 3381 | GLenum type, |
| 3382 | GLuint id, |
| 3383 | GLenum severity, |
| 3384 | GLsizei length, |
| 3385 | const GLchar *buf) |
| 3386 | { |
| 3387 | std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf)); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3388 | mGLState.getDebug().insertMessage(source, type, id, severity, std::move(msg)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3389 | } |
| 3390 | |
| 3391 | void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam) |
| 3392 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3393 | mGLState.getDebug().setCallback(callback, userParam); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3394 | } |
| 3395 | |
| 3396 | GLuint Context::getDebugMessageLog(GLuint count, |
| 3397 | GLsizei bufSize, |
| 3398 | GLenum *sources, |
| 3399 | GLenum *types, |
| 3400 | GLuint *ids, |
| 3401 | GLenum *severities, |
| 3402 | GLsizei *lengths, |
| 3403 | GLchar *messageLog) |
| 3404 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3405 | return static_cast<GLuint>(mGLState.getDebug().getMessages(count, bufSize, sources, types, ids, |
| 3406 | severities, lengths, messageLog)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3407 | } |
| 3408 | |
| 3409 | void Context::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) |
| 3410 | { |
| 3411 | std::string msg(message, (length > 0) ? static_cast<size_t>(length) : strlen(message)); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3412 | mGLState.getDebug().pushGroup(source, id, std::move(msg)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3413 | } |
| 3414 | |
| 3415 | void Context::popDebugGroup() |
| 3416 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3417 | mGLState.getDebug().popGroup(); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3418 | } |
| 3419 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3420 | } // namespace gl |