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