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 | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 12 | #include <string.h> |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 13 | #include <iterator> |
| 14 | #include <sstream> |
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 | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 20 | #include "common/version.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 21 | #include "libANGLE/Buffer.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 22 | #include "libANGLE/Compiler.h" |
Jamie Madill | 948bbe5 | 2017-06-01 13:10:42 -0400 | [diff] [blame] | 23 | #include "libANGLE/Display.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 24 | #include "libANGLE/Fence.h" |
| 25 | #include "libANGLE/Framebuffer.h" |
| 26 | #include "libANGLE/FramebufferAttachment.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 27 | #include "libANGLE/Path.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 28 | #include "libANGLE/Program.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 29 | #include "libANGLE/Query.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 30 | #include "libANGLE/Renderbuffer.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 31 | #include "libANGLE/ResourceManager.h" |
| 32 | #include "libANGLE/Sampler.h" |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 33 | #include "libANGLE/Surface.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 34 | #include "libANGLE/Texture.h" |
| 35 | #include "libANGLE/TransformFeedback.h" |
| 36 | #include "libANGLE/VertexArray.h" |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 37 | #include "libANGLE/Workarounds.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 38 | #include "libANGLE/formatutils.h" |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 39 | #include "libANGLE/queryconversions.h" |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 40 | #include "libANGLE/queryutils.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 41 | #include "libANGLE/renderer/ContextImpl.h" |
| 42 | #include "libANGLE/renderer/EGLImplFactory.h" |
| 43 | #include "libANGLE/validationES.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 44 | |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 45 | namespace |
| 46 | { |
| 47 | |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 48 | #define ANGLE_HANDLE_ERR(X) \ |
| 49 | handleError(X); \ |
| 50 | return; |
| 51 | #define ANGLE_CONTEXT_TRY(EXPR) ANGLE_TRY_TEMPLATE(EXPR, ANGLE_HANDLE_ERR); |
| 52 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 53 | template <typename T> |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 54 | std::vector<gl::Path *> GatherPaths(gl::PathManager &resourceManager, |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 55 | GLsizei numPaths, |
| 56 | const void *paths, |
| 57 | GLuint pathBase) |
| 58 | { |
| 59 | std::vector<gl::Path *> ret; |
| 60 | ret.reserve(numPaths); |
| 61 | |
| 62 | const auto *nameArray = static_cast<const T *>(paths); |
| 63 | |
| 64 | for (GLsizei i = 0; i < numPaths; ++i) |
| 65 | { |
| 66 | const GLuint pathName = nameArray[i] + pathBase; |
| 67 | |
| 68 | ret.push_back(resourceManager.getPath(pathName)); |
| 69 | } |
| 70 | |
| 71 | return ret; |
| 72 | } |
| 73 | |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 74 | std::vector<gl::Path *> GatherPaths(gl::PathManager &resourceManager, |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 75 | GLsizei numPaths, |
| 76 | GLenum pathNameType, |
| 77 | const void *paths, |
| 78 | GLuint pathBase) |
| 79 | { |
| 80 | switch (pathNameType) |
| 81 | { |
| 82 | case GL_UNSIGNED_BYTE: |
| 83 | return GatherPaths<GLubyte>(resourceManager, numPaths, paths, pathBase); |
| 84 | |
| 85 | case GL_BYTE: |
| 86 | return GatherPaths<GLbyte>(resourceManager, numPaths, paths, pathBase); |
| 87 | |
| 88 | case GL_UNSIGNED_SHORT: |
| 89 | return GatherPaths<GLushort>(resourceManager, numPaths, paths, pathBase); |
| 90 | |
| 91 | case GL_SHORT: |
| 92 | return GatherPaths<GLshort>(resourceManager, numPaths, paths, pathBase); |
| 93 | |
| 94 | case GL_UNSIGNED_INT: |
| 95 | return GatherPaths<GLuint>(resourceManager, numPaths, paths, pathBase); |
| 96 | |
| 97 | case GL_INT: |
| 98 | return GatherPaths<GLint>(resourceManager, numPaths, paths, pathBase); |
| 99 | } |
| 100 | |
| 101 | UNREACHABLE(); |
| 102 | return std::vector<gl::Path *>(); |
| 103 | } |
| 104 | |
| 105 | template <typename T> |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 106 | gl::Error GetQueryObjectParameter(gl::Query *query, GLenum pname, T *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 107 | { |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 108 | ASSERT(query != nullptr); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 109 | |
| 110 | switch (pname) |
| 111 | { |
| 112 | case GL_QUERY_RESULT_EXT: |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 113 | return query->getResult(params); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 114 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 115 | { |
| 116 | bool available; |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 117 | gl::Error error = query->isResultAvailable(&available); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 118 | if (!error.isError()) |
| 119 | { |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 120 | *params = gl::ConvertFromGLboolean<T>(available); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 121 | } |
| 122 | return error; |
| 123 | } |
| 124 | default: |
| 125 | UNREACHABLE(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 126 | return gl::InternalError() << "Unreachable Error"; |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 127 | } |
| 128 | } |
| 129 | |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 130 | void MarkTransformFeedbackBufferUsage(gl::TransformFeedback *transformFeedback) |
| 131 | { |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 132 | if (transformFeedback && transformFeedback->isActive() && !transformFeedback->isPaused()) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 133 | { |
| 134 | for (size_t tfBufferIndex = 0; tfBufferIndex < transformFeedback->getIndexedBufferCount(); |
| 135 | tfBufferIndex++) |
| 136 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 137 | const gl::OffsetBindingPointer<gl::Buffer> &buffer = |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 138 | transformFeedback->getIndexedBuffer(tfBufferIndex); |
| 139 | if (buffer.get() != nullptr) |
| 140 | { |
| 141 | buffer->onTransformFeedback(); |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | } |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 146 | |
| 147 | // Attribute map queries. |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 148 | EGLint GetClientMajorVersion(const egl::AttributeMap &attribs) |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 149 | { |
Ian Ewell | ec2c0c5 | 2016-04-05 13:46:26 -0400 | [diff] [blame] | 150 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1)); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 151 | } |
| 152 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 153 | EGLint GetClientMinorVersion(const egl::AttributeMap &attribs) |
| 154 | { |
| 155 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0)); |
| 156 | } |
| 157 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 158 | gl::Version GetClientVersion(const egl::AttributeMap &attribs) |
| 159 | { |
| 160 | return gl::Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs)); |
| 161 | } |
| 162 | |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 163 | GLenum GetResetStrategy(const egl::AttributeMap &attribs) |
| 164 | { |
Ian Ewell | ec2c0c5 | 2016-04-05 13:46:26 -0400 | [diff] [blame] | 165 | EGLAttrib attrib = attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, |
| 166 | EGL_NO_RESET_NOTIFICATION_EXT); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 167 | switch (attrib) |
| 168 | { |
| 169 | case EGL_NO_RESET_NOTIFICATION: |
| 170 | return GL_NO_RESET_NOTIFICATION_EXT; |
| 171 | case EGL_LOSE_CONTEXT_ON_RESET: |
| 172 | return GL_LOSE_CONTEXT_ON_RESET_EXT; |
| 173 | default: |
| 174 | UNREACHABLE(); |
| 175 | return GL_NONE; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | bool GetRobustAccess(const egl::AttributeMap &attribs) |
| 180 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 181 | return (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE) || |
| 182 | ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) != |
| 183 | 0); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | bool GetDebug(const egl::AttributeMap &attribs) |
| 187 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 188 | return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE) || |
| 189 | ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR) != 0); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | bool GetNoError(const egl::AttributeMap &attribs) |
| 193 | { |
| 194 | return (attribs.get(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, EGL_FALSE) == EGL_TRUE); |
| 195 | } |
| 196 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 197 | bool GetWebGLContext(const egl::AttributeMap &attribs) |
| 198 | { |
| 199 | return (attribs.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) == EGL_TRUE); |
| 200 | } |
| 201 | |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 202 | bool GetBindGeneratesResource(const egl::AttributeMap &attribs) |
| 203 | { |
| 204 | return (attribs.get(EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM, EGL_TRUE) == EGL_TRUE); |
| 205 | } |
| 206 | |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 207 | bool GetClientArraysEnabled(const egl::AttributeMap &attribs) |
| 208 | { |
| 209 | return (attribs.get(EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE, EGL_TRUE) == EGL_TRUE); |
| 210 | } |
| 211 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 212 | std::string GetObjectLabelFromPointer(GLsizei length, const GLchar *label) |
| 213 | { |
| 214 | std::string labelName; |
| 215 | if (label != nullptr) |
| 216 | { |
| 217 | size_t labelLength = length < 0 ? strlen(label) : length; |
| 218 | labelName = std::string(label, labelLength); |
| 219 | } |
| 220 | return labelName; |
| 221 | } |
| 222 | |
| 223 | void GetObjectLabelBase(const std::string &objectLabel, |
| 224 | GLsizei bufSize, |
| 225 | GLsizei *length, |
| 226 | GLchar *label) |
| 227 | { |
| 228 | size_t writeLength = objectLabel.length(); |
| 229 | if (label != nullptr && bufSize > 0) |
| 230 | { |
| 231 | writeLength = std::min(static_cast<size_t>(bufSize) - 1, objectLabel.length()); |
| 232 | std::copy(objectLabel.begin(), objectLabel.begin() + writeLength, label); |
| 233 | label[writeLength] = '\0'; |
| 234 | } |
| 235 | |
| 236 | if (length != nullptr) |
| 237 | { |
| 238 | *length = static_cast<GLsizei>(writeLength); |
| 239 | } |
| 240 | } |
| 241 | |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 242 | } // anonymous namespace |
| 243 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 244 | namespace gl |
| 245 | { |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 246 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 247 | Context::Context(rx::EGLImplFactory *implFactory, |
| 248 | const egl::Config *config, |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 249 | const Context *shareContext, |
Geoff Lang | ce02f08 | 2017-02-06 16:46:21 -0500 | [diff] [blame] | 250 | TextureManager *shareTextures, |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 251 | MemoryProgramCache *memoryProgramCache, |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 252 | const egl::AttributeMap &attribs, |
Jamie Madill | 948bbe5 | 2017-06-01 13:10:42 -0400 | [diff] [blame] | 253 | const egl::DisplayExtensions &displayExtensions, |
| 254 | bool robustResourceInit) |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 255 | |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 256 | : ValidationContext(shareContext, |
Geoff Lang | ce02f08 | 2017-02-06 16:46:21 -0500 | [diff] [blame] | 257 | shareTextures, |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 258 | GetClientVersion(attribs), |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 259 | &mGLState, |
Jamie Madill | f25855c | 2015-11-03 11:06:18 -0500 | [diff] [blame] | 260 | mCaps, |
| 261 | mTextureCaps, |
| 262 | mExtensions, |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 263 | mLimitations, |
| 264 | GetNoError(attribs)), |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 265 | mImplementation(implFactory->createContext(mState)), |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 266 | mCompiler(), |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 267 | mConfig(config), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 268 | mClientType(EGL_OPENGL_ES_API), |
| 269 | mHasBeenCurrent(false), |
| 270 | mContextLost(false), |
| 271 | mResetStatus(GL_NO_ERROR), |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 272 | mContextLostForced(false), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 273 | mResetStrategy(GetResetStrategy(attribs)), |
| 274 | mRobustAccess(GetRobustAccess(attribs)), |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 275 | mCurrentSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)), |
| 276 | mCurrentDisplay(static_cast<egl::Display *>(EGL_NO_DISPLAY)), |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 277 | mSurfacelessFramebuffer(nullptr), |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 278 | mWebGLContext(GetWebGLContext(attribs)), |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 279 | mMemoryProgramCache(memoryProgramCache), |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 280 | mScratchBuffer(1000u), |
| 281 | mZeroFilledBuffer(1000u) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 282 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 283 | if (mRobustAccess) |
| 284 | { |
| 285 | UNIMPLEMENTED(); |
| 286 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 287 | |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 288 | initCaps(displayExtensions); |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 289 | initWorkarounds(); |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 290 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 291 | mGLState.initialize(this, GetDebug(attribs), GetBindGeneratesResource(attribs), |
Jamie Madill | c43be72 | 2017-07-13 16:22:14 -0400 | [diff] [blame] | 292 | GetClientArraysEnabled(attribs), robustResourceInit, |
| 293 | mMemoryProgramCache != nullptr); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 294 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 295 | mFenceNVHandleAllocator.setBaseHandle(0); |
Geoff Lang | 7dca186 | 2013-07-30 16:30:46 -0400 | [diff] [blame] | 296 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 297 | // [OpenGL ES 2.0.24] section 3.7 page 83: |
| 298 | // In the initial state, TEXTURE_2D and TEXTURE_CUBE_MAP have twodimensional |
| 299 | // and cube map texture state vectors respectively associated with them. |
| 300 | // In order that access to these initial textures not be lost, they are treated as texture |
| 301 | // objects all of whose names are 0. |
| 302 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 303 | Texture *zeroTexture2D = new Texture(mImplementation.get(), 0, GL_TEXTURE_2D); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 304 | mZeroTextures[GL_TEXTURE_2D].set(this, zeroTexture2D); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 305 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 306 | Texture *zeroTextureCube = new Texture(mImplementation.get(), 0, GL_TEXTURE_CUBE_MAP); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 307 | mZeroTextures[GL_TEXTURE_CUBE_MAP].set(this, zeroTextureCube); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 308 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 309 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 310 | { |
| 311 | // TODO: These could also be enabled via extension |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 312 | Texture *zeroTexture3D = new Texture(mImplementation.get(), 0, GL_TEXTURE_3D); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 313 | mZeroTextures[GL_TEXTURE_3D].set(this, zeroTexture3D); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 314 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 315 | Texture *zeroTexture2DArray = new Texture(mImplementation.get(), 0, GL_TEXTURE_2D_ARRAY); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 316 | mZeroTextures[GL_TEXTURE_2D_ARRAY].set(this, zeroTexture2DArray); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 317 | } |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 318 | if (getClientVersion() >= Version(3, 1)) |
| 319 | { |
| 320 | Texture *zeroTexture2DMultisample = |
| 321 | new Texture(mImplementation.get(), 0, GL_TEXTURE_2D_MULTISAMPLE); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 322 | mZeroTextures[GL_TEXTURE_2D_MULTISAMPLE].set(this, zeroTexture2DMultisample); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 323 | |
| 324 | bindGenericAtomicCounterBuffer(0); |
| 325 | for (unsigned int i = 0; i < mCaps.maxAtomicCounterBufferBindings; i++) |
| 326 | { |
| 327 | bindIndexedAtomicCounterBuffer(0, i, 0, 0); |
| 328 | } |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 329 | |
| 330 | bindGenericShaderStorageBuffer(0); |
| 331 | for (unsigned int i = 0; i < mCaps.maxShaderStorageBufferBindings; i++) |
| 332 | { |
| 333 | bindIndexedShaderStorageBuffer(0, i, 0, 0); |
| 334 | } |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 335 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 336 | |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 337 | if (mExtensions.textureRectangle) |
| 338 | { |
| 339 | Texture *zeroTextureRectangle = |
| 340 | new Texture(mImplementation.get(), 0, GL_TEXTURE_RECTANGLE_ANGLE); |
| 341 | mZeroTextures[GL_TEXTURE_RECTANGLE_ANGLE].set(this, zeroTextureRectangle); |
| 342 | } |
| 343 | |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 344 | if (mExtensions.eglImageExternal || mExtensions.eglStreamConsumerExternal) |
| 345 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 346 | Texture *zeroTextureExternal = |
| 347 | new Texture(mImplementation.get(), 0, GL_TEXTURE_EXTERNAL_OES); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 348 | mZeroTextures[GL_TEXTURE_EXTERNAL_OES].set(this, zeroTextureExternal); |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 349 | } |
| 350 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 351 | mGLState.initializeZeroTextures(this, mZeroTextures); |
Jamie Madill | e6382c3 | 2014-11-07 15:05:26 -0500 | [diff] [blame] | 352 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 353 | bindVertexArray(0); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 354 | bindArrayBuffer(0); |
Jiajia Qin | 9d7d0b1 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 355 | bindDrawIndirectBuffer(0); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 356 | bindElementArrayBuffer(0); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 357 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 358 | bindRenderbuffer(GL_RENDERBUFFER, 0); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 359 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 360 | bindGenericUniformBuffer(0); |
Geoff Lang | 4dc3af0 | 2016-11-18 14:09:27 -0500 | [diff] [blame] | 361 | for (unsigned int i = 0; i < mCaps.maxUniformBufferBindings; i++) |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 362 | { |
| 363 | bindIndexedUniformBuffer(0, i, 0, -1); |
| 364 | } |
| 365 | |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 366 | bindCopyReadBuffer(0); |
| 367 | bindCopyWriteBuffer(0); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 368 | bindPixelPackBuffer(0); |
| 369 | bindPixelUnpackBuffer(0); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 370 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 371 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 372 | { |
| 373 | // [OpenGL ES 3.0.2] section 2.14.1 pg 85: |
| 374 | // In the initial state, a default transform feedback object is bound and treated as |
| 375 | // a transform feedback object with a name of zero. That object is bound any time |
| 376 | // BindTransformFeedback is called with id of zero |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 377 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 378 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 379 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 380 | // Initialize dirty bit masks |
| 381 | // TODO(jmadill): additional ES3 state |
| 382 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_ALIGNMENT); |
| 383 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_ROW_LENGTH); |
| 384 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_IMAGE_HEIGHT); |
| 385 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_SKIP_IMAGES); |
| 386 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_SKIP_ROWS); |
| 387 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_SKIP_PIXELS); |
Corentin Wallez | bbd663a | 2016-04-20 17:49:17 -0400 | [diff] [blame] | 388 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_BUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 389 | // No dirty objects. |
| 390 | |
| 391 | // Readpixels uses the pack state and read FBO |
| 392 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_ALIGNMENT); |
| 393 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_REVERSE_ROW_ORDER); |
| 394 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_ROW_LENGTH); |
| 395 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_SKIP_ROWS); |
| 396 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_SKIP_PIXELS); |
Corentin Wallez | bbd663a | 2016-04-20 17:49:17 -0400 | [diff] [blame] | 397 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_BUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 398 | mReadPixelsDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 399 | |
| 400 | mClearDirtyBits.set(State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED); |
| 401 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 402 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
| 403 | mClearDirtyBits.set(State::DIRTY_BIT_VIEWPORT); |
| 404 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_COLOR); |
| 405 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_DEPTH); |
| 406 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_STENCIL); |
| 407 | mClearDirtyBits.set(State::DIRTY_BIT_COLOR_MASK); |
| 408 | mClearDirtyBits.set(State::DIRTY_BIT_DEPTH_MASK); |
| 409 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT); |
| 410 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_BACK); |
| 411 | mClearDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 412 | |
| 413 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 414 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 415 | mBlitDirtyBits.set(State::DIRTY_BIT_FRAMEBUFFER_SRGB); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 416 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 417 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 418 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 419 | handleError(mImplementation->initialize()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 420 | } |
| 421 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 422 | egl::Error Context::onDestroy(const egl::Display *display) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 423 | { |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 424 | for (auto fence : mFenceNVMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 425 | { |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 426 | SafeDelete(fence.second); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 427 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 428 | mFenceNVMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 429 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 430 | for (auto query : mQueryMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 431 | { |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 432 | if (query.second != nullptr) |
| 433 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 434 | query.second->release(this); |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 435 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 436 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 437 | mQueryMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 438 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 439 | for (auto vertexArray : mVertexArrayMap) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 440 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 441 | if (vertexArray.second) |
| 442 | { |
| 443 | vertexArray.second->onDestroy(this); |
| 444 | } |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 445 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 446 | mVertexArrayMap.clear(); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 447 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 448 | for (auto transformFeedback : mTransformFeedbackMap) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 449 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 450 | if (transformFeedback.second != nullptr) |
| 451 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 452 | transformFeedback.second->release(this); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 453 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 454 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 455 | mTransformFeedbackMap.clear(); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 456 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 457 | for (auto &zeroTexture : mZeroTextures) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 458 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 459 | zeroTexture.second->onDestroy(this); |
| 460 | zeroTexture.second.set(this, nullptr); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 461 | } |
| 462 | mZeroTextures.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 463 | |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 464 | SafeDelete(mSurfacelessFramebuffer); |
| 465 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 466 | ANGLE_TRY(releaseSurface(display)); |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 467 | releaseShaderCompiler(); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 468 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 469 | mGLState.reset(this); |
| 470 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 471 | mState.mBuffers->release(this); |
| 472 | mState.mShaderPrograms->release(this); |
| 473 | mState.mTextures->release(this); |
| 474 | mState.mRenderbuffers->release(this); |
| 475 | mState.mSamplers->release(this); |
| 476 | mState.mFenceSyncs->release(this); |
| 477 | mState.mPaths->release(this); |
| 478 | mState.mFramebuffers->release(this); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 479 | |
| 480 | return egl::NoError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 481 | } |
| 482 | |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 483 | Context::~Context() |
| 484 | { |
| 485 | } |
| 486 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 487 | egl::Error Context::makeCurrent(egl::Display *display, egl::Surface *surface) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 488 | { |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 489 | mCurrentDisplay = display; |
| 490 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 491 | if (!mHasBeenCurrent) |
| 492 | { |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 493 | initRendererString(); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 494 | initVersionStrings(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 495 | initExtensionStrings(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 496 | |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 497 | int width = 0; |
| 498 | int height = 0; |
| 499 | if (surface != nullptr) |
| 500 | { |
| 501 | width = surface->getWidth(); |
| 502 | height = surface->getHeight(); |
| 503 | } |
| 504 | |
| 505 | mGLState.setViewportParams(0, 0, width, height); |
| 506 | mGLState.setScissorParams(0, 0, width, height); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 507 | |
| 508 | mHasBeenCurrent = true; |
| 509 | } |
| 510 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 511 | // TODO(jmadill): Rework this when we support ContextImpl |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 512 | mGLState.setAllDirtyBits(); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 513 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 514 | ANGLE_TRY(releaseSurface(display)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 515 | |
| 516 | Framebuffer *newDefault = nullptr; |
| 517 | if (surface != nullptr) |
| 518 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 519 | ANGLE_TRY(surface->setIsCurrent(this, true)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 520 | mCurrentSurface = surface; |
| 521 | newDefault = surface->getDefaultFramebuffer(); |
| 522 | } |
| 523 | else |
| 524 | { |
| 525 | if (mSurfacelessFramebuffer == nullptr) |
| 526 | { |
| 527 | mSurfacelessFramebuffer = new Framebuffer(mImplementation.get()); |
| 528 | } |
| 529 | |
| 530 | newDefault = mSurfacelessFramebuffer; |
| 531 | } |
Jamie Madill | 18fdcbc | 2015-08-19 18:12:44 +0000 | [diff] [blame] | 532 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 533 | // Update default framebuffer, the binding of the previous default |
| 534 | // framebuffer (or lack of) will have a nullptr. |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 535 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 536 | if (mGLState.getReadFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 537 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 538 | mGLState.setReadFramebufferBinding(newDefault); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 539 | } |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 540 | if (mGLState.getDrawFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 541 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 542 | mGLState.setDrawFramebufferBinding(newDefault); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 543 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 544 | mState.mFramebuffers->setDefaultFramebuffer(newDefault); |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 545 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 546 | |
| 547 | // Notify the renderer of a context switch |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 548 | mImplementation->onMakeCurrent(this); |
| 549 | return egl::NoError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 550 | } |
| 551 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 552 | egl::Error Context::releaseSurface(const egl::Display *display) |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 553 | { |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 554 | // Remove the default framebuffer |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 555 | Framebuffer *currentDefault = nullptr; |
| 556 | if (mCurrentSurface != nullptr) |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 557 | { |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 558 | currentDefault = mCurrentSurface->getDefaultFramebuffer(); |
| 559 | } |
| 560 | else if (mSurfacelessFramebuffer != nullptr) |
| 561 | { |
| 562 | currentDefault = mSurfacelessFramebuffer; |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 563 | } |
| 564 | |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 565 | if (mGLState.getReadFramebuffer() == currentDefault) |
| 566 | { |
| 567 | mGLState.setReadFramebufferBinding(nullptr); |
| 568 | } |
| 569 | if (mGLState.getDrawFramebuffer() == currentDefault) |
| 570 | { |
| 571 | mGLState.setDrawFramebufferBinding(nullptr); |
| 572 | } |
| 573 | mState.mFramebuffers->setDefaultFramebuffer(nullptr); |
| 574 | |
| 575 | if (mCurrentSurface) |
| 576 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 577 | ANGLE_TRY(mCurrentSurface->setIsCurrent(this, false)); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 578 | mCurrentSurface = nullptr; |
| 579 | } |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 580 | |
| 581 | return egl::NoError(); |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 582 | } |
| 583 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 584 | GLuint Context::createBuffer() |
| 585 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 586 | return mState.mBuffers->createBuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | GLuint Context::createProgram() |
| 590 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 591 | return mState.mShaderPrograms->createProgram(mImplementation.get()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | GLuint Context::createShader(GLenum type) |
| 595 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 596 | return mState.mShaderPrograms->createShader(mImplementation.get(), mLimitations, type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | GLuint Context::createTexture() |
| 600 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 601 | return mState.mTextures->createTexture(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | GLuint Context::createRenderbuffer() |
| 605 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 606 | return mState.mRenderbuffers->createRenderbuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 607 | } |
| 608 | |
Geoff Lang | 882033e | 2014-09-30 11:26:07 -0400 | [diff] [blame] | 609 | GLsync Context::createFenceSync() |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 610 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 611 | GLuint handle = mState.mFenceSyncs->createFenceSync(mImplementation.get()); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 612 | |
Cooper Partin | d8e62a3 | 2015-01-29 15:21:25 -0800 | [diff] [blame] | 613 | return reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle)); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 614 | } |
| 615 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 616 | GLuint Context::createPaths(GLsizei range) |
| 617 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 618 | auto resultOrError = mState.mPaths->createPaths(mImplementation.get(), range); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 619 | if (resultOrError.isError()) |
| 620 | { |
| 621 | handleError(resultOrError.getError()); |
| 622 | return 0; |
| 623 | } |
| 624 | return resultOrError.getResult(); |
| 625 | } |
| 626 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 627 | GLuint Context::createSampler() |
| 628 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 629 | return mState.mSamplers->createSampler(); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 630 | } |
| 631 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 632 | // Returns an unused framebuffer name |
| 633 | GLuint Context::createFramebuffer() |
| 634 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 635 | return mState.mFramebuffers->createFramebuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 636 | } |
| 637 | |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 638 | GLuint Context::createFenceNV() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 639 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 640 | GLuint handle = mFenceNVHandleAllocator.allocate(); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 641 | mFenceNVMap.assign(handle, new FenceNV(mImplementation->createFenceNV())); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 642 | return handle; |
| 643 | } |
| 644 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 645 | void Context::deleteBuffer(GLuint buffer) |
| 646 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 647 | if (mState.mBuffers->getBuffer(buffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 648 | { |
| 649 | detachBuffer(buffer); |
| 650 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 651 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 652 | mState.mBuffers->deleteObject(this, buffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | void Context::deleteShader(GLuint shader) |
| 656 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 657 | mState.mShaderPrograms->deleteShader(this, shader); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | void Context::deleteProgram(GLuint program) |
| 661 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 662 | mState.mShaderPrograms->deleteProgram(this, program); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | void Context::deleteTexture(GLuint texture) |
| 666 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 667 | if (mState.mTextures->getTexture(texture)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 668 | { |
| 669 | detachTexture(texture); |
| 670 | } |
| 671 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 672 | mState.mTextures->deleteObject(this, texture); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | void Context::deleteRenderbuffer(GLuint renderbuffer) |
| 676 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 677 | if (mState.mRenderbuffers->getRenderbuffer(renderbuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 678 | { |
| 679 | detachRenderbuffer(renderbuffer); |
| 680 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 681 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 682 | mState.mRenderbuffers->deleteObject(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 683 | } |
| 684 | |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 685 | void Context::deleteFenceSync(GLsync fenceSync) |
| 686 | { |
| 687 | // The spec specifies the underlying Fence object is not deleted until all current |
| 688 | // wait commands finish. However, since the name becomes invalid, we cannot query the fence, |
| 689 | // and since our API is currently designed for being called from a single thread, we can delete |
| 690 | // the fence immediately. |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 691 | mState.mFenceSyncs->deleteObject(this, |
| 692 | static_cast<GLuint>(reinterpret_cast<uintptr_t>(fenceSync))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 693 | } |
| 694 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 695 | void Context::deletePaths(GLuint first, GLsizei range) |
| 696 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 697 | mState.mPaths->deletePaths(first, range); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 698 | } |
| 699 | |
| 700 | bool Context::hasPathData(GLuint path) const |
| 701 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 702 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 703 | if (pathObj == nullptr) |
| 704 | return false; |
| 705 | |
| 706 | return pathObj->hasPathData(); |
| 707 | } |
| 708 | |
| 709 | bool Context::hasPath(GLuint path) const |
| 710 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 711 | return mState.mPaths->hasPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | void Context::setPathCommands(GLuint path, |
| 715 | GLsizei numCommands, |
| 716 | const GLubyte *commands, |
| 717 | GLsizei numCoords, |
| 718 | GLenum coordType, |
| 719 | const void *coords) |
| 720 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 721 | auto *pathObject = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 722 | |
| 723 | handleError(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords)); |
| 724 | } |
| 725 | |
| 726 | void Context::setPathParameterf(GLuint path, GLenum pname, GLfloat value) |
| 727 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 728 | auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 729 | |
| 730 | switch (pname) |
| 731 | { |
| 732 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 733 | pathObj->setStrokeWidth(value); |
| 734 | break; |
| 735 | case GL_PATH_END_CAPS_CHROMIUM: |
| 736 | pathObj->setEndCaps(static_cast<GLenum>(value)); |
| 737 | break; |
| 738 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 739 | pathObj->setJoinStyle(static_cast<GLenum>(value)); |
| 740 | break; |
| 741 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 742 | pathObj->setMiterLimit(value); |
| 743 | break; |
| 744 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 745 | pathObj->setStrokeBound(value); |
| 746 | break; |
| 747 | default: |
| 748 | UNREACHABLE(); |
| 749 | break; |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | void Context::getPathParameterfv(GLuint path, GLenum pname, GLfloat *value) const |
| 754 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 755 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 756 | |
| 757 | switch (pname) |
| 758 | { |
| 759 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 760 | *value = pathObj->getStrokeWidth(); |
| 761 | break; |
| 762 | case GL_PATH_END_CAPS_CHROMIUM: |
| 763 | *value = static_cast<GLfloat>(pathObj->getEndCaps()); |
| 764 | break; |
| 765 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 766 | *value = static_cast<GLfloat>(pathObj->getJoinStyle()); |
| 767 | break; |
| 768 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 769 | *value = pathObj->getMiterLimit(); |
| 770 | break; |
| 771 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 772 | *value = pathObj->getStrokeBound(); |
| 773 | break; |
| 774 | default: |
| 775 | UNREACHABLE(); |
| 776 | break; |
| 777 | } |
| 778 | } |
| 779 | |
| 780 | void Context::setPathStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 781 | { |
| 782 | mGLState.setPathStencilFunc(func, ref, mask); |
| 783 | } |
| 784 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 785 | void Context::deleteSampler(GLuint sampler) |
| 786 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 787 | if (mState.mSamplers->getSampler(sampler)) |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 788 | { |
| 789 | detachSampler(sampler); |
| 790 | } |
| 791 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 792 | mState.mSamplers->deleteObject(this, sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 793 | } |
| 794 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 795 | void Context::deleteFramebuffer(GLuint framebuffer) |
| 796 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 797 | if (mState.mFramebuffers->getFramebuffer(framebuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 798 | { |
| 799 | detachFramebuffer(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 800 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 801 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 802 | mState.mFramebuffers->deleteObject(this, framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 803 | } |
| 804 | |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 805 | void Context::deleteFenceNV(GLuint fence) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 806 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 807 | FenceNV *fenceObject = nullptr; |
| 808 | if (mFenceNVMap.erase(fence, &fenceObject)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 809 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 810 | mFenceNVHandleAllocator.release(fence); |
| 811 | delete fenceObject; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 812 | } |
| 813 | } |
| 814 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 815 | Buffer *Context::getBuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 816 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 817 | return mState.mBuffers->getBuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 818 | } |
| 819 | |
Jamie Madill | 570f7c8 | 2014-07-03 10:38:54 -0400 | [diff] [blame] | 820 | Texture *Context::getTexture(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 821 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 822 | return mState.mTextures->getTexture(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 823 | } |
| 824 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 825 | Renderbuffer *Context::getRenderbuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 826 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 827 | return mState.mRenderbuffers->getRenderbuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 828 | } |
| 829 | |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 830 | FenceSync *Context::getFenceSync(GLsync handle) const |
| 831 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 832 | return mState.mFenceSyncs->getFenceSync( |
| 833 | static_cast<GLuint>(reinterpret_cast<uintptr_t>(handle))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 834 | } |
| 835 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 836 | VertexArray *Context::getVertexArray(GLuint handle) const |
| 837 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 838 | return mVertexArrayMap.query(handle); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 839 | } |
| 840 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 841 | Sampler *Context::getSampler(GLuint handle) const |
| 842 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 843 | return mState.mSamplers->getSampler(handle); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 844 | } |
| 845 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 846 | TransformFeedback *Context::getTransformFeedback(GLuint handle) const |
| 847 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 848 | return mTransformFeedbackMap.query(handle); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 849 | } |
| 850 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 851 | LabeledObject *Context::getLabeledObject(GLenum identifier, GLuint name) const |
| 852 | { |
| 853 | switch (identifier) |
| 854 | { |
| 855 | case GL_BUFFER: |
| 856 | return getBuffer(name); |
| 857 | case GL_SHADER: |
| 858 | return getShader(name); |
| 859 | case GL_PROGRAM: |
| 860 | return getProgram(name); |
| 861 | case GL_VERTEX_ARRAY: |
| 862 | return getVertexArray(name); |
| 863 | case GL_QUERY: |
| 864 | return getQuery(name); |
| 865 | case GL_TRANSFORM_FEEDBACK: |
| 866 | return getTransformFeedback(name); |
| 867 | case GL_SAMPLER: |
| 868 | return getSampler(name); |
| 869 | case GL_TEXTURE: |
| 870 | return getTexture(name); |
| 871 | case GL_RENDERBUFFER: |
| 872 | return getRenderbuffer(name); |
| 873 | case GL_FRAMEBUFFER: |
| 874 | return getFramebuffer(name); |
| 875 | default: |
| 876 | UNREACHABLE(); |
| 877 | return nullptr; |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | LabeledObject *Context::getLabeledObjectFromPtr(const void *ptr) const |
| 882 | { |
| 883 | return getFenceSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr))); |
| 884 | } |
| 885 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 886 | void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label) |
| 887 | { |
| 888 | LabeledObject *object = getLabeledObject(identifier, name); |
| 889 | ASSERT(object != nullptr); |
| 890 | |
| 891 | std::string labelName = GetObjectLabelFromPointer(length, label); |
| 892 | object->setLabel(labelName); |
| 893 | } |
| 894 | |
| 895 | void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label) |
| 896 | { |
| 897 | LabeledObject *object = getLabeledObjectFromPtr(ptr); |
| 898 | ASSERT(object != nullptr); |
| 899 | |
| 900 | std::string labelName = GetObjectLabelFromPointer(length, label); |
| 901 | object->setLabel(labelName); |
| 902 | } |
| 903 | |
| 904 | void Context::getObjectLabel(GLenum identifier, |
| 905 | GLuint name, |
| 906 | GLsizei bufSize, |
| 907 | GLsizei *length, |
| 908 | GLchar *label) const |
| 909 | { |
| 910 | LabeledObject *object = getLabeledObject(identifier, name); |
| 911 | ASSERT(object != nullptr); |
| 912 | |
| 913 | const std::string &objectLabel = object->getLabel(); |
| 914 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 915 | } |
| 916 | |
| 917 | void Context::getObjectPtrLabel(const void *ptr, |
| 918 | GLsizei bufSize, |
| 919 | GLsizei *length, |
| 920 | GLchar *label) const |
| 921 | { |
| 922 | LabeledObject *object = getLabeledObjectFromPtr(ptr); |
| 923 | ASSERT(object != nullptr); |
| 924 | |
| 925 | const std::string &objectLabel = object->getLabel(); |
| 926 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 927 | } |
| 928 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 929 | bool Context::isSampler(GLuint samplerName) const |
| 930 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 931 | return mState.mSamplers->isSampler(samplerName); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 932 | } |
| 933 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 934 | void Context::bindArrayBuffer(GLuint bufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 935 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 936 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 937 | mGLState.setArrayBufferBinding(this, buffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 938 | } |
| 939 | |
Jiajia Qin | 9d7d0b1 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 940 | void Context::bindDrawIndirectBuffer(GLuint bufferHandle) |
| 941 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 942 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 943 | mGLState.setDrawIndirectBufferBinding(this, buffer); |
Jiajia Qin | 9d7d0b1 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 944 | } |
| 945 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 946 | void Context::bindElementArrayBuffer(GLuint bufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 947 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 948 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 949 | mGLState.setElementArrayBuffer(this, buffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 950 | } |
| 951 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 952 | void Context::bindTexture(GLenum target, GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 953 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 954 | Texture *texture = nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 955 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 956 | if (handle == 0) |
| 957 | { |
| 958 | texture = mZeroTextures[target].get(); |
| 959 | } |
| 960 | else |
| 961 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 962 | texture = mState.mTextures->checkTextureAllocation(mImplementation.get(), handle, target); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | ASSERT(texture); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 966 | mGLState.setSamplerTexture(this, target, texture); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 967 | } |
| 968 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 969 | void Context::bindReadFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 970 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 971 | Framebuffer *framebuffer = mState.mFramebuffers->checkFramebufferAllocation( |
| 972 | mImplementation.get(), mCaps, framebufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 973 | mGLState.setReadFramebufferBinding(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 974 | } |
| 975 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 976 | void Context::bindDrawFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 977 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 978 | Framebuffer *framebuffer = mState.mFramebuffers->checkFramebufferAllocation( |
| 979 | mImplementation.get(), mCaps, framebufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 980 | mGLState.setDrawFramebufferBinding(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 981 | } |
| 982 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 983 | void Context::bindVertexArray(GLuint vertexArrayHandle) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 984 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 985 | VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 986 | mGLState.setVertexArrayBinding(vertexArray); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 987 | } |
| 988 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 989 | void Context::bindVertexBuffer(GLuint bindingIndex, |
| 990 | GLuint bufferHandle, |
| 991 | GLintptr offset, |
| 992 | GLsizei stride) |
| 993 | { |
| 994 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 995 | mGLState.bindVertexBuffer(this, bindingIndex, buffer, offset, stride); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 996 | } |
| 997 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 998 | void Context::bindSampler(GLuint textureUnit, GLuint samplerHandle) |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 999 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 1000 | ASSERT(textureUnit < mCaps.maxCombinedTextureImageUnits); |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1001 | Sampler *sampler = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1002 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), samplerHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1003 | mGLState.setSamplerBinding(this, textureUnit, sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1004 | } |
| 1005 | |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1006 | void Context::bindImageTexture(GLuint unit, |
| 1007 | GLuint texture, |
| 1008 | GLint level, |
| 1009 | GLboolean layered, |
| 1010 | GLint layer, |
| 1011 | GLenum access, |
| 1012 | GLenum format) |
| 1013 | { |
| 1014 | Texture *tex = mState.mTextures->getTexture(texture); |
| 1015 | mGLState.setImageUnit(this, unit, tex, level, layered, layer, access, format); |
| 1016 | } |
| 1017 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1018 | void Context::bindGenericUniformBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1019 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1020 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1021 | mGLState.setGenericUniformBufferBinding(this, buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1024 | void Context::bindIndexedUniformBuffer(GLuint bufferHandle, |
| 1025 | GLuint index, |
| 1026 | GLintptr offset, |
| 1027 | GLsizeiptr size) |
shannon.woods%transgaming.com@gtempaccount.com | 3408935 | 2013-04-13 03:36:57 +0000 | [diff] [blame] | 1028 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1029 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1030 | mGLState.setIndexedUniformBufferBinding(this, index, buffer, offset, size); |
shannon.woods%transgaming.com@gtempaccount.com | 3408935 | 2013-04-13 03:36:57 +0000 | [diff] [blame] | 1031 | } |
| 1032 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1033 | void Context::bindGenericTransformFeedbackBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1034 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1035 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1036 | mGLState.getCurrentTransformFeedback()->bindGenericBuffer(this, buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1037 | } |
| 1038 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1039 | void Context::bindIndexedTransformFeedbackBuffer(GLuint bufferHandle, |
| 1040 | GLuint index, |
| 1041 | GLintptr offset, |
| 1042 | GLsizeiptr size) |
shannon.woods%transgaming.com@gtempaccount.com | 3408935 | 2013-04-13 03:36:57 +0000 | [diff] [blame] | 1043 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1044 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1045 | mGLState.getCurrentTransformFeedback()->bindIndexedBuffer(this, index, buffer, offset, size); |
shannon.woods%transgaming.com@gtempaccount.com | 3408935 | 2013-04-13 03:36:57 +0000 | [diff] [blame] | 1046 | } |
| 1047 | |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1048 | void Context::bindGenericAtomicCounterBuffer(GLuint bufferHandle) |
| 1049 | { |
| 1050 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1051 | mGLState.setGenericAtomicCounterBufferBinding(this, buffer); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | void Context::bindIndexedAtomicCounterBuffer(GLuint bufferHandle, |
| 1055 | GLuint index, |
| 1056 | GLintptr offset, |
| 1057 | GLsizeiptr size) |
| 1058 | { |
| 1059 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1060 | mGLState.setIndexedAtomicCounterBufferBinding(this, index, buffer, offset, size); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1061 | } |
| 1062 | |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1063 | void Context::bindGenericShaderStorageBuffer(GLuint bufferHandle) |
| 1064 | { |
| 1065 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1066 | mGLState.setGenericShaderStorageBufferBinding(this, buffer); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1067 | } |
| 1068 | |
| 1069 | void Context::bindIndexedShaderStorageBuffer(GLuint bufferHandle, |
| 1070 | GLuint index, |
| 1071 | GLintptr offset, |
| 1072 | GLsizeiptr size) |
| 1073 | { |
| 1074 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1075 | mGLState.setIndexedShaderStorageBufferBinding(this, index, buffer, offset, size); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1076 | } |
| 1077 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1078 | void Context::bindCopyReadBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1079 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1080 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1081 | mGLState.setCopyReadBufferBinding(this, buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1082 | } |
| 1083 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1084 | void Context::bindCopyWriteBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1085 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1086 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1087 | mGLState.setCopyWriteBufferBinding(this, buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1088 | } |
| 1089 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1090 | void Context::bindPixelPackBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1091 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1092 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1093 | mGLState.setPixelPackBufferBinding(this, buffer); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1094 | } |
| 1095 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1096 | void Context::bindPixelUnpackBuffer(GLuint bufferHandle) |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1097 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1098 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1099 | mGLState.setPixelUnpackBufferBinding(this, buffer); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1100 | } |
| 1101 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1102 | void Context::useProgram(GLuint program) |
| 1103 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 1104 | mGLState.setProgram(this, getProgram(program)); |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1107 | void Context::bindTransformFeedback(GLenum target, GLuint transformFeedbackHandle) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1108 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1109 | ASSERT(target == GL_TRANSFORM_FEEDBACK); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1110 | TransformFeedback *transformFeedback = |
| 1111 | checkTransformFeedbackAllocation(transformFeedbackHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1112 | mGLState.setTransformFeedbackBinding(this, transformFeedback); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1113 | } |
| 1114 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 1115 | void Context::beginQuery(GLenum target, GLuint query) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1116 | { |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1117 | Query *queryObject = getQuery(query, true, target); |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1118 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1119 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1120 | // begin query |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 1121 | ANGLE_CONTEXT_TRY(queryObject->begin()); |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1122 | |
| 1123 | // set query as active for specified target only if begin succeeded |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1124 | mGLState.setActiveQuery(this, target, queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1125 | } |
| 1126 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 1127 | void Context::endQuery(GLenum target) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1128 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1129 | Query *queryObject = mGLState.getActiveQuery(target); |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1130 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1131 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 1132 | handleError(queryObject->end()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1133 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1134 | // Always unbind the query, even if there was an error. This may delete the query object. |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1135 | mGLState.setActiveQuery(this, target, nullptr); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1136 | } |
| 1137 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 1138 | void Context::queryCounter(GLuint id, GLenum target) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1139 | { |
| 1140 | ASSERT(target == GL_TIMESTAMP_EXT); |
| 1141 | |
| 1142 | Query *queryObject = getQuery(id, true, target); |
| 1143 | ASSERT(queryObject); |
| 1144 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 1145 | handleError(queryObject->queryCounter()); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1146 | } |
| 1147 | |
| 1148 | void Context::getQueryiv(GLenum target, GLenum pname, GLint *params) |
| 1149 | { |
| 1150 | switch (pname) |
| 1151 | { |
| 1152 | case GL_CURRENT_QUERY_EXT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1153 | params[0] = mGLState.getActiveQueryId(target); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1154 | break; |
| 1155 | case GL_QUERY_COUNTER_BITS_EXT: |
| 1156 | switch (target) |
| 1157 | { |
| 1158 | case GL_TIME_ELAPSED_EXT: |
| 1159 | params[0] = getExtensions().queryCounterBitsTimeElapsed; |
| 1160 | break; |
| 1161 | case GL_TIMESTAMP_EXT: |
| 1162 | params[0] = getExtensions().queryCounterBitsTimestamp; |
| 1163 | break; |
| 1164 | default: |
| 1165 | UNREACHABLE(); |
| 1166 | params[0] = 0; |
| 1167 | break; |
| 1168 | } |
| 1169 | break; |
| 1170 | default: |
| 1171 | UNREACHABLE(); |
| 1172 | return; |
| 1173 | } |
| 1174 | } |
| 1175 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1176 | void Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1177 | { |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1178 | handleError(GetQueryObjectParameter(getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1179 | } |
| 1180 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1181 | void Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1182 | { |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1183 | handleError(GetQueryObjectParameter(getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1184 | } |
| 1185 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1186 | void Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1187 | { |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1188 | handleError(GetQueryObjectParameter(getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1189 | } |
| 1190 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1191 | void Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1192 | { |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1193 | handleError(GetQueryObjectParameter(getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1194 | } |
| 1195 | |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1196 | Framebuffer *Context::getFramebuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1197 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1198 | return mState.mFramebuffers->getFramebuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1199 | } |
| 1200 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1201 | FenceNV *Context::getFenceNV(GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1202 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1203 | return mFenceNVMap.query(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1204 | } |
| 1205 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1206 | Query *Context::getQuery(GLuint handle, bool create, GLenum type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1207 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1208 | if (!mQueryMap.contains(handle)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1209 | { |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 1210 | return nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1211 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1212 | |
| 1213 | Query *query = mQueryMap.query(handle); |
| 1214 | if (!query && create) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1215 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1216 | query = new Query(mImplementation->createQuery(type), handle); |
| 1217 | query->addRef(); |
| 1218 | mQueryMap.assign(handle, query); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1219 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1220 | return query; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1221 | } |
| 1222 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1223 | Query *Context::getQuery(GLuint handle) const |
| 1224 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1225 | return mQueryMap.query(handle); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1226 | } |
| 1227 | |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 1228 | Texture *Context::getTargetTexture(GLenum target) const |
| 1229 | { |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 1230 | ASSERT(ValidTextureTarget(this, target) || ValidTextureExternalTarget(this, target)); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1231 | return mGLState.getTargetTexture(target); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1232 | } |
| 1233 | |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 1234 | Texture *Context::getSamplerTexture(unsigned int sampler, GLenum type) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1235 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1236 | return mGLState.getSamplerTexture(sampler, type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1237 | } |
| 1238 | |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1239 | Compiler *Context::getCompiler() const |
| 1240 | { |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1241 | if (mCompiler.get() == nullptr) |
| 1242 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1243 | mCompiler.set(this, new Compiler(mImplementation.get(), mState)); |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1244 | } |
| 1245 | return mCompiler.get(); |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1246 | } |
| 1247 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1248 | void Context::getBooleanvImpl(GLenum pname, GLboolean *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1249 | { |
| 1250 | switch (pname) |
| 1251 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1252 | case GL_SHADER_COMPILER: |
| 1253 | *params = GL_TRUE; |
| 1254 | break; |
| 1255 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 1256 | *params = mRobustAccess ? GL_TRUE : GL_FALSE; |
| 1257 | break; |
| 1258 | default: |
| 1259 | mGLState.getBooleanv(pname, params); |
| 1260 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1261 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1262 | } |
| 1263 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1264 | void Context::getFloatvImpl(GLenum pname, GLfloat *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1265 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1266 | // Queries about context capabilities and maximums are answered by Context. |
| 1267 | // Queries about current GL state values are answered by State. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1268 | switch (pname) |
| 1269 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1270 | case GL_ALIASED_LINE_WIDTH_RANGE: |
| 1271 | params[0] = mCaps.minAliasedLineWidth; |
| 1272 | params[1] = mCaps.maxAliasedLineWidth; |
| 1273 | break; |
| 1274 | case GL_ALIASED_POINT_SIZE_RANGE: |
| 1275 | params[0] = mCaps.minAliasedPointSize; |
| 1276 | params[1] = mCaps.maxAliasedPointSize; |
| 1277 | break; |
| 1278 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
| 1279 | ASSERT(mExtensions.textureFilterAnisotropic); |
| 1280 | *params = mExtensions.maxTextureAnisotropy; |
| 1281 | break; |
| 1282 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 1283 | *params = mCaps.maxLODBias; |
| 1284 | break; |
| 1285 | |
| 1286 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 1287 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 1288 | { |
| 1289 | ASSERT(mExtensions.pathRendering); |
| 1290 | const GLfloat *m = mGLState.getPathRenderingMatrix(pname); |
| 1291 | memcpy(params, m, 16 * sizeof(GLfloat)); |
| 1292 | } |
Geoff Lang | e6d4e12 | 2015-06-29 13:33:55 -0400 | [diff] [blame] | 1293 | break; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1294 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1295 | default: |
| 1296 | mGLState.getFloatv(pname, params); |
| 1297 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1298 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1299 | } |
| 1300 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1301 | void Context::getIntegervImpl(GLenum pname, GLint *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1302 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1303 | // Queries about context capabilities and maximums are answered by Context. |
| 1304 | // 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] | 1305 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1306 | switch (pname) |
| 1307 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1308 | case GL_MAX_VERTEX_ATTRIBS: |
| 1309 | *params = mCaps.maxVertexAttributes; |
| 1310 | break; |
| 1311 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 1312 | *params = mCaps.maxVertexUniformVectors; |
| 1313 | break; |
| 1314 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
| 1315 | *params = mCaps.maxVertexUniformComponents; |
| 1316 | break; |
| 1317 | case GL_MAX_VARYING_VECTORS: |
| 1318 | *params = mCaps.maxVaryingVectors; |
| 1319 | break; |
| 1320 | case GL_MAX_VARYING_COMPONENTS: |
| 1321 | *params = mCaps.maxVertexOutputComponents; |
| 1322 | break; |
| 1323 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 1324 | *params = mCaps.maxCombinedTextureImageUnits; |
| 1325 | break; |
| 1326 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 1327 | *params = mCaps.maxVertexTextureImageUnits; |
| 1328 | break; |
| 1329 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
| 1330 | *params = mCaps.maxTextureImageUnits; |
| 1331 | break; |
| 1332 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 1333 | *params = mCaps.maxFragmentUniformVectors; |
| 1334 | break; |
| 1335 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
| 1336 | *params = mCaps.maxFragmentUniformComponents; |
| 1337 | break; |
| 1338 | case GL_MAX_RENDERBUFFER_SIZE: |
| 1339 | *params = mCaps.maxRenderbufferSize; |
| 1340 | break; |
| 1341 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
| 1342 | *params = mCaps.maxColorAttachments; |
| 1343 | break; |
| 1344 | case GL_MAX_DRAW_BUFFERS_EXT: |
| 1345 | *params = mCaps.maxDrawBuffers; |
| 1346 | break; |
| 1347 | // case GL_FRAMEBUFFER_BINDING: // now equivalent to |
| 1348 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE |
| 1349 | case GL_SUBPIXEL_BITS: |
| 1350 | *params = 4; |
| 1351 | break; |
| 1352 | case GL_MAX_TEXTURE_SIZE: |
| 1353 | *params = mCaps.max2DTextureSize; |
| 1354 | break; |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1355 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
| 1356 | *params = mCaps.maxRectangleTextureSize; |
| 1357 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1358 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 1359 | *params = mCaps.maxCubeMapTextureSize; |
| 1360 | break; |
| 1361 | case GL_MAX_3D_TEXTURE_SIZE: |
| 1362 | *params = mCaps.max3DTextureSize; |
| 1363 | break; |
| 1364 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 1365 | *params = mCaps.maxArrayTextureLayers; |
| 1366 | break; |
| 1367 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 1368 | *params = mCaps.uniformBufferOffsetAlignment; |
| 1369 | break; |
| 1370 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 1371 | *params = mCaps.maxUniformBufferBindings; |
| 1372 | break; |
| 1373 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
| 1374 | *params = mCaps.maxVertexUniformBlocks; |
| 1375 | break; |
| 1376 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
| 1377 | *params = mCaps.maxFragmentUniformBlocks; |
| 1378 | break; |
| 1379 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 1380 | *params = mCaps.maxCombinedTextureImageUnits; |
| 1381 | break; |
| 1382 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 1383 | *params = mCaps.maxVertexOutputComponents; |
| 1384 | break; |
| 1385 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 1386 | *params = mCaps.maxFragmentInputComponents; |
| 1387 | break; |
| 1388 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 1389 | *params = mCaps.minProgramTexelOffset; |
| 1390 | break; |
| 1391 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 1392 | *params = mCaps.maxProgramTexelOffset; |
| 1393 | break; |
| 1394 | case GL_MAJOR_VERSION: |
| 1395 | *params = getClientVersion().major; |
| 1396 | break; |
| 1397 | case GL_MINOR_VERSION: |
| 1398 | *params = getClientVersion().minor; |
| 1399 | break; |
| 1400 | case GL_MAX_ELEMENTS_INDICES: |
| 1401 | *params = mCaps.maxElementsIndices; |
| 1402 | break; |
| 1403 | case GL_MAX_ELEMENTS_VERTICES: |
| 1404 | *params = mCaps.maxElementsVertices; |
| 1405 | break; |
| 1406 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 1407 | *params = mCaps.maxTransformFeedbackInterleavedComponents; |
| 1408 | break; |
| 1409 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 1410 | *params = mCaps.maxTransformFeedbackSeparateAttributes; |
| 1411 | break; |
| 1412 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 1413 | *params = mCaps.maxTransformFeedbackSeparateComponents; |
| 1414 | break; |
| 1415 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 1416 | *params = static_cast<GLint>(mCaps.compressedTextureFormats.size()); |
| 1417 | break; |
| 1418 | case GL_MAX_SAMPLES_ANGLE: |
| 1419 | *params = mCaps.maxSamples; |
| 1420 | break; |
| 1421 | case GL_MAX_VIEWPORT_DIMS: |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1422 | { |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1423 | params[0] = mCaps.maxViewportWidth; |
| 1424 | params[1] = mCaps.maxViewportHeight; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1425 | } |
| 1426 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1427 | case GL_COMPRESSED_TEXTURE_FORMATS: |
| 1428 | std::copy(mCaps.compressedTextureFormats.begin(), mCaps.compressedTextureFormats.end(), |
| 1429 | params); |
| 1430 | break; |
| 1431 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 1432 | *params = mResetStrategy; |
| 1433 | break; |
| 1434 | case GL_NUM_SHADER_BINARY_FORMATS: |
| 1435 | *params = static_cast<GLint>(mCaps.shaderBinaryFormats.size()); |
| 1436 | break; |
| 1437 | case GL_SHADER_BINARY_FORMATS: |
| 1438 | std::copy(mCaps.shaderBinaryFormats.begin(), mCaps.shaderBinaryFormats.end(), params); |
| 1439 | break; |
| 1440 | case GL_NUM_PROGRAM_BINARY_FORMATS: |
| 1441 | *params = static_cast<GLint>(mCaps.programBinaryFormats.size()); |
| 1442 | break; |
| 1443 | case GL_PROGRAM_BINARY_FORMATS: |
| 1444 | std::copy(mCaps.programBinaryFormats.begin(), mCaps.programBinaryFormats.end(), params); |
| 1445 | break; |
| 1446 | case GL_NUM_EXTENSIONS: |
| 1447 | *params = static_cast<GLint>(mExtensionStrings.size()); |
| 1448 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1449 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1450 | // GL_KHR_debug |
| 1451 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 1452 | *params = mExtensions.maxDebugMessageLength; |
| 1453 | break; |
| 1454 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 1455 | *params = mExtensions.maxDebugLoggedMessages; |
| 1456 | break; |
| 1457 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 1458 | *params = mExtensions.maxDebugGroupStackDepth; |
| 1459 | break; |
| 1460 | case GL_MAX_LABEL_LENGTH: |
| 1461 | *params = mExtensions.maxLabelLength; |
| 1462 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1463 | |
Martin Radev | e5285d2 | 2017-07-14 16:23:53 +0300 | [diff] [blame] | 1464 | // GL_ANGLE_multiview |
| 1465 | case GL_MAX_VIEWS_ANGLE: |
| 1466 | *params = mExtensions.maxViews; |
| 1467 | break; |
| 1468 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1469 | // GL_EXT_disjoint_timer_query |
| 1470 | case GL_GPU_DISJOINT_EXT: |
| 1471 | *params = mImplementation->getGPUDisjoint(); |
| 1472 | break; |
| 1473 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 1474 | *params = mCaps.maxFramebufferWidth; |
| 1475 | break; |
| 1476 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 1477 | *params = mCaps.maxFramebufferHeight; |
| 1478 | break; |
| 1479 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 1480 | *params = mCaps.maxFramebufferSamples; |
| 1481 | break; |
| 1482 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 1483 | *params = mCaps.maxSampleMaskWords; |
| 1484 | break; |
| 1485 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 1486 | *params = mCaps.maxColorTextureSamples; |
| 1487 | break; |
| 1488 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 1489 | *params = mCaps.maxDepthTextureSamples; |
| 1490 | break; |
| 1491 | case GL_MAX_INTEGER_SAMPLES: |
| 1492 | *params = mCaps.maxIntegerSamples; |
| 1493 | break; |
| 1494 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 1495 | *params = mCaps.maxVertexAttribRelativeOffset; |
| 1496 | break; |
| 1497 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 1498 | *params = mCaps.maxVertexAttribBindings; |
| 1499 | break; |
| 1500 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 1501 | *params = mCaps.maxVertexAttribStride; |
| 1502 | break; |
| 1503 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
| 1504 | *params = mCaps.maxVertexAtomicCounterBuffers; |
| 1505 | break; |
| 1506 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
| 1507 | *params = mCaps.maxVertexAtomicCounters; |
| 1508 | break; |
| 1509 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
| 1510 | *params = mCaps.maxVertexImageUniforms; |
| 1511 | break; |
| 1512 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
| 1513 | *params = mCaps.maxVertexShaderStorageBlocks; |
| 1514 | break; |
| 1515 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
| 1516 | *params = mCaps.maxFragmentAtomicCounterBuffers; |
| 1517 | break; |
| 1518 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
| 1519 | *params = mCaps.maxFragmentAtomicCounters; |
| 1520 | break; |
| 1521 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
| 1522 | *params = mCaps.maxFragmentImageUniforms; |
| 1523 | break; |
| 1524 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
| 1525 | *params = mCaps.maxFragmentShaderStorageBlocks; |
| 1526 | break; |
| 1527 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 1528 | *params = mCaps.minProgramTextureGatherOffset; |
| 1529 | break; |
| 1530 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 1531 | *params = mCaps.maxProgramTextureGatherOffset; |
| 1532 | break; |
| 1533 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 1534 | *params = mCaps.maxComputeWorkGroupInvocations; |
| 1535 | break; |
| 1536 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
| 1537 | *params = mCaps.maxComputeUniformBlocks; |
| 1538 | break; |
| 1539 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
| 1540 | *params = mCaps.maxComputeTextureImageUnits; |
| 1541 | break; |
| 1542 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 1543 | *params = mCaps.maxComputeSharedMemorySize; |
| 1544 | break; |
| 1545 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
| 1546 | *params = mCaps.maxComputeUniformComponents; |
| 1547 | break; |
| 1548 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
| 1549 | *params = mCaps.maxComputeAtomicCounterBuffers; |
| 1550 | break; |
| 1551 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
| 1552 | *params = mCaps.maxComputeAtomicCounters; |
| 1553 | break; |
| 1554 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
| 1555 | *params = mCaps.maxComputeImageUniforms; |
| 1556 | break; |
| 1557 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
| 1558 | *params = mCaps.maxCombinedComputeUniformComponents; |
| 1559 | break; |
| 1560 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
| 1561 | *params = mCaps.maxComputeShaderStorageBlocks; |
| 1562 | break; |
| 1563 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 1564 | *params = mCaps.maxCombinedShaderOutputResources; |
| 1565 | break; |
| 1566 | case GL_MAX_UNIFORM_LOCATIONS: |
| 1567 | *params = mCaps.maxUniformLocations; |
| 1568 | break; |
| 1569 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 1570 | *params = mCaps.maxAtomicCounterBufferBindings; |
| 1571 | break; |
| 1572 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 1573 | *params = mCaps.maxAtomicCounterBufferSize; |
| 1574 | break; |
| 1575 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 1576 | *params = mCaps.maxCombinedAtomicCounterBuffers; |
| 1577 | break; |
| 1578 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 1579 | *params = mCaps.maxCombinedAtomicCounters; |
| 1580 | break; |
| 1581 | case GL_MAX_IMAGE_UNITS: |
| 1582 | *params = mCaps.maxImageUnits; |
| 1583 | break; |
| 1584 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 1585 | *params = mCaps.maxCombinedImageUniforms; |
| 1586 | break; |
| 1587 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 1588 | *params = mCaps.maxShaderStorageBufferBindings; |
| 1589 | break; |
| 1590 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 1591 | *params = mCaps.maxCombinedShaderStorageBlocks; |
| 1592 | break; |
| 1593 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 1594 | *params = mCaps.shaderStorageBufferOffsetAlignment; |
| 1595 | break; |
| 1596 | default: |
| 1597 | mGLState.getIntegerv(this, pname, params); |
| 1598 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1599 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1600 | } |
| 1601 | |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 1602 | void Context::getInteger64v(GLenum pname, GLint64 *params) |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1603 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1604 | // Queries about context capabilities and maximums are answered by Context. |
| 1605 | // Queries about current GL state values are answered by State. |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1606 | switch (pname) |
| 1607 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1608 | case GL_MAX_ELEMENT_INDEX: |
| 1609 | *params = mCaps.maxElementIndex; |
| 1610 | break; |
| 1611 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 1612 | *params = mCaps.maxUniformBlockSize; |
| 1613 | break; |
| 1614 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
| 1615 | *params = mCaps.maxCombinedVertexUniformComponents; |
| 1616 | break; |
| 1617 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
| 1618 | *params = mCaps.maxCombinedFragmentUniformComponents; |
| 1619 | break; |
| 1620 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 1621 | *params = mCaps.maxServerWaitTimeout; |
| 1622 | break; |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 1623 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1624 | // GL_EXT_disjoint_timer_query |
| 1625 | case GL_TIMESTAMP_EXT: |
| 1626 | *params = mImplementation->getTimestamp(); |
| 1627 | break; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1628 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1629 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 1630 | *params = mCaps.maxShaderStorageBlockSize; |
| 1631 | break; |
| 1632 | default: |
| 1633 | UNREACHABLE(); |
| 1634 | break; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1635 | } |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1636 | } |
| 1637 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1638 | void Context::getPointerv(GLenum pname, void **params) const |
| 1639 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1640 | mGLState.getPointerv(pname, params); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1641 | } |
| 1642 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1643 | void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1644 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1645 | // Queries about context capabilities and maximums are answered by Context. |
| 1646 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1647 | |
| 1648 | GLenum nativeType; |
| 1649 | unsigned int numParams; |
| 1650 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1651 | ASSERT(queryStatus); |
| 1652 | |
| 1653 | if (nativeType == GL_INT) |
| 1654 | { |
| 1655 | switch (target) |
| 1656 | { |
| 1657 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 1658 | ASSERT(index < 3u); |
| 1659 | *data = mCaps.maxComputeWorkGroupCount[index]; |
| 1660 | break; |
| 1661 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 1662 | ASSERT(index < 3u); |
| 1663 | *data = mCaps.maxComputeWorkGroupSize[index]; |
| 1664 | break; |
| 1665 | default: |
| 1666 | mGLState.getIntegeri_v(target, index, data); |
| 1667 | } |
| 1668 | } |
| 1669 | else |
| 1670 | { |
| 1671 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1672 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1673 | } |
| 1674 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1675 | void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1676 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1677 | // Queries about context capabilities and maximums are answered by Context. |
| 1678 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1679 | |
| 1680 | GLenum nativeType; |
| 1681 | unsigned int numParams; |
| 1682 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1683 | ASSERT(queryStatus); |
| 1684 | |
| 1685 | if (nativeType == GL_INT_64_ANGLEX) |
| 1686 | { |
| 1687 | mGLState.getInteger64i_v(target, index, data); |
| 1688 | } |
| 1689 | else |
| 1690 | { |
| 1691 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1692 | } |
| 1693 | } |
| 1694 | |
| 1695 | void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data) |
| 1696 | { |
| 1697 | // Queries about context capabilities and maximums are answered by Context. |
| 1698 | // Queries about current GL state values are answered by State. |
| 1699 | |
| 1700 | GLenum nativeType; |
| 1701 | unsigned int numParams; |
| 1702 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1703 | ASSERT(queryStatus); |
| 1704 | |
| 1705 | if (nativeType == GL_BOOL) |
| 1706 | { |
| 1707 | mGLState.getBooleani_v(target, index, data); |
| 1708 | } |
| 1709 | else |
| 1710 | { |
| 1711 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1712 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1713 | } |
| 1714 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1715 | void Context::getBufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 1716 | { |
| 1717 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 1718 | QueryBufferParameteriv(buffer, pname, params); |
| 1719 | } |
| 1720 | |
| 1721 | void Context::getFramebufferAttachmentParameteriv(GLenum target, |
| 1722 | GLenum attachment, |
| 1723 | GLenum pname, |
| 1724 | GLint *params) |
| 1725 | { |
| 1726 | const Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 1727 | QueryFramebufferAttachmentParameteriv(framebuffer, attachment, pname, params); |
| 1728 | } |
| 1729 | |
| 1730 | void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 1731 | { |
| 1732 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
| 1733 | QueryRenderbufferiv(this, renderbuffer, pname, params); |
| 1734 | } |
| 1735 | |
| 1736 | void Context::getTexParameterfv(GLenum target, GLenum pname, GLfloat *params) |
| 1737 | { |
| 1738 | Texture *texture = getTargetTexture(target); |
| 1739 | QueryTexParameterfv(texture, pname, params); |
| 1740 | } |
| 1741 | |
| 1742 | void Context::getTexParameteriv(GLenum target, GLenum pname, GLint *params) |
| 1743 | { |
| 1744 | Texture *texture = getTargetTexture(target); |
| 1745 | QueryTexParameteriv(texture, pname, params); |
| 1746 | } |
| 1747 | void Context::texParameterf(GLenum target, GLenum pname, GLfloat param) |
| 1748 | { |
| 1749 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1750 | SetTexParameterf(this, texture, pname, param); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1751 | } |
| 1752 | |
| 1753 | void Context::texParameterfv(GLenum target, GLenum pname, const GLfloat *params) |
| 1754 | { |
| 1755 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1756 | SetTexParameterfv(this, texture, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1757 | } |
| 1758 | |
| 1759 | void Context::texParameteri(GLenum target, GLenum pname, GLint param) |
| 1760 | { |
| 1761 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1762 | SetTexParameteri(this, texture, pname, param); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1763 | } |
| 1764 | |
| 1765 | void Context::texParameteriv(GLenum target, GLenum pname, const GLint *params) |
| 1766 | { |
| 1767 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1768 | SetTexParameteriv(this, texture, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1769 | } |
| 1770 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 1771 | void Context::drawArrays(GLenum mode, GLint first, GLsizei count) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1772 | { |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 1773 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 1774 | ANGLE_CONTEXT_TRY(mImplementation->drawArrays(this, mode, first, count)); |
| 1775 | MarkTransformFeedbackBufferUsage(mGLState.getCurrentTransformFeedback()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1776 | } |
| 1777 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 1778 | void Context::drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1779 | { |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 1780 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 1781 | ANGLE_CONTEXT_TRY( |
| 1782 | mImplementation->drawArraysInstanced(this, mode, first, count, instanceCount)); |
| 1783 | MarkTransformFeedbackBufferUsage(mGLState.getCurrentTransformFeedback()); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1784 | } |
| 1785 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1786 | void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1787 | { |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 1788 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 1789 | ANGLE_CONTEXT_TRY(mImplementation->drawElements(this, mode, count, type, indices)); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1790 | } |
| 1791 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 1792 | void Context::drawElementsInstanced(GLenum mode, |
| 1793 | GLsizei count, |
| 1794 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1795 | const void *indices, |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 1796 | GLsizei instances) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1797 | { |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 1798 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 1799 | ANGLE_CONTEXT_TRY( |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 1800 | mImplementation->drawElementsInstanced(this, mode, count, type, indices, instances)); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1801 | } |
| 1802 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 1803 | void Context::drawRangeElements(GLenum mode, |
| 1804 | GLuint start, |
| 1805 | GLuint end, |
| 1806 | GLsizei count, |
| 1807 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1808 | const void *indices) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 1809 | { |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 1810 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 1811 | ANGLE_CONTEXT_TRY( |
| 1812 | mImplementation->drawRangeElements(this, mode, start, end, count, type, indices)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1813 | } |
| 1814 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1815 | void Context::drawArraysIndirect(GLenum mode, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 1816 | { |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 1817 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 1818 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysIndirect(this, mode, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 1819 | } |
| 1820 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 1821 | void Context::drawElementsIndirect(GLenum mode, GLenum type, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 1822 | { |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 1823 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 1824 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsIndirect(this, mode, type, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 1825 | } |
| 1826 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 1827 | void Context::flush() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1828 | { |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 1829 | handleError(mImplementation->flush()); |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 1830 | } |
| 1831 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 1832 | void Context::finish() |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 1833 | { |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 1834 | handleError(mImplementation->finish()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1835 | } |
| 1836 | |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 1837 | void Context::insertEventMarker(GLsizei length, const char *marker) |
| 1838 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1839 | ASSERT(mImplementation); |
| 1840 | mImplementation->insertEventMarker(length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 1841 | } |
| 1842 | |
| 1843 | void Context::pushGroupMarker(GLsizei length, const char *marker) |
| 1844 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1845 | ASSERT(mImplementation); |
| 1846 | mImplementation->pushGroupMarker(length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 1847 | } |
| 1848 | |
| 1849 | void Context::popGroupMarker() |
| 1850 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 1851 | ASSERT(mImplementation); |
| 1852 | mImplementation->popGroupMarker(); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 1853 | } |
| 1854 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 1855 | void Context::bindUniformLocation(GLuint program, GLint location, const GLchar *name) |
| 1856 | { |
| 1857 | Program *programObject = getProgram(program); |
| 1858 | ASSERT(programObject); |
| 1859 | |
| 1860 | programObject->bindUniformLocation(location, name); |
| 1861 | } |
| 1862 | |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 1863 | void Context::setCoverageModulation(GLenum components) |
| 1864 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1865 | mGLState.setCoverageModulation(components); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 1866 | } |
| 1867 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1868 | void Context::loadPathRenderingMatrix(GLenum matrixMode, const GLfloat *matrix) |
| 1869 | { |
| 1870 | mGLState.loadPathRenderingMatrix(matrixMode, matrix); |
| 1871 | } |
| 1872 | |
| 1873 | void Context::loadPathRenderingIdentityMatrix(GLenum matrixMode) |
| 1874 | { |
| 1875 | GLfloat I[16]; |
| 1876 | angle::Matrix<GLfloat>::setToIdentity(I); |
| 1877 | |
| 1878 | mGLState.loadPathRenderingMatrix(matrixMode, I); |
| 1879 | } |
| 1880 | |
| 1881 | void Context::stencilFillPath(GLuint path, GLenum fillMode, GLuint mask) |
| 1882 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1883 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1884 | if (!pathObj) |
| 1885 | return; |
| 1886 | |
| 1887 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1888 | syncRendererState(); |
| 1889 | |
| 1890 | mImplementation->stencilFillPath(pathObj, fillMode, mask); |
| 1891 | } |
| 1892 | |
| 1893 | void Context::stencilStrokePath(GLuint path, GLint reference, GLuint mask) |
| 1894 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1895 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1896 | if (!pathObj) |
| 1897 | return; |
| 1898 | |
| 1899 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1900 | syncRendererState(); |
| 1901 | |
| 1902 | mImplementation->stencilStrokePath(pathObj, reference, mask); |
| 1903 | } |
| 1904 | |
| 1905 | void Context::coverFillPath(GLuint path, GLenum coverMode) |
| 1906 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1907 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1908 | if (!pathObj) |
| 1909 | return; |
| 1910 | |
| 1911 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1912 | syncRendererState(); |
| 1913 | |
| 1914 | mImplementation->coverFillPath(pathObj, coverMode); |
| 1915 | } |
| 1916 | |
| 1917 | void Context::coverStrokePath(GLuint path, GLenum coverMode) |
| 1918 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1919 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1920 | if (!pathObj) |
| 1921 | return; |
| 1922 | |
| 1923 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1924 | syncRendererState(); |
| 1925 | |
| 1926 | mImplementation->coverStrokePath(pathObj, coverMode); |
| 1927 | } |
| 1928 | |
| 1929 | void Context::stencilThenCoverFillPath(GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode) |
| 1930 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1931 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1932 | if (!pathObj) |
| 1933 | return; |
| 1934 | |
| 1935 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1936 | syncRendererState(); |
| 1937 | |
| 1938 | mImplementation->stencilThenCoverFillPath(pathObj, fillMode, mask, coverMode); |
| 1939 | } |
| 1940 | |
| 1941 | void Context::stencilThenCoverStrokePath(GLuint path, |
| 1942 | GLint reference, |
| 1943 | GLuint mask, |
| 1944 | GLenum coverMode) |
| 1945 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1946 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1947 | if (!pathObj) |
| 1948 | return; |
| 1949 | |
| 1950 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1951 | syncRendererState(); |
| 1952 | |
| 1953 | mImplementation->stencilThenCoverStrokePath(pathObj, reference, mask, coverMode); |
| 1954 | } |
| 1955 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1956 | void Context::coverFillPathInstanced(GLsizei numPaths, |
| 1957 | GLenum pathNameType, |
| 1958 | const void *paths, |
| 1959 | GLuint pathBase, |
| 1960 | GLenum coverMode, |
| 1961 | GLenum transformType, |
| 1962 | const GLfloat *transformValues) |
| 1963 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1964 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1965 | |
| 1966 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1967 | syncRendererState(); |
| 1968 | |
| 1969 | mImplementation->coverFillPathInstanced(pathObjects, coverMode, transformType, transformValues); |
| 1970 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 1971 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1972 | void Context::coverStrokePathInstanced(GLsizei numPaths, |
| 1973 | GLenum pathNameType, |
| 1974 | const void *paths, |
| 1975 | GLuint pathBase, |
| 1976 | GLenum coverMode, |
| 1977 | GLenum transformType, |
| 1978 | const GLfloat *transformValues) |
| 1979 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1980 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1981 | |
| 1982 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 1983 | syncRendererState(); |
| 1984 | |
| 1985 | mImplementation->coverStrokePathInstanced(pathObjects, coverMode, transformType, |
| 1986 | transformValues); |
| 1987 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 1988 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1989 | void Context::stencilFillPathInstanced(GLsizei numPaths, |
| 1990 | GLenum pathNameType, |
| 1991 | const void *paths, |
| 1992 | GLuint pathBase, |
| 1993 | GLenum fillMode, |
| 1994 | GLuint mask, |
| 1995 | GLenum transformType, |
| 1996 | const GLfloat *transformValues) |
| 1997 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1998 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 1999 | |
| 2000 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 2001 | syncRendererState(); |
| 2002 | |
| 2003 | mImplementation->stencilFillPathInstanced(pathObjects, fillMode, mask, transformType, |
| 2004 | transformValues); |
| 2005 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2006 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2007 | void Context::stencilStrokePathInstanced(GLsizei numPaths, |
| 2008 | GLenum pathNameType, |
| 2009 | const void *paths, |
| 2010 | GLuint pathBase, |
| 2011 | GLint reference, |
| 2012 | GLuint mask, |
| 2013 | GLenum transformType, |
| 2014 | const GLfloat *transformValues) |
| 2015 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2016 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2017 | |
| 2018 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 2019 | syncRendererState(); |
| 2020 | |
| 2021 | mImplementation->stencilStrokePathInstanced(pathObjects, reference, mask, transformType, |
| 2022 | transformValues); |
| 2023 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2024 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2025 | void Context::stencilThenCoverFillPathInstanced(GLsizei numPaths, |
| 2026 | GLenum pathNameType, |
| 2027 | const void *paths, |
| 2028 | GLuint pathBase, |
| 2029 | GLenum fillMode, |
| 2030 | GLuint mask, |
| 2031 | GLenum coverMode, |
| 2032 | GLenum transformType, |
| 2033 | const GLfloat *transformValues) |
| 2034 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2035 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2036 | |
| 2037 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 2038 | syncRendererState(); |
| 2039 | |
| 2040 | mImplementation->stencilThenCoverFillPathInstanced(pathObjects, coverMode, fillMode, mask, |
| 2041 | transformType, transformValues); |
| 2042 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2043 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2044 | void Context::stencilThenCoverStrokePathInstanced(GLsizei numPaths, |
| 2045 | GLenum pathNameType, |
| 2046 | const void *paths, |
| 2047 | GLuint pathBase, |
| 2048 | GLint reference, |
| 2049 | GLuint mask, |
| 2050 | GLenum coverMode, |
| 2051 | GLenum transformType, |
| 2052 | const GLfloat *transformValues) |
| 2053 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2054 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2055 | |
| 2056 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 2057 | syncRendererState(); |
| 2058 | |
| 2059 | mImplementation->stencilThenCoverStrokePathInstanced(pathObjects, coverMode, reference, mask, |
| 2060 | transformType, transformValues); |
| 2061 | } |
| 2062 | |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2063 | void Context::bindFragmentInputLocation(GLuint program, GLint location, const GLchar *name) |
| 2064 | { |
| 2065 | auto *programObject = getProgram(program); |
| 2066 | |
| 2067 | programObject->bindFragmentInputLocation(location, name); |
| 2068 | } |
| 2069 | |
| 2070 | void Context::programPathFragmentInputGen(GLuint program, |
| 2071 | GLint location, |
| 2072 | GLenum genMode, |
| 2073 | GLint components, |
| 2074 | const GLfloat *coeffs) |
| 2075 | { |
| 2076 | auto *programObject = getProgram(program); |
| 2077 | |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 2078 | programObject->pathFragmentInputGen(this, location, genMode, components, coeffs); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2079 | } |
| 2080 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2081 | GLuint Context::getProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar *name) |
| 2082 | { |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2083 | const auto *programObject = getProgram(program); |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2084 | return QueryProgramResourceIndex(programObject, programInterface, name); |
| 2085 | } |
| 2086 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2087 | void Context::getProgramResourceName(GLuint program, |
| 2088 | GLenum programInterface, |
| 2089 | GLuint index, |
| 2090 | GLsizei bufSize, |
| 2091 | GLsizei *length, |
| 2092 | GLchar *name) |
| 2093 | { |
| 2094 | const auto *programObject = getProgram(program); |
| 2095 | QueryProgramResourceName(programObject, programInterface, index, bufSize, length, name); |
| 2096 | } |
| 2097 | |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2098 | GLint Context::getProgramResourceLocation(GLuint program, |
| 2099 | GLenum programInterface, |
| 2100 | const GLchar *name) |
| 2101 | { |
| 2102 | const auto *programObject = getProgram(program); |
| 2103 | return QueryProgramResourceLocation(programObject, programInterface, name); |
| 2104 | } |
| 2105 | |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2106 | void Context::getProgramResourceiv(GLuint program, |
| 2107 | GLenum programInterface, |
| 2108 | GLuint index, |
| 2109 | GLsizei propCount, |
| 2110 | const GLenum *props, |
| 2111 | GLsizei bufSize, |
| 2112 | GLsizei *length, |
| 2113 | GLint *params) |
| 2114 | { |
| 2115 | const auto *programObject = getProgram(program); |
| 2116 | QueryProgramResourceiv(programObject, programInterface, index, propCount, props, bufSize, |
| 2117 | length, params); |
| 2118 | } |
| 2119 | |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 2120 | Error Context::handleError(const Error &error) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2121 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2122 | if (error.isError()) |
| 2123 | { |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2124 | GLenum code = error.getCode(); |
| 2125 | mErrors.insert(code); |
| 2126 | if (code == GL_OUT_OF_MEMORY && getWorkarounds().loseContextOnOutOfMemory) |
| 2127 | { |
| 2128 | markContextLost(); |
| 2129 | } |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2130 | |
| 2131 | if (!error.getMessage().empty()) |
| 2132 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2133 | auto *debug = &mGLState.getDebug(); |
| 2134 | debug->insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, error.getID(), |
| 2135 | GL_DEBUG_SEVERITY_HIGH, error.getMessage()); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2136 | } |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2137 | } |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 2138 | |
| 2139 | return error; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2140 | } |
| 2141 | |
| 2142 | // Get one of the recorded errors and clear its flag, if any. |
| 2143 | // [OpenGL ES 2.0.24] section 2.5 page 13. |
| 2144 | GLenum Context::getError() |
| 2145 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2146 | if (mErrors.empty()) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2147 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2148 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2149 | } |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2150 | else |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2151 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2152 | GLenum error = *mErrors.begin(); |
| 2153 | mErrors.erase(mErrors.begin()); |
| 2154 | return error; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2155 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2156 | } |
| 2157 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2158 | // NOTE: this function should not assume that this context is current! |
| 2159 | void Context::markContextLost() |
| 2160 | { |
| 2161 | if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT) |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2162 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2163 | mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT; |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2164 | mContextLostForced = true; |
| 2165 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2166 | mContextLost = true; |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2167 | } |
| 2168 | |
| 2169 | bool Context::isContextLost() |
| 2170 | { |
| 2171 | return mContextLost; |
| 2172 | } |
| 2173 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2174 | GLenum Context::getResetStatus() |
| 2175 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2176 | // Even if the application doesn't want to know about resets, we want to know |
| 2177 | // as it will allow us to skip all the calls. |
| 2178 | if (mResetStrategy == GL_NO_RESET_NOTIFICATION_EXT) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2179 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2180 | if (!mContextLost && mImplementation->getResetStatus() != GL_NO_ERROR) |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2181 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2182 | mContextLost = true; |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2183 | } |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2184 | |
| 2185 | // EXT_robustness, section 2.6: If the reset notification behavior is |
| 2186 | // NO_RESET_NOTIFICATION_EXT, then the implementation will never deliver notification of |
| 2187 | // reset events, and GetGraphicsResetStatusEXT will always return NO_ERROR. |
| 2188 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2189 | } |
| 2190 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2191 | // The GL_EXT_robustness spec says that if a reset is encountered, a reset |
| 2192 | // status should be returned at least once, and GL_NO_ERROR should be returned |
| 2193 | // once the device has finished resetting. |
| 2194 | if (!mContextLost) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2195 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2196 | ASSERT(mResetStatus == GL_NO_ERROR); |
| 2197 | mResetStatus = mImplementation->getResetStatus(); |
shannon.woods@transgaming.com | ddd6c80 | 2013-02-28 23:05:14 +0000 | [diff] [blame] | 2198 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2199 | if (mResetStatus != GL_NO_ERROR) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2200 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2201 | mContextLost = true; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2202 | } |
| 2203 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2204 | else if (!mContextLostForced && mResetStatus != GL_NO_ERROR) |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2205 | { |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2206 | // If markContextLost was used to mark the context lost then |
| 2207 | // assume that is not recoverable, and continue to report the |
| 2208 | // lost reset status for the lifetime of this context. |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2209 | mResetStatus = mImplementation->getResetStatus(); |
| 2210 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 2211 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2212 | return mResetStatus; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2213 | } |
| 2214 | |
| 2215 | bool Context::isResetNotificationEnabled() |
| 2216 | { |
| 2217 | return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
| 2218 | } |
| 2219 | |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2220 | const egl::Config *Context::getConfig() const |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2221 | { |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2222 | return mConfig; |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2223 | } |
| 2224 | |
| 2225 | EGLenum Context::getClientType() const |
| 2226 | { |
| 2227 | return mClientType; |
| 2228 | } |
| 2229 | |
| 2230 | EGLenum Context::getRenderBuffer() const |
| 2231 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2232 | const Framebuffer *framebuffer = mState.mFramebuffers->getFramebuffer(0); |
| 2233 | if (framebuffer == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 2234 | { |
| 2235 | return EGL_NONE; |
| 2236 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2237 | |
| 2238 | const FramebufferAttachment *backAttachment = framebuffer->getAttachment(GL_BACK); |
| 2239 | ASSERT(backAttachment != nullptr); |
| 2240 | return backAttachment->getSurface()->getRenderBuffer(); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2241 | } |
| 2242 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2243 | VertexArray *Context::checkVertexArrayAllocation(GLuint vertexArrayHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2244 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2245 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2246 | VertexArray *vertexArray = getVertexArray(vertexArrayHandle); |
| 2247 | if (!vertexArray) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2248 | { |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 2249 | vertexArray = new VertexArray(mImplementation.get(), vertexArrayHandle, |
| 2250 | mCaps.maxVertexAttributes, mCaps.maxVertexAttribBindings); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2251 | |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2252 | mVertexArrayMap.assign(vertexArrayHandle, vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2253 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2254 | |
| 2255 | return vertexArray; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2256 | } |
| 2257 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2258 | TransformFeedback *Context::checkTransformFeedbackAllocation(GLuint transformFeedbackHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2259 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2260 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2261 | TransformFeedback *transformFeedback = getTransformFeedback(transformFeedbackHandle); |
| 2262 | if (!transformFeedback) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2263 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2264 | transformFeedback = |
| 2265 | new TransformFeedback(mImplementation.get(), transformFeedbackHandle, mCaps); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2266 | transformFeedback->addRef(); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2267 | mTransformFeedbackMap.assign(transformFeedbackHandle, transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2268 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2269 | |
| 2270 | return transformFeedback; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2271 | } |
| 2272 | |
| 2273 | bool Context::isVertexArrayGenerated(GLuint vertexArray) |
| 2274 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2275 | ASSERT(mVertexArrayMap.contains(0)); |
| 2276 | return mVertexArrayMap.contains(vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2277 | } |
| 2278 | |
| 2279 | bool Context::isTransformFeedbackGenerated(GLuint transformFeedback) |
| 2280 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2281 | ASSERT(mTransformFeedbackMap.contains(0)); |
| 2282 | return mTransformFeedbackMap.contains(transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2283 | } |
| 2284 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2285 | void Context::detachTexture(GLuint texture) |
| 2286 | { |
| 2287 | // Simple pass-through to State's detachTexture method, as textures do not require |
| 2288 | // allocation map management either here or in the resource manager at detach time. |
| 2289 | // Zero textures are held by the Context, and we don't attempt to request them from |
| 2290 | // the State. |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 2291 | mGLState.detachTexture(this, mZeroTextures, texture); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2292 | } |
| 2293 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2294 | void Context::detachBuffer(GLuint buffer) |
| 2295 | { |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2296 | // Simple pass-through to State's detachBuffer method, since |
| 2297 | // only buffer attachments to container objects that are bound to the current context |
| 2298 | // should be detached. And all those are available in State. |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2299 | |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2300 | // [OpenGL ES 3.2] section 5.1.2 page 45: |
| 2301 | // Attachments to unbound container objects, such as |
| 2302 | // deletion of a buffer attached to a vertex array object which is not bound to the context, |
| 2303 | // are not affected and continue to act as references on the deleted object |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2304 | mGLState.detachBuffer(this, buffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2305 | } |
| 2306 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2307 | void Context::detachFramebuffer(GLuint framebuffer) |
| 2308 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2309 | // Framebuffer detachment is handled by Context, because 0 is a valid |
| 2310 | // Framebuffer object, and a pointer to it must be passed from Context |
| 2311 | // to State at binding time. |
| 2312 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2313 | // [OpenGL ES 2.0.24] section 4.4 page 107: |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2314 | // If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as |
| 2315 | // though BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of |
| 2316 | // zero. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2317 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2318 | if (mGLState.removeReadFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2319 | { |
| 2320 | bindReadFramebuffer(0); |
| 2321 | } |
| 2322 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2323 | if (mGLState.removeDrawFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2324 | { |
| 2325 | bindDrawFramebuffer(0); |
| 2326 | } |
| 2327 | } |
| 2328 | |
| 2329 | void Context::detachRenderbuffer(GLuint renderbuffer) |
| 2330 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 2331 | mGLState.detachRenderbuffer(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2332 | } |
| 2333 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2334 | void Context::detachVertexArray(GLuint vertexArray) |
| 2335 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 2336 | // Vertex array detachment is handled by Context, because 0 is a valid |
| 2337 | // 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] | 2338 | // binding time. |
| 2339 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2340 | // [OpenGL ES 3.0.2] section 2.10 page 43: |
| 2341 | // If a vertex array object that is currently bound is deleted, the binding |
| 2342 | // 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] | 2343 | if (mGLState.removeVertexArrayBinding(vertexArray)) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2344 | { |
| 2345 | bindVertexArray(0); |
| 2346 | } |
| 2347 | } |
| 2348 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2349 | void Context::detachTransformFeedback(GLuint transformFeedback) |
| 2350 | { |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2351 | // Transform feedback detachment is handled by Context, because 0 is a valid |
| 2352 | // transform feedback, and a pointer to it must be passed from Context to State at |
| 2353 | // binding time. |
| 2354 | |
| 2355 | // The OpenGL specification doesn't mention what should happen when the currently bound |
| 2356 | // transform feedback object is deleted. Since it is a container object, we treat it like |
| 2357 | // VAOs and FBOs and set the current bound transform feedback back to 0. |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2358 | if (mGLState.removeTransformFeedbackBinding(this, transformFeedback)) |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2359 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 2360 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2361 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2362 | } |
| 2363 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2364 | void Context::detachSampler(GLuint sampler) |
| 2365 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2366 | mGLState.detachSampler(this, sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2367 | } |
| 2368 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2369 | void Context::setVertexAttribDivisor(GLuint index, GLuint divisor) |
| 2370 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 2371 | mGLState.setVertexAttribDivisor(this, index, divisor); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2372 | } |
| 2373 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2374 | void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 2375 | { |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2376 | Sampler *samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2377 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2378 | SetSamplerParameteri(samplerObject, pname, param); |
| 2379 | } |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2380 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2381 | void Context::samplerParameteriv(GLuint sampler, GLenum pname, const GLint *param) |
| 2382 | { |
| 2383 | Sampler *samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2384 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2385 | SetSamplerParameteriv(samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2386 | } |
| 2387 | |
| 2388 | void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 2389 | { |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2390 | Sampler *samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2391 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2392 | SetSamplerParameterf(samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2393 | } |
| 2394 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2395 | void Context::samplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2396 | { |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2397 | Sampler *samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2398 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2399 | SetSamplerParameterfv(samplerObject, pname, param); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2400 | } |
| 2401 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2402 | void Context::getSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2403 | { |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2404 | const Sampler *samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2405 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2406 | QuerySamplerParameteriv(samplerObject, pname, params); |
| 2407 | } |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2408 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2409 | void Context::getSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) |
| 2410 | { |
| 2411 | const Sampler *samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2412 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2413 | QuerySamplerParameterfv(samplerObject, pname, params); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2414 | } |
| 2415 | |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2416 | void Context::programParameteri(GLuint program, GLenum pname, GLint value) |
| 2417 | { |
| 2418 | gl::Program *programObject = getProgram(program); |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 2419 | SetProgramParameteri(programObject, pname, value); |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2420 | } |
| 2421 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2422 | void Context::initRendererString() |
| 2423 | { |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2424 | std::ostringstream rendererString; |
| 2425 | rendererString << "ANGLE ("; |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2426 | rendererString << mImplementation->getRendererDescription(); |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2427 | rendererString << ")"; |
| 2428 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2429 | mRendererString = MakeStaticString(rendererString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2430 | } |
| 2431 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2432 | void Context::initVersionStrings() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2433 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2434 | const Version &clientVersion = getClientVersion(); |
| 2435 | |
| 2436 | std::ostringstream versionString; |
| 2437 | versionString << "OpenGL ES " << clientVersion.major << "." << clientVersion.minor << " (ANGLE " |
| 2438 | << ANGLE_VERSION_STRING << ")"; |
| 2439 | mVersionString = MakeStaticString(versionString.str()); |
| 2440 | |
| 2441 | std::ostringstream shadingLanguageVersionString; |
| 2442 | shadingLanguageVersionString << "OpenGL ES GLSL ES " |
| 2443 | << (clientVersion.major == 2 ? 1 : clientVersion.major) << "." |
| 2444 | << clientVersion.minor << "0 (ANGLE " << ANGLE_VERSION_STRING |
| 2445 | << ")"; |
| 2446 | mShadingLanguageString = MakeStaticString(shadingLanguageVersionString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2447 | } |
| 2448 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2449 | void Context::initExtensionStrings() |
| 2450 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2451 | auto mergeExtensionStrings = [](const std::vector<const char *> &strings) { |
| 2452 | std::ostringstream combinedStringStream; |
| 2453 | std::copy(strings.begin(), strings.end(), |
| 2454 | std::ostream_iterator<const char *>(combinedStringStream, " ")); |
| 2455 | return MakeStaticString(combinedStringStream.str()); |
| 2456 | }; |
| 2457 | |
| 2458 | mExtensionStrings.clear(); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 2459 | for (const auto &extensionString : mExtensions.getStrings()) |
| 2460 | { |
| 2461 | mExtensionStrings.push_back(MakeStaticString(extensionString)); |
| 2462 | } |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2463 | mExtensionString = mergeExtensionStrings(mExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2464 | |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 2465 | const gl::Extensions &nativeExtensions = mImplementation->getNativeExtensions(); |
| 2466 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2467 | mRequestableExtensionStrings.clear(); |
| 2468 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 2469 | { |
| 2470 | if (extensionInfo.second.Requestable && |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 2471 | !(mExtensions.*(extensionInfo.second.ExtensionsMember)) && |
| 2472 | nativeExtensions.*(extensionInfo.second.ExtensionsMember)) |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2473 | { |
| 2474 | mRequestableExtensionStrings.push_back(MakeStaticString(extensionInfo.first)); |
| 2475 | } |
| 2476 | } |
| 2477 | mRequestableExtensionString = mergeExtensionStrings(mRequestableExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2478 | } |
| 2479 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2480 | const GLubyte *Context::getString(GLenum name) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2481 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2482 | switch (name) |
| 2483 | { |
| 2484 | case GL_VENDOR: |
| 2485 | return reinterpret_cast<const GLubyte *>("Google Inc."); |
| 2486 | |
| 2487 | case GL_RENDERER: |
| 2488 | return reinterpret_cast<const GLubyte *>(mRendererString); |
| 2489 | |
| 2490 | case GL_VERSION: |
| 2491 | return reinterpret_cast<const GLubyte *>(mVersionString); |
| 2492 | |
| 2493 | case GL_SHADING_LANGUAGE_VERSION: |
| 2494 | return reinterpret_cast<const GLubyte *>(mShadingLanguageString); |
| 2495 | |
| 2496 | case GL_EXTENSIONS: |
| 2497 | return reinterpret_cast<const GLubyte *>(mExtensionString); |
| 2498 | |
| 2499 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 2500 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionString); |
| 2501 | |
| 2502 | default: |
| 2503 | UNREACHABLE(); |
| 2504 | return nullptr; |
| 2505 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2506 | } |
| 2507 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2508 | const GLubyte *Context::getStringi(GLenum name, GLuint index) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2509 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2510 | switch (name) |
| 2511 | { |
| 2512 | case GL_EXTENSIONS: |
| 2513 | return reinterpret_cast<const GLubyte *>(mExtensionStrings[index]); |
| 2514 | |
| 2515 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 2516 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionStrings[index]); |
| 2517 | |
| 2518 | default: |
| 2519 | UNREACHABLE(); |
| 2520 | return nullptr; |
| 2521 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2522 | } |
| 2523 | |
| 2524 | size_t Context::getExtensionStringCount() const |
| 2525 | { |
| 2526 | return mExtensionStrings.size(); |
| 2527 | } |
| 2528 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2529 | void Context::requestExtension(const char *name) |
| 2530 | { |
| 2531 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 2532 | ASSERT(extensionInfos.find(name) != extensionInfos.end()); |
| 2533 | const auto &extension = extensionInfos.at(name); |
| 2534 | ASSERT(extension.Requestable); |
| 2535 | |
| 2536 | if (mExtensions.*(extension.ExtensionsMember)) |
| 2537 | { |
| 2538 | // Extension already enabled |
| 2539 | return; |
| 2540 | } |
| 2541 | |
| 2542 | mExtensions.*(extension.ExtensionsMember) = true; |
| 2543 | updateCaps(); |
| 2544 | initExtensionStrings(); |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 2545 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 2546 | // Release the shader compiler so it will be re-created with the requested extensions enabled. |
| 2547 | releaseShaderCompiler(); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 2548 | |
| 2549 | // Invalidate all cached completenesses for textures and framebuffer. Some extensions make new |
| 2550 | // formats renderable or sampleable. |
| 2551 | mState.mTextures->invalidateTextureComplenessCache(); |
| 2552 | for (auto &zeroTexture : mZeroTextures) |
| 2553 | { |
| 2554 | zeroTexture.second->invalidateCompletenessCache(); |
| 2555 | } |
| 2556 | |
| 2557 | mState.mFramebuffers->invalidateFramebufferComplenessCache(); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2558 | } |
| 2559 | |
| 2560 | size_t Context::getRequestableExtensionStringCount() const |
| 2561 | { |
| 2562 | return mRequestableExtensionStrings.size(); |
| 2563 | } |
| 2564 | |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2565 | void Context::beginTransformFeedback(GLenum primitiveMode) |
| 2566 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2567 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2568 | ASSERT(transformFeedback != nullptr); |
| 2569 | ASSERT(!transformFeedback->isPaused()); |
| 2570 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 2571 | transformFeedback->begin(this, primitiveMode, mGLState.getProgram()); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 2572 | } |
| 2573 | |
| 2574 | bool Context::hasActiveTransformFeedback(GLuint program) const |
| 2575 | { |
| 2576 | for (auto pair : mTransformFeedbackMap) |
| 2577 | { |
| 2578 | if (pair.second != nullptr && pair.second->hasBoundProgram(program)) |
| 2579 | { |
| 2580 | return true; |
| 2581 | } |
| 2582 | } |
| 2583 | return false; |
| 2584 | } |
| 2585 | |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 2586 | void Context::initCaps(const egl::DisplayExtensions &displayExtensions) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2587 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2588 | mCaps = mImplementation->getNativeCaps(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2589 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2590 | mExtensions = mImplementation->getNativeExtensions(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2591 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2592 | mLimitations = mImplementation->getNativeLimitations(); |
Austin Kinross | 02df796 | 2015-07-01 10:03:42 -0700 | [diff] [blame] | 2593 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 2594 | if (getClientVersion() < Version(3, 0)) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2595 | { |
| 2596 | // Disable ES3+ extensions |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2597 | mExtensions.colorBufferFloat = false; |
Geoff Lang | b66a909 | 2016-05-16 15:59:14 -0400 | [diff] [blame] | 2598 | mExtensions.eglImageExternalEssl3 = false; |
Vincent Lang | 25ab451 | 2016-05-13 18:13:59 +0200 | [diff] [blame] | 2599 | mExtensions.textureNorm16 = false; |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 2600 | mExtensions.multiview = false; |
| 2601 | mExtensions.maxViews = 1u; |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2602 | } |
| 2603 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 2604 | if (getClientVersion() > Version(2, 0)) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2605 | { |
| 2606 | // FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2607 | // mExtensions.sRGB = false; |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2608 | } |
| 2609 | |
Jamie Madill | 00ed7a1 | 2016-05-19 13:13:38 -0400 | [diff] [blame] | 2610 | // Some extensions are always available because they are implemented in the GL layer. |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2611 | mExtensions.bindUniformLocation = true; |
| 2612 | mExtensions.vertexArrayObject = true; |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 2613 | mExtensions.bindGeneratesResource = true; |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 2614 | mExtensions.clientArrays = true; |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2615 | mExtensions.requestExtension = true; |
Jamie Madill | 00ed7a1 | 2016-05-19 13:13:38 -0400 | [diff] [blame] | 2616 | |
| 2617 | // Enable the no error extension if the context was created with the flag. |
| 2618 | mExtensions.noError = mSkipValidation; |
| 2619 | |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 2620 | // Enable surfaceless to advertise we'll have the correct behavior when there is no default FBO |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 2621 | mExtensions.surfacelessContext = displayExtensions.surfacelessContext; |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 2622 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2623 | // Explicitly enable GL_KHR_debug |
| 2624 | mExtensions.debug = true; |
| 2625 | mExtensions.maxDebugMessageLength = 1024; |
| 2626 | mExtensions.maxDebugLoggedMessages = 1024; |
| 2627 | mExtensions.maxDebugGroupStackDepth = 1024; |
| 2628 | mExtensions.maxLabelLength = 1024; |
| 2629 | |
Geoff Lang | ff5b2d5 | 2016-09-07 11:32:23 -0400 | [diff] [blame] | 2630 | // Explicitly enable GL_ANGLE_robust_client_memory |
| 2631 | mExtensions.robustClientMemory = true; |
| 2632 | |
Jamie Madill | e08a1d3 | 2017-03-07 17:24:06 -0500 | [diff] [blame] | 2633 | // Determine robust resource init availability from EGL. |
| 2634 | mExtensions.robustResourceInitialization = |
Jamie Madill | 948bbe5 | 2017-06-01 13:10:42 -0400 | [diff] [blame] | 2635 | egl::Display::GetClientExtensions().displayRobustResourceInitialization; |
Jamie Madill | e08a1d3 | 2017-03-07 17:24:06 -0500 | [diff] [blame] | 2636 | |
Jamie Madill | c43be72 | 2017-07-13 16:22:14 -0400 | [diff] [blame] | 2637 | // Enable the cache control query unconditionally. |
| 2638 | mExtensions.programCacheControl = true; |
| 2639 | |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 2640 | // Apply implementation limits |
| 2641 | mCaps.maxVertexAttributes = std::min<GLuint>(mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 2642 | mCaps.maxVertexAttribBindings = |
| 2643 | getClientVersion() < ES_3_1 |
| 2644 | ? mCaps.maxVertexAttributes |
| 2645 | : std::min<GLuint>(mCaps.maxVertexAttribBindings, MAX_VERTEX_ATTRIB_BINDINGS); |
| 2646 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2647 | mCaps.maxVertexUniformBlocks = std::min<GLuint>( |
| 2648 | mCaps.maxVertexUniformBlocks, IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS); |
| 2649 | mCaps.maxVertexOutputComponents = |
| 2650 | std::min<GLuint>(mCaps.maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 2651 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2652 | mCaps.maxFragmentInputComponents = |
| 2653 | std::min<GLuint>(mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 2654 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 2655 | // WebGL compatibility |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 2656 | mExtensions.webglCompatibility = mWebGLContext; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 2657 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 2658 | { |
| 2659 | // If this context is for WebGL, disable all enableable extensions |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 2660 | if (mWebGLContext && extensionInfo.second.Requestable) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 2661 | { |
| 2662 | mExtensions.*(extensionInfo.second.ExtensionsMember) = false; |
| 2663 | } |
| 2664 | } |
| 2665 | |
| 2666 | // Generate texture caps |
| 2667 | updateCaps(); |
| 2668 | } |
| 2669 | |
| 2670 | void Context::updateCaps() |
| 2671 | { |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 2672 | mCaps.compressedTextureFormats.clear(); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 2673 | mTextureCaps.clear(); |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 2674 | |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 2675 | for (auto capsIt : mImplementation->getNativeTextureCaps()) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2676 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 2677 | GLenum sizedInternalFormat = capsIt.first; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2678 | TextureCaps formatCaps = capsIt.second; |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2679 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 2680 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 2681 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 2682 | // Update the format caps based on the client version and extensions. |
| 2683 | // Caps are AND'd with the renderer caps because some core formats are still unsupported in |
| 2684 | // ES3. |
| 2685 | formatCaps.texturable = |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 2686 | formatCaps.texturable && formatInfo.textureSupport(getClientVersion(), mExtensions); |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 2687 | formatCaps.renderable = |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 2688 | formatCaps.renderable && formatInfo.renderSupport(getClientVersion(), mExtensions); |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 2689 | formatCaps.filterable = |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 2690 | formatCaps.filterable && formatInfo.filterSupport(getClientVersion(), mExtensions); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 2691 | |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 2692 | // OpenGL ES does not support multisampling with non-rendererable formats |
| 2693 | // OpenGL ES 3.0 or prior does not support multisampling with integer formats |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 2694 | if (!formatCaps.renderable || |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 2695 | (getClientVersion() < ES_3_1 && |
| 2696 | (formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT))) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2697 | { |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 2698 | formatCaps.sampleCounts.clear(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2699 | } |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 2700 | else |
| 2701 | { |
| 2702 | // We may have limited the max samples for some required renderbuffer formats due to |
| 2703 | // non-conformant formats. In this case MAX_SAMPLES needs to be lowered accordingly. |
| 2704 | GLuint formatMaxSamples = formatCaps.getMaxSamples(); |
| 2705 | |
| 2706 | // GLES 3.0.5 section 4.4.2.2: "Implementations must support creation of renderbuffers |
| 2707 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with the |
| 2708 | // exception of signed and unsigned integer formats." |
| 2709 | if (formatInfo.componentType != GL_INT && formatInfo.componentType != GL_UNSIGNED_INT && |
| 2710 | formatInfo.isRequiredRenderbufferFormat(getClientVersion())) |
| 2711 | { |
| 2712 | ASSERT(getClientVersion() < ES_3_0 || formatMaxSamples >= 4); |
| 2713 | mCaps.maxSamples = std::min(mCaps.maxSamples, formatMaxSamples); |
| 2714 | } |
| 2715 | |
| 2716 | // Handle GLES 3.1 MAX_*_SAMPLES values similarly to MAX_SAMPLES. |
| 2717 | if (getClientVersion() >= ES_3_1) |
| 2718 | { |
| 2719 | // GLES 3.1 section 9.2.5: "Implementations must support creation of renderbuffers |
| 2720 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with |
| 2721 | // the exception that the signed and unsigned integer formats are required only to |
| 2722 | // support creation of renderbuffers with up to the value of MAX_INTEGER_SAMPLES |
| 2723 | // multisamples, which must be at least one." |
| 2724 | if (formatInfo.componentType == GL_INT || |
| 2725 | formatInfo.componentType == GL_UNSIGNED_INT) |
| 2726 | { |
| 2727 | mCaps.maxIntegerSamples = std::min(mCaps.maxIntegerSamples, formatMaxSamples); |
| 2728 | } |
| 2729 | |
| 2730 | // GLES 3.1 section 19.3.1. |
| 2731 | if (formatCaps.texturable) |
| 2732 | { |
| 2733 | if (formatInfo.depthBits > 0) |
| 2734 | { |
| 2735 | mCaps.maxDepthTextureSamples = |
| 2736 | std::min(mCaps.maxDepthTextureSamples, formatMaxSamples); |
| 2737 | } |
| 2738 | else if (formatInfo.redBits > 0) |
| 2739 | { |
| 2740 | mCaps.maxColorTextureSamples = |
| 2741 | std::min(mCaps.maxColorTextureSamples, formatMaxSamples); |
| 2742 | } |
| 2743 | } |
| 2744 | } |
| 2745 | } |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 2746 | |
| 2747 | if (formatCaps.texturable && formatInfo.compressed) |
| 2748 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 2749 | mCaps.compressedTextureFormats.push_back(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 2750 | } |
| 2751 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 2752 | mTextureCaps.insert(sizedInternalFormat, formatCaps); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2753 | } |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 2754 | |
| 2755 | // If program binary is disabled, blank out the memory cache pointer. |
| 2756 | if (!mImplementation->getNativeExtensions().getProgramBinary) |
| 2757 | { |
| 2758 | mMemoryProgramCache = nullptr; |
| 2759 | } |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 2760 | } |
| 2761 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2762 | void Context::initWorkarounds() |
| 2763 | { |
Jamie Madill | 761b02c | 2017-06-23 16:27:06 -0400 | [diff] [blame] | 2764 | // Apply back-end workarounds. |
| 2765 | mImplementation->applyNativeWorkarounds(&mWorkarounds); |
| 2766 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2767 | // Lose the context upon out of memory error if the application is |
| 2768 | // expecting to watch for those events. |
| 2769 | mWorkarounds.loseContextOnOutOfMemory = (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
| 2770 | } |
| 2771 | |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 2772 | Error Context::prepareForDraw(GLenum drawMode) |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2773 | { |
| 2774 | syncRendererState(); |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 2775 | |
| 2776 | InfoLog infoLog; |
| 2777 | Error err = mImplementation->triggerDrawCallProgramRecompilation(this, &infoLog, |
| 2778 | mMemoryProgramCache, drawMode); |
Jamie Madill | a836b46 | 2017-08-16 14:58:35 -0400 | [diff] [blame] | 2779 | if (err.isError() || infoLog.getLength() > 0) |
Jamie Madill | 4c19a8a | 2017-07-24 11:46:06 -0400 | [diff] [blame] | 2780 | { |
| 2781 | WARN() << "Dynamic recompilation error log: " << infoLog.str(); |
| 2782 | } |
| 2783 | return err; |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2784 | } |
| 2785 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 2786 | void Context::syncRendererState() |
| 2787 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2788 | const State::DirtyBits &dirtyBits = mGLState.getDirtyBits(); |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 2789 | mImplementation->syncState(this, dirtyBits); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2790 | mGLState.clearDirtyBits(); |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2791 | mGLState.syncDirtyObjects(this); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 2792 | } |
| 2793 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2794 | void Context::syncRendererState(const State::DirtyBits &bitMask, |
| 2795 | const State::DirtyObjects &objectMask) |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 2796 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2797 | const State::DirtyBits &dirtyBits = (mGLState.getDirtyBits() & bitMask); |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 2798 | mImplementation->syncState(this, dirtyBits); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2799 | mGLState.clearDirtyBits(dirtyBits); |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2800 | mGLState.syncDirtyObjects(this, objectMask); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 2801 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2802 | |
| 2803 | void Context::blitFramebuffer(GLint srcX0, |
| 2804 | GLint srcY0, |
| 2805 | GLint srcX1, |
| 2806 | GLint srcY1, |
| 2807 | GLint dstX0, |
| 2808 | GLint dstY0, |
| 2809 | GLint dstX1, |
| 2810 | GLint dstY1, |
| 2811 | GLbitfield mask, |
| 2812 | GLenum filter) |
| 2813 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2814 | Framebuffer *drawFramebuffer = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2815 | ASSERT(drawFramebuffer); |
| 2816 | |
| 2817 | Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0); |
| 2818 | Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0); |
| 2819 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2820 | syncStateForBlit(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2821 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 2822 | handleError(drawFramebuffer->blit(this, srcArea, dstArea, mask, filter)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2823 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2824 | |
| 2825 | void Context::clear(GLbitfield mask) |
| 2826 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2827 | syncStateForClear(); |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 2828 | handleError(mGLState.getDrawFramebuffer()->clear(this, mask)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2829 | } |
| 2830 | |
| 2831 | void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values) |
| 2832 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2833 | syncStateForClear(); |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 2834 | handleError(mGLState.getDrawFramebuffer()->clearBufferfv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2835 | } |
| 2836 | |
| 2837 | void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values) |
| 2838 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2839 | syncStateForClear(); |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 2840 | handleError(mGLState.getDrawFramebuffer()->clearBufferuiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2841 | } |
| 2842 | |
| 2843 | void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values) |
| 2844 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2845 | syncStateForClear(); |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 2846 | handleError(mGLState.getDrawFramebuffer()->clearBufferiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2847 | } |
| 2848 | |
| 2849 | void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 2850 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2851 | Framebuffer *framebufferObject = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2852 | ASSERT(framebufferObject); |
| 2853 | |
| 2854 | // If a buffer is not present, the clear has no effect |
| 2855 | if (framebufferObject->getDepthbuffer() == nullptr && |
| 2856 | framebufferObject->getStencilbuffer() == nullptr) |
| 2857 | { |
| 2858 | return; |
| 2859 | } |
| 2860 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2861 | syncStateForClear(); |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 2862 | handleError(framebufferObject->clearBufferfi(this, buffer, drawbuffer, depth, stencil)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2863 | } |
| 2864 | |
| 2865 | void Context::readPixels(GLint x, |
| 2866 | GLint y, |
| 2867 | GLsizei width, |
| 2868 | GLsizei height, |
| 2869 | GLenum format, |
| 2870 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2871 | void *pixels) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2872 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 2873 | if (width == 0 || height == 0) |
| 2874 | { |
| 2875 | return; |
| 2876 | } |
| 2877 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 2878 | syncStateForReadPixels(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2879 | |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2880 | Framebuffer *readFBO = mGLState.getReadFramebuffer(); |
| 2881 | ASSERT(readFBO); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2882 | |
| 2883 | Rectangle area(x, y, width, height); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2884 | handleError(readFBO->readPixels(this, area, format, type, pixels)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2885 | } |
| 2886 | |
| 2887 | void Context::copyTexImage2D(GLenum target, |
| 2888 | GLint level, |
| 2889 | GLenum internalformat, |
| 2890 | GLint x, |
| 2891 | GLint y, |
| 2892 | GLsizei width, |
| 2893 | GLsizei height, |
| 2894 | GLint border) |
| 2895 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2896 | // Only sync the read FBO |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2897 | mGLState.syncDirtyObject(this, GL_READ_FRAMEBUFFER); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2898 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2899 | Rectangle sourceArea(x, y, width, height); |
| 2900 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2901 | const Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2902 | Texture *texture = |
| 2903 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 2904 | handleError(texture->copyImage(this, target, level, sourceArea, internalformat, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2905 | } |
| 2906 | |
| 2907 | void Context::copyTexSubImage2D(GLenum target, |
| 2908 | GLint level, |
| 2909 | GLint xoffset, |
| 2910 | GLint yoffset, |
| 2911 | GLint x, |
| 2912 | GLint y, |
| 2913 | GLsizei width, |
| 2914 | GLsizei height) |
| 2915 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 2916 | if (width == 0 || height == 0) |
| 2917 | { |
| 2918 | return; |
| 2919 | } |
| 2920 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2921 | // Only sync the read FBO |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2922 | mGLState.syncDirtyObject(this, GL_READ_FRAMEBUFFER); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2923 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2924 | Offset destOffset(xoffset, yoffset, 0); |
| 2925 | Rectangle sourceArea(x, y, width, height); |
| 2926 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2927 | const Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2928 | Texture *texture = |
| 2929 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 2930 | handleError(texture->copySubImage(this, target, level, destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2931 | } |
| 2932 | |
| 2933 | void Context::copyTexSubImage3D(GLenum target, |
| 2934 | GLint level, |
| 2935 | GLint xoffset, |
| 2936 | GLint yoffset, |
| 2937 | GLint zoffset, |
| 2938 | GLint x, |
| 2939 | GLint y, |
| 2940 | GLsizei width, |
| 2941 | GLsizei height) |
| 2942 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 2943 | if (width == 0 || height == 0) |
| 2944 | { |
| 2945 | return; |
| 2946 | } |
| 2947 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2948 | // Only sync the read FBO |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2949 | mGLState.syncDirtyObject(this, GL_READ_FRAMEBUFFER); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2950 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2951 | Offset destOffset(xoffset, yoffset, zoffset); |
| 2952 | Rectangle sourceArea(x, y, width, height); |
| 2953 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2954 | const Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2955 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 2956 | handleError(texture->copySubImage(this, target, level, destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2957 | } |
| 2958 | |
| 2959 | void Context::framebufferTexture2D(GLenum target, |
| 2960 | GLenum attachment, |
| 2961 | GLenum textarget, |
| 2962 | GLuint texture, |
| 2963 | GLint level) |
| 2964 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2965 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2966 | ASSERT(framebuffer); |
| 2967 | |
| 2968 | if (texture != 0) |
| 2969 | { |
| 2970 | Texture *textureObj = getTexture(texture); |
| 2971 | |
| 2972 | ImageIndex index = ImageIndex::MakeInvalid(); |
| 2973 | |
| 2974 | if (textarget == GL_TEXTURE_2D) |
| 2975 | { |
| 2976 | index = ImageIndex::Make2D(level); |
| 2977 | } |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 2978 | else if (textarget == GL_TEXTURE_RECTANGLE_ANGLE) |
| 2979 | { |
| 2980 | index = ImageIndex::MakeRectangle(level); |
| 2981 | } |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 2982 | else if (textarget == GL_TEXTURE_2D_MULTISAMPLE) |
| 2983 | { |
| 2984 | ASSERT(level == 0); |
| 2985 | index = ImageIndex::Make2DMultisample(); |
| 2986 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2987 | else |
| 2988 | { |
| 2989 | ASSERT(IsCubeMapTextureTarget(textarget)); |
| 2990 | index = ImageIndex::MakeCube(textarget, level); |
| 2991 | } |
| 2992 | |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 2993 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2994 | } |
| 2995 | else |
| 2996 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 2997 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 2998 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2999 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3000 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3001 | } |
| 3002 | |
| 3003 | void Context::framebufferRenderbuffer(GLenum target, |
| 3004 | GLenum attachment, |
| 3005 | GLenum renderbuffertarget, |
| 3006 | GLuint renderbuffer) |
| 3007 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3008 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3009 | ASSERT(framebuffer); |
| 3010 | |
| 3011 | if (renderbuffer != 0) |
| 3012 | { |
| 3013 | Renderbuffer *renderbufferObject = getRenderbuffer(renderbuffer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3014 | |
| 3015 | framebuffer->setAttachment(this, GL_RENDERBUFFER, attachment, gl::ImageIndex::MakeInvalid(), |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3016 | renderbufferObject); |
| 3017 | } |
| 3018 | else |
| 3019 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3020 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3021 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3022 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3023 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3024 | } |
| 3025 | |
| 3026 | void Context::framebufferTextureLayer(GLenum target, |
| 3027 | GLenum attachment, |
| 3028 | GLuint texture, |
| 3029 | GLint level, |
| 3030 | GLint layer) |
| 3031 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3032 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3033 | ASSERT(framebuffer); |
| 3034 | |
| 3035 | if (texture != 0) |
| 3036 | { |
| 3037 | Texture *textureObject = getTexture(texture); |
| 3038 | |
| 3039 | ImageIndex index = ImageIndex::MakeInvalid(); |
| 3040 | |
| 3041 | if (textureObject->getTarget() == GL_TEXTURE_3D) |
| 3042 | { |
| 3043 | index = ImageIndex::Make3D(level, layer); |
| 3044 | } |
| 3045 | else |
| 3046 | { |
| 3047 | ASSERT(textureObject->getTarget() == GL_TEXTURE_2D_ARRAY); |
| 3048 | index = ImageIndex::Make2DArray(level, layer); |
| 3049 | } |
| 3050 | |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3051 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObject); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3052 | } |
| 3053 | else |
| 3054 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3055 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3056 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3057 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3058 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3059 | } |
| 3060 | |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3061 | void Context::framebufferTextureMultiviewLayeredANGLE(GLenum target, |
| 3062 | GLenum attachment, |
| 3063 | GLuint texture, |
| 3064 | GLint level, |
| 3065 | GLint baseViewIndex, |
| 3066 | GLsizei numViews) |
| 3067 | { |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3068 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 3069 | ASSERT(framebuffer); |
| 3070 | |
| 3071 | if (texture != 0) |
| 3072 | { |
| 3073 | Texture *textureObj = getTexture(texture); |
| 3074 | |
| 3075 | ImageIndex index = ImageIndex::Make2DArray(level, baseViewIndex); |
| 3076 | framebuffer->setAttachmentMultiviewLayered(this, GL_TEXTURE, attachment, index, textureObj, |
| 3077 | numViews, baseViewIndex); |
| 3078 | } |
| 3079 | else |
| 3080 | { |
| 3081 | framebuffer->resetAttachment(this, attachment); |
| 3082 | } |
| 3083 | |
| 3084 | mGLState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3085 | } |
| 3086 | |
| 3087 | void Context::framebufferTextureMultiviewSideBySideANGLE(GLenum target, |
| 3088 | GLenum attachment, |
| 3089 | GLuint texture, |
| 3090 | GLint level, |
| 3091 | GLsizei numViews, |
| 3092 | const GLint *viewportOffsets) |
| 3093 | { |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 3094 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 3095 | ASSERT(framebuffer); |
| 3096 | |
| 3097 | if (texture != 0) |
| 3098 | { |
| 3099 | Texture *textureObj = getTexture(texture); |
| 3100 | |
| 3101 | ImageIndex index = ImageIndex::Make2D(level); |
| 3102 | framebuffer->setAttachmentMultiviewSideBySide(this, GL_TEXTURE, attachment, index, |
| 3103 | textureObj, numViews, viewportOffsets); |
| 3104 | } |
| 3105 | else |
| 3106 | { |
| 3107 | framebuffer->resetAttachment(this, attachment); |
| 3108 | } |
| 3109 | |
| 3110 | mGLState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3111 | } |
| 3112 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3113 | void Context::drawBuffers(GLsizei n, const GLenum *bufs) |
| 3114 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3115 | Framebuffer *framebuffer = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3116 | ASSERT(framebuffer); |
| 3117 | framebuffer->setDrawBuffers(n, bufs); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3118 | mGLState.setObjectDirty(GL_DRAW_FRAMEBUFFER); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3119 | } |
| 3120 | |
| 3121 | void Context::readBuffer(GLenum mode) |
| 3122 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3123 | Framebuffer *readFBO = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3124 | readFBO->setReadBuffer(mode); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3125 | mGLState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3126 | } |
| 3127 | |
| 3128 | void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) |
| 3129 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3130 | // Only sync the FBO |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 3131 | mGLState.syncDirtyObject(this, target); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3132 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3133 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3134 | ASSERT(framebuffer); |
| 3135 | |
| 3136 | // The specification isn't clear what should be done when the framebuffer isn't complete. |
| 3137 | // We leave it up to the framebuffer implementation to decide what to do. |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 3138 | handleError(framebuffer->discard(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3139 | } |
| 3140 | |
| 3141 | void Context::invalidateFramebuffer(GLenum target, |
| 3142 | GLsizei numAttachments, |
| 3143 | const GLenum *attachments) |
| 3144 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3145 | // Only sync the FBO |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 3146 | mGLState.syncDirtyObject(this, target); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3147 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3148 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3149 | ASSERT(framebuffer); |
| 3150 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 3151 | if (framebuffer->checkStatus(this) != GL_FRAMEBUFFER_COMPLETE) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3152 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3153 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3154 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3155 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 3156 | handleError(framebuffer->invalidate(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3157 | } |
| 3158 | |
| 3159 | void Context::invalidateSubFramebuffer(GLenum target, |
| 3160 | GLsizei numAttachments, |
| 3161 | const GLenum *attachments, |
| 3162 | GLint x, |
| 3163 | GLint y, |
| 3164 | GLsizei width, |
| 3165 | GLsizei height) |
| 3166 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3167 | // Only sync the FBO |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 3168 | mGLState.syncDirtyObject(this, target); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3169 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3170 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3171 | ASSERT(framebuffer); |
| 3172 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 3173 | if (framebuffer->checkStatus(this) != GL_FRAMEBUFFER_COMPLETE) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3174 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3175 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3176 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3177 | |
| 3178 | Rectangle area(x, y, width, height); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 3179 | handleError(framebuffer->invalidateSub(this, numAttachments, attachments, area)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3180 | } |
| 3181 | |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3182 | void Context::texImage2D(GLenum target, |
| 3183 | GLint level, |
| 3184 | GLint internalformat, |
| 3185 | GLsizei width, |
| 3186 | GLsizei height, |
| 3187 | GLint border, |
| 3188 | GLenum format, |
| 3189 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3190 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3191 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 3192 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3193 | |
| 3194 | Extents size(width, height, 1); |
| 3195 | Texture *texture = |
| 3196 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 3197 | handleError(texture->setImage(this, mGLState.getUnpackState(), target, level, internalformat, |
| 3198 | size, format, type, reinterpret_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3199 | } |
| 3200 | |
| 3201 | void Context::texImage3D(GLenum target, |
| 3202 | GLint level, |
| 3203 | GLint internalformat, |
| 3204 | GLsizei width, |
| 3205 | GLsizei height, |
| 3206 | GLsizei depth, |
| 3207 | GLint border, |
| 3208 | GLenum format, |
| 3209 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3210 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3211 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 3212 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3213 | |
| 3214 | Extents size(width, height, depth); |
| 3215 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 3216 | handleError(texture->setImage(this, mGLState.getUnpackState(), target, level, internalformat, |
| 3217 | size, format, type, reinterpret_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3218 | } |
| 3219 | |
| 3220 | void Context::texSubImage2D(GLenum target, |
| 3221 | GLint level, |
| 3222 | GLint xoffset, |
| 3223 | GLint yoffset, |
| 3224 | GLsizei width, |
| 3225 | GLsizei height, |
| 3226 | GLenum format, |
| 3227 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3228 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3229 | { |
| 3230 | // Zero sized uploads are valid but no-ops |
| 3231 | if (width == 0 || height == 0) |
| 3232 | { |
| 3233 | return; |
| 3234 | } |
| 3235 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 3236 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3237 | |
| 3238 | Box area(xoffset, yoffset, 0, width, height, 1); |
| 3239 | Texture *texture = |
| 3240 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 3241 | handleError(texture->setSubImage(this, mGLState.getUnpackState(), target, level, area, format, |
| 3242 | type, reinterpret_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3243 | } |
| 3244 | |
| 3245 | void Context::texSubImage3D(GLenum target, |
| 3246 | GLint level, |
| 3247 | GLint xoffset, |
| 3248 | GLint yoffset, |
| 3249 | GLint zoffset, |
| 3250 | GLsizei width, |
| 3251 | GLsizei height, |
| 3252 | GLsizei depth, |
| 3253 | GLenum format, |
| 3254 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3255 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3256 | { |
| 3257 | // Zero sized uploads are valid but no-ops |
| 3258 | if (width == 0 || height == 0 || depth == 0) |
| 3259 | { |
| 3260 | return; |
| 3261 | } |
| 3262 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 3263 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3264 | |
| 3265 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 3266 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 3267 | handleError(texture->setSubImage(this, mGLState.getUnpackState(), target, level, area, format, |
| 3268 | type, reinterpret_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3269 | } |
| 3270 | |
| 3271 | void Context::compressedTexImage2D(GLenum target, |
| 3272 | GLint level, |
| 3273 | GLenum internalformat, |
| 3274 | GLsizei width, |
| 3275 | GLsizei height, |
| 3276 | GLint border, |
| 3277 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3278 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3279 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 3280 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3281 | |
| 3282 | Extents size(width, height, 1); |
| 3283 | Texture *texture = |
| 3284 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 3285 | handleError(texture->setCompressedImage(this, mGLState.getUnpackState(), target, level, |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3286 | internalformat, size, imageSize, |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3287 | reinterpret_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3288 | } |
| 3289 | |
| 3290 | void Context::compressedTexImage3D(GLenum target, |
| 3291 | GLint level, |
| 3292 | GLenum internalformat, |
| 3293 | GLsizei width, |
| 3294 | GLsizei height, |
| 3295 | GLsizei depth, |
| 3296 | GLint border, |
| 3297 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3298 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3299 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 3300 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3301 | |
| 3302 | Extents size(width, height, depth); |
| 3303 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 3304 | handleError(texture->setCompressedImage(this, mGLState.getUnpackState(), target, level, |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3305 | internalformat, size, imageSize, |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3306 | reinterpret_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3307 | } |
| 3308 | |
| 3309 | void Context::compressedTexSubImage2D(GLenum target, |
| 3310 | GLint level, |
| 3311 | GLint xoffset, |
| 3312 | GLint yoffset, |
| 3313 | GLsizei width, |
| 3314 | GLsizei height, |
| 3315 | GLenum format, |
| 3316 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3317 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3318 | { |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 3319 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3320 | |
| 3321 | Box area(xoffset, yoffset, 0, width, height, 1); |
| 3322 | Texture *texture = |
| 3323 | getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 3324 | handleError(texture->setCompressedSubImage(this, mGLState.getUnpackState(), target, level, area, |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3325 | format, imageSize, |
| 3326 | reinterpret_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3327 | } |
| 3328 | |
| 3329 | void Context::compressedTexSubImage3D(GLenum target, |
| 3330 | GLint level, |
| 3331 | GLint xoffset, |
| 3332 | GLint yoffset, |
| 3333 | GLint zoffset, |
| 3334 | GLsizei width, |
| 3335 | GLsizei height, |
| 3336 | GLsizei depth, |
| 3337 | GLenum format, |
| 3338 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3339 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3340 | { |
| 3341 | // Zero sized uploads are valid but no-ops |
| 3342 | if (width == 0 || height == 0) |
| 3343 | { |
| 3344 | return; |
| 3345 | } |
| 3346 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 3347 | syncStateForTexImage(); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3348 | |
| 3349 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 3350 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 3351 | handleError(texture->setCompressedSubImage(this, mGLState.getUnpackState(), target, level, area, |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3352 | format, imageSize, |
| 3353 | reinterpret_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3354 | } |
| 3355 | |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 3356 | void Context::generateMipmap(GLenum target) |
| 3357 | { |
| 3358 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 3359 | handleError(texture->generateMipmap(this)); |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 3360 | } |
| 3361 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 3362 | void Context::copyTextureCHROMIUM(GLuint sourceId, |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 3363 | GLint sourceLevel, |
| 3364 | GLenum destTarget, |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 3365 | GLuint destId, |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 3366 | GLint destLevel, |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 3367 | GLint internalFormat, |
| 3368 | GLenum destType, |
| 3369 | GLboolean unpackFlipY, |
| 3370 | GLboolean unpackPremultiplyAlpha, |
| 3371 | GLboolean unpackUnmultiplyAlpha) |
| 3372 | { |
| 3373 | syncStateForTexImage(); |
| 3374 | |
| 3375 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 3376 | gl::Texture *destTexture = getTexture(destId); |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 3377 | handleError(destTexture->copyTexture( |
| 3378 | this, destTarget, destLevel, internalFormat, destType, sourceLevel, unpackFlipY == GL_TRUE, |
| 3379 | unpackPremultiplyAlpha == GL_TRUE, unpackUnmultiplyAlpha == GL_TRUE, sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 3380 | } |
| 3381 | |
| 3382 | void Context::copySubTextureCHROMIUM(GLuint sourceId, |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 3383 | GLint sourceLevel, |
| 3384 | GLenum destTarget, |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 3385 | GLuint destId, |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 3386 | GLint destLevel, |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 3387 | GLint xoffset, |
| 3388 | GLint yoffset, |
| 3389 | GLint x, |
| 3390 | GLint y, |
| 3391 | GLsizei width, |
| 3392 | GLsizei height, |
| 3393 | GLboolean unpackFlipY, |
| 3394 | GLboolean unpackPremultiplyAlpha, |
| 3395 | GLboolean unpackUnmultiplyAlpha) |
| 3396 | { |
| 3397 | // Zero sized copies are valid but no-ops |
| 3398 | if (width == 0 || height == 0) |
| 3399 | { |
| 3400 | return; |
| 3401 | } |
| 3402 | |
| 3403 | syncStateForTexImage(); |
| 3404 | |
| 3405 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 3406 | gl::Texture *destTexture = getTexture(destId); |
| 3407 | Offset offset(xoffset, yoffset, 0); |
| 3408 | Rectangle area(x, y, width, height); |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 3409 | handleError(destTexture->copySubTexture( |
| 3410 | this, destTarget, destLevel, offset, sourceLevel, area, unpackFlipY == GL_TRUE, |
| 3411 | unpackPremultiplyAlpha == GL_TRUE, unpackUnmultiplyAlpha == GL_TRUE, sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 3412 | } |
| 3413 | |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 3414 | void Context::compressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId) |
| 3415 | { |
| 3416 | syncStateForTexImage(); |
| 3417 | |
| 3418 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 3419 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 3420 | handleError(destTexture->copyCompressedTexture(this, sourceTexture)); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 3421 | } |
| 3422 | |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 3423 | void Context::getBufferPointerv(GLenum target, GLenum pname, void **params) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3424 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3425 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3426 | ASSERT(buffer); |
| 3427 | |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 3428 | QueryBufferPointerv(buffer, pname, params); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3429 | } |
| 3430 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3431 | void *Context::mapBuffer(GLenum target, GLenum access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3432 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3433 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3434 | ASSERT(buffer); |
| 3435 | |
Jamie Madill | 5f56ddb | 2017-01-13 17:29:55 -0500 | [diff] [blame] | 3436 | Error error = buffer->map(this, access); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3437 | if (error.isError()) |
| 3438 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3439 | handleError(error); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3440 | return nullptr; |
| 3441 | } |
| 3442 | |
| 3443 | return buffer->getMapPointer(); |
| 3444 | } |
| 3445 | |
| 3446 | GLboolean Context::unmapBuffer(GLenum target) |
| 3447 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3448 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3449 | ASSERT(buffer); |
| 3450 | |
| 3451 | GLboolean result; |
Jamie Madill | 5f56ddb | 2017-01-13 17:29:55 -0500 | [diff] [blame] | 3452 | Error error = buffer->unmap(this, &result); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3453 | if (error.isError()) |
| 3454 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3455 | handleError(error); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3456 | return GL_FALSE; |
| 3457 | } |
| 3458 | |
| 3459 | return result; |
| 3460 | } |
| 3461 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3462 | void *Context::mapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3463 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3464 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3465 | ASSERT(buffer); |
| 3466 | |
Jamie Madill | 5f56ddb | 2017-01-13 17:29:55 -0500 | [diff] [blame] | 3467 | Error error = buffer->mapRange(this, offset, length, access); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3468 | if (error.isError()) |
| 3469 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3470 | handleError(error); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 3471 | return nullptr; |
| 3472 | } |
| 3473 | |
| 3474 | return buffer->getMapPointer(); |
| 3475 | } |
| 3476 | |
| 3477 | void Context::flushMappedBufferRange(GLenum /*target*/, GLintptr /*offset*/, GLsizeiptr /*length*/) |
| 3478 | { |
| 3479 | // We do not currently support a non-trivial implementation of FlushMappedBufferRange |
| 3480 | } |
| 3481 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 3482 | void Context::syncStateForReadPixels() |
| 3483 | { |
| 3484 | syncRendererState(mReadPixelsDirtyBits, mReadPixelsDirtyObjects); |
| 3485 | } |
| 3486 | |
| 3487 | void Context::syncStateForTexImage() |
| 3488 | { |
| 3489 | syncRendererState(mTexImageDirtyBits, mTexImageDirtyObjects); |
| 3490 | } |
| 3491 | |
| 3492 | void Context::syncStateForClear() |
| 3493 | { |
| 3494 | syncRendererState(mClearDirtyBits, mClearDirtyObjects); |
| 3495 | } |
| 3496 | |
| 3497 | void Context::syncStateForBlit() |
| 3498 | { |
| 3499 | syncRendererState(mBlitDirtyBits, mBlitDirtyObjects); |
| 3500 | } |
| 3501 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3502 | void Context::activeTexture(GLenum texture) |
| 3503 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3504 | mGLState.setActiveSampler(texture - GL_TEXTURE0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3505 | } |
| 3506 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3507 | void Context::blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3508 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3509 | mGLState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3510 | } |
| 3511 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 3512 | void Context::blendEquation(GLenum mode) |
| 3513 | { |
| 3514 | mGLState.setBlendEquation(mode, mode); |
| 3515 | } |
| 3516 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3517 | void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 3518 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3519 | mGLState.setBlendEquation(modeRGB, modeAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3520 | } |
| 3521 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 3522 | void Context::blendFunc(GLenum sfactor, GLenum dfactor) |
| 3523 | { |
| 3524 | mGLState.setBlendFactors(sfactor, dfactor, sfactor, dfactor); |
| 3525 | } |
| 3526 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3527 | void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 3528 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3529 | mGLState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3530 | } |
| 3531 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3532 | void Context::clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3533 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3534 | mGLState.setColorClearValue(red, green, blue, alpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3535 | } |
| 3536 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3537 | void Context::clearDepthf(GLfloat depth) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3538 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3539 | mGLState.setDepthClearValue(depth); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3540 | } |
| 3541 | |
| 3542 | void Context::clearStencil(GLint s) |
| 3543 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3544 | mGLState.setStencilClearValue(s); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3545 | } |
| 3546 | |
| 3547 | void Context::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 3548 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3549 | 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] | 3550 | } |
| 3551 | |
| 3552 | void Context::cullFace(GLenum mode) |
| 3553 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3554 | mGLState.setCullMode(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3555 | } |
| 3556 | |
| 3557 | void Context::depthFunc(GLenum func) |
| 3558 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3559 | mGLState.setDepthFunc(func); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3560 | } |
| 3561 | |
| 3562 | void Context::depthMask(GLboolean flag) |
| 3563 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3564 | mGLState.setDepthMask(flag != GL_FALSE); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3565 | } |
| 3566 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3567 | void Context::depthRangef(GLfloat zNear, GLfloat zFar) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3568 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3569 | mGLState.setDepthRange(zNear, zFar); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3570 | } |
| 3571 | |
| 3572 | void Context::disable(GLenum cap) |
| 3573 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3574 | mGLState.setEnableFeature(cap, false); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3575 | } |
| 3576 | |
| 3577 | void Context::disableVertexAttribArray(GLuint index) |
| 3578 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3579 | mGLState.setEnableVertexAttribArray(index, false); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3580 | } |
| 3581 | |
| 3582 | void Context::enable(GLenum cap) |
| 3583 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3584 | mGLState.setEnableFeature(cap, true); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3585 | } |
| 3586 | |
| 3587 | void Context::enableVertexAttribArray(GLuint index) |
| 3588 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3589 | mGLState.setEnableVertexAttribArray(index, true); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3590 | } |
| 3591 | |
| 3592 | void Context::frontFace(GLenum mode) |
| 3593 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3594 | mGLState.setFrontFace(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3595 | } |
| 3596 | |
| 3597 | void Context::hint(GLenum target, GLenum mode) |
| 3598 | { |
| 3599 | switch (target) |
| 3600 | { |
| 3601 | case GL_GENERATE_MIPMAP_HINT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3602 | mGLState.setGenerateMipmapHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3603 | break; |
| 3604 | |
| 3605 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3606 | mGLState.setFragmentShaderDerivativeHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3607 | break; |
| 3608 | |
| 3609 | default: |
| 3610 | UNREACHABLE(); |
| 3611 | return; |
| 3612 | } |
| 3613 | } |
| 3614 | |
| 3615 | void Context::lineWidth(GLfloat width) |
| 3616 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3617 | mGLState.setLineWidth(width); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3618 | } |
| 3619 | |
| 3620 | void Context::pixelStorei(GLenum pname, GLint param) |
| 3621 | { |
| 3622 | switch (pname) |
| 3623 | { |
| 3624 | case GL_UNPACK_ALIGNMENT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3625 | mGLState.setUnpackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3626 | break; |
| 3627 | |
| 3628 | case GL_PACK_ALIGNMENT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3629 | mGLState.setPackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3630 | break; |
| 3631 | |
| 3632 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3633 | mGLState.setPackReverseRowOrder(param != 0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3634 | break; |
| 3635 | |
| 3636 | case GL_UNPACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3637 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3638 | mGLState.setUnpackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3639 | break; |
| 3640 | |
| 3641 | case GL_UNPACK_IMAGE_HEIGHT: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3642 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3643 | mGLState.setUnpackImageHeight(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3644 | break; |
| 3645 | |
| 3646 | case GL_UNPACK_SKIP_IMAGES: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3647 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3648 | mGLState.setUnpackSkipImages(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3649 | break; |
| 3650 | |
| 3651 | case GL_UNPACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3652 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3653 | mGLState.setUnpackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3654 | break; |
| 3655 | |
| 3656 | case GL_UNPACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3657 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3658 | mGLState.setUnpackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3659 | break; |
| 3660 | |
| 3661 | case GL_PACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3662 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3663 | mGLState.setPackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3664 | break; |
| 3665 | |
| 3666 | case GL_PACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3667 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3668 | mGLState.setPackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3669 | break; |
| 3670 | |
| 3671 | case GL_PACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 3672 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3673 | mGLState.setPackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3674 | break; |
| 3675 | |
| 3676 | default: |
| 3677 | UNREACHABLE(); |
| 3678 | return; |
| 3679 | } |
| 3680 | } |
| 3681 | |
| 3682 | void Context::polygonOffset(GLfloat factor, GLfloat units) |
| 3683 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3684 | mGLState.setPolygonOffsetParams(factor, units); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3685 | } |
| 3686 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3687 | void Context::sampleCoverage(GLfloat value, GLboolean invert) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3688 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3689 | mGLState.setSampleCoverageParams(clamp01(value), invert == GL_TRUE); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3690 | } |
| 3691 | |
| 3692 | void Context::scissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 3693 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3694 | mGLState.setScissorParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3695 | } |
| 3696 | |
| 3697 | void Context::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 3698 | { |
| 3699 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 3700 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3701 | mGLState.setStencilParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3702 | } |
| 3703 | |
| 3704 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 3705 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3706 | mGLState.setStencilBackParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3707 | } |
| 3708 | } |
| 3709 | |
| 3710 | void Context::stencilMaskSeparate(GLenum face, GLuint mask) |
| 3711 | { |
| 3712 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 3713 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3714 | mGLState.setStencilWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3715 | } |
| 3716 | |
| 3717 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 3718 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3719 | mGLState.setStencilBackWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3720 | } |
| 3721 | } |
| 3722 | |
| 3723 | void Context::stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 3724 | { |
| 3725 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 3726 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3727 | mGLState.setStencilOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3728 | } |
| 3729 | |
| 3730 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 3731 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3732 | mGLState.setStencilBackOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3733 | } |
| 3734 | } |
| 3735 | |
| 3736 | void Context::vertexAttrib1f(GLuint index, GLfloat x) |
| 3737 | { |
| 3738 | GLfloat vals[4] = {x, 0, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3739 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3740 | } |
| 3741 | |
| 3742 | void Context::vertexAttrib1fv(GLuint index, const GLfloat *values) |
| 3743 | { |
| 3744 | GLfloat vals[4] = {values[0], 0, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3745 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3746 | } |
| 3747 | |
| 3748 | void Context::vertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 3749 | { |
| 3750 | GLfloat vals[4] = {x, y, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3751 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3752 | } |
| 3753 | |
| 3754 | void Context::vertexAttrib2fv(GLuint index, const GLfloat *values) |
| 3755 | { |
| 3756 | GLfloat vals[4] = {values[0], values[1], 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3757 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3758 | } |
| 3759 | |
| 3760 | void Context::vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 3761 | { |
| 3762 | GLfloat vals[4] = {x, y, z, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3763 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3764 | } |
| 3765 | |
| 3766 | void Context::vertexAttrib3fv(GLuint index, const GLfloat *values) |
| 3767 | { |
| 3768 | GLfloat vals[4] = {values[0], values[1], values[2], 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3769 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3770 | } |
| 3771 | |
| 3772 | void Context::vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 3773 | { |
| 3774 | GLfloat vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3775 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3776 | } |
| 3777 | |
| 3778 | void Context::vertexAttrib4fv(GLuint index, const GLfloat *values) |
| 3779 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3780 | mGLState.setVertexAttribf(index, values); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3781 | } |
| 3782 | |
| 3783 | void Context::vertexAttribPointer(GLuint index, |
| 3784 | GLint size, |
| 3785 | GLenum type, |
| 3786 | GLboolean normalized, |
| 3787 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3788 | const void *ptr) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3789 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 3790 | mGLState.setVertexAttribPointer(this, index, mGLState.getTargetBuffer(GL_ARRAY_BUFFER), size, |
| 3791 | type, normalized == GL_TRUE, false, stride, ptr); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3792 | } |
| 3793 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 3794 | void Context::vertexAttribFormat(GLuint attribIndex, |
| 3795 | GLint size, |
| 3796 | GLenum type, |
| 3797 | GLboolean normalized, |
| 3798 | GLuint relativeOffset) |
| 3799 | { |
| 3800 | mGLState.setVertexAttribFormat(attribIndex, size, type, normalized == GL_TRUE, false, |
| 3801 | relativeOffset); |
| 3802 | } |
| 3803 | |
| 3804 | void Context::vertexAttribIFormat(GLuint attribIndex, |
| 3805 | GLint size, |
| 3806 | GLenum type, |
| 3807 | GLuint relativeOffset) |
| 3808 | { |
| 3809 | mGLState.setVertexAttribFormat(attribIndex, size, type, false, true, relativeOffset); |
| 3810 | } |
| 3811 | |
| 3812 | void Context::vertexAttribBinding(GLuint attribIndex, GLuint bindingIndex) |
| 3813 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 3814 | mGLState.setVertexAttribBinding(this, attribIndex, bindingIndex); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 3815 | } |
| 3816 | |
| 3817 | void Context::setVertexBindingDivisor(GLuint bindingIndex, GLuint divisor) |
| 3818 | { |
| 3819 | mGLState.setVertexBindingDivisor(bindingIndex, divisor); |
| 3820 | } |
| 3821 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3822 | void Context::viewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 3823 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3824 | mGLState.setViewportParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3825 | } |
| 3826 | |
| 3827 | void Context::vertexAttribIPointer(GLuint index, |
| 3828 | GLint size, |
| 3829 | GLenum type, |
| 3830 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3831 | const void *pointer) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3832 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 3833 | mGLState.setVertexAttribPointer(this, index, mGLState.getTargetBuffer(GL_ARRAY_BUFFER), size, |
| 3834 | type, false, true, stride, pointer); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3835 | } |
| 3836 | |
| 3837 | void Context::vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 3838 | { |
| 3839 | GLint vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3840 | mGLState.setVertexAttribi(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3841 | } |
| 3842 | |
| 3843 | void Context::vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 3844 | { |
| 3845 | GLuint vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3846 | mGLState.setVertexAttribu(index, vals); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3847 | } |
| 3848 | |
| 3849 | void Context::vertexAttribI4iv(GLuint index, const GLint *v) |
| 3850 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3851 | mGLState.setVertexAttribi(index, v); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3852 | } |
| 3853 | |
| 3854 | void Context::vertexAttribI4uiv(GLuint index, const GLuint *v) |
| 3855 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3856 | mGLState.setVertexAttribu(index, v); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3857 | } |
| 3858 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 3859 | void Context::getVertexAttribiv(GLuint index, GLenum pname, GLint *params) |
| 3860 | { |
| 3861 | const VertexAttribCurrentValueData ¤tValues = |
| 3862 | getGLState().getVertexAttribCurrentValue(index); |
| 3863 | const VertexArray *vao = getGLState().getVertexArray(); |
| 3864 | QueryVertexAttribiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 3865 | currentValues, pname, params); |
| 3866 | } |
| 3867 | |
| 3868 | void Context::getVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) |
| 3869 | { |
| 3870 | const VertexAttribCurrentValueData ¤tValues = |
| 3871 | getGLState().getVertexAttribCurrentValue(index); |
| 3872 | const VertexArray *vao = getGLState().getVertexArray(); |
| 3873 | QueryVertexAttribfv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 3874 | currentValues, pname, params); |
| 3875 | } |
| 3876 | |
| 3877 | void Context::getVertexAttribIiv(GLuint index, GLenum pname, GLint *params) |
| 3878 | { |
| 3879 | const VertexAttribCurrentValueData ¤tValues = |
| 3880 | getGLState().getVertexAttribCurrentValue(index); |
| 3881 | const VertexArray *vao = getGLState().getVertexArray(); |
| 3882 | QueryVertexAttribIiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 3883 | currentValues, pname, params); |
| 3884 | } |
| 3885 | |
| 3886 | void Context::getVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) |
| 3887 | { |
| 3888 | const VertexAttribCurrentValueData ¤tValues = |
| 3889 | getGLState().getVertexAttribCurrentValue(index); |
| 3890 | const VertexArray *vao = getGLState().getVertexArray(); |
| 3891 | QueryVertexAttribIuiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 3892 | currentValues, pname, params); |
| 3893 | } |
| 3894 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3895 | void Context::getVertexAttribPointerv(GLuint index, GLenum pname, void **pointer) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 3896 | { |
| 3897 | const VertexAttribute &attrib = getGLState().getVertexArray()->getVertexAttribute(index); |
| 3898 | QueryVertexAttribPointerv(attrib, pname, pointer); |
| 3899 | } |
| 3900 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3901 | void Context::debugMessageControl(GLenum source, |
| 3902 | GLenum type, |
| 3903 | GLenum severity, |
| 3904 | GLsizei count, |
| 3905 | const GLuint *ids, |
| 3906 | GLboolean enabled) |
| 3907 | { |
| 3908 | std::vector<GLuint> idVector(ids, ids + count); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3909 | mGLState.getDebug().setMessageControl(source, type, severity, std::move(idVector), |
| 3910 | (enabled != GL_FALSE)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3911 | } |
| 3912 | |
| 3913 | void Context::debugMessageInsert(GLenum source, |
| 3914 | GLenum type, |
| 3915 | GLuint id, |
| 3916 | GLenum severity, |
| 3917 | GLsizei length, |
| 3918 | const GLchar *buf) |
| 3919 | { |
| 3920 | 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] | 3921 | mGLState.getDebug().insertMessage(source, type, id, severity, std::move(msg)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3922 | } |
| 3923 | |
| 3924 | void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam) |
| 3925 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3926 | mGLState.getDebug().setCallback(callback, userParam); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3927 | } |
| 3928 | |
| 3929 | GLuint Context::getDebugMessageLog(GLuint count, |
| 3930 | GLsizei bufSize, |
| 3931 | GLenum *sources, |
| 3932 | GLenum *types, |
| 3933 | GLuint *ids, |
| 3934 | GLenum *severities, |
| 3935 | GLsizei *lengths, |
| 3936 | GLchar *messageLog) |
| 3937 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3938 | return static_cast<GLuint>(mGLState.getDebug().getMessages(count, bufSize, sources, types, ids, |
| 3939 | severities, lengths, messageLog)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3940 | } |
| 3941 | |
| 3942 | void Context::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) |
| 3943 | { |
| 3944 | 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] | 3945 | mGLState.getDebug().pushGroup(source, id, std::move(msg)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3946 | } |
| 3947 | |
| 3948 | void Context::popDebugGroup() |
| 3949 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3950 | mGLState.getDebug().popGroup(); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 3951 | } |
| 3952 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3953 | void Context::bufferData(GLenum target, GLsizeiptr size, const void *data, GLenum usage) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 3954 | { |
| 3955 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 3956 | ASSERT(buffer); |
Jamie Madill | b8353b0 | 2017-01-25 12:57:21 -0800 | [diff] [blame] | 3957 | handleError(buffer->bufferData(this, target, data, size, usage)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 3958 | } |
| 3959 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3960 | void Context::bufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void *data) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 3961 | { |
| 3962 | if (data == nullptr) |
| 3963 | { |
| 3964 | return; |
| 3965 | } |
| 3966 | |
| 3967 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 3968 | ASSERT(buffer); |
Jamie Madill | b8353b0 | 2017-01-25 12:57:21 -0800 | [diff] [blame] | 3969 | handleError(buffer->bufferSubData(this, target, data, size, offset)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 3970 | } |
| 3971 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 3972 | void Context::attachShader(GLuint program, GLuint shader) |
| 3973 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 3974 | auto programObject = mState.mShaderPrograms->getProgram(program); |
| 3975 | auto shaderObject = mState.mShaderPrograms->getShader(shader); |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 3976 | ASSERT(programObject && shaderObject); |
| 3977 | programObject->attachShader(shaderObject); |
| 3978 | } |
| 3979 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3980 | const Workarounds &Context::getWorkarounds() const |
| 3981 | { |
| 3982 | return mWorkarounds; |
| 3983 | } |
| 3984 | |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 3985 | void Context::copyBufferSubData(GLenum readTarget, |
| 3986 | GLenum writeTarget, |
| 3987 | GLintptr readOffset, |
| 3988 | GLintptr writeOffset, |
| 3989 | GLsizeiptr size) |
| 3990 | { |
| 3991 | // if size is zero, the copy is a successful no-op |
| 3992 | if (size == 0) |
| 3993 | { |
| 3994 | return; |
| 3995 | } |
| 3996 | |
| 3997 | // TODO(jmadill): cache these. |
| 3998 | Buffer *readBuffer = mGLState.getTargetBuffer(readTarget); |
| 3999 | Buffer *writeBuffer = mGLState.getTargetBuffer(writeTarget); |
| 4000 | |
Jamie Madill | 5f56ddb | 2017-01-13 17:29:55 -0500 | [diff] [blame] | 4001 | handleError(writeBuffer->copyBufferSubData(this, readBuffer, readOffset, writeOffset, size)); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 4002 | } |
| 4003 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4004 | void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *name) |
| 4005 | { |
| 4006 | Program *programObject = getProgram(program); |
| 4007 | // TODO(jmadill): Re-use this from the validation if possible. |
| 4008 | ASSERT(programObject); |
| 4009 | programObject->bindAttributeLocation(index, name); |
| 4010 | } |
| 4011 | |
| 4012 | void Context::bindBuffer(GLenum target, GLuint buffer) |
| 4013 | { |
| 4014 | switch (target) |
| 4015 | { |
| 4016 | case GL_ARRAY_BUFFER: |
| 4017 | bindArrayBuffer(buffer); |
| 4018 | break; |
| 4019 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4020 | bindElementArrayBuffer(buffer); |
| 4021 | break; |
| 4022 | case GL_COPY_READ_BUFFER: |
| 4023 | bindCopyReadBuffer(buffer); |
| 4024 | break; |
| 4025 | case GL_COPY_WRITE_BUFFER: |
| 4026 | bindCopyWriteBuffer(buffer); |
| 4027 | break; |
| 4028 | case GL_PIXEL_PACK_BUFFER: |
| 4029 | bindPixelPackBuffer(buffer); |
| 4030 | break; |
| 4031 | case GL_PIXEL_UNPACK_BUFFER: |
| 4032 | bindPixelUnpackBuffer(buffer); |
| 4033 | break; |
| 4034 | case GL_UNIFORM_BUFFER: |
| 4035 | bindGenericUniformBuffer(buffer); |
| 4036 | break; |
| 4037 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 4038 | bindGenericTransformFeedbackBuffer(buffer); |
| 4039 | break; |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 4040 | case GL_ATOMIC_COUNTER_BUFFER: |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 4041 | bindGenericAtomicCounterBuffer(buffer); |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 4042 | break; |
| 4043 | case GL_SHADER_STORAGE_BUFFER: |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 4044 | bindGenericShaderStorageBuffer(buffer); |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 4045 | break; |
| 4046 | case GL_DRAW_INDIRECT_BUFFER: |
Jiajia Qin | 9d7d0b1 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 4047 | bindDrawIndirectBuffer(buffer); |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 4048 | break; |
| 4049 | case GL_DISPATCH_INDIRECT_BUFFER: |
Geoff Lang | 9f09037 | 2016-12-02 10:20:43 -0500 | [diff] [blame] | 4050 | if (buffer != 0) |
| 4051 | { |
| 4052 | // Binding buffers to this binding point is not implemented yet. |
| 4053 | UNIMPLEMENTED(); |
| 4054 | } |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 4055 | break; |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4056 | |
| 4057 | default: |
| 4058 | UNREACHABLE(); |
| 4059 | break; |
| 4060 | } |
| 4061 | } |
| 4062 | |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 4063 | void Context::bindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 4064 | { |
| 4065 | bindBufferRange(target, index, buffer, 0, 0); |
| 4066 | } |
| 4067 | |
| 4068 | void Context::bindBufferRange(GLenum target, |
| 4069 | GLuint index, |
| 4070 | GLuint buffer, |
| 4071 | GLintptr offset, |
| 4072 | GLsizeiptr size) |
| 4073 | { |
| 4074 | switch (target) |
| 4075 | { |
| 4076 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 4077 | bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 4078 | bindGenericTransformFeedbackBuffer(buffer); |
| 4079 | break; |
| 4080 | case GL_UNIFORM_BUFFER: |
| 4081 | bindIndexedUniformBuffer(buffer, index, offset, size); |
| 4082 | bindGenericUniformBuffer(buffer); |
| 4083 | break; |
| 4084 | case GL_ATOMIC_COUNTER_BUFFER: |
| 4085 | bindIndexedAtomicCounterBuffer(buffer, index, offset, size); |
| 4086 | bindGenericAtomicCounterBuffer(buffer); |
| 4087 | break; |
| 4088 | case GL_SHADER_STORAGE_BUFFER: |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 4089 | bindIndexedShaderStorageBuffer(buffer, index, offset, size); |
| 4090 | bindGenericShaderStorageBuffer(buffer); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 4091 | break; |
| 4092 | default: |
| 4093 | UNREACHABLE(); |
| 4094 | break; |
| 4095 | } |
| 4096 | } |
| 4097 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4098 | void Context::bindFramebuffer(GLenum target, GLuint framebuffer) |
| 4099 | { |
| 4100 | if (target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 4101 | { |
| 4102 | bindReadFramebuffer(framebuffer); |
| 4103 | } |
| 4104 | |
| 4105 | if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 4106 | { |
| 4107 | bindDrawFramebuffer(framebuffer); |
| 4108 | } |
| 4109 | } |
| 4110 | |
| 4111 | void Context::bindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 4112 | { |
| 4113 | ASSERT(target == GL_RENDERBUFFER); |
| 4114 | Renderbuffer *object = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 4115 | mState.mRenderbuffers->checkRenderbufferAllocation(mImplementation.get(), renderbuffer); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 4116 | mGLState.setRenderbufferBinding(this, object); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 4117 | } |
| 4118 | |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 4119 | void Context::texStorage2DMultisample(GLenum target, |
| 4120 | GLsizei samples, |
| 4121 | GLenum internalformat, |
| 4122 | GLsizei width, |
| 4123 | GLsizei height, |
| 4124 | GLboolean fixedsamplelocations) |
| 4125 | { |
| 4126 | Extents size(width, height, 1); |
| 4127 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 8897afa | 2017-02-06 17:17:23 -0500 | [diff] [blame] | 4128 | handleError(texture->setStorageMultisample(this, target, samples, internalformat, size, |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 4129 | fixedsamplelocations)); |
| 4130 | } |
| 4131 | |
| 4132 | void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val) |
| 4133 | { |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 4134 | mGLState.syncDirtyObject(this, GL_READ_FRAMEBUFFER); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 4135 | const Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
| 4136 | |
| 4137 | switch (pname) |
| 4138 | { |
| 4139 | case GL_SAMPLE_POSITION: |
| 4140 | handleError(framebuffer->getSamplePosition(index, val)); |
| 4141 | break; |
| 4142 | default: |
| 4143 | UNREACHABLE(); |
| 4144 | } |
| 4145 | } |
| 4146 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 4147 | void Context::renderbufferStorage(GLenum target, |
| 4148 | GLenum internalformat, |
| 4149 | GLsizei width, |
| 4150 | GLsizei height) |
| 4151 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 4152 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 4153 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
| 4154 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 4155 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 4156 | handleError(renderbuffer->setStorage(this, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 4157 | } |
| 4158 | |
| 4159 | void Context::renderbufferStorageMultisample(GLenum target, |
| 4160 | GLsizei samples, |
| 4161 | GLenum internalformat, |
| 4162 | GLsizei width, |
| 4163 | GLsizei height) |
| 4164 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 4165 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 4166 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 4167 | |
| 4168 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 4169 | handleError( |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 4170 | renderbuffer->setStorageMultisample(this, samples, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 4171 | } |
| 4172 | |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 4173 | void Context::getSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) |
| 4174 | { |
| 4175 | const FenceSync *syncObject = getFenceSync(sync); |
Geoff Lang | 82483b9 | 2017-04-11 15:33:00 -0400 | [diff] [blame] | 4176 | handleError(QuerySynciv(syncObject, pname, bufSize, length, values)); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 4177 | } |
| 4178 | |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 4179 | void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 4180 | { |
| 4181 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 4182 | QueryFramebufferParameteriv(framebuffer, pname, params); |
| 4183 | } |
| 4184 | |
| 4185 | void Context::setFramebufferParameteri(GLenum target, GLenum pname, GLint param) |
| 4186 | { |
| 4187 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 4188 | SetFramebufferParameteri(framebuffer, pname, param); |
| 4189 | } |
| 4190 | |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 4191 | Error Context::getScratchBuffer(size_t requstedSizeBytes, |
| 4192 | angle::MemoryBuffer **scratchBufferOut) const |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 4193 | { |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 4194 | if (!mScratchBuffer.get(requstedSizeBytes, scratchBufferOut)) |
| 4195 | { |
| 4196 | return OutOfMemory() << "Failed to allocate internal buffer."; |
| 4197 | } |
| 4198 | return NoError(); |
| 4199 | } |
| 4200 | |
| 4201 | Error Context::getZeroFilledBuffer(size_t requstedSizeBytes, |
| 4202 | angle::MemoryBuffer **zeroBufferOut) const |
| 4203 | { |
| 4204 | if (!mZeroFilledBuffer.getInitialized(requstedSizeBytes, zeroBufferOut, 0)) |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 4205 | { |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 4206 | return OutOfMemory() << "Failed to allocate internal buffer."; |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 4207 | } |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 4208 | return NoError(); |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 4209 | } |
| 4210 | |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 4211 | void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) |
| 4212 | { |
| 4213 | if (numGroupsX == 0u || numGroupsY == 0u || numGroupsZ == 0u) |
| 4214 | { |
| 4215 | return; |
| 4216 | } |
| 4217 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 4218 | mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 4219 | } |
| 4220 | |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 4221 | void Context::texStorage2D(GLenum target, |
| 4222 | GLsizei levels, |
| 4223 | GLenum internalFormat, |
| 4224 | GLsizei width, |
| 4225 | GLsizei height) |
| 4226 | { |
| 4227 | Extents size(width, height, 1); |
| 4228 | Texture *texture = getTargetTexture(target); |
| 4229 | handleError(texture->setStorage(this, target, levels, internalFormat, size)); |
| 4230 | } |
| 4231 | |
| 4232 | void Context::texStorage3D(GLenum target, |
| 4233 | GLsizei levels, |
| 4234 | GLenum internalFormat, |
| 4235 | GLsizei width, |
| 4236 | GLsizei height, |
| 4237 | GLsizei depth) |
| 4238 | { |
| 4239 | Extents size(width, height, depth); |
| 4240 | Texture *texture = getTargetTexture(target); |
| 4241 | handleError(texture->setStorage(this, target, levels, internalFormat, size)); |
| 4242 | } |
| 4243 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 4244 | GLenum Context::checkFramebufferStatus(GLenum target) |
| 4245 | { |
| 4246 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 4247 | ASSERT(framebuffer); |
| 4248 | |
| 4249 | return framebuffer->checkStatus(this); |
| 4250 | } |
| 4251 | |
| 4252 | void Context::compileShader(GLuint shader) |
| 4253 | { |
| 4254 | Shader *shaderObject = GetValidShader(this, shader); |
| 4255 | if (!shaderObject) |
| 4256 | { |
| 4257 | return; |
| 4258 | } |
| 4259 | shaderObject->compile(this); |
| 4260 | } |
| 4261 | |
| 4262 | void Context::deleteBuffers(GLsizei n, const GLuint *buffers) |
| 4263 | { |
| 4264 | for (int i = 0; i < n; i++) |
| 4265 | { |
| 4266 | deleteBuffer(buffers[i]); |
| 4267 | } |
| 4268 | } |
| 4269 | |
| 4270 | void Context::deleteFramebuffers(GLsizei n, const GLuint *framebuffers) |
| 4271 | { |
| 4272 | for (int i = 0; i < n; i++) |
| 4273 | { |
| 4274 | if (framebuffers[i] != 0) |
| 4275 | { |
| 4276 | deleteFramebuffer(framebuffers[i]); |
| 4277 | } |
| 4278 | } |
| 4279 | } |
| 4280 | |
| 4281 | void Context::deleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) |
| 4282 | { |
| 4283 | for (int i = 0; i < n; i++) |
| 4284 | { |
| 4285 | deleteRenderbuffer(renderbuffers[i]); |
| 4286 | } |
| 4287 | } |
| 4288 | |
| 4289 | void Context::deleteTextures(GLsizei n, const GLuint *textures) |
| 4290 | { |
| 4291 | for (int i = 0; i < n; i++) |
| 4292 | { |
| 4293 | if (textures[i] != 0) |
| 4294 | { |
| 4295 | deleteTexture(textures[i]); |
| 4296 | } |
| 4297 | } |
| 4298 | } |
| 4299 | |
| 4300 | void Context::detachShader(GLuint program, GLuint shader) |
| 4301 | { |
| 4302 | Program *programObject = getProgram(program); |
| 4303 | ASSERT(programObject); |
| 4304 | |
| 4305 | Shader *shaderObject = getShader(shader); |
| 4306 | ASSERT(shaderObject); |
| 4307 | |
| 4308 | programObject->detachShader(this, shaderObject); |
| 4309 | } |
| 4310 | |
| 4311 | void Context::genBuffers(GLsizei n, GLuint *buffers) |
| 4312 | { |
| 4313 | for (int i = 0; i < n; i++) |
| 4314 | { |
| 4315 | buffers[i] = createBuffer(); |
| 4316 | } |
| 4317 | } |
| 4318 | |
| 4319 | void Context::genFramebuffers(GLsizei n, GLuint *framebuffers) |
| 4320 | { |
| 4321 | for (int i = 0; i < n; i++) |
| 4322 | { |
| 4323 | framebuffers[i] = createFramebuffer(); |
| 4324 | } |
| 4325 | } |
| 4326 | |
| 4327 | void Context::genRenderbuffers(GLsizei n, GLuint *renderbuffers) |
| 4328 | { |
| 4329 | for (int i = 0; i < n; i++) |
| 4330 | { |
| 4331 | renderbuffers[i] = createRenderbuffer(); |
| 4332 | } |
| 4333 | } |
| 4334 | |
| 4335 | void Context::genTextures(GLsizei n, GLuint *textures) |
| 4336 | { |
| 4337 | for (int i = 0; i < n; i++) |
| 4338 | { |
| 4339 | textures[i] = createTexture(); |
| 4340 | } |
| 4341 | } |
| 4342 | |
| 4343 | void Context::getActiveAttrib(GLuint program, |
| 4344 | GLuint index, |
| 4345 | GLsizei bufsize, |
| 4346 | GLsizei *length, |
| 4347 | GLint *size, |
| 4348 | GLenum *type, |
| 4349 | GLchar *name) |
| 4350 | { |
| 4351 | Program *programObject = getProgram(program); |
| 4352 | ASSERT(programObject); |
| 4353 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4354 | } |
| 4355 | |
| 4356 | void Context::getActiveUniform(GLuint program, |
| 4357 | GLuint index, |
| 4358 | GLsizei bufsize, |
| 4359 | GLsizei *length, |
| 4360 | GLint *size, |
| 4361 | GLenum *type, |
| 4362 | GLchar *name) |
| 4363 | { |
| 4364 | Program *programObject = getProgram(program); |
| 4365 | ASSERT(programObject); |
| 4366 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4367 | } |
| 4368 | |
| 4369 | void Context::getAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) |
| 4370 | { |
| 4371 | Program *programObject = getProgram(program); |
| 4372 | ASSERT(programObject); |
| 4373 | programObject->getAttachedShaders(maxcount, count, shaders); |
| 4374 | } |
| 4375 | |
| 4376 | GLint Context::getAttribLocation(GLuint program, const GLchar *name) |
| 4377 | { |
| 4378 | Program *programObject = getProgram(program); |
| 4379 | ASSERT(programObject); |
| 4380 | return programObject->getAttributeLocation(name); |
| 4381 | } |
| 4382 | |
| 4383 | void Context::getBooleanv(GLenum pname, GLboolean *params) |
| 4384 | { |
| 4385 | GLenum nativeType; |
| 4386 | unsigned int numParams = 0; |
| 4387 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 4388 | |
| 4389 | if (nativeType == GL_BOOL) |
| 4390 | { |
| 4391 | getBooleanvImpl(pname, params); |
| 4392 | } |
| 4393 | else |
| 4394 | { |
| 4395 | CastStateValues(this, nativeType, pname, numParams, params); |
| 4396 | } |
| 4397 | } |
| 4398 | |
| 4399 | void Context::getFloatv(GLenum pname, GLfloat *params) |
| 4400 | { |
| 4401 | GLenum nativeType; |
| 4402 | unsigned int numParams = 0; |
| 4403 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 4404 | |
| 4405 | if (nativeType == GL_FLOAT) |
| 4406 | { |
| 4407 | getFloatvImpl(pname, params); |
| 4408 | } |
| 4409 | else |
| 4410 | { |
| 4411 | CastStateValues(this, nativeType, pname, numParams, params); |
| 4412 | } |
| 4413 | } |
| 4414 | |
| 4415 | void Context::getIntegerv(GLenum pname, GLint *params) |
| 4416 | { |
| 4417 | GLenum nativeType; |
| 4418 | unsigned int numParams = 0; |
| 4419 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 4420 | |
| 4421 | if (nativeType == GL_INT) |
| 4422 | { |
| 4423 | getIntegervImpl(pname, params); |
| 4424 | } |
| 4425 | else |
| 4426 | { |
| 4427 | CastStateValues(this, nativeType, pname, numParams, params); |
| 4428 | } |
| 4429 | } |
| 4430 | |
| 4431 | void Context::getProgramiv(GLuint program, GLenum pname, GLint *params) |
| 4432 | { |
| 4433 | Program *programObject = getProgram(program); |
| 4434 | ASSERT(programObject); |
Jamie Madill | ffe00c0 | 2017-06-27 16:26:55 -0400 | [diff] [blame] | 4435 | QueryProgramiv(this, programObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 4436 | } |
| 4437 | |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 4438 | void Context::getProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 4439 | { |
| 4440 | Program *programObject = getProgram(program); |
| 4441 | ASSERT(programObject); |
| 4442 | programObject->getInfoLog(bufsize, length, infolog); |
| 4443 | } |
| 4444 | |
| 4445 | void Context::getShaderiv(GLuint shader, GLenum pname, GLint *params) |
| 4446 | { |
| 4447 | Shader *shaderObject = getShader(shader); |
| 4448 | ASSERT(shaderObject); |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 4449 | QueryShaderiv(this, shaderObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 4450 | } |
| 4451 | |
| 4452 | void Context::getShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
| 4453 | { |
| 4454 | Shader *shaderObject = getShader(shader); |
| 4455 | ASSERT(shaderObject); |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 4456 | shaderObject->getInfoLog(this, bufsize, length, infolog); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 4457 | } |
| 4458 | |
| 4459 | void Context::getShaderPrecisionFormat(GLenum shadertype, |
| 4460 | GLenum precisiontype, |
| 4461 | GLint *range, |
| 4462 | GLint *precision) |
| 4463 | { |
| 4464 | // TODO(jmadill): Compute shaders. |
| 4465 | |
| 4466 | switch (shadertype) |
| 4467 | { |
| 4468 | case GL_VERTEX_SHADER: |
| 4469 | switch (precisiontype) |
| 4470 | { |
| 4471 | case GL_LOW_FLOAT: |
| 4472 | mCaps.vertexLowpFloat.get(range, precision); |
| 4473 | break; |
| 4474 | case GL_MEDIUM_FLOAT: |
| 4475 | mCaps.vertexMediumpFloat.get(range, precision); |
| 4476 | break; |
| 4477 | case GL_HIGH_FLOAT: |
| 4478 | mCaps.vertexHighpFloat.get(range, precision); |
| 4479 | break; |
| 4480 | |
| 4481 | case GL_LOW_INT: |
| 4482 | mCaps.vertexLowpInt.get(range, precision); |
| 4483 | break; |
| 4484 | case GL_MEDIUM_INT: |
| 4485 | mCaps.vertexMediumpInt.get(range, precision); |
| 4486 | break; |
| 4487 | case GL_HIGH_INT: |
| 4488 | mCaps.vertexHighpInt.get(range, precision); |
| 4489 | break; |
| 4490 | |
| 4491 | default: |
| 4492 | UNREACHABLE(); |
| 4493 | return; |
| 4494 | } |
| 4495 | break; |
| 4496 | |
| 4497 | case GL_FRAGMENT_SHADER: |
| 4498 | switch (precisiontype) |
| 4499 | { |
| 4500 | case GL_LOW_FLOAT: |
| 4501 | mCaps.fragmentLowpFloat.get(range, precision); |
| 4502 | break; |
| 4503 | case GL_MEDIUM_FLOAT: |
| 4504 | mCaps.fragmentMediumpFloat.get(range, precision); |
| 4505 | break; |
| 4506 | case GL_HIGH_FLOAT: |
| 4507 | mCaps.fragmentHighpFloat.get(range, precision); |
| 4508 | break; |
| 4509 | |
| 4510 | case GL_LOW_INT: |
| 4511 | mCaps.fragmentLowpInt.get(range, precision); |
| 4512 | break; |
| 4513 | case GL_MEDIUM_INT: |
| 4514 | mCaps.fragmentMediumpInt.get(range, precision); |
| 4515 | break; |
| 4516 | case GL_HIGH_INT: |
| 4517 | mCaps.fragmentHighpInt.get(range, precision); |
| 4518 | break; |
| 4519 | |
| 4520 | default: |
| 4521 | UNREACHABLE(); |
| 4522 | return; |
| 4523 | } |
| 4524 | break; |
| 4525 | |
| 4526 | default: |
| 4527 | UNREACHABLE(); |
| 4528 | return; |
| 4529 | } |
| 4530 | } |
| 4531 | |
| 4532 | void Context::getShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source) |
| 4533 | { |
| 4534 | Shader *shaderObject = getShader(shader); |
| 4535 | ASSERT(shaderObject); |
| 4536 | shaderObject->getSource(bufsize, length, source); |
| 4537 | } |
| 4538 | |
| 4539 | void Context::getUniformfv(GLuint program, GLint location, GLfloat *params) |
| 4540 | { |
| 4541 | Program *programObject = getProgram(program); |
| 4542 | ASSERT(programObject); |
| 4543 | programObject->getUniformfv(location, params); |
| 4544 | } |
| 4545 | |
| 4546 | void Context::getUniformiv(GLuint program, GLint location, GLint *params) |
| 4547 | { |
| 4548 | Program *programObject = getProgram(program); |
| 4549 | ASSERT(programObject); |
| 4550 | programObject->getUniformiv(location, params); |
| 4551 | } |
| 4552 | |
| 4553 | GLint Context::getUniformLocation(GLuint program, const GLchar *name) |
| 4554 | { |
| 4555 | Program *programObject = getProgram(program); |
| 4556 | ASSERT(programObject); |
| 4557 | return programObject->getUniformLocation(name); |
| 4558 | } |
| 4559 | |
| 4560 | GLboolean Context::isBuffer(GLuint buffer) |
| 4561 | { |
| 4562 | if (buffer == 0) |
| 4563 | { |
| 4564 | return GL_FALSE; |
| 4565 | } |
| 4566 | |
| 4567 | return (getBuffer(buffer) ? GL_TRUE : GL_FALSE); |
| 4568 | } |
| 4569 | |
| 4570 | GLboolean Context::isEnabled(GLenum cap) |
| 4571 | { |
| 4572 | return mGLState.getEnableFeature(cap); |
| 4573 | } |
| 4574 | |
| 4575 | GLboolean Context::isFramebuffer(GLuint framebuffer) |
| 4576 | { |
| 4577 | if (framebuffer == 0) |
| 4578 | { |
| 4579 | return GL_FALSE; |
| 4580 | } |
| 4581 | |
| 4582 | return (getFramebuffer(framebuffer) ? GL_TRUE : GL_FALSE); |
| 4583 | } |
| 4584 | |
| 4585 | GLboolean Context::isProgram(GLuint program) |
| 4586 | { |
| 4587 | if (program == 0) |
| 4588 | { |
| 4589 | return GL_FALSE; |
| 4590 | } |
| 4591 | |
| 4592 | return (getProgram(program) ? GL_TRUE : GL_FALSE); |
| 4593 | } |
| 4594 | |
| 4595 | GLboolean Context::isRenderbuffer(GLuint renderbuffer) |
| 4596 | { |
| 4597 | if (renderbuffer == 0) |
| 4598 | { |
| 4599 | return GL_FALSE; |
| 4600 | } |
| 4601 | |
| 4602 | return (getRenderbuffer(renderbuffer) ? GL_TRUE : GL_FALSE); |
| 4603 | } |
| 4604 | |
| 4605 | GLboolean Context::isShader(GLuint shader) |
| 4606 | { |
| 4607 | if (shader == 0) |
| 4608 | { |
| 4609 | return GL_FALSE; |
| 4610 | } |
| 4611 | |
| 4612 | return (getShader(shader) ? GL_TRUE : GL_FALSE); |
| 4613 | } |
| 4614 | |
| 4615 | GLboolean Context::isTexture(GLuint texture) |
| 4616 | { |
| 4617 | if (texture == 0) |
| 4618 | { |
| 4619 | return GL_FALSE; |
| 4620 | } |
| 4621 | |
| 4622 | return (getTexture(texture) ? GL_TRUE : GL_FALSE); |
| 4623 | } |
| 4624 | |
| 4625 | void Context::linkProgram(GLuint program) |
| 4626 | { |
| 4627 | Program *programObject = getProgram(program); |
| 4628 | ASSERT(programObject); |
| 4629 | handleError(programObject->link(this)); |
| 4630 | } |
| 4631 | |
| 4632 | void Context::releaseShaderCompiler() |
| 4633 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 4634 | mCompiler.set(this, nullptr); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 4635 | } |
| 4636 | |
| 4637 | void Context::shaderBinary(GLsizei n, |
| 4638 | const GLuint *shaders, |
| 4639 | GLenum binaryformat, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4640 | const void *binary, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 4641 | GLsizei length) |
| 4642 | { |
| 4643 | // No binary shader formats are supported. |
| 4644 | UNIMPLEMENTED(); |
| 4645 | } |
| 4646 | |
| 4647 | void Context::shaderSource(GLuint shader, |
| 4648 | GLsizei count, |
| 4649 | const GLchar *const *string, |
| 4650 | const GLint *length) |
| 4651 | { |
| 4652 | Shader *shaderObject = getShader(shader); |
| 4653 | ASSERT(shaderObject); |
| 4654 | shaderObject->setSource(count, string, length); |
| 4655 | } |
| 4656 | |
| 4657 | void Context::stencilFunc(GLenum func, GLint ref, GLuint mask) |
| 4658 | { |
| 4659 | stencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
| 4660 | } |
| 4661 | |
| 4662 | void Context::stencilMask(GLuint mask) |
| 4663 | { |
| 4664 | stencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 4665 | } |
| 4666 | |
| 4667 | void Context::stencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 4668 | { |
| 4669 | stencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 4670 | } |
| 4671 | |
| 4672 | void Context::uniform1f(GLint location, GLfloat x) |
| 4673 | { |
| 4674 | Program *program = mGLState.getProgram(); |
| 4675 | program->setUniform1fv(location, 1, &x); |
| 4676 | } |
| 4677 | |
| 4678 | void Context::uniform1fv(GLint location, GLsizei count, const GLfloat *v) |
| 4679 | { |
| 4680 | Program *program = mGLState.getProgram(); |
| 4681 | program->setUniform1fv(location, count, v); |
| 4682 | } |
| 4683 | |
| 4684 | void Context::uniform1i(GLint location, GLint x) |
| 4685 | { |
| 4686 | Program *program = mGLState.getProgram(); |
| 4687 | program->setUniform1iv(location, 1, &x); |
| 4688 | } |
| 4689 | |
| 4690 | void Context::uniform1iv(GLint location, GLsizei count, const GLint *v) |
| 4691 | { |
| 4692 | Program *program = mGLState.getProgram(); |
| 4693 | program->setUniform1iv(location, count, v); |
| 4694 | } |
| 4695 | |
| 4696 | void Context::uniform2f(GLint location, GLfloat x, GLfloat y) |
| 4697 | { |
| 4698 | GLfloat xy[2] = {x, y}; |
| 4699 | Program *program = mGLState.getProgram(); |
| 4700 | program->setUniform2fv(location, 1, xy); |
| 4701 | } |
| 4702 | |
| 4703 | void Context::uniform2fv(GLint location, GLsizei count, const GLfloat *v) |
| 4704 | { |
| 4705 | Program *program = mGLState.getProgram(); |
| 4706 | program->setUniform2fv(location, count, v); |
| 4707 | } |
| 4708 | |
| 4709 | void Context::uniform2i(GLint location, GLint x, GLint y) |
| 4710 | { |
| 4711 | GLint xy[2] = {x, y}; |
| 4712 | Program *program = mGLState.getProgram(); |
| 4713 | program->setUniform2iv(location, 1, xy); |
| 4714 | } |
| 4715 | |
| 4716 | void Context::uniform2iv(GLint location, GLsizei count, const GLint *v) |
| 4717 | { |
| 4718 | Program *program = mGLState.getProgram(); |
| 4719 | program->setUniform2iv(location, count, v); |
| 4720 | } |
| 4721 | |
| 4722 | void Context::uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 4723 | { |
| 4724 | GLfloat xyz[3] = {x, y, z}; |
| 4725 | Program *program = mGLState.getProgram(); |
| 4726 | program->setUniform3fv(location, 1, xyz); |
| 4727 | } |
| 4728 | |
| 4729 | void Context::uniform3fv(GLint location, GLsizei count, const GLfloat *v) |
| 4730 | { |
| 4731 | Program *program = mGLState.getProgram(); |
| 4732 | program->setUniform3fv(location, count, v); |
| 4733 | } |
| 4734 | |
| 4735 | void Context::uniform3i(GLint location, GLint x, GLint y, GLint z) |
| 4736 | { |
| 4737 | GLint xyz[3] = {x, y, z}; |
| 4738 | Program *program = mGLState.getProgram(); |
| 4739 | program->setUniform3iv(location, 1, xyz); |
| 4740 | } |
| 4741 | |
| 4742 | void Context::uniform3iv(GLint location, GLsizei count, const GLint *v) |
| 4743 | { |
| 4744 | Program *program = mGLState.getProgram(); |
| 4745 | program->setUniform3iv(location, count, v); |
| 4746 | } |
| 4747 | |
| 4748 | void Context::uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4749 | { |
| 4750 | GLfloat xyzw[4] = {x, y, z, w}; |
| 4751 | Program *program = mGLState.getProgram(); |
| 4752 | program->setUniform4fv(location, 1, xyzw); |
| 4753 | } |
| 4754 | |
| 4755 | void Context::uniform4fv(GLint location, GLsizei count, const GLfloat *v) |
| 4756 | { |
| 4757 | Program *program = mGLState.getProgram(); |
| 4758 | program->setUniform4fv(location, count, v); |
| 4759 | } |
| 4760 | |
| 4761 | void Context::uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 4762 | { |
| 4763 | GLint xyzw[4] = {x, y, z, w}; |
| 4764 | Program *program = mGLState.getProgram(); |
| 4765 | program->setUniform4iv(location, 1, xyzw); |
| 4766 | } |
| 4767 | |
| 4768 | void Context::uniform4iv(GLint location, GLsizei count, const GLint *v) |
| 4769 | { |
| 4770 | Program *program = mGLState.getProgram(); |
| 4771 | program->setUniform4iv(location, count, v); |
| 4772 | } |
| 4773 | |
| 4774 | void Context::uniformMatrix2fv(GLint location, |
| 4775 | GLsizei count, |
| 4776 | GLboolean transpose, |
| 4777 | const GLfloat *value) |
| 4778 | { |
| 4779 | Program *program = mGLState.getProgram(); |
| 4780 | program->setUniformMatrix2fv(location, count, transpose, value); |
| 4781 | } |
| 4782 | |
| 4783 | void Context::uniformMatrix3fv(GLint location, |
| 4784 | GLsizei count, |
| 4785 | GLboolean transpose, |
| 4786 | const GLfloat *value) |
| 4787 | { |
| 4788 | Program *program = mGLState.getProgram(); |
| 4789 | program->setUniformMatrix3fv(location, count, transpose, value); |
| 4790 | } |
| 4791 | |
| 4792 | void Context::uniformMatrix4fv(GLint location, |
| 4793 | GLsizei count, |
| 4794 | GLboolean transpose, |
| 4795 | const GLfloat *value) |
| 4796 | { |
| 4797 | Program *program = mGLState.getProgram(); |
| 4798 | program->setUniformMatrix4fv(location, count, transpose, value); |
| 4799 | } |
| 4800 | |
| 4801 | void Context::validateProgram(GLuint program) |
| 4802 | { |
| 4803 | Program *programObject = getProgram(program); |
| 4804 | ASSERT(programObject); |
| 4805 | programObject->validate(mCaps); |
| 4806 | } |
| 4807 | |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 4808 | void Context::getProgramBinary(GLuint program, |
| 4809 | GLsizei bufSize, |
| 4810 | GLsizei *length, |
| 4811 | GLenum *binaryFormat, |
| 4812 | void *binary) |
| 4813 | { |
| 4814 | Program *programObject = getProgram(program); |
| 4815 | ASSERT(programObject != nullptr); |
| 4816 | |
| 4817 | handleError(programObject->saveBinary(this, binaryFormat, binary, bufSize, length)); |
| 4818 | } |
| 4819 | |
| 4820 | void Context::programBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length) |
| 4821 | { |
| 4822 | Program *programObject = getProgram(program); |
| 4823 | ASSERT(programObject != nullptr); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 4824 | |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 4825 | handleError(programObject->loadBinary(this, binaryFormat, binary, length)); |
| 4826 | } |
| 4827 | |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 4828 | void Context::uniform1ui(GLint location, GLuint v0) |
| 4829 | { |
| 4830 | Program *program = mGLState.getProgram(); |
| 4831 | program->setUniform1uiv(location, 1, &v0); |
| 4832 | } |
| 4833 | |
| 4834 | void Context::uniform2ui(GLint location, GLuint v0, GLuint v1) |
| 4835 | { |
| 4836 | Program *program = mGLState.getProgram(); |
| 4837 | const GLuint xy[] = {v0, v1}; |
| 4838 | program->setUniform2uiv(location, 1, xy); |
| 4839 | } |
| 4840 | |
| 4841 | void Context::uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 4842 | { |
| 4843 | Program *program = mGLState.getProgram(); |
| 4844 | const GLuint xyz[] = {v0, v1, v2}; |
| 4845 | program->setUniform3uiv(location, 1, xyz); |
| 4846 | } |
| 4847 | |
| 4848 | void Context::uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 4849 | { |
| 4850 | Program *program = mGLState.getProgram(); |
| 4851 | const GLuint xyzw[] = {v0, v1, v2, v3}; |
| 4852 | program->setUniform4uiv(location, 1, xyzw); |
| 4853 | } |
| 4854 | |
| 4855 | void Context::uniform1uiv(GLint location, GLsizei count, const GLuint *value) |
| 4856 | { |
| 4857 | Program *program = mGLState.getProgram(); |
| 4858 | program->setUniform1uiv(location, count, value); |
| 4859 | } |
| 4860 | void Context::uniform2uiv(GLint location, GLsizei count, const GLuint *value) |
| 4861 | { |
| 4862 | Program *program = mGLState.getProgram(); |
| 4863 | program->setUniform2uiv(location, count, value); |
| 4864 | } |
| 4865 | |
| 4866 | void Context::uniform3uiv(GLint location, GLsizei count, const GLuint *value) |
| 4867 | { |
| 4868 | Program *program = mGLState.getProgram(); |
| 4869 | program->setUniform3uiv(location, count, value); |
| 4870 | } |
| 4871 | |
| 4872 | void Context::uniform4uiv(GLint location, GLsizei count, const GLuint *value) |
| 4873 | { |
| 4874 | Program *program = mGLState.getProgram(); |
| 4875 | program->setUniform4uiv(location, count, value); |
| 4876 | } |
| 4877 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 4878 | void Context::genQueries(GLsizei n, GLuint *ids) |
| 4879 | { |
| 4880 | for (GLsizei i = 0; i < n; i++) |
| 4881 | { |
| 4882 | GLuint handle = mQueryHandleAllocator.allocate(); |
| 4883 | mQueryMap.assign(handle, nullptr); |
| 4884 | ids[i] = handle; |
| 4885 | } |
| 4886 | } |
| 4887 | |
| 4888 | void Context::deleteQueries(GLsizei n, const GLuint *ids) |
| 4889 | { |
| 4890 | for (int i = 0; i < n; i++) |
| 4891 | { |
| 4892 | GLuint query = ids[i]; |
| 4893 | |
| 4894 | Query *queryObject = nullptr; |
| 4895 | if (mQueryMap.erase(query, &queryObject)) |
| 4896 | { |
| 4897 | mQueryHandleAllocator.release(query); |
| 4898 | if (queryObject) |
| 4899 | { |
| 4900 | queryObject->release(this); |
| 4901 | } |
| 4902 | } |
| 4903 | } |
| 4904 | } |
| 4905 | |
| 4906 | GLboolean Context::isQuery(GLuint id) |
| 4907 | { |
| 4908 | return (getQuery(id, false, GL_NONE) != nullptr) ? GL_TRUE : GL_FALSE; |
| 4909 | } |
| 4910 | |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 4911 | void Context::uniformMatrix2x3fv(GLint location, |
| 4912 | GLsizei count, |
| 4913 | GLboolean transpose, |
| 4914 | const GLfloat *value) |
| 4915 | { |
| 4916 | Program *program = mGLState.getProgram(); |
| 4917 | program->setUniformMatrix2x3fv(location, count, transpose, value); |
| 4918 | } |
| 4919 | |
| 4920 | void Context::uniformMatrix3x2fv(GLint location, |
| 4921 | GLsizei count, |
| 4922 | GLboolean transpose, |
| 4923 | const GLfloat *value) |
| 4924 | { |
| 4925 | Program *program = mGLState.getProgram(); |
| 4926 | program->setUniformMatrix3x2fv(location, count, transpose, value); |
| 4927 | } |
| 4928 | |
| 4929 | void Context::uniformMatrix2x4fv(GLint location, |
| 4930 | GLsizei count, |
| 4931 | GLboolean transpose, |
| 4932 | const GLfloat *value) |
| 4933 | { |
| 4934 | Program *program = mGLState.getProgram(); |
| 4935 | program->setUniformMatrix2x4fv(location, count, transpose, value); |
| 4936 | } |
| 4937 | |
| 4938 | void Context::uniformMatrix4x2fv(GLint location, |
| 4939 | GLsizei count, |
| 4940 | GLboolean transpose, |
| 4941 | const GLfloat *value) |
| 4942 | { |
| 4943 | Program *program = mGLState.getProgram(); |
| 4944 | program->setUniformMatrix4x2fv(location, count, transpose, value); |
| 4945 | } |
| 4946 | |
| 4947 | void Context::uniformMatrix3x4fv(GLint location, |
| 4948 | GLsizei count, |
| 4949 | GLboolean transpose, |
| 4950 | const GLfloat *value) |
| 4951 | { |
| 4952 | Program *program = mGLState.getProgram(); |
| 4953 | program->setUniformMatrix3x4fv(location, count, transpose, value); |
| 4954 | } |
| 4955 | |
| 4956 | void Context::uniformMatrix4x3fv(GLint location, |
| 4957 | GLsizei count, |
| 4958 | GLboolean transpose, |
| 4959 | const GLfloat *value) |
| 4960 | { |
| 4961 | Program *program = mGLState.getProgram(); |
| 4962 | program->setUniformMatrix4x3fv(location, count, transpose, value); |
| 4963 | } |
| 4964 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 4965 | void Context::deleteVertexArrays(GLsizei n, const GLuint *arrays) |
| 4966 | { |
| 4967 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 4968 | { |
| 4969 | GLuint vertexArray = arrays[arrayIndex]; |
| 4970 | |
| 4971 | if (arrays[arrayIndex] != 0) |
| 4972 | { |
| 4973 | VertexArray *vertexArrayObject = nullptr; |
| 4974 | if (mVertexArrayMap.erase(vertexArray, &vertexArrayObject)) |
| 4975 | { |
| 4976 | if (vertexArrayObject != nullptr) |
| 4977 | { |
| 4978 | detachVertexArray(vertexArray); |
| 4979 | vertexArrayObject->onDestroy(this); |
| 4980 | } |
| 4981 | |
| 4982 | mVertexArrayHandleAllocator.release(vertexArray); |
| 4983 | } |
| 4984 | } |
| 4985 | } |
| 4986 | } |
| 4987 | |
| 4988 | void Context::genVertexArrays(GLsizei n, GLuint *arrays) |
| 4989 | { |
| 4990 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 4991 | { |
| 4992 | GLuint vertexArray = mVertexArrayHandleAllocator.allocate(); |
| 4993 | mVertexArrayMap.assign(vertexArray, nullptr); |
| 4994 | arrays[arrayIndex] = vertexArray; |
| 4995 | } |
| 4996 | } |
| 4997 | |
| 4998 | bool Context::isVertexArray(GLuint array) |
| 4999 | { |
| 5000 | if (array == 0) |
| 5001 | { |
| 5002 | return GL_FALSE; |
| 5003 | } |
| 5004 | |
| 5005 | VertexArray *vao = getVertexArray(array); |
| 5006 | return (vao != nullptr ? GL_TRUE : GL_FALSE); |
| 5007 | } |
| 5008 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 5009 | void Context::endTransformFeedback() |
| 5010 | { |
| 5011 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
| 5012 | transformFeedback->end(this); |
| 5013 | } |
| 5014 | |
| 5015 | void Context::transformFeedbackVaryings(GLuint program, |
| 5016 | GLsizei count, |
| 5017 | const GLchar *const *varyings, |
| 5018 | GLenum bufferMode) |
| 5019 | { |
| 5020 | Program *programObject = getProgram(program); |
| 5021 | ASSERT(programObject); |
| 5022 | programObject->setTransformFeedbackVaryings(count, varyings, bufferMode); |
| 5023 | } |
| 5024 | |
| 5025 | void Context::getTransformFeedbackVarying(GLuint program, |
| 5026 | GLuint index, |
| 5027 | GLsizei bufSize, |
| 5028 | GLsizei *length, |
| 5029 | GLsizei *size, |
| 5030 | GLenum *type, |
| 5031 | GLchar *name) |
| 5032 | { |
| 5033 | Program *programObject = getProgram(program); |
| 5034 | ASSERT(programObject); |
| 5035 | programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name); |
| 5036 | } |
| 5037 | |
| 5038 | void Context::deleteTransformFeedbacks(GLsizei n, const GLuint *ids) |
| 5039 | { |
| 5040 | for (int i = 0; i < n; i++) |
| 5041 | { |
| 5042 | GLuint transformFeedback = ids[i]; |
| 5043 | if (transformFeedback == 0) |
| 5044 | { |
| 5045 | continue; |
| 5046 | } |
| 5047 | |
| 5048 | TransformFeedback *transformFeedbackObject = nullptr; |
| 5049 | if (mTransformFeedbackMap.erase(transformFeedback, &transformFeedbackObject)) |
| 5050 | { |
| 5051 | if (transformFeedbackObject != nullptr) |
| 5052 | { |
| 5053 | detachTransformFeedback(transformFeedback); |
| 5054 | transformFeedbackObject->release(this); |
| 5055 | } |
| 5056 | |
| 5057 | mTransformFeedbackHandleAllocator.release(transformFeedback); |
| 5058 | } |
| 5059 | } |
| 5060 | } |
| 5061 | |
| 5062 | void Context::genTransformFeedbacks(GLsizei n, GLuint *ids) |
| 5063 | { |
| 5064 | for (int i = 0; i < n; i++) |
| 5065 | { |
| 5066 | GLuint transformFeedback = mTransformFeedbackHandleAllocator.allocate(); |
| 5067 | mTransformFeedbackMap.assign(transformFeedback, nullptr); |
| 5068 | ids[i] = transformFeedback; |
| 5069 | } |
| 5070 | } |
| 5071 | |
| 5072 | bool Context::isTransformFeedback(GLuint id) |
| 5073 | { |
| 5074 | if (id == 0) |
| 5075 | { |
| 5076 | // The 3.0.4 spec [section 6.1.11] states that if ID is zero, IsTransformFeedback |
| 5077 | // returns FALSE |
| 5078 | return GL_FALSE; |
| 5079 | } |
| 5080 | |
| 5081 | const TransformFeedback *transformFeedback = getTransformFeedback(id); |
| 5082 | return ((transformFeedback != nullptr) ? GL_TRUE : GL_FALSE); |
| 5083 | } |
| 5084 | |
| 5085 | void Context::pauseTransformFeedback() |
| 5086 | { |
| 5087 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
| 5088 | transformFeedback->pause(); |
| 5089 | } |
| 5090 | |
| 5091 | void Context::resumeTransformFeedback() |
| 5092 | { |
| 5093 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
| 5094 | transformFeedback->resume(); |
| 5095 | } |
| 5096 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame^] | 5097 | void Context::getUniformuiv(GLuint program, GLint location, GLuint *params) |
| 5098 | { |
| 5099 | const Program *programObject = getProgram(program); |
| 5100 | programObject->getUniformuiv(location, params); |
| 5101 | } |
| 5102 | |
| 5103 | GLint Context::getFragDataLocation(GLuint program, const GLchar *name) |
| 5104 | { |
| 5105 | const Program *programObject = getProgram(program); |
| 5106 | return programObject->getFragDataLocation(name); |
| 5107 | } |
| 5108 | |
| 5109 | void Context::getUniformIndices(GLuint program, |
| 5110 | GLsizei uniformCount, |
| 5111 | const GLchar *const *uniformNames, |
| 5112 | GLuint *uniformIndices) |
| 5113 | { |
| 5114 | const Program *programObject = getProgram(program); |
| 5115 | if (!programObject->isLinked()) |
| 5116 | { |
| 5117 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 5118 | { |
| 5119 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 5120 | } |
| 5121 | } |
| 5122 | else |
| 5123 | { |
| 5124 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 5125 | { |
| 5126 | uniformIndices[uniformId] = programObject->getUniformIndex(uniformNames[uniformId]); |
| 5127 | } |
| 5128 | } |
| 5129 | } |
| 5130 | |
| 5131 | void Context::getActiveUniformsiv(GLuint program, |
| 5132 | GLsizei uniformCount, |
| 5133 | const GLuint *uniformIndices, |
| 5134 | GLenum pname, |
| 5135 | GLint *params) |
| 5136 | { |
| 5137 | const Program *programObject = getProgram(program); |
| 5138 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 5139 | { |
| 5140 | const GLuint index = uniformIndices[uniformId]; |
| 5141 | params[uniformId] = programObject->getActiveUniformi(index, pname); |
| 5142 | } |
| 5143 | } |
| 5144 | |
| 5145 | GLuint Context::getUniformBlockIndex(GLuint program, const GLchar *uniformBlockName) |
| 5146 | { |
| 5147 | const Program *programObject = getProgram(program); |
| 5148 | return programObject->getUniformBlockIndex(uniformBlockName); |
| 5149 | } |
| 5150 | |
| 5151 | void Context::getActiveUniformBlockiv(GLuint program, |
| 5152 | GLuint uniformBlockIndex, |
| 5153 | GLenum pname, |
| 5154 | GLint *params) |
| 5155 | { |
| 5156 | const Program *programObject = getProgram(program); |
| 5157 | QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params); |
| 5158 | } |
| 5159 | |
| 5160 | void Context::getActiveUniformBlockName(GLuint program, |
| 5161 | GLuint uniformBlockIndex, |
| 5162 | GLsizei bufSize, |
| 5163 | GLsizei *length, |
| 5164 | GLchar *uniformBlockName) |
| 5165 | { |
| 5166 | const Program *programObject = getProgram(program); |
| 5167 | programObject->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 5168 | } |
| 5169 | |
| 5170 | void Context::uniformBlockBinding(GLuint program, |
| 5171 | GLuint uniformBlockIndex, |
| 5172 | GLuint uniformBlockBinding) |
| 5173 | { |
| 5174 | Program *programObject = getProgram(program); |
| 5175 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 5176 | } |
| 5177 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 5178 | } // namespace gl |