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