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" |
Markus Tavenrath | cb9609f | 2018-12-26 00:52:44 +0900 | [diff] [blame] | 11 | #include "libANGLE/Context.inl.h" |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 12 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 13 | #include <string.h> |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 14 | #include <iterator> |
| 15 | #include <sstream> |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 16 | #include <vector> |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 17 | |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 18 | #include "common/PackedEnums.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 19 | #include "common/matrix_utils.h" |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 20 | #include "common/platform.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 21 | #include "common/utilities.h" |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 22 | #include "common/version.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 23 | #include "libANGLE/Buffer.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 24 | #include "libANGLE/Compiler.h" |
Jamie Madill | 948bbe5 | 2017-06-01 13:10:42 -0400 | [diff] [blame] | 25 | #include "libANGLE/Display.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 26 | #include "libANGLE/Fence.h" |
| 27 | #include "libANGLE/Framebuffer.h" |
| 28 | #include "libANGLE/FramebufferAttachment.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 29 | #include "libANGLE/Path.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 30 | #include "libANGLE/Program.h" |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 31 | #include "libANGLE/ProgramPipeline.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 32 | #include "libANGLE/Query.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 33 | #include "libANGLE/Renderbuffer.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 34 | #include "libANGLE/ResourceManager.h" |
| 35 | #include "libANGLE/Sampler.h" |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 36 | #include "libANGLE/Surface.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 37 | #include "libANGLE/Texture.h" |
| 38 | #include "libANGLE/TransformFeedback.h" |
| 39 | #include "libANGLE/VertexArray.h" |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 40 | #include "libANGLE/Workarounds.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 41 | #include "libANGLE/formatutils.h" |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 42 | #include "libANGLE/queryconversions.h" |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 43 | #include "libANGLE/queryutils.h" |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 44 | #include "libANGLE/renderer/BufferImpl.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 45 | #include "libANGLE/renderer/EGLImplFactory.h" |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 46 | #include "libANGLE/renderer/Format.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 47 | #include "libANGLE/validationES.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 48 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 49 | namespace gl |
| 50 | { |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 51 | namespace |
| 52 | { |
| 53 | |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 54 | #define ANGLE_HANDLE_ERR(X) \ |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 55 | (void)(X); \ |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 56 | return; |
| 57 | #define ANGLE_CONTEXT_TRY(EXPR) ANGLE_TRY_TEMPLATE(EXPR, ANGLE_HANDLE_ERR); |
| 58 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 59 | template <typename T> |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 60 | std::vector<Path *> GatherPaths(PathManager &resourceManager, |
| 61 | GLsizei numPaths, |
| 62 | const void *paths, |
| 63 | GLuint pathBase) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 64 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 65 | std::vector<Path *> ret; |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 66 | ret.reserve(numPaths); |
| 67 | |
| 68 | const auto *nameArray = static_cast<const T *>(paths); |
| 69 | |
| 70 | for (GLsizei i = 0; i < numPaths; ++i) |
| 71 | { |
| 72 | const GLuint pathName = nameArray[i] + pathBase; |
| 73 | |
| 74 | ret.push_back(resourceManager.getPath(pathName)); |
| 75 | } |
| 76 | |
| 77 | return ret; |
| 78 | } |
| 79 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 80 | std::vector<Path *> GatherPaths(PathManager &resourceManager, |
| 81 | GLsizei numPaths, |
| 82 | GLenum pathNameType, |
| 83 | const void *paths, |
| 84 | GLuint pathBase) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 85 | { |
| 86 | switch (pathNameType) |
| 87 | { |
| 88 | case GL_UNSIGNED_BYTE: |
| 89 | return GatherPaths<GLubyte>(resourceManager, numPaths, paths, pathBase); |
| 90 | |
| 91 | case GL_BYTE: |
| 92 | return GatherPaths<GLbyte>(resourceManager, numPaths, paths, pathBase); |
| 93 | |
| 94 | case GL_UNSIGNED_SHORT: |
| 95 | return GatherPaths<GLushort>(resourceManager, numPaths, paths, pathBase); |
| 96 | |
| 97 | case GL_SHORT: |
| 98 | return GatherPaths<GLshort>(resourceManager, numPaths, paths, pathBase); |
| 99 | |
| 100 | case GL_UNSIGNED_INT: |
| 101 | return GatherPaths<GLuint>(resourceManager, numPaths, paths, pathBase); |
| 102 | |
| 103 | case GL_INT: |
| 104 | return GatherPaths<GLint>(resourceManager, numPaths, paths, pathBase); |
| 105 | } |
| 106 | |
| 107 | UNREACHABLE(); |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 108 | return std::vector<Path *>(); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | template <typename T> |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 112 | angle::Result GetQueryObjectParameter(const Context *context, Query *query, GLenum pname, T *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 113 | { |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 114 | ASSERT(query != nullptr); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 115 | |
| 116 | switch (pname) |
| 117 | { |
| 118 | case GL_QUERY_RESULT_EXT: |
Jamie Madill | 5188a27 | 2018-07-25 10:53:56 -0400 | [diff] [blame] | 119 | return query->getResult(context, params); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 120 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 121 | { |
| 122 | bool available; |
Jamie Madill | 666818e | 2018-11-14 09:54:33 -0500 | [diff] [blame] | 123 | ANGLE_TRY(query->isResultAvailable(context, &available)); |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 124 | *params = CastFromStateValue<T>(pname, static_cast<GLuint>(available)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 125 | return angle::Result::Continue; |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 126 | } |
| 127 | default: |
| 128 | UNREACHABLE(); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 129 | return angle::Result::Stop; |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 130 | } |
| 131 | } |
| 132 | |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 133 | // Attribute map queries. |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 134 | EGLint GetClientMajorVersion(const egl::AttributeMap &attribs) |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 135 | { |
Ian Ewell | ec2c0c5 | 2016-04-05 13:46:26 -0400 | [diff] [blame] | 136 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1)); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 137 | } |
| 138 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 139 | EGLint GetClientMinorVersion(const egl::AttributeMap &attribs) |
| 140 | { |
| 141 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0)); |
| 142 | } |
| 143 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 144 | Version GetClientVersion(const egl::AttributeMap &attribs) |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 145 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 146 | return Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs)); |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 147 | } |
| 148 | |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 149 | GLenum GetResetStrategy(const egl::AttributeMap &attribs) |
| 150 | { |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 151 | EGLAttrib attrib = |
| 152 | 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] | 153 | switch (attrib) |
| 154 | { |
| 155 | case EGL_NO_RESET_NOTIFICATION: |
| 156 | return GL_NO_RESET_NOTIFICATION_EXT; |
| 157 | case EGL_LOSE_CONTEXT_ON_RESET: |
| 158 | return GL_LOSE_CONTEXT_ON_RESET_EXT; |
| 159 | default: |
| 160 | UNREACHABLE(); |
| 161 | return GL_NONE; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | bool GetRobustAccess(const egl::AttributeMap &attribs) |
| 166 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 167 | return (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE) || |
| 168 | ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) != |
| 169 | 0); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | bool GetDebug(const egl::AttributeMap &attribs) |
| 173 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 174 | return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE) || |
| 175 | ((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] | 176 | } |
| 177 | |
| 178 | bool GetNoError(const egl::AttributeMap &attribs) |
| 179 | { |
| 180 | return (attribs.get(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, EGL_FALSE) == EGL_TRUE); |
| 181 | } |
| 182 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 183 | bool GetWebGLContext(const egl::AttributeMap &attribs) |
| 184 | { |
Jamie Madill | 4230d48 | 2018-09-14 10:14:45 -0400 | [diff] [blame] | 185 | return (attribs.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) == EGL_TRUE); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 186 | } |
| 187 | |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 188 | bool GetExtensionsEnabled(const egl::AttributeMap &attribs, bool webGLContext) |
| 189 | { |
| 190 | // If the context is WebGL, extensions are disabled by default |
| 191 | EGLAttrib defaultValue = webGLContext ? EGL_FALSE : EGL_TRUE; |
| 192 | return (attribs.get(EGL_EXTENSIONS_ENABLED_ANGLE, defaultValue) == EGL_TRUE); |
| 193 | } |
| 194 | |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 195 | bool GetBindGeneratesResource(const egl::AttributeMap &attribs) |
| 196 | { |
Jamie Madill | 4230d48 | 2018-09-14 10:14:45 -0400 | [diff] [blame] | 197 | return (attribs.get(EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM, EGL_TRUE) == EGL_TRUE); |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 198 | } |
| 199 | |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 200 | bool GetClientArraysEnabled(const egl::AttributeMap &attribs) |
| 201 | { |
| 202 | return (attribs.get(EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE, EGL_TRUE) == EGL_TRUE); |
| 203 | } |
| 204 | |
Geoff Lang | b433e87 | 2017-10-05 14:01:47 -0400 | [diff] [blame] | 205 | bool GetRobustResourceInit(const egl::AttributeMap &attribs) |
| 206 | { |
| 207 | return (attribs.get(EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE, EGL_FALSE) == EGL_TRUE); |
| 208 | } |
| 209 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 210 | std::string GetObjectLabelFromPointer(GLsizei length, const GLchar *label) |
| 211 | { |
| 212 | std::string labelName; |
| 213 | if (label != nullptr) |
| 214 | { |
| 215 | size_t labelLength = length < 0 ? strlen(label) : length; |
| 216 | labelName = std::string(label, labelLength); |
| 217 | } |
| 218 | return labelName; |
| 219 | } |
| 220 | |
| 221 | void GetObjectLabelBase(const std::string &objectLabel, |
| 222 | GLsizei bufSize, |
| 223 | GLsizei *length, |
| 224 | GLchar *label) |
| 225 | { |
| 226 | size_t writeLength = objectLabel.length(); |
| 227 | if (label != nullptr && bufSize > 0) |
| 228 | { |
| 229 | writeLength = std::min(static_cast<size_t>(bufSize) - 1, objectLabel.length()); |
| 230 | std::copy(objectLabel.begin(), objectLabel.begin() + writeLength, label); |
| 231 | label[writeLength] = '\0'; |
| 232 | } |
| 233 | |
| 234 | if (length != nullptr) |
| 235 | { |
| 236 | *length = static_cast<GLsizei>(writeLength); |
| 237 | } |
| 238 | } |
| 239 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 240 | template <typename CapT, typename MaxT> |
| 241 | void LimitCap(CapT *cap, MaxT maximum) |
| 242 | { |
| 243 | *cap = std::min(*cap, static_cast<CapT>(maximum)); |
| 244 | } |
| 245 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 246 | // The rest default to false. |
| 247 | constexpr angle::PackedEnumMap<PrimitiveMode, bool, angle::EnumSize<PrimitiveMode>() + 1> |
| 248 | kValidBasicDrawModes = {{ |
| 249 | {PrimitiveMode::Points, true}, |
| 250 | {PrimitiveMode::Lines, true}, |
| 251 | {PrimitiveMode::LineLoop, true}, |
| 252 | {PrimitiveMode::LineStrip, true}, |
| 253 | {PrimitiveMode::Triangles, true}, |
| 254 | {PrimitiveMode::TriangleStrip, true}, |
| 255 | {PrimitiveMode::TriangleFan, true}, |
| 256 | }}; |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 257 | |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 258 | enum SubjectIndexes : angle::SubjectIndex |
| 259 | { |
| 260 | kTexture0SubjectIndex = 0, |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 261 | kTextureMaxSubjectIndex = kTexture0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES, |
Qin Jiajia | 3f01f53 | 2018-12-11 15:13:51 +0800 | [diff] [blame] | 262 | kUniformBuffer0SubjectIndex = kTextureMaxSubjectIndex, |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 263 | kUniformBufferMaxSubjectIndex = |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 264 | kUniformBuffer0SubjectIndex + IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS, |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 265 | kSampler0SubjectIndex = kUniformBufferMaxSubjectIndex, |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 266 | kSamplerMaxSubjectIndex = kSampler0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES, |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 267 | kVertexArraySubjectIndex = kSamplerMaxSubjectIndex, |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 268 | kReadFramebufferSubjectIndex, |
| 269 | kDrawFramebufferSubjectIndex |
| 270 | }; |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 271 | } // anonymous namespace |
| 272 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 273 | Context::Context(rx::EGLImplFactory *implFactory, |
| 274 | const egl::Config *config, |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 275 | const Context *shareContext, |
Geoff Lang | ce02f08 | 2017-02-06 16:46:21 -0500 | [diff] [blame] | 276 | TextureManager *shareTextures, |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 277 | MemoryProgramCache *memoryProgramCache, |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 278 | const egl::AttributeMap &attribs, |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 279 | const egl::DisplayExtensions &displayExtensions, |
| 280 | const egl::ClientExtensions &clientExtensions) |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 281 | : mState(reinterpret_cast<ContextID>(this), |
| 282 | shareContext ? &shareContext->mState : nullptr, |
| 283 | shareTextures, |
| 284 | GetClientVersion(attribs), |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 285 | GetDebug(attribs), |
| 286 | GetBindGeneratesResource(attribs), |
| 287 | GetClientArraysEnabled(attribs), |
| 288 | GetRobustResourceInit(attribs), |
| 289 | memoryProgramCache != nullptr), |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 290 | mSkipValidation(GetNoError(attribs)), |
| 291 | mDisplayTextureShareGroup(shareTextures != nullptr), |
Jamie Madill | 0c66721 | 2019-01-01 14:40:36 -0500 | [diff] [blame] | 292 | mErrors(this), |
| 293 | mImplementation(implFactory->createContext(mState, &mErrors, config, shareContext, attribs)), |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 294 | mLabel(nullptr), |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 295 | mCompiler(), |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 296 | mConfig(config), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 297 | mClientType(EGL_OPENGL_ES_API), |
| 298 | mHasBeenCurrent(false), |
| 299 | mContextLost(false), |
| 300 | mResetStatus(GL_NO_ERROR), |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 301 | mContextLostForced(false), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 302 | mResetStrategy(GetResetStrategy(attribs)), |
| 303 | mRobustAccess(GetRobustAccess(attribs)), |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 304 | mSurfacelessSupported(displayExtensions.surfacelessContext), |
| 305 | mExplicitContextAvailable(clientExtensions.explicitContext), |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 306 | mCurrentSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)), |
| 307 | mCurrentDisplay(static_cast<egl::Display *>(EGL_NO_DISPLAY)), |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 308 | mWebGLContext(GetWebGLContext(attribs)), |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 309 | mExtensionsEnabled(GetExtensionsEnabled(attribs, mWebGLContext)), |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 310 | mMemoryProgramCache(memoryProgramCache), |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 311 | mVertexArrayObserverBinding(this, kVertexArraySubjectIndex), |
| 312 | mDrawFramebufferObserverBinding(this, kDrawFramebufferSubjectIndex), |
| 313 | mReadFramebufferObserverBinding(this, kReadFramebufferSubjectIndex), |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 314 | mScratchBuffer(1000u), |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 315 | mZeroFilledBuffer(1000u), |
| 316 | mThreadPool(nullptr) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 317 | { |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 318 | for (angle::SubjectIndex uboIndex = kUniformBuffer0SubjectIndex; |
| 319 | uboIndex < kUniformBufferMaxSubjectIndex; ++uboIndex) |
| 320 | { |
| 321 | mUniformBufferObserverBindings.emplace_back(this, uboIndex); |
| 322 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 323 | |
| 324 | for (angle::SubjectIndex samplerIndex = kSampler0SubjectIndex; |
| 325 | samplerIndex < kSamplerMaxSubjectIndex; ++samplerIndex) |
| 326 | { |
| 327 | mSamplerObserverBindings.emplace_back(this, samplerIndex); |
| 328 | } |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 329 | } |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 330 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 331 | void Context::initialize() |
| 332 | { |
| 333 | mImplementation->setMemoryProgramCache(mMemoryProgramCache); |
Jamie Madill | 14bbb3f | 2017-09-12 15:23:01 -0400 | [diff] [blame] | 334 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 335 | initCaps(); |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 336 | initWorkarounds(); |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 337 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 338 | mState.initialize(this); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 339 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 340 | mFenceNVHandleAllocator.setBaseHandle(0); |
Geoff Lang | 7dca186 | 2013-07-30 16:30:46 -0400 | [diff] [blame] | 341 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 342 | // [OpenGL ES 2.0.24] section 3.7 page 83: |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 343 | // 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] | 344 | // and cube map texture state vectors respectively associated with them. |
| 345 | // In order that access to these initial textures not be lost, they are treated as texture |
| 346 | // objects all of whose names are 0. |
| 347 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 348 | Texture *zeroTexture2D = new Texture(mImplementation.get(), 0, TextureType::_2D); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 349 | mZeroTextures[TextureType::_2D].set(this, zeroTexture2D); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 350 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 351 | Texture *zeroTextureCube = new Texture(mImplementation.get(), 0, TextureType::CubeMap); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 352 | mZeroTextures[TextureType::CubeMap].set(this, zeroTextureCube); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 353 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 354 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 355 | { |
| 356 | // TODO: These could also be enabled via extension |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 357 | Texture *zeroTexture3D = new Texture(mImplementation.get(), 0, TextureType::_3D); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 358 | mZeroTextures[TextureType::_3D].set(this, zeroTexture3D); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 359 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 360 | Texture *zeroTexture2DArray = new Texture(mImplementation.get(), 0, TextureType::_2DArray); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 361 | mZeroTextures[TextureType::_2DArray].set(this, zeroTexture2DArray); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 362 | } |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 363 | if (getClientVersion() >= Version(3, 1) || mSupportedExtensions.textureMultisample) |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 364 | { |
| 365 | Texture *zeroTexture2DMultisample = |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 366 | new Texture(mImplementation.get(), 0, TextureType::_2DMultisample); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 367 | mZeroTextures[TextureType::_2DMultisample].set(this, zeroTexture2DMultisample); |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 368 | } |
| 369 | if (getClientVersion() >= Version(3, 1)) |
| 370 | { |
Olli Etuaho | d310a43 | 2018-08-24 15:40:23 +0300 | [diff] [blame] | 371 | Texture *zeroTexture2DMultisampleArray = |
| 372 | new Texture(mImplementation.get(), 0, TextureType::_2DMultisampleArray); |
| 373 | mZeroTextures[TextureType::_2DMultisampleArray].set(this, zeroTexture2DMultisampleArray); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 374 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 375 | for (unsigned int i = 0; i < mState.mCaps.maxAtomicCounterBufferBindings; i++) |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 376 | { |
Qin Jiajia | 339f65b | 2018-02-27 12:52:48 +0800 | [diff] [blame] | 377 | bindBufferRange(BufferBinding::AtomicCounter, i, 0, 0, 0); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 378 | } |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 379 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 380 | for (unsigned int i = 0; i < mState.mCaps.maxShaderStorageBufferBindings; i++) |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 381 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 382 | bindBufferRange(BufferBinding::ShaderStorage, i, 0, 0, 0); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 383 | } |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 384 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 385 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 386 | if (mSupportedExtensions.textureRectangle) |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 387 | { |
| 388 | Texture *zeroTextureRectangle = |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 389 | new Texture(mImplementation.get(), 0, TextureType::Rectangle); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 390 | mZeroTextures[TextureType::Rectangle].set(this, zeroTextureRectangle); |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 391 | } |
| 392 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 393 | if (mSupportedExtensions.eglImageExternal || mSupportedExtensions.eglStreamConsumerExternal) |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 394 | { |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 395 | Texture *zeroTextureExternal = new Texture(mImplementation.get(), 0, TextureType::External); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 396 | mZeroTextures[TextureType::External].set(this, zeroTextureExternal); |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 397 | } |
| 398 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 399 | mState.initializeZeroTextures(this, mZeroTextures); |
Jamie Madill | e6382c3 | 2014-11-07 15:05:26 -0500 | [diff] [blame] | 400 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 401 | bindVertexArray(0); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 402 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 403 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 404 | { |
| 405 | // [OpenGL ES 3.0.2] section 2.14.1 pg 85: |
| 406 | // In the initial state, a default transform feedback object is bound and treated as |
| 407 | // a transform feedback object with a name of zero. That object is bound any time |
| 408 | // BindTransformFeedback is called with id of zero |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 409 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 410 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 411 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 412 | for (auto type : angle::AllEnums<BufferBinding>()) |
| 413 | { |
| 414 | bindBuffer(type, 0); |
| 415 | } |
| 416 | |
| 417 | bindRenderbuffer(GL_RENDERBUFFER, 0); |
| 418 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 419 | for (unsigned int i = 0; i < mState.mCaps.maxUniformBufferBindings; i++) |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 420 | { |
| 421 | bindBufferRange(BufferBinding::Uniform, i, 0, 0, -1); |
| 422 | } |
| 423 | |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 424 | // Initialize GLES1 renderer if appropriate. |
| 425 | if (getClientVersion() < Version(2, 0)) |
| 426 | { |
| 427 | mGLES1Renderer.reset(new GLES1Renderer()); |
| 428 | } |
| 429 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 430 | // Initialize dirty bit masks |
Jamie Madill | 9d0bb3d | 2018-10-09 20:29:13 -0400 | [diff] [blame] | 431 | mAllDirtyBits.set(); |
| 432 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 433 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 434 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 435 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 436 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 437 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 438 | |
| 439 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 440 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 441 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 442 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 443 | |
Jamie Madill | c67323a | 2017-11-02 23:11:41 -0400 | [diff] [blame] | 444 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_STATE); |
Corentin Wallez | 29a2099 | 2017-11-06 18:23:16 -0500 | [diff] [blame] | 445 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_BUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 446 | // No dirty objects. |
| 447 | |
| 448 | // Readpixels uses the pack state and read FBO |
Jamie Madill | c67323a | 2017-11-02 23:11:41 -0400 | [diff] [blame] | 449 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_STATE); |
Corentin Wallez | 29a2099 | 2017-11-06 18:23:16 -0500 | [diff] [blame] | 450 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_BUFFER_BINDING); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 451 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 452 | mReadPixelsDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 453 | |
| 454 | mClearDirtyBits.set(State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED); |
| 455 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 456 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
| 457 | mClearDirtyBits.set(State::DIRTY_BIT_VIEWPORT); |
| 458 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_COLOR); |
| 459 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_DEPTH); |
| 460 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_STENCIL); |
| 461 | mClearDirtyBits.set(State::DIRTY_BIT_COLOR_MASK); |
| 462 | mClearDirtyBits.set(State::DIRTY_BIT_DEPTH_MASK); |
| 463 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT); |
| 464 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_BACK); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 465 | mClearDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 466 | mClearDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 467 | |
| 468 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 469 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 470 | mBlitDirtyBits.set(State::DIRTY_BIT_FRAMEBUFFER_SRGB); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 471 | mBlitDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 472 | mBlitDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 473 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 474 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 475 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 476 | mComputeDirtyBits.set(State::DIRTY_BIT_SHADER_STORAGE_BUFFER_BINDING); |
jchen10 | 99118c1 | 2018-09-10 16:28:51 +0800 | [diff] [blame] | 477 | mComputeDirtyBits.set(State::DIRTY_BIT_UNIFORM_BUFFER_BINDINGS); |
| 478 | mComputeDirtyBits.set(State::DIRTY_BIT_ATOMIC_COUNTER_BUFFER_BINDING); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 479 | mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_BINDING); |
| 480 | mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_EXECUTABLE); |
| 481 | mComputeDirtyBits.set(State::DIRTY_BIT_TEXTURE_BINDINGS); |
| 482 | mComputeDirtyBits.set(State::DIRTY_BIT_SAMPLER_BINDINGS); |
jchen10 | 99118c1 | 2018-09-10 16:28:51 +0800 | [diff] [blame] | 483 | mComputeDirtyBits.set(State::DIRTY_BIT_IMAGE_BINDINGS); |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 484 | mComputeDirtyBits.set(State::DIRTY_BIT_DISPATCH_INDIRECT_BUFFER_BINDING); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 485 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 486 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 487 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 488 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 489 | ANGLE_CONTEXT_TRY(mImplementation->initialize()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 490 | } |
| 491 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 492 | egl::Error Context::onDestroy(const egl::Display *display) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 493 | { |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 494 | if (mGLES1Renderer) |
| 495 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 496 | mGLES1Renderer->onDestroy(this, &mState); |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 497 | } |
| 498 | |
Jamie Madill | e7b3fe2 | 2018-04-05 09:42:46 -0400 | [diff] [blame] | 499 | ANGLE_TRY(releaseSurface(display)); |
| 500 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 501 | for (auto fence : mFenceNVMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 502 | { |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 503 | SafeDelete(fence.second); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 504 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 505 | mFenceNVMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 506 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 507 | for (auto query : mQueryMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 508 | { |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 509 | if (query.second != nullptr) |
| 510 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 511 | query.second->release(this); |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 512 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 513 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 514 | mQueryMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 515 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 516 | for (auto vertexArray : mVertexArrayMap) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 517 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 518 | if (vertexArray.second) |
| 519 | { |
| 520 | vertexArray.second->onDestroy(this); |
| 521 | } |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 522 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 523 | mVertexArrayMap.clear(); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 524 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 525 | for (auto transformFeedback : mTransformFeedbackMap) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 526 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 527 | if (transformFeedback.second != nullptr) |
| 528 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 529 | transformFeedback.second->release(this); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 530 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 531 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 532 | mTransformFeedbackMap.clear(); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 533 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 534 | for (BindingPointer<Texture> &zeroTexture : mZeroTextures) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 535 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 536 | if (zeroTexture.get() != nullptr) |
| 537 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 538 | zeroTexture.set(this, nullptr); |
| 539 | } |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 540 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 541 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 542 | releaseShaderCompiler(); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 543 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 544 | mState.reset(this); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 545 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 546 | mState.mBufferManager->release(this); |
| 547 | mState.mShaderProgramManager->release(this); |
| 548 | mState.mTextureManager->release(this); |
| 549 | mState.mRenderbufferManager->release(this); |
| 550 | mState.mSamplerManager->release(this); |
| 551 | mState.mSyncManager->release(this); |
| 552 | mState.mPathManager->release(this); |
| 553 | mState.mFramebufferManager->release(this); |
| 554 | mState.mProgramPipelineManager->release(this); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 555 | |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 556 | mThreadPool.reset(); |
| 557 | |
Jamie Madill | 76e471e | 2017-10-21 09:56:01 -0400 | [diff] [blame] | 558 | mImplementation->onDestroy(this); |
| 559 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 560 | return egl::NoError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 561 | } |
| 562 | |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 563 | Context::~Context() {} |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 564 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 565 | void Context::setLabel(EGLLabelKHR label) |
| 566 | { |
| 567 | mLabel = label; |
| 568 | } |
| 569 | |
| 570 | EGLLabelKHR Context::getLabel() const |
| 571 | { |
| 572 | return mLabel; |
| 573 | } |
| 574 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 575 | egl::Error Context::makeCurrent(egl::Display *display, egl::Surface *surface) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 576 | { |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 577 | mCurrentDisplay = display; |
| 578 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 579 | if (!mHasBeenCurrent) |
| 580 | { |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 581 | initialize(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 582 | initRendererString(); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 583 | initVersionStrings(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 584 | initExtensionStrings(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 585 | |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 586 | int width = 0; |
| 587 | int height = 0; |
| 588 | if (surface != nullptr) |
| 589 | { |
| 590 | width = surface->getWidth(); |
| 591 | height = surface->getHeight(); |
| 592 | } |
| 593 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 594 | mState.setViewportParams(0, 0, width, height); |
| 595 | mState.setScissorParams(0, 0, width, height); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 596 | |
| 597 | mHasBeenCurrent = true; |
| 598 | } |
| 599 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 600 | // TODO(jmadill): Rework this when we support ContextImpl |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 601 | mState.setAllDirtyBits(); |
| 602 | mState.setAllDirtyObjects(); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 603 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 604 | ANGLE_TRY(releaseSurface(display)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 605 | |
| 606 | Framebuffer *newDefault = nullptr; |
| 607 | if (surface != nullptr) |
| 608 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 609 | ANGLE_TRY(surface->setIsCurrent(this, true)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 610 | mCurrentSurface = surface; |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 611 | newDefault = surface->createDefaultFramebuffer(this); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 612 | } |
| 613 | else |
| 614 | { |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 615 | newDefault = new Framebuffer(mImplementation.get()); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 616 | } |
Jamie Madill | 18fdcbc | 2015-08-19 18:12:44 +0000 | [diff] [blame] | 617 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 618 | // Update default framebuffer, the binding of the previous default |
| 619 | // framebuffer (or lack of) will have a nullptr. |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 620 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 621 | mState.mFramebufferManager->setDefaultFramebuffer(newDefault); |
| 622 | if (mState.getReadFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 623 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 624 | bindReadFramebuffer(0); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 625 | } |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 626 | if (mState.getDrawFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 627 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 628 | bindDrawFramebuffer(0); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 629 | } |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 630 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 631 | |
Jamie Madill | 32643ce | 2018-10-19 11:38:03 -0400 | [diff] [blame] | 632 | // Notify the renderer of a context switch. |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 633 | return angle::ResultToEGL(mImplementation->onMakeCurrent(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 634 | } |
| 635 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 636 | egl::Error Context::releaseSurface(const egl::Display *display) |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 637 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 638 | gl::Framebuffer *defaultFramebuffer = mState.mFramebufferManager->getFramebuffer(0); |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 639 | |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 640 | // Remove the default framebuffer |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 641 | if (mState.getReadFramebuffer() == defaultFramebuffer) |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 642 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 643 | mState.setReadFramebufferBinding(nullptr); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 644 | mReadFramebufferObserverBinding.bind(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 645 | } |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 646 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 647 | if (mState.getDrawFramebuffer() == defaultFramebuffer) |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 648 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 649 | mState.setDrawFramebufferBinding(nullptr); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 650 | mDrawFramebufferObserverBinding.bind(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 651 | } |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 652 | |
| 653 | if (defaultFramebuffer) |
| 654 | { |
| 655 | defaultFramebuffer->onDestroy(this); |
| 656 | delete defaultFramebuffer; |
| 657 | } |
| 658 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 659 | mState.mFramebufferManager->setDefaultFramebuffer(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 660 | |
| 661 | if (mCurrentSurface) |
| 662 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 663 | ANGLE_TRY(mCurrentSurface->setIsCurrent(this, false)); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 664 | mCurrentSurface = nullptr; |
| 665 | } |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 666 | |
| 667 | return egl::NoError(); |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 668 | } |
| 669 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 670 | GLuint Context::createBuffer() |
| 671 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 672 | return mState.mBufferManager->createBuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | GLuint Context::createProgram() |
| 676 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 677 | return mState.mShaderProgramManager->createProgram(mImplementation.get()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 678 | } |
| 679 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 680 | GLuint Context::createShader(ShaderType type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 681 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 682 | return mState.mShaderProgramManager->createShader(mImplementation.get(), mState.mLimitations, |
| 683 | type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | GLuint Context::createTexture() |
| 687 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 688 | return mState.mTextureManager->createTexture(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 689 | } |
| 690 | |
| 691 | GLuint Context::createRenderbuffer() |
| 692 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 693 | return mState.mRenderbufferManager->createRenderbuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 694 | } |
| 695 | |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 696 | void Context::tryGenPaths(GLsizei range, GLuint *createdOut) |
| 697 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 698 | ANGLE_CONTEXT_TRY(mState.mPathManager->createPaths(this, range, createdOut)); |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 699 | } |
| 700 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 701 | GLuint Context::genPaths(GLsizei range) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 702 | { |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 703 | GLuint created = 0; |
| 704 | tryGenPaths(range, &created); |
| 705 | return created; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 706 | } |
| 707 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 708 | // Returns an unused framebuffer name |
| 709 | GLuint Context::createFramebuffer() |
| 710 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 711 | return mState.mFramebufferManager->createFramebuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 712 | } |
| 713 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 714 | void Context::genFencesNV(GLsizei n, GLuint *fences) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 715 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 716 | for (int i = 0; i < n; i++) |
| 717 | { |
| 718 | GLuint handle = mFenceNVHandleAllocator.allocate(); |
| 719 | mFenceNVMap.assign(handle, new FenceNV(mImplementation->createFenceNV())); |
| 720 | fences[i] = handle; |
| 721 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 722 | } |
| 723 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 724 | GLuint Context::createProgramPipeline() |
| 725 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 726 | return mState.mProgramPipelineManager->createProgramPipeline(); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 727 | } |
| 728 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 729 | GLuint Context::createShaderProgramv(ShaderType type, GLsizei count, const GLchar *const *strings) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 730 | { |
| 731 | UNIMPLEMENTED(); |
| 732 | return 0u; |
| 733 | } |
| 734 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 735 | void Context::deleteBuffer(GLuint bufferName) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 736 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 737 | Buffer *buffer = mState.mBufferManager->getBuffer(bufferName); |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 738 | if (buffer) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 739 | { |
| 740 | detachBuffer(buffer); |
| 741 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 742 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 743 | mState.mBufferManager->deleteObject(this, bufferName); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | void Context::deleteShader(GLuint shader) |
| 747 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 748 | mState.mShaderProgramManager->deleteShader(this, shader); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | void Context::deleteProgram(GLuint program) |
| 752 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 753 | mState.mShaderProgramManager->deleteProgram(this, program); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | void Context::deleteTexture(GLuint texture) |
| 757 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 758 | if (mState.mTextureManager->getTexture(texture)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 759 | { |
| 760 | detachTexture(texture); |
| 761 | } |
| 762 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 763 | mState.mTextureManager->deleteObject(this, texture); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | void Context::deleteRenderbuffer(GLuint renderbuffer) |
| 767 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 768 | if (mState.mRenderbufferManager->getRenderbuffer(renderbuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 769 | { |
| 770 | detachRenderbuffer(renderbuffer); |
| 771 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 772 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 773 | mState.mRenderbufferManager->deleteObject(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 774 | } |
| 775 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 776 | void Context::deleteSync(GLsync sync) |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 777 | { |
| 778 | // The spec specifies the underlying Fence object is not deleted until all current |
| 779 | // wait commands finish. However, since the name becomes invalid, we cannot query the fence, |
| 780 | // and since our API is currently designed for being called from a single thread, we can delete |
| 781 | // the fence immediately. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 782 | mState.mSyncManager->deleteObject(this, static_cast<GLuint>(reinterpret_cast<uintptr_t>(sync))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 783 | } |
| 784 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 785 | void Context::deleteProgramPipeline(GLuint pipeline) |
| 786 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 787 | if (mState.mProgramPipelineManager->getProgramPipeline(pipeline)) |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 788 | { |
| 789 | detachProgramPipeline(pipeline); |
| 790 | } |
| 791 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 792 | mState.mProgramPipelineManager->deleteObject(this, pipeline); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 793 | } |
| 794 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 795 | void Context::deletePaths(GLuint first, GLsizei range) |
| 796 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 797 | mState.mPathManager->deletePaths(first, range); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 798 | } |
| 799 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 800 | bool Context::isPath(GLuint path) const |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 801 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 802 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 803 | if (pathObj == nullptr) |
| 804 | return false; |
| 805 | |
| 806 | return pathObj->hasPathData(); |
| 807 | } |
| 808 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 809 | bool Context::isPathGenerated(GLuint path) const |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 810 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 811 | return mState.mPathManager->hasPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 812 | } |
| 813 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 814 | void Context::pathCommands(GLuint path, |
| 815 | GLsizei numCommands, |
| 816 | const GLubyte *commands, |
| 817 | GLsizei numCoords, |
| 818 | GLenum coordType, |
| 819 | const void *coords) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 820 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 821 | auto *pathObject = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 822 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 823 | ANGLE_CONTEXT_TRY(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords)); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 824 | } |
| 825 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 826 | void Context::pathParameterf(GLuint path, GLenum pname, GLfloat value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 827 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 828 | Path *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 829 | |
| 830 | switch (pname) |
| 831 | { |
| 832 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 833 | pathObj->setStrokeWidth(value); |
| 834 | break; |
| 835 | case GL_PATH_END_CAPS_CHROMIUM: |
| 836 | pathObj->setEndCaps(static_cast<GLenum>(value)); |
| 837 | break; |
| 838 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 839 | pathObj->setJoinStyle(static_cast<GLenum>(value)); |
| 840 | break; |
| 841 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 842 | pathObj->setMiterLimit(value); |
| 843 | break; |
| 844 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 845 | pathObj->setStrokeBound(value); |
| 846 | break; |
| 847 | default: |
| 848 | UNREACHABLE(); |
| 849 | break; |
| 850 | } |
| 851 | } |
| 852 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 853 | void Context::pathParameteri(GLuint path, GLenum pname, GLint value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 854 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 855 | // TODO(jmadill): Should use proper clamping/casting. |
| 856 | pathParameterf(path, pname, static_cast<GLfloat>(value)); |
| 857 | } |
| 858 | |
| 859 | void Context::getPathParameterfv(GLuint path, GLenum pname, GLfloat *value) |
| 860 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 861 | const Path *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 862 | |
| 863 | switch (pname) |
| 864 | { |
| 865 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 866 | *value = pathObj->getStrokeWidth(); |
| 867 | break; |
| 868 | case GL_PATH_END_CAPS_CHROMIUM: |
| 869 | *value = static_cast<GLfloat>(pathObj->getEndCaps()); |
| 870 | break; |
| 871 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 872 | *value = static_cast<GLfloat>(pathObj->getJoinStyle()); |
| 873 | break; |
| 874 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 875 | *value = pathObj->getMiterLimit(); |
| 876 | break; |
| 877 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 878 | *value = pathObj->getStrokeBound(); |
| 879 | break; |
| 880 | default: |
| 881 | UNREACHABLE(); |
| 882 | break; |
| 883 | } |
| 884 | } |
| 885 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 886 | void Context::getPathParameteriv(GLuint path, GLenum pname, GLint *value) |
| 887 | { |
| 888 | GLfloat val = 0.0f; |
| 889 | getPathParameterfv(path, pname, value != nullptr ? &val : nullptr); |
| 890 | if (value) |
| 891 | *value = static_cast<GLint>(val); |
| 892 | } |
| 893 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 894 | void Context::pathStencilFunc(GLenum func, GLint ref, GLuint mask) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 895 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 896 | mState.setPathStencilFunc(func, ref, mask); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 897 | } |
| 898 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 899 | void Context::deleteFramebuffer(GLuint framebuffer) |
| 900 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 901 | if (mState.mFramebufferManager->getFramebuffer(framebuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 902 | { |
| 903 | detachFramebuffer(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 904 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 905 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 906 | mState.mFramebufferManager->deleteObject(this, framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 907 | } |
| 908 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 909 | void Context::deleteFencesNV(GLsizei n, const GLuint *fences) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 910 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 911 | for (int i = 0; i < n; i++) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 912 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 913 | GLuint fence = fences[i]; |
| 914 | |
| 915 | FenceNV *fenceObject = nullptr; |
| 916 | if (mFenceNVMap.erase(fence, &fenceObject)) |
| 917 | { |
| 918 | mFenceNVHandleAllocator.release(fence); |
| 919 | delete fenceObject; |
| 920 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 921 | } |
| 922 | } |
| 923 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 924 | Buffer *Context::getBuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 925 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 926 | return mState.mBufferManager->getBuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 927 | } |
| 928 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 929 | Renderbuffer *Context::getRenderbuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 930 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 931 | return mState.mRenderbufferManager->getRenderbuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 932 | } |
| 933 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 934 | Sync *Context::getSync(GLsync handle) const |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 935 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 936 | return mState.mSyncManager->getSync(static_cast<GLuint>(reinterpret_cast<uintptr_t>(handle))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 937 | } |
| 938 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 939 | VertexArray *Context::getVertexArray(GLuint handle) const |
| 940 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 941 | return mVertexArrayMap.query(handle); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 942 | } |
| 943 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 944 | Sampler *Context::getSampler(GLuint handle) const |
| 945 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 946 | return mState.mSamplerManager->getSampler(handle); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 947 | } |
| 948 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 949 | TransformFeedback *Context::getTransformFeedback(GLuint handle) const |
| 950 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 951 | return mTransformFeedbackMap.query(handle); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 952 | } |
| 953 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 954 | ProgramPipeline *Context::getProgramPipeline(GLuint handle) const |
| 955 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 956 | return mState.mProgramPipelineManager->getProgramPipeline(handle); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 957 | } |
| 958 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 959 | gl::LabeledObject *Context::getLabeledObject(GLenum identifier, GLuint name) const |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 960 | { |
| 961 | switch (identifier) |
| 962 | { |
| 963 | case GL_BUFFER: |
| 964 | return getBuffer(name); |
| 965 | case GL_SHADER: |
| 966 | return getShader(name); |
| 967 | case GL_PROGRAM: |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 968 | return getProgramNoResolveLink(name); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 969 | case GL_VERTEX_ARRAY: |
| 970 | return getVertexArray(name); |
| 971 | case GL_QUERY: |
| 972 | return getQuery(name); |
| 973 | case GL_TRANSFORM_FEEDBACK: |
| 974 | return getTransformFeedback(name); |
| 975 | case GL_SAMPLER: |
| 976 | return getSampler(name); |
| 977 | case GL_TEXTURE: |
| 978 | return getTexture(name); |
| 979 | case GL_RENDERBUFFER: |
| 980 | return getRenderbuffer(name); |
| 981 | case GL_FRAMEBUFFER: |
| 982 | return getFramebuffer(name); |
| 983 | default: |
| 984 | UNREACHABLE(); |
| 985 | return nullptr; |
| 986 | } |
| 987 | } |
| 988 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 989 | gl::LabeledObject *Context::getLabeledObjectFromPtr(const void *ptr) const |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 990 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 991 | return getSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr))); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 992 | } |
| 993 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 994 | void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label) |
| 995 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 996 | gl::LabeledObject *object = getLabeledObject(identifier, name); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 997 | ASSERT(object != nullptr); |
| 998 | |
| 999 | std::string labelName = GetObjectLabelFromPointer(length, label); |
Jamie Madill | e90d4ee | 2018-11-28 14:04:00 -0500 | [diff] [blame] | 1000 | object->setLabel(this, labelName); |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 1001 | |
| 1002 | // TODO(jmadill): Determine if the object is dirty based on 'name'. Conservatively assume the |
| 1003 | // specified object is active until we do this. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1004 | mState.setObjectDirty(identifier); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1005 | } |
| 1006 | |
| 1007 | void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label) |
| 1008 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1009 | gl::LabeledObject *object = getLabeledObjectFromPtr(ptr); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1010 | ASSERT(object != nullptr); |
| 1011 | |
| 1012 | std::string labelName = GetObjectLabelFromPointer(length, label); |
Jamie Madill | e90d4ee | 2018-11-28 14:04:00 -0500 | [diff] [blame] | 1013 | object->setLabel(this, labelName); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | void Context::getObjectLabel(GLenum identifier, |
| 1017 | GLuint name, |
| 1018 | GLsizei bufSize, |
| 1019 | GLsizei *length, |
| 1020 | GLchar *label) const |
| 1021 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1022 | gl::LabeledObject *object = getLabeledObject(identifier, name); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1023 | ASSERT(object != nullptr); |
| 1024 | |
| 1025 | const std::string &objectLabel = object->getLabel(); |
| 1026 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 1027 | } |
| 1028 | |
| 1029 | void Context::getObjectPtrLabel(const void *ptr, |
| 1030 | GLsizei bufSize, |
| 1031 | GLsizei *length, |
| 1032 | GLchar *label) const |
| 1033 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1034 | gl::LabeledObject *object = getLabeledObjectFromPtr(ptr); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1035 | ASSERT(object != nullptr); |
| 1036 | |
| 1037 | const std::string &objectLabel = object->getLabel(); |
| 1038 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 1039 | } |
| 1040 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1041 | bool Context::isSampler(GLuint samplerName) const |
| 1042 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1043 | return mState.mSamplerManager->isSampler(samplerName); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1044 | } |
| 1045 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1046 | void Context::bindTexture(TextureType target, GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1047 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1048 | Texture *texture = nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1049 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 1050 | if (handle == 0) |
| 1051 | { |
| 1052 | texture = mZeroTextures[target].get(); |
| 1053 | } |
| 1054 | else |
| 1055 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1056 | texture = |
| 1057 | mState.mTextureManager->checkTextureAllocation(mImplementation.get(), handle, target); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 1058 | } |
| 1059 | |
| 1060 | ASSERT(texture); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1061 | mState.setSamplerTexture(this, target, texture); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1062 | mStateCache.onActiveTextureChange(this); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 1063 | } |
| 1064 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1065 | void Context::bindReadFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1066 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1067 | Framebuffer *framebuffer = mState.mFramebufferManager->checkFramebufferAllocation( |
| 1068 | mImplementation.get(), mState.mCaps, framebufferHandle); |
| 1069 | mState.setReadFramebufferBinding(framebuffer); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1070 | mReadFramebufferObserverBinding.bind(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1071 | } |
| 1072 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1073 | void Context::bindDrawFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1074 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1075 | Framebuffer *framebuffer = mState.mFramebufferManager->checkFramebufferAllocation( |
| 1076 | mImplementation.get(), mState.mCaps, framebufferHandle); |
| 1077 | mState.setDrawFramebufferBinding(framebuffer); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1078 | mDrawFramebufferObserverBinding.bind(framebuffer); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1079 | mStateCache.onDrawFramebufferChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1080 | } |
| 1081 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1082 | void Context::bindVertexArray(GLuint vertexArrayHandle) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1083 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1084 | VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1085 | mState.setVertexArrayBinding(this, vertexArray); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1086 | mVertexArrayObserverBinding.bind(vertexArray); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1087 | mStateCache.onVertexArrayBindingChange(this); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1088 | } |
| 1089 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1090 | void Context::bindVertexBuffer(GLuint bindingIndex, |
| 1091 | GLuint bufferHandle, |
| 1092 | GLintptr offset, |
| 1093 | GLsizei stride) |
| 1094 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1095 | Buffer *buffer = |
| 1096 | mState.mBufferManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
| 1097 | mState.bindVertexBuffer(this, bindingIndex, buffer, offset, stride); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1098 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1099 | } |
| 1100 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1101 | void Context::bindSampler(GLuint textureUnit, GLuint samplerHandle) |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1102 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1103 | ASSERT(textureUnit < mState.mCaps.maxCombinedTextureImageUnits); |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1104 | Sampler *sampler = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1105 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), samplerHandle); |
| 1106 | mState.setSamplerBinding(this, textureUnit, sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 1107 | mSamplerObserverBindings[textureUnit].bind(sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1108 | } |
| 1109 | |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1110 | void Context::bindImageTexture(GLuint unit, |
| 1111 | GLuint texture, |
| 1112 | GLint level, |
| 1113 | GLboolean layered, |
| 1114 | GLint layer, |
| 1115 | GLenum access, |
| 1116 | GLenum format) |
| 1117 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1118 | Texture *tex = mState.mTextureManager->getTexture(texture); |
| 1119 | mState.setImageUnit(this, unit, tex, level, layered, layer, access, format); |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1120 | } |
| 1121 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1122 | void Context::useProgram(GLuint program) |
| 1123 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1124 | ANGLE_CONTEXT_TRY(mState.setProgram(this, getProgramResolveLink(program))); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1125 | mStateCache.onProgramExecutableChange(this); |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 1126 | } |
| 1127 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 1128 | void Context::useProgramStages(GLuint pipeline, GLbitfield stages, GLuint program) |
| 1129 | { |
| 1130 | UNIMPLEMENTED(); |
| 1131 | } |
| 1132 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1133 | void Context::bindTransformFeedback(GLenum target, GLuint transformFeedbackHandle) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1134 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1135 | ASSERT(target == GL_TRANSFORM_FEEDBACK); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1136 | TransformFeedback *transformFeedback = |
| 1137 | checkTransformFeedbackAllocation(transformFeedbackHandle); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1138 | mState.setTransformFeedbackBinding(this, transformFeedback); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1139 | } |
| 1140 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1141 | void Context::bindProgramPipeline(GLuint pipelineHandle) |
| 1142 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1143 | ProgramPipeline *pipeline = mState.mProgramPipelineManager->checkProgramPipelineAllocation( |
| 1144 | mImplementation.get(), pipelineHandle); |
| 1145 | mState.setProgramPipelineBinding(this, pipeline); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1146 | } |
| 1147 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1148 | void Context::beginQuery(QueryType target, GLuint query) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1149 | { |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1150 | Query *queryObject = getQuery(query, true, target); |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1151 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1152 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1153 | // begin query |
Jamie Madill | 5188a27 | 2018-07-25 10:53:56 -0400 | [diff] [blame] | 1154 | ANGLE_CONTEXT_TRY(queryObject->begin(this)); |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1155 | |
| 1156 | // set query as active for specified target only if begin succeeded |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1157 | mState.setActiveQuery(this, target, queryObject); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1158 | mStateCache.onQueryChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1159 | } |
| 1160 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1161 | void Context::endQuery(QueryType target) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1162 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1163 | Query *queryObject = mState.getActiveQuery(target); |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1164 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1165 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1166 | // Intentionally don't call try here. We don't want an early return. |
| 1167 | (void)(queryObject->end(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1168 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1169 | // Always unbind the query, even if there was an error. This may delete the query object. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1170 | mState.setActiveQuery(this, target, nullptr); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1171 | mStateCache.onQueryChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1172 | } |
| 1173 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1174 | void Context::queryCounter(GLuint id, QueryType target) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1175 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1176 | ASSERT(target == QueryType::Timestamp); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1177 | |
| 1178 | Query *queryObject = getQuery(id, true, target); |
| 1179 | ASSERT(queryObject); |
| 1180 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1181 | ANGLE_CONTEXT_TRY(queryObject->queryCounter(this)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1182 | } |
| 1183 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1184 | void Context::getQueryiv(QueryType target, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1185 | { |
| 1186 | switch (pname) |
| 1187 | { |
| 1188 | case GL_CURRENT_QUERY_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1189 | params[0] = mState.getActiveQueryId(target); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1190 | break; |
| 1191 | case GL_QUERY_COUNTER_BITS_EXT: |
| 1192 | switch (target) |
| 1193 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1194 | case QueryType::TimeElapsed: |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1195 | params[0] = getExtensions().queryCounterBitsTimeElapsed; |
| 1196 | break; |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1197 | case QueryType::Timestamp: |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1198 | params[0] = getExtensions().queryCounterBitsTimestamp; |
| 1199 | break; |
| 1200 | default: |
| 1201 | UNREACHABLE(); |
| 1202 | params[0] = 0; |
| 1203 | break; |
| 1204 | } |
| 1205 | break; |
| 1206 | default: |
| 1207 | UNREACHABLE(); |
| 1208 | return; |
| 1209 | } |
| 1210 | } |
| 1211 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1212 | void Context::getQueryivRobust(QueryType target, |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1213 | GLenum pname, |
| 1214 | GLsizei bufSize, |
| 1215 | GLsizei *length, |
| 1216 | GLint *params) |
| 1217 | { |
| 1218 | getQueryiv(target, pname, params); |
| 1219 | } |
| 1220 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1221 | void Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1222 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1223 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1224 | } |
| 1225 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1226 | void Context::getQueryObjectivRobust(GLuint id, |
| 1227 | GLenum pname, |
| 1228 | GLsizei bufSize, |
| 1229 | GLsizei *length, |
| 1230 | GLint *params) |
| 1231 | { |
| 1232 | getQueryObjectiv(id, pname, params); |
| 1233 | } |
| 1234 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1235 | void Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1236 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1237 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1238 | } |
| 1239 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1240 | void Context::getQueryObjectuivRobust(GLuint id, |
| 1241 | GLenum pname, |
| 1242 | GLsizei bufSize, |
| 1243 | GLsizei *length, |
| 1244 | GLuint *params) |
| 1245 | { |
| 1246 | getQueryObjectuiv(id, pname, params); |
| 1247 | } |
| 1248 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1249 | void Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1250 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1251 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1252 | } |
| 1253 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1254 | void Context::getQueryObjecti64vRobust(GLuint id, |
| 1255 | GLenum pname, |
| 1256 | GLsizei bufSize, |
| 1257 | GLsizei *length, |
| 1258 | GLint64 *params) |
| 1259 | { |
| 1260 | getQueryObjecti64v(id, pname, params); |
| 1261 | } |
| 1262 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1263 | void Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1264 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1265 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1266 | } |
| 1267 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1268 | void Context::getQueryObjectui64vRobust(GLuint id, |
| 1269 | GLenum pname, |
| 1270 | GLsizei bufSize, |
| 1271 | GLsizei *length, |
| 1272 | GLuint64 *params) |
| 1273 | { |
| 1274 | getQueryObjectui64v(id, pname, params); |
| 1275 | } |
| 1276 | |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1277 | Framebuffer *Context::getFramebuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1278 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1279 | return mState.mFramebufferManager->getFramebuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1280 | } |
| 1281 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1282 | FenceNV *Context::getFenceNV(GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1283 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1284 | return mFenceNVMap.query(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1285 | } |
| 1286 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1287 | Query *Context::getQuery(GLuint handle, bool create, QueryType type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1288 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1289 | if (!mQueryMap.contains(handle)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1290 | { |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 1291 | return nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1292 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1293 | |
| 1294 | Query *query = mQueryMap.query(handle); |
| 1295 | if (!query && create) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1296 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1297 | ASSERT(type != QueryType::InvalidEnum); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1298 | query = new Query(mImplementation->createQuery(type), handle); |
| 1299 | query->addRef(); |
| 1300 | mQueryMap.assign(handle, query); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1301 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1302 | return query; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1303 | } |
| 1304 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1305 | Query *Context::getQuery(GLuint handle) const |
| 1306 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1307 | return mQueryMap.query(handle); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1308 | } |
| 1309 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1310 | Texture *Context::getTargetTexture(TextureType type) const |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 1311 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1312 | ASSERT(ValidTextureTarget(this, type) || ValidTextureExternalTarget(this, type)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1313 | return mState.getTargetTexture(type); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1314 | } |
| 1315 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1316 | Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1317 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1318 | return mState.getSamplerTexture(sampler, type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1319 | } |
| 1320 | |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1321 | Compiler *Context::getCompiler() const |
| 1322 | { |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1323 | if (mCompiler.get() == nullptr) |
| 1324 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1325 | mCompiler.set(this, new Compiler(mImplementation.get(), mState)); |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1326 | } |
| 1327 | return mCompiler.get(); |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1328 | } |
| 1329 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1330 | void Context::getBooleanvImpl(GLenum pname, GLboolean *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1331 | { |
| 1332 | switch (pname) |
| 1333 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1334 | case GL_SHADER_COMPILER: |
| 1335 | *params = GL_TRUE; |
| 1336 | break; |
| 1337 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 1338 | *params = mRobustAccess ? GL_TRUE : GL_FALSE; |
| 1339 | break; |
Jeff Gilbert | 465d609 | 2019-01-02 16:21:18 -0800 | [diff] [blame] | 1340 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1341 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1342 | mState.getBooleanv(pname, params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1343 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1344 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1345 | } |
| 1346 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1347 | void Context::getFloatvImpl(GLenum pname, GLfloat *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1348 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1349 | // Queries about context capabilities and maximums are answered by Context. |
| 1350 | // Queries about current GL state values are answered by State. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1351 | switch (pname) |
| 1352 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1353 | case GL_ALIASED_LINE_WIDTH_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1354 | params[0] = mState.mCaps.minAliasedLineWidth; |
| 1355 | params[1] = mState.mCaps.maxAliasedLineWidth; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1356 | break; |
| 1357 | case GL_ALIASED_POINT_SIZE_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1358 | params[0] = mState.mCaps.minAliasedPointSize; |
| 1359 | params[1] = mState.mCaps.maxAliasedPointSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1360 | break; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 1361 | case GL_SMOOTH_POINT_SIZE_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1362 | params[0] = mState.mCaps.minSmoothPointSize; |
| 1363 | params[1] = mState.mCaps.maxSmoothPointSize; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 1364 | break; |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 1365 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1366 | params[0] = mState.mCaps.minSmoothLineWidth; |
| 1367 | params[1] = mState.mCaps.maxSmoothLineWidth; |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 1368 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1369 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1370 | ASSERT(mState.mExtensions.textureFilterAnisotropic); |
| 1371 | *params = mState.mExtensions.maxTextureAnisotropy; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1372 | break; |
| 1373 | case GL_MAX_TEXTURE_LOD_BIAS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1374 | *params = mState.mCaps.maxLODBias; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1375 | break; |
| 1376 | |
| 1377 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 1378 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 1379 | { |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1380 | // GLES1 emulation: // GL_PATH_(MODELVIEW|PROJECTION)_MATRIX_CHROMIUM collides with the |
| 1381 | // GLES1 constants for modelview/projection matrix. |
| 1382 | if (getClientVersion() < Version(2, 0)) |
| 1383 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1384 | mState.getFloatv(pname, params); |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1385 | } |
| 1386 | else |
| 1387 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1388 | ASSERT(mState.mExtensions.pathRendering); |
| 1389 | const GLfloat *m = mState.getPathRenderingMatrix(pname); |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1390 | memcpy(params, m, 16 * sizeof(GLfloat)); |
| 1391 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1392 | } |
Geoff Lang | e6d4e12 | 2015-06-29 13:33:55 -0400 | [diff] [blame] | 1393 | break; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1394 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1395 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1396 | mState.getFloatv(pname, params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1397 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1398 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1399 | } |
| 1400 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1401 | void Context::getIntegervImpl(GLenum pname, GLint *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1402 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1403 | // Queries about context capabilities and maximums are answered by Context. |
| 1404 | // 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] | 1405 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1406 | switch (pname) |
| 1407 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1408 | case GL_MAX_VERTEX_ATTRIBS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1409 | *params = mState.mCaps.maxVertexAttributes; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1410 | break; |
| 1411 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1412 | *params = mState.mCaps.maxVertexUniformVectors; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1413 | break; |
| 1414 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1415 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1416 | break; |
| 1417 | case GL_MAX_VARYING_VECTORS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1418 | *params = mState.mCaps.maxVaryingVectors; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1419 | break; |
| 1420 | case GL_MAX_VARYING_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1421 | *params = mState.mCaps.maxVertexOutputComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1422 | break; |
| 1423 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1424 | *params = mState.mCaps.maxCombinedTextureImageUnits; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1425 | break; |
| 1426 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1427 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1428 | break; |
| 1429 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1430 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1431 | break; |
| 1432 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1433 | *params = mState.mCaps.maxFragmentUniformVectors; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1434 | break; |
| 1435 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1436 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1437 | break; |
| 1438 | case GL_MAX_RENDERBUFFER_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1439 | *params = mState.mCaps.maxRenderbufferSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1440 | break; |
| 1441 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1442 | *params = mState.mCaps.maxColorAttachments; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1443 | break; |
| 1444 | case GL_MAX_DRAW_BUFFERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1445 | *params = mState.mCaps.maxDrawBuffers; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1446 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1447 | case GL_SUBPIXEL_BITS: |
| 1448 | *params = 4; |
| 1449 | break; |
| 1450 | case GL_MAX_TEXTURE_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1451 | *params = mState.mCaps.max2DTextureSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1452 | break; |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1453 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1454 | *params = mState.mCaps.maxRectangleTextureSize; |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1455 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1456 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1457 | *params = mState.mCaps.maxCubeMapTextureSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1458 | break; |
| 1459 | case GL_MAX_3D_TEXTURE_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1460 | *params = mState.mCaps.max3DTextureSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1461 | break; |
| 1462 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1463 | *params = mState.mCaps.maxArrayTextureLayers; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1464 | break; |
| 1465 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1466 | *params = mState.mCaps.uniformBufferOffsetAlignment; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1467 | break; |
| 1468 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1469 | *params = mState.mCaps.maxUniformBufferBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1470 | break; |
| 1471 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1472 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1473 | break; |
| 1474 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1475 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1476 | break; |
| 1477 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1478 | *params = mState.mCaps.maxCombinedTextureImageUnits; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1479 | break; |
| 1480 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1481 | *params = mState.mCaps.maxVertexOutputComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1482 | break; |
| 1483 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1484 | *params = mState.mCaps.maxFragmentInputComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1485 | break; |
| 1486 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1487 | *params = mState.mCaps.minProgramTexelOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1488 | break; |
| 1489 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1490 | *params = mState.mCaps.maxProgramTexelOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1491 | break; |
| 1492 | case GL_MAJOR_VERSION: |
| 1493 | *params = getClientVersion().major; |
| 1494 | break; |
| 1495 | case GL_MINOR_VERSION: |
| 1496 | *params = getClientVersion().minor; |
| 1497 | break; |
| 1498 | case GL_MAX_ELEMENTS_INDICES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1499 | *params = mState.mCaps.maxElementsIndices; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1500 | break; |
| 1501 | case GL_MAX_ELEMENTS_VERTICES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1502 | *params = mState.mCaps.maxElementsVertices; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1503 | break; |
| 1504 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1505 | *params = mState.mCaps.maxTransformFeedbackInterleavedComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1506 | break; |
| 1507 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1508 | *params = mState.mCaps.maxTransformFeedbackSeparateAttributes; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1509 | break; |
| 1510 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1511 | *params = mState.mCaps.maxTransformFeedbackSeparateComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1512 | break; |
| 1513 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1514 | *params = static_cast<GLint>(mState.mCaps.compressedTextureFormats.size()); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1515 | break; |
| 1516 | case GL_MAX_SAMPLES_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1517 | *params = mState.mCaps.maxSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1518 | break; |
| 1519 | case GL_MAX_VIEWPORT_DIMS: |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1520 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1521 | params[0] = mState.mCaps.maxViewportWidth; |
| 1522 | params[1] = mState.mCaps.maxViewportHeight; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1523 | } |
| 1524 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1525 | case GL_COMPRESSED_TEXTURE_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1526 | std::copy(mState.mCaps.compressedTextureFormats.begin(), |
| 1527 | mState.mCaps.compressedTextureFormats.end(), params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1528 | break; |
| 1529 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 1530 | *params = mResetStrategy; |
| 1531 | break; |
| 1532 | case GL_NUM_SHADER_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1533 | *params = static_cast<GLint>(mState.mCaps.shaderBinaryFormats.size()); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1534 | break; |
| 1535 | case GL_SHADER_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1536 | std::copy(mState.mCaps.shaderBinaryFormats.begin(), |
| 1537 | mState.mCaps.shaderBinaryFormats.end(), params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1538 | break; |
| 1539 | case GL_NUM_PROGRAM_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1540 | *params = static_cast<GLint>(mState.mCaps.programBinaryFormats.size()); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1541 | break; |
| 1542 | case GL_PROGRAM_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1543 | std::copy(mState.mCaps.programBinaryFormats.begin(), |
| 1544 | mState.mCaps.programBinaryFormats.end(), params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1545 | break; |
| 1546 | case GL_NUM_EXTENSIONS: |
| 1547 | *params = static_cast<GLint>(mExtensionStrings.size()); |
| 1548 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1549 | |
Geoff Lang | 38f24ee | 2018-10-01 13:04:59 -0400 | [diff] [blame] | 1550 | // GL_ANGLE_request_extension |
| 1551 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 1552 | *params = static_cast<GLint>(mRequestableExtensionStrings.size()); |
| 1553 | break; |
| 1554 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1555 | // GL_KHR_debug |
| 1556 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1557 | *params = mState.mExtensions.maxDebugMessageLength; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1558 | break; |
| 1559 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1560 | *params = mState.mExtensions.maxDebugLoggedMessages; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1561 | break; |
| 1562 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1563 | *params = mState.mExtensions.maxDebugGroupStackDepth; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1564 | break; |
| 1565 | case GL_MAX_LABEL_LENGTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1566 | *params = mState.mExtensions.maxLabelLength; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1567 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1568 | |
Martin Radev | e5285d2 | 2017-07-14 16:23:53 +0300 | [diff] [blame] | 1569 | // GL_ANGLE_multiview |
| 1570 | case GL_MAX_VIEWS_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1571 | *params = mState.mExtensions.maxViews; |
Martin Radev | e5285d2 | 2017-07-14 16:23:53 +0300 | [diff] [blame] | 1572 | break; |
| 1573 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1574 | // GL_EXT_disjoint_timer_query |
| 1575 | case GL_GPU_DISJOINT_EXT: |
| 1576 | *params = mImplementation->getGPUDisjoint(); |
| 1577 | break; |
| 1578 | case GL_MAX_FRAMEBUFFER_WIDTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1579 | *params = mState.mCaps.maxFramebufferWidth; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1580 | break; |
| 1581 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1582 | *params = mState.mCaps.maxFramebufferHeight; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1583 | break; |
| 1584 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1585 | *params = mState.mCaps.maxFramebufferSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1586 | break; |
| 1587 | case GL_MAX_SAMPLE_MASK_WORDS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1588 | *params = mState.mCaps.maxSampleMaskWords; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1589 | break; |
| 1590 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1591 | *params = mState.mCaps.maxColorTextureSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1592 | break; |
| 1593 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1594 | *params = mState.mCaps.maxDepthTextureSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1595 | break; |
| 1596 | case GL_MAX_INTEGER_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1597 | *params = mState.mCaps.maxIntegerSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1598 | break; |
| 1599 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1600 | *params = mState.mCaps.maxVertexAttribRelativeOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1601 | break; |
| 1602 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1603 | *params = mState.mCaps.maxVertexAttribBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1604 | break; |
| 1605 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1606 | *params = mState.mCaps.maxVertexAttribStride; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1607 | break; |
| 1608 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1609 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1610 | break; |
| 1611 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1612 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1613 | break; |
| 1614 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1615 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1616 | break; |
| 1617 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1618 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1619 | break; |
| 1620 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1621 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1622 | break; |
| 1623 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1624 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1625 | break; |
| 1626 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1627 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1628 | break; |
| 1629 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1630 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1631 | break; |
| 1632 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1633 | *params = mState.mCaps.minProgramTextureGatherOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1634 | break; |
| 1635 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1636 | *params = mState.mCaps.maxProgramTextureGatherOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1637 | break; |
| 1638 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1639 | *params = mState.mCaps.maxComputeWorkGroupInvocations; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1640 | break; |
| 1641 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1642 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1643 | break; |
| 1644 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1645 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1646 | break; |
| 1647 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1648 | *params = mState.mCaps.maxComputeSharedMemorySize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1649 | break; |
| 1650 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1651 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1652 | break; |
| 1653 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1654 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1655 | break; |
| 1656 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1657 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1658 | break; |
| 1659 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1660 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1661 | break; |
| 1662 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1663 | *params = static_cast<GLint>( |
| 1664 | mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Compute]); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1665 | break; |
| 1666 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1667 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1668 | break; |
| 1669 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1670 | *params = mState.mCaps.maxCombinedShaderOutputResources; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1671 | break; |
| 1672 | case GL_MAX_UNIFORM_LOCATIONS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1673 | *params = mState.mCaps.maxUniformLocations; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1674 | break; |
| 1675 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1676 | *params = mState.mCaps.maxAtomicCounterBufferBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1677 | break; |
| 1678 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1679 | *params = mState.mCaps.maxAtomicCounterBufferSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1680 | break; |
| 1681 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1682 | *params = mState.mCaps.maxCombinedAtomicCounterBuffers; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1683 | break; |
| 1684 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1685 | *params = mState.mCaps.maxCombinedAtomicCounters; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1686 | break; |
| 1687 | case GL_MAX_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1688 | *params = mState.mCaps.maxImageUnits; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1689 | break; |
| 1690 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1691 | *params = mState.mCaps.maxCombinedImageUniforms; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1692 | break; |
| 1693 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1694 | *params = mState.mCaps.maxShaderStorageBufferBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1695 | break; |
| 1696 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1697 | *params = mState.mCaps.maxCombinedShaderStorageBlocks; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1698 | break; |
| 1699 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1700 | *params = mState.mCaps.shaderStorageBufferOffsetAlignment; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1701 | break; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1702 | |
| 1703 | // GL_EXT_geometry_shader |
| 1704 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1705 | *params = mState.mCaps.maxFramebufferLayers; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1706 | break; |
| 1707 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1708 | *params = mState.mCaps.layerProvokingVertex; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1709 | break; |
| 1710 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1711 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1712 | break; |
| 1713 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1714 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1715 | break; |
| 1716 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1717 | *params = static_cast<GLint>( |
| 1718 | mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Geometry]); |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1719 | break; |
| 1720 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1721 | *params = mState.mCaps.maxGeometryInputComponents; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1722 | break; |
| 1723 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1724 | *params = mState.mCaps.maxGeometryOutputComponents; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1725 | break; |
| 1726 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1727 | *params = mState.mCaps.maxGeometryOutputVertices; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1728 | break; |
| 1729 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1730 | *params = mState.mCaps.maxGeometryTotalOutputComponents; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1731 | break; |
| 1732 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1733 | *params = mState.mCaps.maxGeometryShaderInvocations; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1734 | break; |
| 1735 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1736 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1737 | break; |
| 1738 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1739 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1740 | break; |
| 1741 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1742 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1743 | break; |
| 1744 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1745 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1746 | break; |
| 1747 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1748 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1749 | break; |
Lingfeng Yang | 96310cd | 2018-03-28 11:56:28 -0700 | [diff] [blame] | 1750 | // GLES1 emulation: Caps queries |
| 1751 | case GL_MAX_TEXTURE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1752 | *params = mState.mCaps.maxMultitextureUnits; |
Lingfeng Yang | 96310cd | 2018-03-28 11:56:28 -0700 | [diff] [blame] | 1753 | break; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1754 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1755 | *params = mState.mCaps.maxModelviewMatrixStackDepth; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1756 | break; |
| 1757 | case GL_MAX_PROJECTION_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1758 | *params = mState.mCaps.maxProjectionMatrixStackDepth; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1759 | break; |
| 1760 | case GL_MAX_TEXTURE_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1761 | *params = mState.mCaps.maxTextureMatrixStackDepth; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1762 | break; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 1763 | case GL_MAX_LIGHTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1764 | *params = mState.mCaps.maxLights; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 1765 | break; |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 1766 | case GL_MAX_CLIP_PLANES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1767 | *params = mState.mCaps.maxClipPlanes; |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 1768 | break; |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 1769 | // GLES1 emulation: Vertex attribute queries |
| 1770 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 1771 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 1772 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 1773 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
| 1774 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 1775 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1776 | GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, params); |
| 1777 | break; |
| 1778 | case GL_VERTEX_ARRAY_STRIDE: |
| 1779 | case GL_NORMAL_ARRAY_STRIDE: |
| 1780 | case GL_COLOR_ARRAY_STRIDE: |
| 1781 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 1782 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 1783 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1784 | GL_VERTEX_ATTRIB_ARRAY_STRIDE, params); |
| 1785 | break; |
| 1786 | case GL_VERTEX_ARRAY_SIZE: |
| 1787 | case GL_COLOR_ARRAY_SIZE: |
| 1788 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 1789 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1790 | GL_VERTEX_ATTRIB_ARRAY_SIZE, params); |
| 1791 | break; |
| 1792 | case GL_VERTEX_ARRAY_TYPE: |
| 1793 | case GL_COLOR_ARRAY_TYPE: |
| 1794 | case GL_NORMAL_ARRAY_TYPE: |
| 1795 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 1796 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 1797 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1798 | GL_VERTEX_ATTRIB_ARRAY_TYPE, params); |
| 1799 | break; |
| 1800 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 1801 | // GL_KHR_parallel_shader_compile |
| 1802 | case GL_MAX_SHADER_COMPILER_THREADS_KHR: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1803 | *params = mState.getMaxShaderCompilerThreads(); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 1804 | break; |
| 1805 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 1806 | // GL_EXT_blend_func_extended |
| 1807 | case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1808 | *params = mState.mExtensions.maxDualSourceDrawBuffers; |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 1809 | break; |
| 1810 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1811 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1812 | ANGLE_CONTEXT_TRY(mState.getIntegerv(this, pname, params)); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1813 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1814 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1815 | } |
| 1816 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 1817 | void Context::getInteger64vImpl(GLenum pname, GLint64 *params) |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1818 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1819 | // Queries about context capabilities and maximums are answered by Context. |
| 1820 | // Queries about current GL state values are answered by State. |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1821 | switch (pname) |
| 1822 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1823 | case GL_MAX_ELEMENT_INDEX: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1824 | *params = mState.mCaps.maxElementIndex; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1825 | break; |
| 1826 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1827 | *params = mState.mCaps.maxUniformBlockSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1828 | break; |
| 1829 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1830 | *params = mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1831 | break; |
| 1832 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1833 | *params = mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1834 | break; |
| 1835 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1836 | *params = mState.mCaps.maxServerWaitTimeout; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1837 | break; |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 1838 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1839 | // GL_EXT_disjoint_timer_query |
| 1840 | case GL_TIMESTAMP_EXT: |
| 1841 | *params = mImplementation->getTimestamp(); |
| 1842 | break; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1843 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1844 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1845 | *params = mState.mCaps.maxShaderStorageBlockSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1846 | break; |
| 1847 | default: |
| 1848 | UNREACHABLE(); |
| 1849 | break; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1850 | } |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1851 | } |
| 1852 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1853 | void Context::getPointerv(GLenum pname, void **params) const |
| 1854 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1855 | mState.getPointerv(this, pname, params); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1856 | } |
| 1857 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 1858 | void Context::getPointervRobustANGLERobust(GLenum pname, |
| 1859 | GLsizei bufSize, |
| 1860 | GLsizei *length, |
| 1861 | void **params) |
| 1862 | { |
| 1863 | UNIMPLEMENTED(); |
| 1864 | } |
| 1865 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1866 | void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1867 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1868 | // Queries about context capabilities and maximums are answered by Context. |
| 1869 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1870 | |
| 1871 | GLenum nativeType; |
| 1872 | unsigned int numParams; |
| 1873 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1874 | ASSERT(queryStatus); |
| 1875 | |
| 1876 | if (nativeType == GL_INT) |
| 1877 | { |
| 1878 | switch (target) |
| 1879 | { |
| 1880 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 1881 | ASSERT(index < 3u); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1882 | *data = mState.mCaps.maxComputeWorkGroupCount[index]; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1883 | break; |
| 1884 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 1885 | ASSERT(index < 3u); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1886 | *data = mState.mCaps.maxComputeWorkGroupSize[index]; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1887 | break; |
| 1888 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1889 | mState.getIntegeri_v(target, index, data); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1890 | } |
| 1891 | } |
| 1892 | else |
| 1893 | { |
| 1894 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1895 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1896 | } |
| 1897 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1898 | void Context::getIntegeri_vRobust(GLenum target, |
| 1899 | GLuint index, |
| 1900 | GLsizei bufSize, |
| 1901 | GLsizei *length, |
| 1902 | GLint *data) |
| 1903 | { |
| 1904 | getIntegeri_v(target, index, data); |
| 1905 | } |
| 1906 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1907 | void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1908 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1909 | // Queries about context capabilities and maximums are answered by Context. |
| 1910 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1911 | |
| 1912 | GLenum nativeType; |
| 1913 | unsigned int numParams; |
| 1914 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1915 | ASSERT(queryStatus); |
| 1916 | |
| 1917 | if (nativeType == GL_INT_64_ANGLEX) |
| 1918 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1919 | mState.getInteger64i_v(target, index, data); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1920 | } |
| 1921 | else |
| 1922 | { |
| 1923 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1924 | } |
| 1925 | } |
| 1926 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1927 | void Context::getInteger64i_vRobust(GLenum target, |
| 1928 | GLuint index, |
| 1929 | GLsizei bufSize, |
| 1930 | GLsizei *length, |
| 1931 | GLint64 *data) |
| 1932 | { |
| 1933 | getInteger64i_v(target, index, data); |
| 1934 | } |
| 1935 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1936 | void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data) |
| 1937 | { |
| 1938 | // Queries about context capabilities and maximums are answered by Context. |
| 1939 | // Queries about current GL state values are answered by State. |
| 1940 | |
| 1941 | GLenum nativeType; |
| 1942 | unsigned int numParams; |
| 1943 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1944 | ASSERT(queryStatus); |
| 1945 | |
| 1946 | if (nativeType == GL_BOOL) |
| 1947 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1948 | mState.getBooleani_v(target, index, data); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1949 | } |
| 1950 | else |
| 1951 | { |
| 1952 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1953 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1954 | } |
| 1955 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1956 | void Context::getBooleani_vRobust(GLenum target, |
| 1957 | GLuint index, |
| 1958 | GLsizei bufSize, |
| 1959 | GLsizei *length, |
| 1960 | GLboolean *data) |
| 1961 | { |
| 1962 | getBooleani_v(target, index, data); |
| 1963 | } |
| 1964 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 1965 | void Context::getBufferParameteriv(BufferBinding target, GLenum pname, GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1966 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1967 | Buffer *buffer = mState.getTargetBuffer(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1968 | QueryBufferParameteriv(buffer, pname, params); |
| 1969 | } |
| 1970 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1971 | void Context::getBufferParameterivRobust(BufferBinding target, |
| 1972 | GLenum pname, |
| 1973 | GLsizei bufSize, |
| 1974 | GLsizei *length, |
| 1975 | GLint *params) |
| 1976 | { |
| 1977 | getBufferParameteriv(target, pname, params); |
| 1978 | } |
| 1979 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1980 | void Context::getFramebufferAttachmentParameteriv(GLenum target, |
| 1981 | GLenum attachment, |
| 1982 | GLenum pname, |
| 1983 | GLint *params) |
| 1984 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1985 | const Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 1986 | QueryFramebufferAttachmentParameteriv(this, framebuffer, attachment, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1987 | } |
| 1988 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1989 | void Context::getFramebufferAttachmentParameterivRobust(GLenum target, |
| 1990 | GLenum attachment, |
| 1991 | GLenum pname, |
| 1992 | GLsizei bufSize, |
| 1993 | GLsizei *length, |
| 1994 | GLint *params) |
| 1995 | { |
| 1996 | getFramebufferAttachmentParameteriv(target, attachment, pname, params); |
| 1997 | } |
| 1998 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1999 | void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 2000 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2001 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2002 | QueryRenderbufferiv(this, renderbuffer, pname, params); |
| 2003 | } |
| 2004 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2005 | void Context::getRenderbufferParameterivRobust(GLenum target, |
| 2006 | GLenum pname, |
| 2007 | GLsizei bufSize, |
| 2008 | GLsizei *length, |
| 2009 | GLint *params) |
| 2010 | { |
| 2011 | getRenderbufferParameteriv(target, pname, params); |
| 2012 | } |
| 2013 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2014 | void Context::getTexParameterfv(TextureType target, GLenum pname, GLfloat *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2015 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2016 | const Texture *const texture = getTargetTexture(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2017 | QueryTexParameterfv(texture, pname, params); |
| 2018 | } |
| 2019 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2020 | void Context::getTexParameterfvRobust(TextureType target, |
| 2021 | GLenum pname, |
| 2022 | GLsizei bufSize, |
| 2023 | GLsizei *length, |
| 2024 | GLfloat *params) |
| 2025 | { |
| 2026 | getTexParameterfv(target, pname, params); |
| 2027 | } |
| 2028 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2029 | void Context::getTexParameteriv(TextureType target, GLenum pname, GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2030 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2031 | const Texture *const texture = getTargetTexture(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2032 | QueryTexParameteriv(texture, pname, params); |
| 2033 | } |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2034 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2035 | void Context::getTexParameterIiv(TextureType target, GLenum pname, GLint *params) |
| 2036 | { |
| 2037 | const Texture *const texture = getTargetTexture(target); |
| 2038 | QueryTexParameterIiv(texture, pname, params); |
| 2039 | } |
| 2040 | |
| 2041 | void Context::getTexParameterIuiv(TextureType target, GLenum pname, GLuint *params) |
| 2042 | { |
| 2043 | const Texture *const texture = getTargetTexture(target); |
| 2044 | QueryTexParameterIuiv(texture, pname, params); |
| 2045 | } |
| 2046 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2047 | void Context::getTexParameterivRobust(TextureType target, |
| 2048 | GLenum pname, |
| 2049 | GLsizei bufSize, |
| 2050 | GLsizei *length, |
| 2051 | GLint *params) |
| 2052 | { |
| 2053 | getTexParameteriv(target, pname, params); |
| 2054 | } |
| 2055 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2056 | void Context::getTexParameterIivRobust(TextureType target, |
| 2057 | GLenum pname, |
| 2058 | GLsizei bufSize, |
| 2059 | GLsizei *length, |
| 2060 | GLint *params) |
| 2061 | { |
| 2062 | UNIMPLEMENTED(); |
| 2063 | } |
| 2064 | |
| 2065 | void Context::getTexParameterIuivRobust(TextureType target, |
| 2066 | GLenum pname, |
| 2067 | GLsizei bufSize, |
| 2068 | GLsizei *length, |
| 2069 | GLuint *params) |
| 2070 | { |
| 2071 | UNIMPLEMENTED(); |
| 2072 | } |
| 2073 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2074 | void Context::getTexLevelParameteriv(TextureTarget target, GLint level, GLenum pname, GLint *params) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2075 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2076 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 2077 | QueryTexLevelParameteriv(texture, target, level, pname, params); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2078 | } |
| 2079 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2080 | void Context::getTexLevelParameterivRobust(TextureTarget target, |
| 2081 | GLint level, |
| 2082 | GLenum pname, |
| 2083 | GLsizei bufSize, |
| 2084 | GLsizei *length, |
| 2085 | GLint *params) |
| 2086 | { |
| 2087 | UNIMPLEMENTED(); |
| 2088 | } |
| 2089 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2090 | void Context::getTexLevelParameterfv(TextureTarget target, |
| 2091 | GLint level, |
| 2092 | GLenum pname, |
| 2093 | GLfloat *params) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2094 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2095 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 2096 | QueryTexLevelParameterfv(texture, target, level, pname, params); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2097 | } |
| 2098 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2099 | void Context::getTexLevelParameterfvRobust(TextureTarget target, |
| 2100 | GLint level, |
| 2101 | GLenum pname, |
| 2102 | GLsizei bufSize, |
| 2103 | GLsizei *length, |
| 2104 | GLfloat *params) |
| 2105 | { |
| 2106 | UNIMPLEMENTED(); |
| 2107 | } |
| 2108 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2109 | void Context::texParameterf(TextureType target, GLenum pname, GLfloat param) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2110 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2111 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2112 | SetTexParameterf(this, texture, pname, param); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2113 | } |
| 2114 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2115 | void Context::texParameterfv(TextureType target, GLenum pname, const GLfloat *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2116 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2117 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2118 | SetTexParameterfv(this, texture, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2119 | } |
| 2120 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2121 | void Context::texParameterfvRobust(TextureType target, |
| 2122 | GLenum pname, |
| 2123 | GLsizei bufSize, |
| 2124 | const GLfloat *params) |
| 2125 | { |
| 2126 | texParameterfv(target, pname, params); |
| 2127 | } |
| 2128 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2129 | void Context::texParameteri(TextureType target, GLenum pname, GLint param) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2130 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2131 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2132 | SetTexParameteri(this, texture, pname, param); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2133 | } |
| 2134 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2135 | void Context::texParameteriv(TextureType target, GLenum pname, const GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2136 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2137 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2138 | SetTexParameteriv(this, texture, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2139 | } |
| 2140 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2141 | void Context::texParameterIiv(TextureType target, GLenum pname, const GLint *params) |
| 2142 | { |
| 2143 | Texture *const texture = getTargetTexture(target); |
| 2144 | SetTexParameterIiv(this, texture, pname, params); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2145 | } |
| 2146 | |
| 2147 | void Context::texParameterIuiv(TextureType target, GLenum pname, const GLuint *params) |
| 2148 | { |
| 2149 | Texture *const texture = getTargetTexture(target); |
| 2150 | SetTexParameterIuiv(this, texture, pname, params); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2151 | } |
| 2152 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2153 | void Context::texParameterivRobust(TextureType target, |
| 2154 | GLenum pname, |
| 2155 | GLsizei bufSize, |
| 2156 | const GLint *params) |
| 2157 | { |
| 2158 | texParameteriv(target, pname, params); |
| 2159 | } |
| 2160 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2161 | void Context::texParameterIivRobust(TextureType target, |
| 2162 | GLenum pname, |
| 2163 | GLsizei bufSize, |
| 2164 | const GLint *params) |
| 2165 | { |
| 2166 | UNIMPLEMENTED(); |
| 2167 | } |
| 2168 | |
| 2169 | void Context::texParameterIuivRobust(TextureType target, |
| 2170 | GLenum pname, |
| 2171 | GLsizei bufSize, |
| 2172 | const GLuint *params) |
| 2173 | { |
| 2174 | UNIMPLEMENTED(); |
| 2175 | } |
| 2176 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2177 | void Context::drawArraysInstanced(PrimitiveMode mode, |
| 2178 | GLint first, |
| 2179 | GLsizei count, |
| 2180 | GLsizei instanceCount) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2181 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2182 | // No-op if count draws no primitives for given mode |
| 2183 | if (noopDrawInstanced(mode, count, instanceCount)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2184 | { |
| 2185 | return; |
| 2186 | } |
| 2187 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2188 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2189 | ANGLE_CONTEXT_TRY( |
| 2190 | mImplementation->drawArraysInstanced(this, mode, first, count, instanceCount)); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 2191 | MarkTransformFeedbackBufferUsage(this, count, instanceCount); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2192 | } |
| 2193 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2194 | void Context::drawElementsInstanced(PrimitiveMode mode, |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2195 | GLsizei count, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2196 | DrawElementsType type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2197 | const void *indices, |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 2198 | GLsizei instances) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2199 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2200 | // No-op if count draws no primitives for given mode |
| 2201 | if (noopDrawInstanced(mode, count, instances)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2202 | { |
| 2203 | return; |
| 2204 | } |
| 2205 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2206 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2207 | ANGLE_CONTEXT_TRY( |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 2208 | mImplementation->drawElementsInstanced(this, mode, count, type, indices, instances)); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2209 | } |
| 2210 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2211 | void Context::drawRangeElements(PrimitiveMode mode, |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2212 | GLuint start, |
| 2213 | GLuint end, |
| 2214 | GLsizei count, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2215 | DrawElementsType type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2216 | const void *indices) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2217 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2218 | // No-op if count draws no primitives for given mode |
| 2219 | if (noopDraw(mode, count)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2220 | { |
| 2221 | return; |
| 2222 | } |
| 2223 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2224 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2225 | ANGLE_CONTEXT_TRY( |
| 2226 | mImplementation->drawRangeElements(this, mode, start, end, count, type, indices)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2227 | } |
| 2228 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2229 | void Context::drawArraysIndirect(PrimitiveMode mode, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2230 | { |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2231 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2232 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysIndirect(this, mode, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2233 | } |
| 2234 | |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2235 | void Context::drawElementsIndirect(PrimitiveMode mode, DrawElementsType type, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2236 | { |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2237 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2238 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsIndirect(this, mode, type, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2239 | } |
| 2240 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2241 | void Context::flush() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2242 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 2243 | ANGLE_CONTEXT_TRY(mImplementation->flush(this)); |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 2244 | } |
| 2245 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2246 | void Context::finish() |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 2247 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 2248 | ANGLE_CONTEXT_TRY(mImplementation->finish(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2249 | } |
| 2250 | |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2251 | void Context::insertEventMarker(GLsizei length, const char *marker) |
| 2252 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2253 | ASSERT(mImplementation); |
| 2254 | mImplementation->insertEventMarker(length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2255 | } |
| 2256 | |
| 2257 | void Context::pushGroupMarker(GLsizei length, const char *marker) |
| 2258 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2259 | ASSERT(mImplementation); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 2260 | |
| 2261 | if (marker == nullptr) |
| 2262 | { |
| 2263 | // From the EXT_debug_marker spec, |
| 2264 | // "If <marker> is null then an empty string is pushed on the stack." |
| 2265 | mImplementation->pushGroupMarker(length, ""); |
| 2266 | } |
| 2267 | else |
| 2268 | { |
| 2269 | mImplementation->pushGroupMarker(length, marker); |
| 2270 | } |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2271 | } |
| 2272 | |
| 2273 | void Context::popGroupMarker() |
| 2274 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2275 | ASSERT(mImplementation); |
| 2276 | mImplementation->popGroupMarker(); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2277 | } |
| 2278 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 2279 | void Context::bindUniformLocation(GLuint program, GLint location, const GLchar *name) |
| 2280 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2281 | Program *programObject = getProgramResolveLink(program); |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 2282 | ASSERT(programObject); |
| 2283 | |
| 2284 | programObject->bindUniformLocation(location, name); |
| 2285 | } |
| 2286 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2287 | void Context::coverageModulation(GLenum components) |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2288 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2289 | mState.setCoverageModulation(components); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2290 | } |
| 2291 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2292 | void Context::matrixLoadf(GLenum matrixMode, const GLfloat *matrix) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2293 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2294 | mState.loadPathRenderingMatrix(matrixMode, matrix); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2295 | } |
| 2296 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2297 | void Context::matrixLoadIdentity(GLenum matrixMode) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2298 | { |
| 2299 | GLfloat I[16]; |
| 2300 | angle::Matrix<GLfloat>::setToIdentity(I); |
| 2301 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2302 | mState.loadPathRenderingMatrix(matrixMode, I); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2303 | } |
| 2304 | |
| 2305 | void Context::stencilFillPath(GLuint path, GLenum fillMode, GLuint mask) |
| 2306 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2307 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2308 | if (!pathObj) |
| 2309 | return; |
| 2310 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2311 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2312 | |
| 2313 | mImplementation->stencilFillPath(pathObj, fillMode, mask); |
| 2314 | } |
| 2315 | |
| 2316 | void Context::stencilStrokePath(GLuint path, GLint reference, GLuint mask) |
| 2317 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2318 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2319 | if (!pathObj) |
| 2320 | return; |
| 2321 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2322 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2323 | |
| 2324 | mImplementation->stencilStrokePath(pathObj, reference, mask); |
| 2325 | } |
| 2326 | |
| 2327 | void Context::coverFillPath(GLuint path, GLenum coverMode) |
| 2328 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2329 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2330 | if (!pathObj) |
| 2331 | return; |
| 2332 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2333 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2334 | |
| 2335 | mImplementation->coverFillPath(pathObj, coverMode); |
| 2336 | } |
| 2337 | |
| 2338 | void Context::coverStrokePath(GLuint path, GLenum coverMode) |
| 2339 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2340 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2341 | if (!pathObj) |
| 2342 | return; |
| 2343 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2344 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2345 | |
| 2346 | mImplementation->coverStrokePath(pathObj, coverMode); |
| 2347 | } |
| 2348 | |
| 2349 | void Context::stencilThenCoverFillPath(GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode) |
| 2350 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2351 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2352 | if (!pathObj) |
| 2353 | return; |
| 2354 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2355 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2356 | |
| 2357 | mImplementation->stencilThenCoverFillPath(pathObj, fillMode, mask, coverMode); |
| 2358 | } |
| 2359 | |
| 2360 | void Context::stencilThenCoverStrokePath(GLuint path, |
| 2361 | GLint reference, |
| 2362 | GLuint mask, |
| 2363 | GLenum coverMode) |
| 2364 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2365 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2366 | if (!pathObj) |
| 2367 | return; |
| 2368 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2369 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2370 | |
| 2371 | mImplementation->stencilThenCoverStrokePath(pathObj, reference, mask, coverMode); |
| 2372 | } |
| 2373 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2374 | void Context::coverFillPathInstanced(GLsizei numPaths, |
| 2375 | GLenum pathNameType, |
| 2376 | const void *paths, |
| 2377 | GLuint pathBase, |
| 2378 | GLenum coverMode, |
| 2379 | GLenum transformType, |
| 2380 | const GLfloat *transformValues) |
| 2381 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2382 | const auto &pathObjects = |
| 2383 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2384 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2385 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2386 | |
| 2387 | mImplementation->coverFillPathInstanced(pathObjects, coverMode, transformType, transformValues); |
| 2388 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2389 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2390 | void Context::coverStrokePathInstanced(GLsizei numPaths, |
| 2391 | GLenum pathNameType, |
| 2392 | const void *paths, |
| 2393 | GLuint pathBase, |
| 2394 | GLenum coverMode, |
| 2395 | GLenum transformType, |
| 2396 | const GLfloat *transformValues) |
| 2397 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2398 | const auto &pathObjects = |
| 2399 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2400 | |
| 2401 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2402 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2403 | |
| 2404 | mImplementation->coverStrokePathInstanced(pathObjects, coverMode, transformType, |
| 2405 | transformValues); |
| 2406 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2407 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2408 | void Context::stencilFillPathInstanced(GLsizei numPaths, |
| 2409 | GLenum pathNameType, |
| 2410 | const void *paths, |
| 2411 | GLuint pathBase, |
| 2412 | GLenum fillMode, |
| 2413 | GLuint mask, |
| 2414 | GLenum transformType, |
| 2415 | const GLfloat *transformValues) |
| 2416 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2417 | const auto &pathObjects = |
| 2418 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2419 | |
| 2420 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2421 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2422 | |
| 2423 | mImplementation->stencilFillPathInstanced(pathObjects, fillMode, mask, transformType, |
| 2424 | transformValues); |
| 2425 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2426 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2427 | void Context::stencilStrokePathInstanced(GLsizei numPaths, |
| 2428 | GLenum pathNameType, |
| 2429 | const void *paths, |
| 2430 | GLuint pathBase, |
| 2431 | GLint reference, |
| 2432 | GLuint mask, |
| 2433 | GLenum transformType, |
| 2434 | const GLfloat *transformValues) |
| 2435 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2436 | const auto &pathObjects = |
| 2437 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2438 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2439 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2440 | |
| 2441 | mImplementation->stencilStrokePathInstanced(pathObjects, reference, mask, transformType, |
| 2442 | transformValues); |
| 2443 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2444 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2445 | void Context::stencilThenCoverFillPathInstanced(GLsizei numPaths, |
| 2446 | GLenum pathNameType, |
| 2447 | const void *paths, |
| 2448 | GLuint pathBase, |
| 2449 | GLenum fillMode, |
| 2450 | GLuint mask, |
| 2451 | GLenum coverMode, |
| 2452 | GLenum transformType, |
| 2453 | const GLfloat *transformValues) |
| 2454 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2455 | const auto &pathObjects = |
| 2456 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2457 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2458 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2459 | |
| 2460 | mImplementation->stencilThenCoverFillPathInstanced(pathObjects, coverMode, fillMode, mask, |
| 2461 | transformType, transformValues); |
| 2462 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2463 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2464 | void Context::stencilThenCoverStrokePathInstanced(GLsizei numPaths, |
| 2465 | GLenum pathNameType, |
| 2466 | const void *paths, |
| 2467 | GLuint pathBase, |
| 2468 | GLint reference, |
| 2469 | GLuint mask, |
| 2470 | GLenum coverMode, |
| 2471 | GLenum transformType, |
| 2472 | const GLfloat *transformValues) |
| 2473 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2474 | const auto &pathObjects = |
| 2475 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2476 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2477 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2478 | |
| 2479 | mImplementation->stencilThenCoverStrokePathInstanced(pathObjects, coverMode, reference, mask, |
| 2480 | transformType, transformValues); |
| 2481 | } |
| 2482 | |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2483 | void Context::bindFragmentInputLocation(GLuint program, GLint location, const GLchar *name) |
| 2484 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2485 | auto *programObject = getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2486 | |
| 2487 | programObject->bindFragmentInputLocation(location, name); |
| 2488 | } |
| 2489 | |
| 2490 | void Context::programPathFragmentInputGen(GLuint program, |
| 2491 | GLint location, |
| 2492 | GLenum genMode, |
| 2493 | GLint components, |
| 2494 | const GLfloat *coeffs) |
| 2495 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2496 | auto *programObject = getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2497 | |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 2498 | programObject->pathFragmentInputGen(location, genMode, components, coeffs); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2499 | } |
| 2500 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2501 | GLuint Context::getProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar *name) |
| 2502 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2503 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2504 | return QueryProgramResourceIndex(programObject, programInterface, name); |
| 2505 | } |
| 2506 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2507 | void Context::getProgramResourceName(GLuint program, |
| 2508 | GLenum programInterface, |
| 2509 | GLuint index, |
| 2510 | GLsizei bufSize, |
| 2511 | GLsizei *length, |
| 2512 | GLchar *name) |
| 2513 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2514 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2515 | QueryProgramResourceName(programObject, programInterface, index, bufSize, length, name); |
| 2516 | } |
| 2517 | |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2518 | GLint Context::getProgramResourceLocation(GLuint program, |
| 2519 | GLenum programInterface, |
| 2520 | const GLchar *name) |
| 2521 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2522 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2523 | return QueryProgramResourceLocation(programObject, programInterface, name); |
| 2524 | } |
| 2525 | |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2526 | void Context::getProgramResourceiv(GLuint program, |
| 2527 | GLenum programInterface, |
| 2528 | GLuint index, |
| 2529 | GLsizei propCount, |
| 2530 | const GLenum *props, |
| 2531 | GLsizei bufSize, |
| 2532 | GLsizei *length, |
| 2533 | GLint *params) |
| 2534 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2535 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2536 | QueryProgramResourceiv(programObject, programInterface, index, propCount, props, bufSize, |
| 2537 | length, params); |
| 2538 | } |
| 2539 | |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 2540 | void Context::getProgramInterfaceiv(GLuint program, |
| 2541 | GLenum programInterface, |
| 2542 | GLenum pname, |
| 2543 | GLint *params) |
| 2544 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2545 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 2546 | QueryProgramInterfaceiv(programObject, programInterface, pname, params); |
| 2547 | } |
| 2548 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2549 | void Context::getProgramInterfaceivRobust(GLuint program, |
| 2550 | GLenum programInterface, |
| 2551 | GLenum pname, |
| 2552 | GLsizei bufSize, |
| 2553 | GLsizei *length, |
| 2554 | GLint *params) |
| 2555 | { |
| 2556 | UNIMPLEMENTED(); |
| 2557 | } |
| 2558 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 2559 | void Context::handleError(GLenum errorCode, |
| 2560 | const char *message, |
| 2561 | const char *file, |
| 2562 | const char *function, |
| 2563 | unsigned int line) |
| 2564 | { |
| 2565 | mErrors.handleError(errorCode, message, file, function, line); |
| 2566 | } |
| 2567 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 2568 | void Context::validationError(GLenum errorCode, const char *message) |
| 2569 | { |
| 2570 | mErrors.validationError(errorCode, message); |
| 2571 | } |
| 2572 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2573 | // Get one of the recorded errors and clear its flag, if any. |
| 2574 | // [OpenGL ES 2.0.24] section 2.5 page 13. |
| 2575 | GLenum Context::getError() |
| 2576 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2577 | if (mErrors.empty()) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2578 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2579 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2580 | } |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2581 | else |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2582 | { |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 2583 | return mErrors.popError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2584 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2585 | } |
| 2586 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2587 | // NOTE: this function should not assume that this context is current! |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 2588 | void Context::markContextLost() |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2589 | { |
| 2590 | if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT) |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2591 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2592 | mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT; |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2593 | mContextLostForced = true; |
| 2594 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2595 | mContextLost = true; |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2596 | } |
| 2597 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 2598 | GLenum Context::getGraphicsResetStatus() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2599 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2600 | // Even if the application doesn't want to know about resets, we want to know |
| 2601 | // as it will allow us to skip all the calls. |
| 2602 | if (mResetStrategy == GL_NO_RESET_NOTIFICATION_EXT) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2603 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2604 | if (!mContextLost && mImplementation->getResetStatus() != GL_NO_ERROR) |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2605 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2606 | mContextLost = true; |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2607 | } |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2608 | |
| 2609 | // EXT_robustness, section 2.6: If the reset notification behavior is |
| 2610 | // NO_RESET_NOTIFICATION_EXT, then the implementation will never deliver notification of |
| 2611 | // reset events, and GetGraphicsResetStatusEXT will always return NO_ERROR. |
| 2612 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2613 | } |
| 2614 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2615 | // The GL_EXT_robustness spec says that if a reset is encountered, a reset |
| 2616 | // status should be returned at least once, and GL_NO_ERROR should be returned |
| 2617 | // once the device has finished resetting. |
| 2618 | if (!mContextLost) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2619 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2620 | ASSERT(mResetStatus == GL_NO_ERROR); |
| 2621 | mResetStatus = mImplementation->getResetStatus(); |
shannon.woods@transgaming.com | ddd6c80 | 2013-02-28 23:05:14 +0000 | [diff] [blame] | 2622 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2623 | if (mResetStatus != GL_NO_ERROR) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2624 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2625 | mContextLost = true; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2626 | } |
| 2627 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2628 | else if (!mContextLostForced && mResetStatus != GL_NO_ERROR) |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2629 | { |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2630 | // If markContextLost was used to mark the context lost then |
| 2631 | // assume that is not recoverable, and continue to report the |
| 2632 | // lost reset status for the lifetime of this context. |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2633 | mResetStatus = mImplementation->getResetStatus(); |
| 2634 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 2635 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2636 | return mResetStatus; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2637 | } |
| 2638 | |
| 2639 | bool Context::isResetNotificationEnabled() |
| 2640 | { |
| 2641 | return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
| 2642 | } |
| 2643 | |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2644 | const egl::Config *Context::getConfig() const |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2645 | { |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2646 | return mConfig; |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2647 | } |
| 2648 | |
| 2649 | EGLenum Context::getClientType() const |
| 2650 | { |
| 2651 | return mClientType; |
| 2652 | } |
| 2653 | |
| 2654 | EGLenum Context::getRenderBuffer() const |
| 2655 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2656 | const Framebuffer *framebuffer = mState.mFramebufferManager->getFramebuffer(0); |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2657 | if (framebuffer == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 2658 | { |
| 2659 | return EGL_NONE; |
| 2660 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2661 | |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 2662 | const FramebufferAttachment *backAttachment = framebuffer->getAttachment(this, GL_BACK); |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2663 | ASSERT(backAttachment != nullptr); |
| 2664 | return backAttachment->getSurface()->getRenderBuffer(); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2665 | } |
| 2666 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2667 | VertexArray *Context::checkVertexArrayAllocation(GLuint vertexArrayHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2668 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2669 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2670 | VertexArray *vertexArray = getVertexArray(vertexArrayHandle); |
| 2671 | if (!vertexArray) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2672 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2673 | vertexArray = |
| 2674 | new VertexArray(mImplementation.get(), vertexArrayHandle, |
| 2675 | mState.mCaps.maxVertexAttributes, mState.mCaps.maxVertexAttribBindings); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2676 | |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2677 | mVertexArrayMap.assign(vertexArrayHandle, vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2678 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2679 | |
| 2680 | return vertexArray; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2681 | } |
| 2682 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2683 | TransformFeedback *Context::checkTransformFeedbackAllocation(GLuint transformFeedbackHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2684 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2685 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2686 | TransformFeedback *transformFeedback = getTransformFeedback(transformFeedbackHandle); |
| 2687 | if (!transformFeedback) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2688 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2689 | transformFeedback = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2690 | new TransformFeedback(mImplementation.get(), transformFeedbackHandle, mState.mCaps); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2691 | transformFeedback->addRef(); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2692 | mTransformFeedbackMap.assign(transformFeedbackHandle, transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2693 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2694 | |
| 2695 | return transformFeedback; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2696 | } |
| 2697 | |
| 2698 | bool Context::isVertexArrayGenerated(GLuint vertexArray) |
| 2699 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2700 | ASSERT(mVertexArrayMap.contains(0)); |
| 2701 | return mVertexArrayMap.contains(vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2702 | } |
| 2703 | |
| 2704 | bool Context::isTransformFeedbackGenerated(GLuint transformFeedback) |
| 2705 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2706 | ASSERT(mTransformFeedbackMap.contains(0)); |
| 2707 | return mTransformFeedbackMap.contains(transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2708 | } |
| 2709 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2710 | void Context::detachTexture(GLuint texture) |
| 2711 | { |
| 2712 | // Simple pass-through to State's detachTexture method, as textures do not require |
| 2713 | // allocation map management either here or in the resource manager at detach time. |
| 2714 | // Zero textures are held by the Context, and we don't attempt to request them from |
| 2715 | // the State. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2716 | mState.detachTexture(this, mZeroTextures, texture); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2717 | } |
| 2718 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 2719 | void Context::detachBuffer(Buffer *buffer) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2720 | { |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2721 | // Simple pass-through to State's detachBuffer method, since |
| 2722 | // only buffer attachments to container objects that are bound to the current context |
| 2723 | // should be detached. And all those are available in State. |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2724 | |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2725 | // [OpenGL ES 3.2] section 5.1.2 page 45: |
| 2726 | // Attachments to unbound container objects, such as |
| 2727 | // deletion of a buffer attached to a vertex array object which is not bound to the context, |
| 2728 | // are not affected and continue to act as references on the deleted object |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2729 | ANGLE_CONTEXT_TRY(mState.detachBuffer(this, buffer)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2730 | } |
| 2731 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2732 | void Context::detachFramebuffer(GLuint framebuffer) |
| 2733 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2734 | // Framebuffer detachment is handled by Context, because 0 is a valid |
| 2735 | // Framebuffer object, and a pointer to it must be passed from Context |
| 2736 | // to State at binding time. |
| 2737 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2738 | // [OpenGL ES 2.0.24] section 4.4 page 107: |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2739 | // If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as |
| 2740 | // though BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of |
| 2741 | // zero. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2742 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2743 | if (mState.removeReadFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2744 | { |
| 2745 | bindReadFramebuffer(0); |
| 2746 | } |
| 2747 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2748 | if (mState.removeDrawFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2749 | { |
| 2750 | bindDrawFramebuffer(0); |
| 2751 | } |
| 2752 | } |
| 2753 | |
| 2754 | void Context::detachRenderbuffer(GLuint renderbuffer) |
| 2755 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2756 | mState.detachRenderbuffer(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2757 | } |
| 2758 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2759 | void Context::detachVertexArray(GLuint vertexArray) |
| 2760 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 2761 | // Vertex array detachment is handled by Context, because 0 is a valid |
| 2762 | // 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] | 2763 | // binding time. |
| 2764 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2765 | // [OpenGL ES 3.0.2] section 2.10 page 43: |
| 2766 | // If a vertex array object that is currently bound is deleted, the binding |
| 2767 | // for that object reverts to zero and the default vertex array becomes current. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2768 | if (mState.removeVertexArrayBinding(this, vertexArray)) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2769 | { |
| 2770 | bindVertexArray(0); |
| 2771 | } |
| 2772 | } |
| 2773 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2774 | void Context::detachTransformFeedback(GLuint transformFeedback) |
| 2775 | { |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2776 | // Transform feedback detachment is handled by Context, because 0 is a valid |
| 2777 | // transform feedback, and a pointer to it must be passed from Context to State at |
| 2778 | // binding time. |
| 2779 | |
| 2780 | // The OpenGL specification doesn't mention what should happen when the currently bound |
| 2781 | // transform feedback object is deleted. Since it is a container object, we treat it like |
| 2782 | // VAOs and FBOs and set the current bound transform feedback back to 0. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2783 | if (mState.removeTransformFeedbackBinding(this, transformFeedback)) |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2784 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 2785 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2786 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2787 | } |
| 2788 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2789 | void Context::detachSampler(GLuint sampler) |
| 2790 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2791 | mState.detachSampler(this, sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2792 | } |
| 2793 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 2794 | void Context::detachProgramPipeline(GLuint pipeline) |
| 2795 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2796 | mState.detachProgramPipeline(this, pipeline); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 2797 | } |
| 2798 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 2799 | void Context::vertexAttribDivisor(GLuint index, GLuint divisor) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2800 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2801 | mState.setVertexAttribDivisor(this, index, divisor); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 2802 | mStateCache.onVertexArrayStateChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2803 | } |
| 2804 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2805 | void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 2806 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2807 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2808 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2809 | SetSamplerParameteri(this, samplerObject, pname, param); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2810 | } |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2811 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2812 | void Context::samplerParameteriv(GLuint sampler, GLenum pname, const GLint *param) |
| 2813 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2814 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2815 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2816 | SetSamplerParameteriv(this, samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2817 | } |
| 2818 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2819 | void Context::samplerParameterIiv(GLuint sampler, GLenum pname, const GLint *param) |
| 2820 | { |
| 2821 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2822 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2823 | SetSamplerParameterIiv(this, samplerObject, pname, param); |
| 2824 | } |
| 2825 | |
| 2826 | void Context::samplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *param) |
| 2827 | { |
| 2828 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2829 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2830 | SetSamplerParameterIuiv(this, samplerObject, pname, param); |
| 2831 | } |
| 2832 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2833 | void Context::samplerParameterivRobust(GLuint sampler, |
| 2834 | GLenum pname, |
| 2835 | GLsizei bufSize, |
| 2836 | const GLint *param) |
| 2837 | { |
| 2838 | samplerParameteriv(sampler, pname, param); |
| 2839 | } |
| 2840 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2841 | void Context::samplerParameterIivRobust(GLuint sampler, |
| 2842 | GLenum pname, |
| 2843 | GLsizei bufSize, |
| 2844 | const GLint *param) |
| 2845 | { |
| 2846 | UNIMPLEMENTED(); |
| 2847 | } |
| 2848 | |
| 2849 | void Context::samplerParameterIuivRobust(GLuint sampler, |
| 2850 | GLenum pname, |
| 2851 | GLsizei bufSize, |
| 2852 | const GLuint *param) |
| 2853 | { |
| 2854 | UNIMPLEMENTED(); |
| 2855 | } |
| 2856 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2857 | void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 2858 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2859 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2860 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2861 | SetSamplerParameterf(this, samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2862 | } |
| 2863 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2864 | void Context::samplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2865 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2866 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2867 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2868 | SetSamplerParameterfv(this, samplerObject, pname, param); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2869 | } |
| 2870 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2871 | void Context::samplerParameterfvRobust(GLuint sampler, |
| 2872 | GLenum pname, |
| 2873 | GLsizei bufSize, |
| 2874 | const GLfloat *param) |
| 2875 | { |
| 2876 | samplerParameterfv(sampler, pname, param); |
| 2877 | } |
| 2878 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2879 | void Context::getSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2880 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2881 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2882 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2883 | QuerySamplerParameteriv(samplerObject, pname, params); |
| 2884 | } |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2885 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2886 | void Context::getSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) |
| 2887 | { |
| 2888 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2889 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2890 | QuerySamplerParameterIiv(samplerObject, pname, params); |
| 2891 | } |
| 2892 | |
| 2893 | void Context::getSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) |
| 2894 | { |
| 2895 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2896 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2897 | QuerySamplerParameterIuiv(samplerObject, pname, params); |
| 2898 | } |
| 2899 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2900 | void Context::getSamplerParameterivRobust(GLuint sampler, |
| 2901 | GLenum pname, |
| 2902 | GLsizei bufSize, |
| 2903 | GLsizei *length, |
| 2904 | GLint *params) |
| 2905 | { |
| 2906 | getSamplerParameteriv(sampler, pname, params); |
| 2907 | } |
| 2908 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2909 | void Context::getSamplerParameterIivRobust(GLuint sampler, |
| 2910 | GLenum pname, |
| 2911 | GLsizei bufSize, |
| 2912 | GLsizei *length, |
| 2913 | GLint *params) |
| 2914 | { |
| 2915 | UNIMPLEMENTED(); |
| 2916 | } |
| 2917 | |
| 2918 | void Context::getSamplerParameterIuivRobust(GLuint sampler, |
| 2919 | GLenum pname, |
| 2920 | GLsizei bufSize, |
| 2921 | GLsizei *length, |
| 2922 | GLuint *params) |
| 2923 | { |
| 2924 | UNIMPLEMENTED(); |
| 2925 | } |
| 2926 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2927 | void Context::getSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) |
| 2928 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2929 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2930 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2931 | QuerySamplerParameterfv(samplerObject, pname, params); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2932 | } |
| 2933 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2934 | void Context::getSamplerParameterfvRobust(GLuint sampler, |
| 2935 | GLenum pname, |
| 2936 | GLsizei bufSize, |
| 2937 | GLsizei *length, |
| 2938 | GLfloat *params) |
| 2939 | { |
| 2940 | getSamplerParameterfv(sampler, pname, params); |
| 2941 | } |
| 2942 | |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2943 | void Context::programParameteri(GLuint program, GLenum pname, GLint value) |
| 2944 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2945 | gl::Program *programObject = getProgramResolveLink(program); |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 2946 | SetProgramParameteri(programObject, pname, value); |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2947 | } |
| 2948 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2949 | void Context::initRendererString() |
| 2950 | { |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2951 | std::ostringstream rendererString; |
| 2952 | rendererString << "ANGLE ("; |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2953 | rendererString << mImplementation->getRendererDescription(); |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2954 | rendererString << ")"; |
| 2955 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2956 | mRendererString = MakeStaticString(rendererString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2957 | } |
| 2958 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2959 | void Context::initVersionStrings() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2960 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2961 | const Version &clientVersion = getClientVersion(); |
| 2962 | |
| 2963 | std::ostringstream versionString; |
| 2964 | versionString << "OpenGL ES " << clientVersion.major << "." << clientVersion.minor << " (ANGLE " |
| 2965 | << ANGLE_VERSION_STRING << ")"; |
| 2966 | mVersionString = MakeStaticString(versionString.str()); |
| 2967 | |
| 2968 | std::ostringstream shadingLanguageVersionString; |
| 2969 | shadingLanguageVersionString << "OpenGL ES GLSL ES " |
| 2970 | << (clientVersion.major == 2 ? 1 : clientVersion.major) << "." |
| 2971 | << clientVersion.minor << "0 (ANGLE " << ANGLE_VERSION_STRING |
| 2972 | << ")"; |
| 2973 | mShadingLanguageString = MakeStaticString(shadingLanguageVersionString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2974 | } |
| 2975 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2976 | void Context::initExtensionStrings() |
| 2977 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2978 | auto mergeExtensionStrings = [](const std::vector<const char *> &strings) { |
| 2979 | std::ostringstream combinedStringStream; |
| 2980 | std::copy(strings.begin(), strings.end(), |
| 2981 | std::ostream_iterator<const char *>(combinedStringStream, " ")); |
| 2982 | return MakeStaticString(combinedStringStream.str()); |
| 2983 | }; |
| 2984 | |
| 2985 | mExtensionStrings.clear(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2986 | for (const auto &extensionString : mState.mExtensions.getStrings()) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 2987 | { |
| 2988 | mExtensionStrings.push_back(MakeStaticString(extensionString)); |
| 2989 | } |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2990 | mExtensionString = mergeExtensionStrings(mExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2991 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2992 | mRequestableExtensionStrings.clear(); |
| 2993 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 2994 | { |
| 2995 | if (extensionInfo.second.Requestable && |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2996 | !(mState.mExtensions.*(extensionInfo.second.ExtensionsMember)) && |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 2997 | mSupportedExtensions.*(extensionInfo.second.ExtensionsMember)) |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2998 | { |
| 2999 | mRequestableExtensionStrings.push_back(MakeStaticString(extensionInfo.first)); |
| 3000 | } |
| 3001 | } |
| 3002 | mRequestableExtensionString = mergeExtensionStrings(mRequestableExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3003 | } |
| 3004 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3005 | const GLubyte *Context::getString(GLenum name) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3006 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3007 | switch (name) |
| 3008 | { |
| 3009 | case GL_VENDOR: |
| 3010 | return reinterpret_cast<const GLubyte *>("Google Inc."); |
| 3011 | |
| 3012 | case GL_RENDERER: |
| 3013 | return reinterpret_cast<const GLubyte *>(mRendererString); |
| 3014 | |
| 3015 | case GL_VERSION: |
| 3016 | return reinterpret_cast<const GLubyte *>(mVersionString); |
| 3017 | |
| 3018 | case GL_SHADING_LANGUAGE_VERSION: |
| 3019 | return reinterpret_cast<const GLubyte *>(mShadingLanguageString); |
| 3020 | |
| 3021 | case GL_EXTENSIONS: |
| 3022 | return reinterpret_cast<const GLubyte *>(mExtensionString); |
| 3023 | |
| 3024 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 3025 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionString); |
| 3026 | |
| 3027 | default: |
| 3028 | UNREACHABLE(); |
| 3029 | return nullptr; |
| 3030 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3031 | } |
| 3032 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3033 | const GLubyte *Context::getStringi(GLenum name, GLuint index) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3034 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3035 | switch (name) |
| 3036 | { |
| 3037 | case GL_EXTENSIONS: |
| 3038 | return reinterpret_cast<const GLubyte *>(mExtensionStrings[index]); |
| 3039 | |
| 3040 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 3041 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionStrings[index]); |
| 3042 | |
| 3043 | default: |
| 3044 | UNREACHABLE(); |
| 3045 | return nullptr; |
| 3046 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3047 | } |
| 3048 | |
| 3049 | size_t Context::getExtensionStringCount() const |
| 3050 | { |
| 3051 | return mExtensionStrings.size(); |
| 3052 | } |
| 3053 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3054 | bool Context::isExtensionRequestable(const char *name) |
| 3055 | { |
| 3056 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 3057 | auto extension = extensionInfos.find(name); |
| 3058 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3059 | return extension != extensionInfos.end() && extension->second.Requestable && |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3060 | mSupportedExtensions.*(extension->second.ExtensionsMember); |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3061 | } |
| 3062 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3063 | void Context::requestExtension(const char *name) |
| 3064 | { |
| 3065 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 3066 | ASSERT(extensionInfos.find(name) != extensionInfos.end()); |
| 3067 | const auto &extension = extensionInfos.at(name); |
| 3068 | ASSERT(extension.Requestable); |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3069 | ASSERT(isExtensionRequestable(name)); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3070 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3071 | if (mState.mExtensions.*(extension.ExtensionsMember)) |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3072 | { |
| 3073 | // Extension already enabled |
| 3074 | return; |
| 3075 | } |
| 3076 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3077 | mState.mExtensions.*(extension.ExtensionsMember) = true; |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3078 | updateCaps(); |
| 3079 | initExtensionStrings(); |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 3080 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 3081 | // Release the shader compiler so it will be re-created with the requested extensions enabled. |
| 3082 | releaseShaderCompiler(); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3083 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 3084 | // Invalidate all textures and framebuffer. Some extensions make new formats renderable or |
| 3085 | // sampleable. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3086 | mState.mTextureManager->signalAllTexturesDirty(this); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3087 | for (auto &zeroTexture : mZeroTextures) |
| 3088 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3089 | if (zeroTexture.get() != nullptr) |
| 3090 | { |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 3091 | zeroTexture->signalDirtyStorage(this, InitState::Initialized); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3092 | } |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3093 | } |
| 3094 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3095 | mState.mFramebufferManager->invalidateFramebufferComplenessCache(this); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3096 | } |
| 3097 | |
| 3098 | size_t Context::getRequestableExtensionStringCount() const |
| 3099 | { |
| 3100 | return mRequestableExtensionStrings.size(); |
| 3101 | } |
| 3102 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 3103 | void Context::beginTransformFeedback(PrimitiveMode primitiveMode) |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3104 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3105 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3106 | ASSERT(transformFeedback != nullptr); |
| 3107 | ASSERT(!transformFeedback->isPaused()); |
| 3108 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3109 | ANGLE_CONTEXT_TRY(transformFeedback->begin(this, primitiveMode, mState.getProgram())); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 3110 | mStateCache.onActiveTransformFeedbackChange(this); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3111 | } |
| 3112 | |
| 3113 | bool Context::hasActiveTransformFeedback(GLuint program) const |
| 3114 | { |
| 3115 | for (auto pair : mTransformFeedbackMap) |
| 3116 | { |
| 3117 | if (pair.second != nullptr && pair.second->hasBoundProgram(program)) |
| 3118 | { |
| 3119 | return true; |
| 3120 | } |
| 3121 | } |
| 3122 | return false; |
| 3123 | } |
| 3124 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3125 | Extensions Context::generateSupportedExtensions() const |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3126 | { |
| 3127 | Extensions supportedExtensions = mImplementation->getNativeExtensions(); |
| 3128 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 3129 | // Explicitly enable GL_KHR_parallel_shader_compile |
| 3130 | supportedExtensions.parallelShaderCompile = true; |
| 3131 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3132 | if (getClientVersion() < ES_2_0) |
| 3133 | { |
| 3134 | // Default extensions for GLES1 |
Lingfeng Yang | 0df813c | 2018-07-12 12:52:06 -0700 | [diff] [blame] | 3135 | supportedExtensions.pointSizeArray = true; |
| 3136 | supportedExtensions.textureCubeMap = true; |
| 3137 | supportedExtensions.pointSprite = true; |
| 3138 | supportedExtensions.drawTexture = true; |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 3139 | supportedExtensions.parallelShaderCompile = false; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3140 | } |
| 3141 | |
| 3142 | if (getClientVersion() < ES_3_0) |
| 3143 | { |
| 3144 | // Disable ES3+ extensions |
| 3145 | supportedExtensions.colorBufferFloat = false; |
| 3146 | supportedExtensions.eglImageExternalEssl3 = false; |
| 3147 | supportedExtensions.textureNorm16 = false; |
| 3148 | supportedExtensions.multiview = false; |
| 3149 | supportedExtensions.maxViews = 1u; |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 3150 | supportedExtensions.copyTexture3d = false; |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 3151 | supportedExtensions.textureMultisample = false; |
Geoff Lang | 7198ebc | 2018-11-22 14:36:06 -0500 | [diff] [blame] | 3152 | |
| 3153 | // Don't expose GL_EXT_texture_sRGB_decode without sRGB texture support |
| 3154 | if (!supportedExtensions.sRGB) |
| 3155 | { |
| 3156 | supportedExtensions.textureSRGBDecode = false; |
| 3157 | } |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3158 | } |
| 3159 | |
| 3160 | if (getClientVersion() < ES_3_1) |
| 3161 | { |
| 3162 | // Disable ES3.1+ extensions |
| 3163 | supportedExtensions.geometryShader = false; |
Olli Etuaho | d310a43 | 2018-08-24 15:40:23 +0300 | [diff] [blame] | 3164 | |
| 3165 | // TODO(http://anglebug.com/2775): Multisample arrays could be supported on ES 3.0 as well |
| 3166 | // once 2D multisample texture extension is exposed there. |
Olli Etuaho | 064458a | 2018-08-30 14:02:02 +0300 | [diff] [blame] | 3167 | supportedExtensions.textureStorageMultisample2DArray = false; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3168 | } |
| 3169 | |
| 3170 | if (getClientVersion() > ES_2_0) |
| 3171 | { |
| 3172 | // FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts |
| 3173 | // supportedExtensions.sRGB = false; |
| 3174 | } |
| 3175 | |
| 3176 | // Some extensions are always available because they are implemented in the GL layer. |
| 3177 | supportedExtensions.bindUniformLocation = true; |
| 3178 | supportedExtensions.vertexArrayObject = true; |
| 3179 | supportedExtensions.bindGeneratesResource = true; |
| 3180 | supportedExtensions.clientArrays = true; |
| 3181 | supportedExtensions.requestExtension = true; |
Austin Eng | 7cf9cd2 | 2018-10-09 15:27:32 -0700 | [diff] [blame] | 3182 | supportedExtensions.multiDraw = true; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3183 | |
| 3184 | // Enable the no error extension if the context was created with the flag. |
| 3185 | supportedExtensions.noError = mSkipValidation; |
| 3186 | |
| 3187 | // Enable surfaceless to advertise we'll have the correct behavior when there is no default FBO |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3188 | supportedExtensions.surfacelessContext = mSurfacelessSupported; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3189 | |
| 3190 | // Explicitly enable GL_KHR_debug |
| 3191 | supportedExtensions.debug = true; |
| 3192 | supportedExtensions.maxDebugMessageLength = 1024; |
| 3193 | supportedExtensions.maxDebugLoggedMessages = 1024; |
| 3194 | supportedExtensions.maxDebugGroupStackDepth = 1024; |
| 3195 | supportedExtensions.maxLabelLength = 1024; |
| 3196 | |
| 3197 | // Explicitly enable GL_ANGLE_robust_client_memory |
| 3198 | supportedExtensions.robustClientMemory = true; |
| 3199 | |
| 3200 | // Determine robust resource init availability from EGL. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3201 | supportedExtensions.robustResourceInitialization = mState.isRobustResourceInitEnabled(); |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3202 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3203 | // mState.mExtensions.robustBufferAccessBehavior is true only if robust access is true and the |
| 3204 | // backend supports it. |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3205 | supportedExtensions.robustBufferAccessBehavior = |
| 3206 | mRobustAccess && supportedExtensions.robustBufferAccessBehavior; |
| 3207 | |
| 3208 | // Enable the cache control query unconditionally. |
| 3209 | supportedExtensions.programCacheControl = true; |
| 3210 | |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 3211 | // Enable EGL_ANGLE_explicit_context subextensions |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3212 | if (mExplicitContextAvailable) |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 3213 | { |
| 3214 | // GL_ANGLE_explicit_context_gles1 |
| 3215 | supportedExtensions.explicitContextGles1 = true; |
| 3216 | // GL_ANGLE_explicit_context |
| 3217 | supportedExtensions.explicitContext = true; |
| 3218 | } |
| 3219 | |
Shahbaz Youssefi | 5313c8a | 2019-01-14 17:02:52 -0500 | [diff] [blame^] | 3220 | // If EGL_KHR_fence_sync is not enabled, don't expose GL_OES_EGL_sync. |
| 3221 | ASSERT(mCurrentDisplay); |
| 3222 | if (!mCurrentDisplay->getExtensions().fenceSync) |
| 3223 | { |
| 3224 | supportedExtensions.eglSync = false; |
| 3225 | } |
| 3226 | |
Geoff Lang | 79b9140 | 2018-10-04 15:11:30 -0400 | [diff] [blame] | 3227 | supportedExtensions.memorySize = true; |
| 3228 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3229 | return supportedExtensions; |
| 3230 | } |
| 3231 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3232 | void Context::initCaps() |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3233 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3234 | mState.mCaps = mImplementation->getNativeCaps(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3235 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3236 | mSupportedExtensions = generateSupportedExtensions(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3237 | mState.mExtensions = mSupportedExtensions; |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 3238 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3239 | mState.mLimitations = mImplementation->getNativeLimitations(); |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 3240 | |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3241 | // GLES1 emulation: Initialize caps (Table 6.20 / 6.22 in the ES 1.1 spec) |
| 3242 | if (getClientVersion() < Version(2, 0)) |
| 3243 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3244 | mState.mCaps.maxMultitextureUnits = 4; |
| 3245 | mState.mCaps.maxClipPlanes = 6; |
| 3246 | mState.mCaps.maxLights = 8; |
| 3247 | mState.mCaps.maxModelviewMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3248 | mState.mCaps.maxProjectionMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3249 | mState.mCaps.maxTextureMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3250 | mState.mCaps.minSmoothPointSize = 1.0f; |
| 3251 | mState.mCaps.maxSmoothPointSize = 1.0f; |
| 3252 | mState.mCaps.minSmoothLineWidth = 1.0f; |
| 3253 | mState.mCaps.maxSmoothLineWidth = 1.0f; |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3254 | } |
| 3255 | |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3256 | // Apply/Verify implementation limits |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3257 | LimitCap(&mState.mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 3258 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3259 | ASSERT(mState.mCaps.minAliasedPointSize >= 1.0f); |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3260 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3261 | if (getClientVersion() < ES_3_1) |
| 3262 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3263 | mState.mCaps.maxVertexAttribBindings = mState.mCaps.maxVertexAttributes; |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3264 | } |
| 3265 | else |
| 3266 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3267 | LimitCap(&mState.mCaps.maxVertexAttribBindings, MAX_VERTEX_ATTRIB_BINDINGS); |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3268 | } |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 3269 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3270 | LimitCap(&mState.mCaps.maxShaderUniformBlocks[ShaderType::Vertex], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3271 | IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3272 | LimitCap(&mState.mCaps.maxUniformBufferBindings, IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 3273 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3274 | LimitCap(&mState.mCaps.maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
| 3275 | LimitCap(&mState.mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3276 | |
| 3277 | // Limit textures as well, so we can use fast bitsets with texture bindings. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3278 | LimitCap(&mState.mCaps.maxCombinedTextureImageUnits, IMPLEMENTATION_MAX_ACTIVE_TEXTURES); |
| 3279 | LimitCap(&mState.mCaps.maxShaderTextureImageUnits[ShaderType::Vertex], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3280 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3281 | LimitCap(&mState.mCaps.maxShaderTextureImageUnits[ShaderType::Fragment], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3282 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 3283 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3284 | LimitCap(&mState.mCaps.maxImageUnits, IMPLEMENTATION_MAX_IMAGE_UNITS); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 3285 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3286 | mState.mCaps.maxSampleMaskWords = |
| 3287 | std::min<GLuint>(mState.mCaps.maxSampleMaskWords, MAX_SAMPLE_MASK_WORDS); |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 3288 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3289 | // WebGL compatibility |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3290 | mState.mExtensions.webglCompatibility = mWebGLContext; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3291 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 3292 | { |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 3293 | // If the user has requested that extensions start disabled and they are requestable, |
| 3294 | // disable them. |
| 3295 | if (!mExtensionsEnabled && extensionInfo.second.Requestable) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3296 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3297 | mState.mExtensions.*(extensionInfo.second.ExtensionsMember) = false; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3298 | } |
| 3299 | } |
| 3300 | |
| 3301 | // Generate texture caps |
| 3302 | updateCaps(); |
| 3303 | } |
| 3304 | |
| 3305 | void Context::updateCaps() |
| 3306 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3307 | mState.mCaps.compressedTextureFormats.clear(); |
| 3308 | mState.mTextureCaps.clear(); |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3309 | |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3310 | for (GLenum sizedInternalFormat : GetAllSizedInternalFormats()) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3311 | { |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3312 | TextureCaps formatCaps = mImplementation->getNativeTextureCaps().get(sizedInternalFormat); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3313 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3314 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 3315 | // Update the format caps based on the client version and extensions. |
| 3316 | // Caps are AND'd with the renderer caps because some core formats are still unsupported in |
| 3317 | // ES3. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3318 | formatCaps.texturable = formatCaps.texturable && |
| 3319 | formatInfo.textureSupport(getClientVersion(), mState.mExtensions); |
| 3320 | formatCaps.filterable = formatCaps.filterable && |
| 3321 | formatInfo.filterSupport(getClientVersion(), mState.mExtensions); |
Yuly Novikov | f15f886 | 2018-06-04 18:59:41 -0400 | [diff] [blame] | 3322 | formatCaps.textureAttachment = |
| 3323 | formatCaps.textureAttachment && |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3324 | formatInfo.textureAttachmentSupport(getClientVersion(), mState.mExtensions); |
| 3325 | formatCaps.renderbuffer = |
| 3326 | formatCaps.renderbuffer && |
| 3327 | formatInfo.renderbufferSupport(getClientVersion(), mState.mExtensions); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3328 | |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3329 | // OpenGL ES does not support multisampling with non-rendererable formats |
| 3330 | // OpenGL ES 3.0 or prior does not support multisampling with integer formats |
Yuly Novikov | f15f886 | 2018-06-04 18:59:41 -0400 | [diff] [blame] | 3331 | if (!formatCaps.renderbuffer || |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3332 | (getClientVersion() < ES_3_1 && !mSupportedExtensions.textureMultisample && |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3333 | (formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT))) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3334 | { |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3335 | formatCaps.sampleCounts.clear(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3336 | } |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3337 | else |
| 3338 | { |
| 3339 | // We may have limited the max samples for some required renderbuffer formats due to |
| 3340 | // non-conformant formats. In this case MAX_SAMPLES needs to be lowered accordingly. |
| 3341 | GLuint formatMaxSamples = formatCaps.getMaxSamples(); |
| 3342 | |
| 3343 | // GLES 3.0.5 section 4.4.2.2: "Implementations must support creation of renderbuffers |
| 3344 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with the |
| 3345 | // exception of signed and unsigned integer formats." |
| 3346 | if (formatInfo.componentType != GL_INT && formatInfo.componentType != GL_UNSIGNED_INT && |
| 3347 | formatInfo.isRequiredRenderbufferFormat(getClientVersion())) |
| 3348 | { |
| 3349 | ASSERT(getClientVersion() < ES_3_0 || formatMaxSamples >= 4); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3350 | mState.mCaps.maxSamples = std::min(mState.mCaps.maxSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3351 | } |
| 3352 | |
| 3353 | // Handle GLES 3.1 MAX_*_SAMPLES values similarly to MAX_SAMPLES. |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3354 | if (getClientVersion() >= ES_3_1 || mSupportedExtensions.textureMultisample) |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3355 | { |
| 3356 | // GLES 3.1 section 9.2.5: "Implementations must support creation of renderbuffers |
| 3357 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with |
| 3358 | // the exception that the signed and unsigned integer formats are required only to |
| 3359 | // support creation of renderbuffers with up to the value of MAX_INTEGER_SAMPLES |
| 3360 | // multisamples, which must be at least one." |
| 3361 | if (formatInfo.componentType == GL_INT || |
| 3362 | formatInfo.componentType == GL_UNSIGNED_INT) |
| 3363 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3364 | mState.mCaps.maxIntegerSamples = |
| 3365 | std::min(mState.mCaps.maxIntegerSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3366 | } |
| 3367 | |
| 3368 | // GLES 3.1 section 19.3.1. |
| 3369 | if (formatCaps.texturable) |
| 3370 | { |
| 3371 | if (formatInfo.depthBits > 0) |
| 3372 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3373 | mState.mCaps.maxDepthTextureSamples = |
| 3374 | std::min(mState.mCaps.maxDepthTextureSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3375 | } |
| 3376 | else if (formatInfo.redBits > 0) |
| 3377 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3378 | mState.mCaps.maxColorTextureSamples = |
| 3379 | std::min(mState.mCaps.maxColorTextureSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3380 | } |
| 3381 | } |
| 3382 | } |
| 3383 | } |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3384 | |
| 3385 | if (formatCaps.texturable && formatInfo.compressed) |
| 3386 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3387 | mState.mCaps.compressedTextureFormats.push_back(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3388 | } |
| 3389 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3390 | mState.mTextureCaps.insert(sizedInternalFormat, formatCaps); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3391 | } |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3392 | |
| 3393 | // If program binary is disabled, blank out the memory cache pointer. |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3394 | if (!mSupportedExtensions.getProgramBinary) |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3395 | { |
| 3396 | mMemoryProgramCache = nullptr; |
| 3397 | } |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3398 | |
| 3399 | // Compute which buffer types are allowed |
| 3400 | mValidBufferBindings.reset(); |
| 3401 | mValidBufferBindings.set(BufferBinding::ElementArray); |
| 3402 | mValidBufferBindings.set(BufferBinding::Array); |
| 3403 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3404 | if (mState.mExtensions.pixelBufferObject || getClientVersion() >= ES_3_0) |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3405 | { |
| 3406 | mValidBufferBindings.set(BufferBinding::PixelPack); |
| 3407 | mValidBufferBindings.set(BufferBinding::PixelUnpack); |
| 3408 | } |
| 3409 | |
| 3410 | if (getClientVersion() >= ES_3_0) |
| 3411 | { |
| 3412 | mValidBufferBindings.set(BufferBinding::CopyRead); |
| 3413 | mValidBufferBindings.set(BufferBinding::CopyWrite); |
| 3414 | mValidBufferBindings.set(BufferBinding::TransformFeedback); |
| 3415 | mValidBufferBindings.set(BufferBinding::Uniform); |
| 3416 | } |
| 3417 | |
| 3418 | if (getClientVersion() >= ES_3_1) |
| 3419 | { |
| 3420 | mValidBufferBindings.set(BufferBinding::AtomicCounter); |
| 3421 | mValidBufferBindings.set(BufferBinding::ShaderStorage); |
| 3422 | mValidBufferBindings.set(BufferBinding::DrawIndirect); |
| 3423 | mValidBufferBindings.set(BufferBinding::DispatchIndirect); |
| 3424 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 3425 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3426 | mThreadPool = angle::WorkerThreadPool::Create(mState.mExtensions.parallelShaderCompile); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3427 | |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3428 | // Reinitialize some dirty bits that depend on extensions. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3429 | bool robustInit = mState.isRobustResourceInitEnabled(); |
Jamie Madill | 132d15c | 2018-11-30 15:25:38 -0500 | [diff] [blame] | 3430 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, robustInit); |
| 3431 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES_INIT, robustInit); |
| 3432 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_IMAGES_INIT, robustInit); |
| 3433 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, robustInit); |
| 3434 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES_INIT, robustInit); |
| 3435 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_IMAGES_INIT, robustInit); |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3436 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3437 | // Reinitialize state cache after extension changes. |
| 3438 | mStateCache.initialize(this); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3439 | } |
| 3440 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3441 | void Context::initWorkarounds() |
| 3442 | { |
Jamie Madill | 761b02c | 2017-06-23 16:27:06 -0400 | [diff] [blame] | 3443 | // Apply back-end workarounds. |
| 3444 | mImplementation->applyNativeWorkarounds(&mWorkarounds); |
| 3445 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3446 | // Lose the context upon out of memory error if the application is |
| 3447 | // expecting to watch for those events. |
| 3448 | mWorkarounds.loseContextOnOutOfMemory = (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
Jamie Madill | d4f0776 | 2018-10-19 19:24:07 -0400 | [diff] [blame] | 3449 | |
| 3450 | if (mWorkarounds.syncFramebufferBindingsOnTexImage) |
| 3451 | { |
| 3452 | // Update the Framebuffer bindings on TexImage to work around an Intel bug. |
| 3453 | mTexImageDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 3454 | mTexImageDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
| 3455 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3456 | } |
| 3457 | |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 3458 | bool Context::noopDrawInstanced(PrimitiveMode mode, GLsizei count, GLsizei instanceCount) |
| 3459 | { |
| 3460 | return (instanceCount == 0) || noopDraw(mode, count); |
| 3461 | } |
| 3462 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3463 | angle::Result Context::prepareForClear(GLbitfield mask) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3464 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3465 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3466 | ANGLE_TRY(mState.getDrawFramebuffer()->ensureClearAttachmentsInitialized(this, mask)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3467 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3468 | return angle::Result::Continue; |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3469 | } |
| 3470 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3471 | angle::Result Context::prepareForClearBuffer(GLenum buffer, GLint drawbuffer) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3472 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3473 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3474 | ANGLE_TRY(mState.getDrawFramebuffer()->ensureClearBufferAttachmentsInitialized(this, buffer, |
| 3475 | drawbuffer)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3476 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3477 | return angle::Result::Continue; |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3478 | } |
| 3479 | |
Jamie Madill | 132d15c | 2018-11-30 15:25:38 -0500 | [diff] [blame] | 3480 | ANGLE_INLINE angle::Result Context::prepareForDispatch() |
| 3481 | { |
| 3482 | ANGLE_TRY(syncDirtyObjects(mComputeDirtyObjects)); |
| 3483 | return syncDirtyBits(mComputeDirtyBits); |
| 3484 | } |
| 3485 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3486 | angle::Result Context::syncState(const State::DirtyBits &bitMask, |
| 3487 | const State::DirtyObjects &objectMask) |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 3488 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3489 | ANGLE_TRY(syncDirtyObjects(objectMask)); |
| 3490 | ANGLE_TRY(syncDirtyBits(bitMask)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3491 | return angle::Result::Continue; |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3492 | } |
| 3493 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3494 | void Context::blitFramebuffer(GLint srcX0, |
| 3495 | GLint srcY0, |
| 3496 | GLint srcX1, |
| 3497 | GLint srcY1, |
| 3498 | GLint dstX0, |
| 3499 | GLint dstY0, |
| 3500 | GLint dstX1, |
| 3501 | GLint dstY1, |
| 3502 | GLbitfield mask, |
| 3503 | GLenum filter) |
| 3504 | { |
Qin Jiajia | aef9216 | 2018-02-27 13:51:44 +0800 | [diff] [blame] | 3505 | if (mask == 0) |
| 3506 | { |
| 3507 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 3508 | // buffers are copied. |
| 3509 | return; |
| 3510 | } |
| 3511 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3512 | Framebuffer *drawFramebuffer = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3513 | ASSERT(drawFramebuffer); |
| 3514 | |
| 3515 | Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0); |
| 3516 | Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0); |
| 3517 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3518 | ANGLE_CONTEXT_TRY(syncStateForBlit()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3519 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3520 | ANGLE_CONTEXT_TRY(drawFramebuffer->blit(this, srcArea, dstArea, mask, filter)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3521 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3522 | |
| 3523 | void Context::clear(GLbitfield mask) |
| 3524 | { |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3525 | ANGLE_CONTEXT_TRY(prepareForClear(mask)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3526 | ANGLE_CONTEXT_TRY(mState.getDrawFramebuffer()->clear(this, mask)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3527 | } |
| 3528 | |
| 3529 | void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values) |
| 3530 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3531 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3532 | const FramebufferAttachment *attachment = nullptr; |
| 3533 | if (buffer == GL_DEPTH) |
| 3534 | { |
| 3535 | attachment = framebufferObject->getDepthbuffer(); |
| 3536 | } |
| 3537 | if (buffer == GL_COLOR && |
| 3538 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3539 | { |
| 3540 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3541 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3542 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3543 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3544 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3545 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3546 | return; |
| 3547 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3548 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3549 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3550 | } |
| 3551 | |
| 3552 | void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values) |
| 3553 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3554 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3555 | const FramebufferAttachment *attachment = nullptr; |
| 3556 | if (buffer == GL_COLOR && |
| 3557 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3558 | { |
| 3559 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3560 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3561 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3562 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3563 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3564 | { |
| 3565 | return; |
| 3566 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3567 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3568 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferuiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3569 | } |
| 3570 | |
| 3571 | void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values) |
| 3572 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3573 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3574 | const FramebufferAttachment *attachment = nullptr; |
| 3575 | if (buffer == GL_STENCIL) |
| 3576 | { |
| 3577 | attachment = framebufferObject->getStencilbuffer(); |
| 3578 | } |
| 3579 | if (buffer == GL_COLOR && |
| 3580 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3581 | { |
| 3582 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3583 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3584 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3585 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3586 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3587 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3588 | return; |
| 3589 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3590 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3591 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3592 | } |
| 3593 | |
| 3594 | void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 3595 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3596 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3597 | ASSERT(framebufferObject); |
| 3598 | |
| 3599 | // If a buffer is not present, the clear has no effect |
| 3600 | if (framebufferObject->getDepthbuffer() == nullptr && |
| 3601 | framebufferObject->getStencilbuffer() == nullptr) |
| 3602 | { |
| 3603 | return; |
| 3604 | } |
| 3605 | |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3606 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
| 3607 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfi(this, buffer, drawbuffer, depth, stencil)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3608 | } |
| 3609 | |
| 3610 | void Context::readPixels(GLint x, |
| 3611 | GLint y, |
| 3612 | GLsizei width, |
| 3613 | GLsizei height, |
| 3614 | GLenum format, |
| 3615 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3616 | void *pixels) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3617 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3618 | if (width == 0 || height == 0) |
| 3619 | { |
| 3620 | return; |
| 3621 | } |
| 3622 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3623 | ANGLE_CONTEXT_TRY(syncStateForReadPixels()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3624 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3625 | Framebuffer *readFBO = mState.getReadFramebuffer(); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 3626 | ASSERT(readFBO); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3627 | |
| 3628 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3629 | ANGLE_CONTEXT_TRY(readFBO->readPixels(this, area, format, type, pixels)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3630 | } |
| 3631 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3632 | void Context::readPixelsRobust(GLint x, |
| 3633 | GLint y, |
| 3634 | GLsizei width, |
| 3635 | GLsizei height, |
| 3636 | GLenum format, |
| 3637 | GLenum type, |
| 3638 | GLsizei bufSize, |
| 3639 | GLsizei *length, |
| 3640 | GLsizei *columns, |
| 3641 | GLsizei *rows, |
| 3642 | void *pixels) |
| 3643 | { |
| 3644 | readPixels(x, y, width, height, format, type, pixels); |
| 3645 | } |
| 3646 | |
| 3647 | void Context::readnPixelsRobust(GLint x, |
| 3648 | GLint y, |
| 3649 | GLsizei width, |
| 3650 | GLsizei height, |
| 3651 | GLenum format, |
| 3652 | GLenum type, |
| 3653 | GLsizei bufSize, |
| 3654 | GLsizei *length, |
| 3655 | GLsizei *columns, |
| 3656 | GLsizei *rows, |
| 3657 | void *data) |
| 3658 | { |
| 3659 | readPixels(x, y, width, height, format, type, data); |
| 3660 | } |
| 3661 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3662 | void Context::copyTexImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3663 | GLint level, |
| 3664 | GLenum internalformat, |
| 3665 | GLint x, |
| 3666 | GLint y, |
| 3667 | GLsizei width, |
| 3668 | GLsizei height, |
| 3669 | GLint border) |
| 3670 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3671 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3672 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3673 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3674 | Rectangle sourceArea(x, y, width, height); |
| 3675 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3676 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3677 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3678 | ANGLE_CONTEXT_TRY( |
| 3679 | texture->copyImage(this, target, level, sourceArea, internalformat, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3680 | } |
| 3681 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3682 | void Context::copyTexSubImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3683 | GLint level, |
| 3684 | GLint xoffset, |
| 3685 | GLint yoffset, |
| 3686 | GLint x, |
| 3687 | GLint y, |
| 3688 | GLsizei width, |
| 3689 | GLsizei height) |
| 3690 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3691 | if (width == 0 || height == 0) |
| 3692 | { |
| 3693 | return; |
| 3694 | } |
| 3695 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3696 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3697 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3698 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3699 | Offset destOffset(xoffset, yoffset, 0); |
| 3700 | Rectangle sourceArea(x, y, width, height); |
| 3701 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3702 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3703 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3704 | ANGLE_CONTEXT_TRY( |
| 3705 | texture->copySubImage(this, target, level, destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3706 | } |
| 3707 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3708 | void Context::copyTexSubImage3D(TextureType target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3709 | GLint level, |
| 3710 | GLint xoffset, |
| 3711 | GLint yoffset, |
| 3712 | GLint zoffset, |
| 3713 | GLint x, |
| 3714 | GLint y, |
| 3715 | GLsizei width, |
| 3716 | GLsizei height) |
| 3717 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3718 | if (width == 0 || height == 0) |
| 3719 | { |
| 3720 | return; |
| 3721 | } |
| 3722 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3723 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3724 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3725 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3726 | Offset destOffset(xoffset, yoffset, zoffset); |
| 3727 | Rectangle sourceArea(x, y, width, height); |
| 3728 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3729 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3730 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3731 | ANGLE_CONTEXT_TRY(texture->copySubImage(this, NonCubeTextureTypeToTarget(target), level, |
| 3732 | destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3733 | } |
| 3734 | |
| 3735 | void Context::framebufferTexture2D(GLenum target, |
| 3736 | GLenum attachment, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3737 | TextureTarget textarget, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3738 | GLuint texture, |
| 3739 | GLint level) |
| 3740 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3741 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3742 | ASSERT(framebuffer); |
| 3743 | |
| 3744 | if (texture != 0) |
| 3745 | { |
| 3746 | Texture *textureObj = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3747 | ImageIndex index = ImageIndex::MakeFromTarget(textarget, level); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3748 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3749 | } |
| 3750 | else |
| 3751 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3752 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3753 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3754 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3755 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3756 | } |
| 3757 | |
| 3758 | void Context::framebufferRenderbuffer(GLenum target, |
| 3759 | GLenum attachment, |
| 3760 | GLenum renderbuffertarget, |
| 3761 | GLuint renderbuffer) |
| 3762 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3763 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3764 | ASSERT(framebuffer); |
| 3765 | |
| 3766 | if (renderbuffer != 0) |
| 3767 | { |
| 3768 | Renderbuffer *renderbufferObject = getRenderbuffer(renderbuffer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3769 | |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3770 | framebuffer->setAttachment(this, GL_RENDERBUFFER, attachment, gl::ImageIndex(), |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3771 | renderbufferObject); |
| 3772 | } |
| 3773 | else |
| 3774 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3775 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3776 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3777 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3778 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3779 | } |
| 3780 | |
| 3781 | void Context::framebufferTextureLayer(GLenum target, |
| 3782 | GLenum attachment, |
| 3783 | GLuint texture, |
| 3784 | GLint level, |
| 3785 | GLint layer) |
| 3786 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3787 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3788 | ASSERT(framebuffer); |
| 3789 | |
| 3790 | if (texture != 0) |
| 3791 | { |
| 3792 | Texture *textureObject = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3793 | ImageIndex index = ImageIndex::MakeFromType(textureObject->getType(), level, layer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3794 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObject); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3795 | } |
| 3796 | else |
| 3797 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3798 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3799 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3800 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3801 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3802 | } |
| 3803 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3804 | void Context::framebufferTextureMultiviewLayered(GLenum target, |
| 3805 | GLenum attachment, |
| 3806 | GLuint texture, |
| 3807 | GLint level, |
| 3808 | GLint baseViewIndex, |
| 3809 | GLsizei numViews) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3810 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3811 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3812 | ASSERT(framebuffer); |
| 3813 | |
| 3814 | if (texture != 0) |
| 3815 | { |
| 3816 | Texture *textureObj = getTexture(texture); |
| 3817 | |
Olli Etuaho | 2c8f084 | 2018-09-12 14:44:55 +0300 | [diff] [blame] | 3818 | ImageIndex index; |
| 3819 | if (textureObj->getType() == TextureType::_2DArray) |
| 3820 | { |
| 3821 | index = ImageIndex::Make2DArrayRange(level, baseViewIndex, numViews); |
| 3822 | } |
| 3823 | else |
| 3824 | { |
| 3825 | ASSERT(textureObj->getType() == TextureType::_2DMultisampleArray); |
| 3826 | ASSERT(level == 0); |
| 3827 | index = ImageIndex::Make2DMultisampleArrayRange(baseViewIndex, numViews); |
| 3828 | } |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3829 | framebuffer->setAttachmentMultiviewLayered(this, GL_TEXTURE, attachment, index, textureObj, |
| 3830 | numViews, baseViewIndex); |
| 3831 | } |
| 3832 | else |
| 3833 | { |
| 3834 | framebuffer->resetAttachment(this, attachment); |
| 3835 | } |
| 3836 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3837 | mState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3838 | } |
| 3839 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3840 | void Context::framebufferTextureMultiviewSideBySide(GLenum target, |
| 3841 | GLenum attachment, |
| 3842 | GLuint texture, |
| 3843 | GLint level, |
| 3844 | GLsizei numViews, |
| 3845 | const GLint *viewportOffsets) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3846 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3847 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 3848 | ASSERT(framebuffer); |
| 3849 | |
| 3850 | if (texture != 0) |
| 3851 | { |
| 3852 | Texture *textureObj = getTexture(texture); |
| 3853 | |
| 3854 | ImageIndex index = ImageIndex::Make2D(level); |
| 3855 | framebuffer->setAttachmentMultiviewSideBySide(this, GL_TEXTURE, attachment, index, |
| 3856 | textureObj, numViews, viewportOffsets); |
| 3857 | } |
| 3858 | else |
| 3859 | { |
| 3860 | framebuffer->resetAttachment(this, attachment); |
| 3861 | } |
| 3862 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3863 | mState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3864 | } |
| 3865 | |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3866 | void Context::framebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level) |
| 3867 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3868 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jiawei Shao | a880247 | 2018-05-28 11:17:47 +0800 | [diff] [blame] | 3869 | ASSERT(framebuffer); |
| 3870 | |
| 3871 | if (texture != 0) |
| 3872 | { |
| 3873 | Texture *textureObj = getTexture(texture); |
| 3874 | |
| 3875 | ImageIndex index = ImageIndex::MakeFromType( |
| 3876 | textureObj->getType(), level, ImageIndex::kEntireLevel, ImageIndex::kEntireLevel); |
| 3877 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
| 3878 | } |
| 3879 | else |
| 3880 | { |
| 3881 | framebuffer->resetAttachment(this, attachment); |
| 3882 | } |
| 3883 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3884 | mState.setObjectDirty(target); |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3885 | } |
| 3886 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3887 | void Context::drawBuffers(GLsizei n, const GLenum *bufs) |
| 3888 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3889 | Framebuffer *framebuffer = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3890 | ASSERT(framebuffer); |
| 3891 | framebuffer->setDrawBuffers(n, bufs); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3892 | mState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 3893 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3894 | } |
| 3895 | |
| 3896 | void Context::readBuffer(GLenum mode) |
| 3897 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3898 | Framebuffer *readFBO = mState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3899 | readFBO->setReadBuffer(mode); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3900 | mState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3901 | } |
| 3902 | |
| 3903 | void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) |
| 3904 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3905 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3906 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3907 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3908 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3909 | ASSERT(framebuffer); |
| 3910 | |
| 3911 | // The specification isn't clear what should be done when the framebuffer isn't complete. |
| 3912 | // We leave it up to the framebuffer implementation to decide what to do. |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3913 | ANGLE_CONTEXT_TRY(framebuffer->discard(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3914 | } |
| 3915 | |
| 3916 | void Context::invalidateFramebuffer(GLenum target, |
| 3917 | GLsizei numAttachments, |
| 3918 | const GLenum *attachments) |
| 3919 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3920 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3921 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3922 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3923 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3924 | ASSERT(framebuffer); |
| 3925 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 3926 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3927 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3928 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3929 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3930 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3931 | ANGLE_CONTEXT_TRY(framebuffer->invalidate(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3932 | } |
| 3933 | |
| 3934 | void Context::invalidateSubFramebuffer(GLenum target, |
| 3935 | GLsizei numAttachments, |
| 3936 | const GLenum *attachments, |
| 3937 | GLint x, |
| 3938 | GLint y, |
| 3939 | GLsizei width, |
| 3940 | GLsizei height) |
| 3941 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3942 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3943 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3944 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3945 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3946 | ASSERT(framebuffer); |
| 3947 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 3948 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3949 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3950 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3951 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3952 | |
| 3953 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3954 | ANGLE_CONTEXT_TRY(framebuffer->invalidateSub(this, numAttachments, attachments, area)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3955 | } |
| 3956 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3957 | void Context::texImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3958 | GLint level, |
| 3959 | GLint internalformat, |
| 3960 | GLsizei width, |
| 3961 | GLsizei height, |
| 3962 | GLint border, |
| 3963 | GLenum format, |
| 3964 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3965 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3966 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3967 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3968 | |
| 3969 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3970 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3971 | ANGLE_CONTEXT_TRY(texture->setImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3972 | internalformat, size, format, type, |
| 3973 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3974 | } |
| 3975 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3976 | void Context::texImage2DRobust(TextureTarget target, |
| 3977 | GLint level, |
| 3978 | GLint internalformat, |
| 3979 | GLsizei width, |
| 3980 | GLsizei height, |
| 3981 | GLint border, |
| 3982 | GLenum format, |
| 3983 | GLenum type, |
| 3984 | GLsizei bufSize, |
| 3985 | const void *pixels) |
| 3986 | { |
| 3987 | texImage2D(target, level, internalformat, width, height, border, format, type, pixels); |
| 3988 | } |
| 3989 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3990 | void Context::texImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3991 | GLint level, |
| 3992 | GLint internalformat, |
| 3993 | GLsizei width, |
| 3994 | GLsizei height, |
| 3995 | GLsizei depth, |
| 3996 | GLint border, |
| 3997 | GLenum format, |
| 3998 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3999 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4000 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4001 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4002 | |
| 4003 | Extents size(width, height, depth); |
| 4004 | Texture *texture = getTargetTexture(target); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4005 | ANGLE_CONTEXT_TRY(texture->setImage(this, mState.getUnpackState(), |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4006 | NonCubeTextureTypeToTarget(target), level, internalformat, |
| 4007 | size, format, type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4008 | } |
| 4009 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4010 | void Context::texImage3DRobust(TextureType target, |
| 4011 | GLint level, |
| 4012 | GLint internalformat, |
| 4013 | GLsizei width, |
| 4014 | GLsizei height, |
| 4015 | GLsizei depth, |
| 4016 | GLint border, |
| 4017 | GLenum format, |
| 4018 | GLenum type, |
| 4019 | GLsizei bufSize, |
| 4020 | const void *pixels) |
| 4021 | { |
| 4022 | texImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 4023 | } |
| 4024 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4025 | void Context::texSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4026 | GLint level, |
| 4027 | GLint xoffset, |
| 4028 | GLint yoffset, |
| 4029 | GLsizei width, |
| 4030 | GLsizei height, |
| 4031 | GLenum format, |
| 4032 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4033 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4034 | { |
| 4035 | // Zero sized uploads are valid but no-ops |
| 4036 | if (width == 0 || height == 0) |
| 4037 | { |
| 4038 | return; |
| 4039 | } |
| 4040 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4041 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4042 | |
| 4043 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4044 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4045 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4046 | gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4047 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4048 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mState.getUnpackState(), unpackBuffer, target, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4049 | level, area, format, type, |
| 4050 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4051 | } |
| 4052 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4053 | void Context::texSubImage2DRobust(TextureTarget target, |
| 4054 | GLint level, |
| 4055 | GLint xoffset, |
| 4056 | GLint yoffset, |
| 4057 | GLsizei width, |
| 4058 | GLsizei height, |
| 4059 | GLenum format, |
| 4060 | GLenum type, |
| 4061 | GLsizei bufSize, |
| 4062 | const void *pixels) |
| 4063 | { |
| 4064 | texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 4065 | } |
| 4066 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4067 | void Context::texSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4068 | GLint level, |
| 4069 | GLint xoffset, |
| 4070 | GLint yoffset, |
| 4071 | GLint zoffset, |
| 4072 | GLsizei width, |
| 4073 | GLsizei height, |
| 4074 | GLsizei depth, |
| 4075 | GLenum format, |
| 4076 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4077 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4078 | { |
| 4079 | // Zero sized uploads are valid but no-ops |
| 4080 | if (width == 0 || height == 0 || depth == 0) |
| 4081 | { |
| 4082 | return; |
| 4083 | } |
| 4084 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4085 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4086 | |
| 4087 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4088 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4089 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4090 | gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4091 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4092 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mState.getUnpackState(), unpackBuffer, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4093 | NonCubeTextureTypeToTarget(target), level, area, format, |
| 4094 | type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4095 | } |
| 4096 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4097 | void Context::texSubImage3DRobust(TextureType target, |
| 4098 | GLint level, |
| 4099 | GLint xoffset, |
| 4100 | GLint yoffset, |
| 4101 | GLint zoffset, |
| 4102 | GLsizei width, |
| 4103 | GLsizei height, |
| 4104 | GLsizei depth, |
| 4105 | GLenum format, |
| 4106 | GLenum type, |
| 4107 | GLsizei bufSize, |
| 4108 | const void *pixels) |
| 4109 | { |
| 4110 | texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, |
| 4111 | pixels); |
| 4112 | } |
| 4113 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4114 | void Context::compressedTexImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4115 | GLint level, |
| 4116 | GLenum internalformat, |
| 4117 | GLsizei width, |
| 4118 | GLsizei height, |
| 4119 | GLint border, |
| 4120 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4121 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4122 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4123 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4124 | |
| 4125 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4126 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4127 | ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4128 | internalformat, size, imageSize, |
| 4129 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4130 | } |
| 4131 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4132 | void Context::compressedTexImage2DRobust(TextureTarget target, |
| 4133 | GLint level, |
| 4134 | GLenum internalformat, |
| 4135 | GLsizei width, |
| 4136 | GLsizei height, |
| 4137 | GLint border, |
| 4138 | GLsizei imageSize, |
| 4139 | GLsizei dataSize, |
| 4140 | const GLvoid *data) |
| 4141 | { |
| 4142 | compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); |
| 4143 | } |
| 4144 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4145 | void Context::compressedTexImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4146 | GLint level, |
| 4147 | GLenum internalformat, |
| 4148 | GLsizei width, |
| 4149 | GLsizei height, |
| 4150 | GLsizei depth, |
| 4151 | GLint border, |
| 4152 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4153 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4154 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4155 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4156 | |
| 4157 | Extents size(width, height, depth); |
| 4158 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4159 | ANGLE_CONTEXT_TRY(texture->setCompressedImage( |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4160 | this, mState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, internalformat, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4161 | size, imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4162 | } |
| 4163 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4164 | void Context::compressedTexImage3DRobust(TextureType target, |
| 4165 | GLint level, |
| 4166 | GLenum internalformat, |
| 4167 | GLsizei width, |
| 4168 | GLsizei height, |
| 4169 | GLsizei depth, |
| 4170 | GLint border, |
| 4171 | GLsizei imageSize, |
| 4172 | GLsizei dataSize, |
| 4173 | const GLvoid *data) |
| 4174 | { |
| 4175 | compressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, |
| 4176 | data); |
| 4177 | } |
| 4178 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4179 | void Context::compressedTexSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4180 | GLint level, |
| 4181 | GLint xoffset, |
| 4182 | GLint yoffset, |
| 4183 | GLsizei width, |
| 4184 | GLsizei height, |
| 4185 | GLenum format, |
| 4186 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4187 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4188 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4189 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4190 | |
| 4191 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4192 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4193 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4194 | area, format, imageSize, |
| 4195 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4196 | } |
| 4197 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4198 | void Context::compressedTexSubImage2DRobust(TextureTarget target, |
| 4199 | GLint level, |
| 4200 | GLint xoffset, |
| 4201 | GLint yoffset, |
| 4202 | GLsizei width, |
| 4203 | GLsizei height, |
| 4204 | GLenum format, |
| 4205 | GLsizei imageSize, |
| 4206 | GLsizei dataSize, |
| 4207 | const GLvoid *data) |
| 4208 | { |
| 4209 | compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, |
| 4210 | data); |
| 4211 | } |
| 4212 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4213 | void Context::compressedTexSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4214 | GLint level, |
| 4215 | GLint xoffset, |
| 4216 | GLint yoffset, |
| 4217 | GLint zoffset, |
| 4218 | GLsizei width, |
| 4219 | GLsizei height, |
| 4220 | GLsizei depth, |
| 4221 | GLenum format, |
| 4222 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4223 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4224 | { |
| 4225 | // Zero sized uploads are valid but no-ops |
| 4226 | if (width == 0 || height == 0) |
| 4227 | { |
| 4228 | return; |
| 4229 | } |
| 4230 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4231 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4232 | |
| 4233 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4234 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4235 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage( |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4236 | this, mState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, area, format, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4237 | imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4238 | } |
| 4239 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4240 | void Context::compressedTexSubImage3DRobust(TextureType target, |
| 4241 | GLint level, |
| 4242 | GLint xoffset, |
| 4243 | GLint yoffset, |
| 4244 | GLint zoffset, |
| 4245 | GLsizei width, |
| 4246 | GLsizei height, |
| 4247 | GLsizei depth, |
| 4248 | GLenum format, |
| 4249 | GLsizei imageSize, |
| 4250 | GLsizei dataSize, |
| 4251 | const GLvoid *data) |
| 4252 | { |
| 4253 | compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, |
| 4254 | imageSize, data); |
| 4255 | } |
| 4256 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4257 | void Context::generateMipmap(TextureType target) |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4258 | { |
| 4259 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4260 | ANGLE_CONTEXT_TRY(texture->generateMipmap(this)); |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4261 | } |
| 4262 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4263 | void Context::copyTexture(GLuint sourceId, |
| 4264 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4265 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4266 | GLuint destId, |
| 4267 | GLint destLevel, |
| 4268 | GLint internalFormat, |
| 4269 | GLenum destType, |
| 4270 | GLboolean unpackFlipY, |
| 4271 | GLboolean unpackPremultiplyAlpha, |
| 4272 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4273 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4274 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4275 | |
| 4276 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4277 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4278 | ANGLE_CONTEXT_TRY( |
| 4279 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4280 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4281 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4282 | } |
| 4283 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4284 | void Context::copySubTexture(GLuint sourceId, |
| 4285 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4286 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4287 | GLuint destId, |
| 4288 | GLint destLevel, |
| 4289 | GLint xoffset, |
| 4290 | GLint yoffset, |
| 4291 | GLint x, |
| 4292 | GLint y, |
| 4293 | GLsizei width, |
| 4294 | GLsizei height, |
| 4295 | GLboolean unpackFlipY, |
| 4296 | GLboolean unpackPremultiplyAlpha, |
| 4297 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4298 | { |
| 4299 | // Zero sized copies are valid but no-ops |
| 4300 | if (width == 0 || height == 0) |
| 4301 | { |
| 4302 | return; |
| 4303 | } |
| 4304 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4305 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4306 | |
| 4307 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4308 | gl::Texture *destTexture = getTexture(destId); |
| 4309 | Offset offset(xoffset, yoffset, 0); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4310 | Box box(x, y, 0, width, height, 1); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4311 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4312 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4313 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4314 | sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4315 | } |
| 4316 | |
| 4317 | void Context::copyTexture3D(GLuint sourceId, |
| 4318 | GLint sourceLevel, |
| 4319 | TextureTarget destTarget, |
| 4320 | GLuint destId, |
| 4321 | GLint destLevel, |
| 4322 | GLint internalFormat, |
| 4323 | GLenum destType, |
| 4324 | GLboolean unpackFlipY, |
| 4325 | GLboolean unpackPremultiplyAlpha, |
| 4326 | GLboolean unpackUnmultiplyAlpha) |
| 4327 | { |
| 4328 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4329 | |
| 4330 | Texture *sourceTexture = getTexture(sourceId); |
| 4331 | Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4332 | ANGLE_CONTEXT_TRY( |
| 4333 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4334 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4335 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4336 | } |
| 4337 | |
| 4338 | void Context::copySubTexture3D(GLuint sourceId, |
| 4339 | GLint sourceLevel, |
| 4340 | TextureTarget destTarget, |
| 4341 | GLuint destId, |
| 4342 | GLint destLevel, |
| 4343 | GLint xoffset, |
| 4344 | GLint yoffset, |
| 4345 | GLint zoffset, |
| 4346 | GLint x, |
| 4347 | GLint y, |
| 4348 | GLint z, |
| 4349 | GLsizei width, |
| 4350 | GLsizei height, |
| 4351 | GLsizei depth, |
| 4352 | GLboolean unpackFlipY, |
| 4353 | GLboolean unpackPremultiplyAlpha, |
| 4354 | GLboolean unpackUnmultiplyAlpha) |
| 4355 | { |
| 4356 | // Zero sized copies are valid but no-ops |
| 4357 | if (width == 0 || height == 0 || depth == 0) |
| 4358 | { |
| 4359 | return; |
| 4360 | } |
| 4361 | |
| 4362 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4363 | |
| 4364 | Texture *sourceTexture = getTexture(sourceId); |
| 4365 | Texture *destTexture = getTexture(destId); |
| 4366 | Offset offset(xoffset, yoffset, zoffset); |
| 4367 | Box box(x, y, z, width, height, depth); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4368 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4369 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4370 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4371 | sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4372 | } |
| 4373 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4374 | void Context::compressedCopyTexture(GLuint sourceId, GLuint destId) |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4375 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4376 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4377 | |
| 4378 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4379 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4380 | ANGLE_CONTEXT_TRY(destTexture->copyCompressedTexture(this, sourceTexture)); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4381 | } |
| 4382 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4383 | void Context::getBufferPointerv(BufferBinding target, GLenum pname, void **params) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4384 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4385 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4386 | ASSERT(buffer); |
| 4387 | |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 4388 | QueryBufferPointerv(buffer, pname, params); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4389 | } |
| 4390 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4391 | void Context::getBufferPointervRobust(BufferBinding target, |
| 4392 | GLenum pname, |
| 4393 | GLsizei bufSize, |
| 4394 | GLsizei *length, |
| 4395 | void **params) |
| 4396 | { |
| 4397 | getBufferPointerv(target, pname, params); |
| 4398 | } |
| 4399 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4400 | void *Context::mapBuffer(BufferBinding target, GLenum access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4401 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4402 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4403 | ASSERT(buffer); |
| 4404 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4405 | if (buffer->map(this, access) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4406 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4407 | return nullptr; |
| 4408 | } |
| 4409 | |
| 4410 | return buffer->getMapPointer(); |
| 4411 | } |
| 4412 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4413 | GLboolean Context::unmapBuffer(BufferBinding target) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4414 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4415 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4416 | ASSERT(buffer); |
| 4417 | |
| 4418 | GLboolean result; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4419 | if (buffer->unmap(this, &result) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4420 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4421 | return GL_FALSE; |
| 4422 | } |
| 4423 | |
| 4424 | return result; |
| 4425 | } |
| 4426 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4427 | void *Context::mapBufferRange(BufferBinding target, |
| 4428 | GLintptr offset, |
| 4429 | GLsizeiptr length, |
| 4430 | GLbitfield access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4431 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4432 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4433 | ASSERT(buffer); |
| 4434 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4435 | if (buffer->mapRange(this, offset, length, access) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4436 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4437 | return nullptr; |
| 4438 | } |
| 4439 | |
| 4440 | return buffer->getMapPointer(); |
| 4441 | } |
| 4442 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4443 | void Context::flushMappedBufferRange(BufferBinding /*target*/, |
| 4444 | GLintptr /*offset*/, |
| 4445 | GLsizeiptr /*length*/) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4446 | { |
| 4447 | // We do not currently support a non-trivial implementation of FlushMappedBufferRange |
| 4448 | } |
| 4449 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4450 | angle::Result Context::syncStateForReadPixels() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4451 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4452 | return syncState(mReadPixelsDirtyBits, mReadPixelsDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4453 | } |
| 4454 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4455 | angle::Result Context::syncStateForTexImage() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4456 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4457 | return syncState(mTexImageDirtyBits, mTexImageDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4458 | } |
| 4459 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4460 | angle::Result Context::syncStateForBlit() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4461 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4462 | return syncState(mBlitDirtyBits, mBlitDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4463 | } |
| 4464 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4465 | angle::Result Context::syncStateForPathOperation() |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4466 | { |
| 4467 | ANGLE_TRY(syncDirtyObjects(mPathOperationDirtyObjects)); |
| 4468 | |
| 4469 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 4470 | ANGLE_TRY(syncDirtyBits()); |
| 4471 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4472 | return angle::Result::Continue; |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4473 | } |
| 4474 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4475 | void Context::activeShaderProgram(GLuint pipeline, GLuint program) |
| 4476 | { |
| 4477 | UNIMPLEMENTED(); |
| 4478 | } |
| 4479 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4480 | void Context::activeTexture(GLenum texture) |
| 4481 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4482 | mState.setActiveSampler(texture - GL_TEXTURE0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4483 | } |
| 4484 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4485 | void Context::blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4486 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4487 | mState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4488 | } |
| 4489 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4490 | void Context::blendEquation(GLenum mode) |
| 4491 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4492 | mState.setBlendEquation(mode, mode); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4493 | } |
| 4494 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4495 | void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 4496 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4497 | mState.setBlendEquation(modeRGB, modeAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4498 | } |
| 4499 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4500 | void Context::blendFunc(GLenum sfactor, GLenum dfactor) |
| 4501 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4502 | mState.setBlendFactors(sfactor, dfactor, sfactor, dfactor); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4503 | } |
| 4504 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4505 | void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 4506 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4507 | mState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4508 | } |
| 4509 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4510 | void Context::clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4511 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4512 | mState.setColorClearValue(red, green, blue, alpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4513 | } |
| 4514 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4515 | void Context::clearDepthf(GLfloat depth) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4516 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4517 | mState.setDepthClearValue(clamp01(depth)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4518 | } |
| 4519 | |
| 4520 | void Context::clearStencil(GLint s) |
| 4521 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4522 | mState.setStencilClearValue(s); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4523 | } |
| 4524 | |
| 4525 | void Context::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 4526 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4527 | mState.setColorMask(ConvertToBool(red), ConvertToBool(green), ConvertToBool(blue), |
| 4528 | ConvertToBool(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4529 | } |
| 4530 | |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 4531 | void Context::cullFace(CullFaceMode mode) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4532 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4533 | mState.setCullMode(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4534 | } |
| 4535 | |
| 4536 | void Context::depthFunc(GLenum func) |
| 4537 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4538 | mState.setDepthFunc(func); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4539 | } |
| 4540 | |
| 4541 | void Context::depthMask(GLboolean flag) |
| 4542 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4543 | mState.setDepthMask(ConvertToBool(flag)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4544 | } |
| 4545 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4546 | void Context::depthRangef(GLfloat zNear, GLfloat zFar) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4547 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4548 | mState.setDepthRange(clamp01(zNear), clamp01(zFar)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4549 | } |
| 4550 | |
| 4551 | void Context::disable(GLenum cap) |
| 4552 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4553 | mState.setEnableFeature(cap, false); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4554 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4555 | } |
| 4556 | |
| 4557 | void Context::disableVertexAttribArray(GLuint index) |
| 4558 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4559 | mState.setEnableVertexAttribArray(index, false); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4560 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4561 | } |
| 4562 | |
| 4563 | void Context::enable(GLenum cap) |
| 4564 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4565 | mState.setEnableFeature(cap, true); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4566 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4567 | } |
| 4568 | |
| 4569 | void Context::enableVertexAttribArray(GLuint index) |
| 4570 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4571 | mState.setEnableVertexAttribArray(index, true); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4572 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4573 | } |
| 4574 | |
| 4575 | void Context::frontFace(GLenum mode) |
| 4576 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4577 | mState.setFrontFace(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4578 | } |
| 4579 | |
| 4580 | void Context::hint(GLenum target, GLenum mode) |
| 4581 | { |
| 4582 | switch (target) |
| 4583 | { |
| 4584 | case GL_GENERATE_MIPMAP_HINT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4585 | mState.setGenerateMipmapHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4586 | break; |
| 4587 | |
| 4588 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4589 | mState.setFragmentShaderDerivativeHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4590 | break; |
| 4591 | |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 4592 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 4593 | case GL_POINT_SMOOTH_HINT: |
| 4594 | case GL_LINE_SMOOTH_HINT: |
| 4595 | case GL_FOG_HINT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4596 | mState.gles1().setHint(target, mode); |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 4597 | break; |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4598 | default: |
| 4599 | UNREACHABLE(); |
| 4600 | return; |
| 4601 | } |
| 4602 | } |
| 4603 | |
| 4604 | void Context::lineWidth(GLfloat width) |
| 4605 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4606 | mState.setLineWidth(width); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4607 | } |
| 4608 | |
| 4609 | void Context::pixelStorei(GLenum pname, GLint param) |
| 4610 | { |
| 4611 | switch (pname) |
| 4612 | { |
| 4613 | case GL_UNPACK_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4614 | mState.setUnpackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4615 | break; |
| 4616 | |
| 4617 | case GL_PACK_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4618 | mState.setPackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4619 | break; |
| 4620 | |
| 4621 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4622 | mState.setPackReverseRowOrder(param != 0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4623 | break; |
| 4624 | |
| 4625 | case GL_UNPACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4626 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4627 | mState.setUnpackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4628 | break; |
| 4629 | |
| 4630 | case GL_UNPACK_IMAGE_HEIGHT: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4631 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4632 | mState.setUnpackImageHeight(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4633 | break; |
| 4634 | |
| 4635 | case GL_UNPACK_SKIP_IMAGES: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4636 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4637 | mState.setUnpackSkipImages(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4638 | break; |
| 4639 | |
| 4640 | case GL_UNPACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4641 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4642 | mState.setUnpackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4643 | break; |
| 4644 | |
| 4645 | case GL_UNPACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4646 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4647 | mState.setUnpackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4648 | break; |
| 4649 | |
| 4650 | case GL_PACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4651 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4652 | mState.setPackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4653 | break; |
| 4654 | |
| 4655 | case GL_PACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4656 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4657 | mState.setPackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4658 | break; |
| 4659 | |
| 4660 | case GL_PACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4661 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4662 | mState.setPackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4663 | break; |
| 4664 | |
| 4665 | default: |
| 4666 | UNREACHABLE(); |
| 4667 | return; |
| 4668 | } |
| 4669 | } |
| 4670 | |
| 4671 | void Context::polygonOffset(GLfloat factor, GLfloat units) |
| 4672 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4673 | mState.setPolygonOffsetParams(factor, units); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4674 | } |
| 4675 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4676 | void Context::sampleCoverage(GLfloat value, GLboolean invert) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4677 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4678 | mState.setSampleCoverageParams(clamp01(value), ConvertToBool(invert)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4679 | } |
| 4680 | |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 4681 | void Context::sampleMaski(GLuint maskNumber, GLbitfield mask) |
| 4682 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4683 | mState.setSampleMaskParams(maskNumber, mask); |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 4684 | } |
| 4685 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4686 | void Context::scissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4687 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4688 | mState.setScissorParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4689 | } |
| 4690 | |
| 4691 | void Context::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 4692 | { |
| 4693 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4694 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4695 | mState.setStencilParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4696 | } |
| 4697 | |
| 4698 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4699 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4700 | mState.setStencilBackParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4701 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4702 | |
| 4703 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4704 | } |
| 4705 | |
| 4706 | void Context::stencilMaskSeparate(GLenum face, GLuint mask) |
| 4707 | { |
| 4708 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4709 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4710 | mState.setStencilWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4711 | } |
| 4712 | |
| 4713 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4714 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4715 | mState.setStencilBackWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4716 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4717 | |
| 4718 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4719 | } |
| 4720 | |
| 4721 | void Context::stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 4722 | { |
| 4723 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4724 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4725 | mState.setStencilOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4726 | } |
| 4727 | |
| 4728 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4729 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4730 | mState.setStencilBackOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4731 | } |
| 4732 | } |
| 4733 | |
| 4734 | void Context::vertexAttrib1f(GLuint index, GLfloat x) |
| 4735 | { |
| 4736 | GLfloat vals[4] = {x, 0, 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4737 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4738 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4739 | } |
| 4740 | |
| 4741 | void Context::vertexAttrib1fv(GLuint index, const GLfloat *values) |
| 4742 | { |
| 4743 | GLfloat vals[4] = {values[0], 0, 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4744 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4745 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4746 | } |
| 4747 | |
| 4748 | void Context::vertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 4749 | { |
| 4750 | GLfloat vals[4] = {x, y, 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4751 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4752 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4753 | } |
| 4754 | |
| 4755 | void Context::vertexAttrib2fv(GLuint index, const GLfloat *values) |
| 4756 | { |
| 4757 | GLfloat vals[4] = {values[0], values[1], 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4758 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4759 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4760 | } |
| 4761 | |
| 4762 | void Context::vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 4763 | { |
| 4764 | GLfloat vals[4] = {x, y, z, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4765 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4766 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4767 | } |
| 4768 | |
| 4769 | void Context::vertexAttrib3fv(GLuint index, const GLfloat *values) |
| 4770 | { |
| 4771 | GLfloat vals[4] = {values[0], values[1], values[2], 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4772 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4773 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4774 | } |
| 4775 | |
| 4776 | void Context::vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4777 | { |
| 4778 | GLfloat vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4779 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4780 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4781 | } |
| 4782 | |
| 4783 | void Context::vertexAttrib4fv(GLuint index, const GLfloat *values) |
| 4784 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4785 | mState.setVertexAttribf(index, values); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4786 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4787 | } |
| 4788 | |
| 4789 | void Context::vertexAttribPointer(GLuint index, |
| 4790 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4791 | VertexAttribType type, |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4792 | GLboolean normalized, |
| 4793 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4794 | const void *ptr) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4795 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4796 | mState.setVertexAttribPointer(this, index, mState.getTargetBuffer(BufferBinding::Array), size, |
Jamie Madill | 6e18a23 | 2019-01-16 13:27:14 -0500 | [diff] [blame] | 4797 | type, ConvertToBool(normalized), stride, ptr); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4798 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4799 | } |
| 4800 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4801 | void Context::vertexAttribFormat(GLuint attribIndex, |
| 4802 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4803 | VertexAttribType type, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4804 | GLboolean normalized, |
| 4805 | GLuint relativeOffset) |
| 4806 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4807 | mState.setVertexAttribFormat(attribIndex, size, type, ConvertToBool(normalized), false, |
| 4808 | relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4809 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4810 | } |
| 4811 | |
| 4812 | void Context::vertexAttribIFormat(GLuint attribIndex, |
| 4813 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4814 | VertexAttribType type, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4815 | GLuint relativeOffset) |
| 4816 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4817 | mState.setVertexAttribFormat(attribIndex, size, type, false, true, relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4818 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4819 | } |
| 4820 | |
| 4821 | void Context::vertexAttribBinding(GLuint attribIndex, GLuint bindingIndex) |
| 4822 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4823 | mState.setVertexAttribBinding(this, attribIndex, bindingIndex); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4824 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4825 | } |
| 4826 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4827 | void Context::vertexBindingDivisor(GLuint bindingIndex, GLuint divisor) |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4828 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4829 | mState.setVertexBindingDivisor(bindingIndex, divisor); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4830 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4831 | } |
| 4832 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4833 | void Context::viewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4834 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4835 | mState.setViewportParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4836 | } |
| 4837 | |
| 4838 | void Context::vertexAttribIPointer(GLuint index, |
| 4839 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4840 | VertexAttribType type, |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4841 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4842 | const void *pointer) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4843 | { |
Jamie Madill | 6e18a23 | 2019-01-16 13:27:14 -0500 | [diff] [blame] | 4844 | mState.setVertexAttribIPointer(this, index, mState.getTargetBuffer(BufferBinding::Array), size, |
| 4845 | type, stride, pointer); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4846 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4847 | } |
| 4848 | |
| 4849 | void Context::vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 4850 | { |
| 4851 | GLint vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4852 | mState.setVertexAttribi(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4853 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4854 | } |
| 4855 | |
| 4856 | void Context::vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 4857 | { |
| 4858 | GLuint vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4859 | mState.setVertexAttribu(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4860 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4861 | } |
| 4862 | |
| 4863 | void Context::vertexAttribI4iv(GLuint index, const GLint *v) |
| 4864 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4865 | mState.setVertexAttribi(index, v); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4866 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4867 | } |
| 4868 | |
| 4869 | void Context::vertexAttribI4uiv(GLuint index, const GLuint *v) |
| 4870 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4871 | mState.setVertexAttribu(index, v); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4872 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4873 | } |
| 4874 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4875 | void Context::getVertexAttribiv(GLuint index, GLenum pname, GLint *params) |
| 4876 | { |
| 4877 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4878 | getState().getVertexAttribCurrentValue(index); |
| 4879 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4880 | QueryVertexAttribiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4881 | currentValues, pname, params); |
| 4882 | } |
| 4883 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4884 | void Context::getVertexAttribivRobust(GLuint index, |
| 4885 | GLenum pname, |
| 4886 | GLsizei bufSize, |
| 4887 | GLsizei *length, |
| 4888 | GLint *params) |
| 4889 | { |
| 4890 | getVertexAttribiv(index, pname, params); |
| 4891 | } |
| 4892 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4893 | void Context::getVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) |
| 4894 | { |
| 4895 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4896 | getState().getVertexAttribCurrentValue(index); |
| 4897 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4898 | QueryVertexAttribfv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4899 | currentValues, pname, params); |
| 4900 | } |
| 4901 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4902 | void Context::getVertexAttribfvRobust(GLuint index, |
| 4903 | GLenum pname, |
| 4904 | GLsizei bufSize, |
| 4905 | GLsizei *length, |
| 4906 | GLfloat *params) |
| 4907 | { |
| 4908 | getVertexAttribfv(index, pname, params); |
| 4909 | } |
| 4910 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4911 | void Context::getVertexAttribIiv(GLuint index, GLenum pname, GLint *params) |
| 4912 | { |
| 4913 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4914 | getState().getVertexAttribCurrentValue(index); |
| 4915 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4916 | QueryVertexAttribIiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4917 | currentValues, pname, params); |
| 4918 | } |
| 4919 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4920 | void Context::getVertexAttribIivRobust(GLuint index, |
| 4921 | GLenum pname, |
| 4922 | GLsizei bufSize, |
| 4923 | GLsizei *length, |
| 4924 | GLint *params) |
| 4925 | { |
| 4926 | getVertexAttribIiv(index, pname, params); |
| 4927 | } |
| 4928 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4929 | void Context::getVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) |
| 4930 | { |
| 4931 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4932 | getState().getVertexAttribCurrentValue(index); |
| 4933 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4934 | QueryVertexAttribIuiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4935 | currentValues, pname, params); |
| 4936 | } |
| 4937 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4938 | void Context::getVertexAttribIuivRobust(GLuint index, |
| 4939 | GLenum pname, |
| 4940 | GLsizei bufSize, |
| 4941 | GLsizei *length, |
| 4942 | GLuint *params) |
| 4943 | { |
| 4944 | getVertexAttribIuiv(index, pname, params); |
| 4945 | } |
| 4946 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4947 | void Context::getVertexAttribPointerv(GLuint index, GLenum pname, void **pointer) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4948 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4949 | const VertexAttribute &attrib = getState().getVertexArray()->getVertexAttribute(index); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4950 | QueryVertexAttribPointerv(attrib, pname, pointer); |
| 4951 | } |
| 4952 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4953 | void Context::getVertexAttribPointervRobust(GLuint index, |
| 4954 | GLenum pname, |
| 4955 | GLsizei bufSize, |
| 4956 | GLsizei *length, |
| 4957 | void **pointer) |
| 4958 | { |
| 4959 | getVertexAttribPointerv(index, pname, pointer); |
| 4960 | } |
| 4961 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4962 | void Context::debugMessageControl(GLenum source, |
| 4963 | GLenum type, |
| 4964 | GLenum severity, |
| 4965 | GLsizei count, |
| 4966 | const GLuint *ids, |
| 4967 | GLboolean enabled) |
| 4968 | { |
| 4969 | std::vector<GLuint> idVector(ids, ids + count); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4970 | mState.getDebug().setMessageControl(source, type, severity, std::move(idVector), |
| 4971 | ConvertToBool(enabled)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4972 | } |
| 4973 | |
| 4974 | void Context::debugMessageInsert(GLenum source, |
| 4975 | GLenum type, |
| 4976 | GLuint id, |
| 4977 | GLenum severity, |
| 4978 | GLsizei length, |
| 4979 | const GLchar *buf) |
| 4980 | { |
| 4981 | std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4982 | mState.getDebug().insertMessage(source, type, id, severity, std::move(msg)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4983 | } |
| 4984 | |
| 4985 | void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam) |
| 4986 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4987 | mState.getDebug().setCallback(callback, userParam); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4988 | } |
| 4989 | |
| 4990 | GLuint Context::getDebugMessageLog(GLuint count, |
| 4991 | GLsizei bufSize, |
| 4992 | GLenum *sources, |
| 4993 | GLenum *types, |
| 4994 | GLuint *ids, |
| 4995 | GLenum *severities, |
| 4996 | GLsizei *lengths, |
| 4997 | GLchar *messageLog) |
| 4998 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4999 | return static_cast<GLuint>(mState.getDebug().getMessages(count, bufSize, sources, types, ids, |
| 5000 | severities, lengths, messageLog)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5001 | } |
| 5002 | |
| 5003 | void Context::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) |
| 5004 | { |
| 5005 | std::string msg(message, (length > 0) ? static_cast<size_t>(length) : strlen(message)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5006 | mState.getDebug().pushGroup(source, id, std::move(msg)); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5007 | mImplementation->pushDebugGroup(source, id, length, message); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5008 | } |
| 5009 | |
| 5010 | void Context::popDebugGroup() |
| 5011 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5012 | mState.getDebug().popGroup(); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5013 | mImplementation->popDebugGroup(); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5014 | } |
| 5015 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5016 | void Context::bufferData(BufferBinding target, GLsizeiptr size, const void *data, BufferUsage usage) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5017 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5018 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5019 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5020 | ANGLE_CONTEXT_TRY(buffer->bufferData(this, target, data, size, usage)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5021 | } |
| 5022 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5023 | void Context::bufferSubData(BufferBinding target, |
| 5024 | GLintptr offset, |
| 5025 | GLsizeiptr size, |
| 5026 | const void *data) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5027 | { |
Courtney Goeltzenleuchter | 62114aa | 2018-08-28 09:36:46 -0600 | [diff] [blame] | 5028 | if (data == nullptr || size == 0) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5029 | { |
| 5030 | return; |
| 5031 | } |
| 5032 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5033 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5034 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5035 | ANGLE_CONTEXT_TRY(buffer->bufferSubData(this, target, data, size, offset)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5036 | } |
| 5037 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5038 | void Context::attachShader(GLuint program, GLuint shader) |
| 5039 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5040 | Program *programObject = mState.mShaderProgramManager->getProgram(program); |
| 5041 | Shader *shaderObject = mState.mShaderProgramManager->getShader(shader); |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5042 | ASSERT(programObject && shaderObject); |
| 5043 | programObject->attachShader(shaderObject); |
| 5044 | } |
| 5045 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 5046 | const Workarounds &Context::getWorkarounds() const |
| 5047 | { |
| 5048 | return mWorkarounds; |
| 5049 | } |
| 5050 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5051 | void Context::copyBufferSubData(BufferBinding readTarget, |
| 5052 | BufferBinding writeTarget, |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5053 | GLintptr readOffset, |
| 5054 | GLintptr writeOffset, |
| 5055 | GLsizeiptr size) |
| 5056 | { |
| 5057 | // if size is zero, the copy is a successful no-op |
| 5058 | if (size == 0) |
| 5059 | { |
| 5060 | return; |
| 5061 | } |
| 5062 | |
| 5063 | // TODO(jmadill): cache these. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5064 | Buffer *readBuffer = mState.getTargetBuffer(readTarget); |
| 5065 | Buffer *writeBuffer = mState.getTargetBuffer(writeTarget); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5066 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5067 | ANGLE_CONTEXT_TRY( |
| 5068 | writeBuffer->copyBufferSubData(this, readBuffer, readOffset, writeOffset, size)); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5069 | } |
| 5070 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5071 | void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *name) |
| 5072 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5073 | // Ideally we could share the program query with the validation layer if possible. |
| 5074 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5075 | ASSERT(programObject); |
| 5076 | programObject->bindAttributeLocation(index, name); |
| 5077 | } |
| 5078 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5079 | void Context::bindBufferBase(BufferBinding target, GLuint index, GLuint buffer) |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5080 | { |
| 5081 | bindBufferRange(target, index, buffer, 0, 0); |
| 5082 | } |
| 5083 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5084 | void Context::bindBufferRange(BufferBinding target, |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5085 | GLuint index, |
| 5086 | GLuint buffer, |
| 5087 | GLintptr offset, |
| 5088 | GLsizeiptr size) |
| 5089 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5090 | Buffer *object = mState.mBufferManager->checkBufferAllocation(mImplementation.get(), buffer); |
| 5091 | ANGLE_CONTEXT_TRY(mState.setIndexedBufferBinding(this, target, index, object, offset, size)); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5092 | if (target == BufferBinding::Uniform) |
| 5093 | { |
Jamie Madill | 472ddc8 | 2018-10-18 18:41:56 -0400 | [diff] [blame] | 5094 | mUniformBufferObserverBindings[index].bind(object); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 5095 | mStateCache.onUniformBufferStateChange(this); |
| 5096 | } |
| 5097 | else |
| 5098 | { |
| 5099 | mStateCache.onBufferBindingChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5100 | } |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5101 | } |
| 5102 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5103 | void Context::bindFramebuffer(GLenum target, GLuint framebuffer) |
| 5104 | { |
| 5105 | if (target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5106 | { |
| 5107 | bindReadFramebuffer(framebuffer); |
| 5108 | } |
| 5109 | |
| 5110 | if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5111 | { |
| 5112 | bindDrawFramebuffer(framebuffer); |
| 5113 | } |
| 5114 | } |
| 5115 | |
| 5116 | void Context::bindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 5117 | { |
| 5118 | ASSERT(target == GL_RENDERBUFFER); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5119 | Renderbuffer *object = mState.mRenderbufferManager->checkRenderbufferAllocation( |
| 5120 | mImplementation.get(), renderbuffer); |
| 5121 | mState.setRenderbufferBinding(this, object); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5122 | } |
| 5123 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5124 | void Context::texStorage2DMultisample(TextureType target, |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5125 | GLsizei samples, |
| 5126 | GLenum internalformat, |
| 5127 | GLsizei width, |
| 5128 | GLsizei height, |
| 5129 | GLboolean fixedsamplelocations) |
| 5130 | { |
| 5131 | Extents size(width, height, 1); |
| 5132 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5133 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5134 | ConvertToBool(fixedsamplelocations))); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5135 | } |
| 5136 | |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5137 | void Context::texStorage3DMultisample(TextureType target, |
| 5138 | GLsizei samples, |
| 5139 | GLenum internalformat, |
| 5140 | GLsizei width, |
| 5141 | GLsizei height, |
| 5142 | GLsizei depth, |
| 5143 | GLboolean fixedsamplelocations) |
| 5144 | { |
Olli Etuaho | 0c5a9e2 | 2018-08-27 14:36:23 +0300 | [diff] [blame] | 5145 | Extents size(width, height, depth); |
| 5146 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5147 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5148 | ConvertToBool(fixedsamplelocations))); |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5149 | } |
| 5150 | |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5151 | void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val) |
| 5152 | { |
JiangYizhou | 5b03f47 | 2017-01-09 10:22:53 +0800 | [diff] [blame] | 5153 | // According to spec 3.1 Table 20.49: Framebuffer Dependent Values, |
| 5154 | // the sample position should be queried by DRAW_FRAMEBUFFER. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5155 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_DRAW_FRAMEBUFFER)); |
| 5156 | const Framebuffer *framebuffer = mState.getDrawFramebuffer(); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5157 | |
| 5158 | switch (pname) |
| 5159 | { |
| 5160 | case GL_SAMPLE_POSITION: |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5161 | ANGLE_CONTEXT_TRY(framebuffer->getSamplePosition(this, index, val)); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5162 | break; |
| 5163 | default: |
| 5164 | UNREACHABLE(); |
| 5165 | } |
| 5166 | } |
| 5167 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5168 | void Context::getMultisamplefvRobust(GLenum pname, |
| 5169 | GLuint index, |
| 5170 | GLsizei bufSize, |
| 5171 | GLsizei *length, |
| 5172 | GLfloat *val) |
| 5173 | { |
| 5174 | UNIMPLEMENTED(); |
| 5175 | } |
| 5176 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5177 | void Context::renderbufferStorage(GLenum target, |
| 5178 | GLenum internalformat, |
| 5179 | GLsizei width, |
| 5180 | GLsizei height) |
| 5181 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5182 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5183 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
| 5184 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5185 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5186 | ANGLE_CONTEXT_TRY(renderbuffer->setStorage(this, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5187 | } |
| 5188 | |
| 5189 | void Context::renderbufferStorageMultisample(GLenum target, |
| 5190 | GLsizei samples, |
| 5191 | GLenum internalformat, |
| 5192 | GLsizei width, |
| 5193 | GLsizei height) |
| 5194 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5195 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5196 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5197 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5198 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5199 | ANGLE_CONTEXT_TRY( |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5200 | renderbuffer->setStorageMultisample(this, samples, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5201 | } |
| 5202 | |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5203 | void Context::getSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) |
| 5204 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 5205 | const Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5206 | ANGLE_CONTEXT_TRY(QuerySynciv(this, syncObject, pname, bufSize, length, values)); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5207 | } |
| 5208 | |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5209 | void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 5210 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5211 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5212 | QueryFramebufferParameteriv(framebuffer, pname, params); |
| 5213 | } |
| 5214 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5215 | void Context::getFramebufferParameterivRobust(GLenum target, |
| 5216 | GLenum pname, |
| 5217 | GLsizei bufSize, |
| 5218 | GLsizei *length, |
| 5219 | GLint *params) |
| 5220 | { |
| 5221 | UNIMPLEMENTED(); |
| 5222 | } |
| 5223 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5224 | void Context::framebufferParameteri(GLenum target, GLenum pname, GLint param) |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5225 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5226 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | b983a4b | 2018-08-01 11:34:51 -0400 | [diff] [blame] | 5227 | SetFramebufferParameteri(this, framebuffer, pname, param); |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5228 | } |
| 5229 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5230 | bool Context::getScratchBuffer(size_t requstedSizeBytes, |
| 5231 | angle::MemoryBuffer **scratchBufferOut) const |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5232 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5233 | return mScratchBuffer.get(requstedSizeBytes, scratchBufferOut); |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5234 | } |
| 5235 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5236 | bool Context::getZeroFilledBuffer(size_t requstedSizeBytes, |
| 5237 | angle::MemoryBuffer **zeroBufferOut) const |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5238 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5239 | return mZeroFilledBuffer.getInitialized(requstedSizeBytes, zeroBufferOut, 0); |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5240 | } |
| 5241 | |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5242 | void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) |
| 5243 | { |
| 5244 | if (numGroupsX == 0u || numGroupsY == 0u || numGroupsZ == 0u) |
| 5245 | { |
| 5246 | return; |
| 5247 | } |
| 5248 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 5249 | ANGLE_CONTEXT_TRY(prepareForDispatch()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5250 | ANGLE_CONTEXT_TRY(mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ)); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5251 | } |
| 5252 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5253 | void Context::dispatchComputeIndirect(GLintptr indirect) |
| 5254 | { |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 5255 | ANGLE_CONTEXT_TRY(prepareForDispatch()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5256 | ANGLE_CONTEXT_TRY(mImplementation->dispatchComputeIndirect(this, indirect)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5257 | } |
| 5258 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5259 | void Context::texStorage2D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5260 | GLsizei levels, |
| 5261 | GLenum internalFormat, |
| 5262 | GLsizei width, |
| 5263 | GLsizei height) |
| 5264 | { |
| 5265 | Extents size(width, height, 1); |
| 5266 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5267 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5268 | } |
| 5269 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5270 | void Context::texStorage3D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5271 | GLsizei levels, |
| 5272 | GLenum internalFormat, |
| 5273 | GLsizei width, |
| 5274 | GLsizei height, |
| 5275 | GLsizei depth) |
| 5276 | { |
| 5277 | Extents size(width, height, depth); |
| 5278 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5279 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5280 | } |
| 5281 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5282 | void Context::memoryBarrier(GLbitfield barriers) |
| 5283 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5284 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrier(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5285 | } |
| 5286 | |
| 5287 | void Context::memoryBarrierByRegion(GLbitfield barriers) |
| 5288 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5289 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrierByRegion(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5290 | } |
| 5291 | |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5292 | void Context::multiDrawArrays(PrimitiveMode mode, |
| 5293 | const GLint *firsts, |
| 5294 | const GLsizei *counts, |
| 5295 | GLsizei drawcount) |
| 5296 | { |
| 5297 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5298 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5299 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5300 | if (hasDrawID) |
| 5301 | { |
| 5302 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5303 | { |
| 5304 | if (noopDraw(mode, counts[drawID])) |
| 5305 | { |
| 5306 | continue; |
| 5307 | } |
| 5308 | programObject->setDrawIDUniform(drawID); |
| 5309 | ANGLE_CONTEXT_TRY( |
| 5310 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5311 | MarkTransformFeedbackBufferUsage(this, counts[drawID], 1); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5312 | } |
| 5313 | } |
| 5314 | else |
| 5315 | { |
| 5316 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5317 | { |
| 5318 | if (noopDraw(mode, counts[drawID])) |
| 5319 | { |
| 5320 | continue; |
| 5321 | } |
| 5322 | ANGLE_CONTEXT_TRY( |
| 5323 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5324 | MarkTransformFeedbackBufferUsage(this, counts[drawID], 1); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5325 | } |
| 5326 | } |
| 5327 | } |
| 5328 | |
| 5329 | void Context::multiDrawArraysInstanced(PrimitiveMode mode, |
| 5330 | const GLint *firsts, |
| 5331 | const GLsizei *counts, |
| 5332 | const GLsizei *instanceCounts, |
| 5333 | GLsizei drawcount) |
| 5334 | { |
| 5335 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5336 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5337 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5338 | if (hasDrawID) |
| 5339 | { |
| 5340 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5341 | { |
| 5342 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5343 | { |
| 5344 | continue; |
| 5345 | } |
| 5346 | programObject->setDrawIDUniform(drawID); |
| 5347 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5348 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5349 | MarkTransformFeedbackBufferUsage(this, counts[drawID], instanceCounts[drawID]); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5350 | } |
| 5351 | } |
| 5352 | else |
| 5353 | { |
| 5354 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5355 | { |
| 5356 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5357 | { |
| 5358 | continue; |
| 5359 | } |
| 5360 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5361 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5362 | MarkTransformFeedbackBufferUsage(this, counts[drawID], instanceCounts[drawID]); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5363 | } |
| 5364 | } |
| 5365 | } |
| 5366 | |
| 5367 | void Context::multiDrawElements(PrimitiveMode mode, |
| 5368 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5369 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5370 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5371 | GLsizei drawcount) |
| 5372 | { |
| 5373 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5374 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5375 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5376 | if (hasDrawID) |
| 5377 | { |
| 5378 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5379 | { |
| 5380 | if (noopDraw(mode, counts[drawID])) |
| 5381 | { |
| 5382 | continue; |
| 5383 | } |
| 5384 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5385 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5386 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5387 | } |
| 5388 | } |
| 5389 | else |
| 5390 | { |
| 5391 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5392 | { |
| 5393 | if (noopDraw(mode, counts[drawID])) |
| 5394 | { |
| 5395 | continue; |
| 5396 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5397 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5398 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5399 | } |
| 5400 | } |
| 5401 | } |
| 5402 | |
| 5403 | void Context::multiDrawElementsInstanced(PrimitiveMode mode, |
| 5404 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5405 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5406 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5407 | const GLsizei *instanceCounts, |
| 5408 | GLsizei drawcount) |
| 5409 | { |
| 5410 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5411 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5412 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5413 | if (hasDrawID) |
| 5414 | { |
| 5415 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5416 | { |
| 5417 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5418 | { |
| 5419 | continue; |
| 5420 | } |
| 5421 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5422 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5423 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5424 | } |
| 5425 | } |
| 5426 | else |
| 5427 | { |
| 5428 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5429 | { |
| 5430 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5431 | { |
| 5432 | continue; |
| 5433 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5434 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5435 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5436 | } |
| 5437 | } |
| 5438 | } |
| 5439 | |
Jeff Gilbert | 465d609 | 2019-01-02 16:21:18 -0800 | [diff] [blame] | 5440 | void Context::provokingVertex(ProvokingVertex provokeMode) |
| 5441 | { |
| 5442 | mState.setProvokingVertex(provokeMode); |
| 5443 | } |
| 5444 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5445 | GLenum Context::checkFramebufferStatus(GLenum target) |
| 5446 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5447 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5448 | ASSERT(framebuffer); |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 5449 | return framebuffer->checkStatus(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5450 | } |
| 5451 | |
| 5452 | void Context::compileShader(GLuint shader) |
| 5453 | { |
| 5454 | Shader *shaderObject = GetValidShader(this, shader); |
| 5455 | if (!shaderObject) |
| 5456 | { |
| 5457 | return; |
| 5458 | } |
| 5459 | shaderObject->compile(this); |
| 5460 | } |
| 5461 | |
| 5462 | void Context::deleteBuffers(GLsizei n, const GLuint *buffers) |
| 5463 | { |
| 5464 | for (int i = 0; i < n; i++) |
| 5465 | { |
| 5466 | deleteBuffer(buffers[i]); |
| 5467 | } |
| 5468 | } |
| 5469 | |
| 5470 | void Context::deleteFramebuffers(GLsizei n, const GLuint *framebuffers) |
| 5471 | { |
| 5472 | for (int i = 0; i < n; i++) |
| 5473 | { |
| 5474 | if (framebuffers[i] != 0) |
| 5475 | { |
| 5476 | deleteFramebuffer(framebuffers[i]); |
| 5477 | } |
| 5478 | } |
| 5479 | } |
| 5480 | |
| 5481 | void Context::deleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) |
| 5482 | { |
| 5483 | for (int i = 0; i < n; i++) |
| 5484 | { |
| 5485 | deleteRenderbuffer(renderbuffers[i]); |
| 5486 | } |
| 5487 | } |
| 5488 | |
| 5489 | void Context::deleteTextures(GLsizei n, const GLuint *textures) |
| 5490 | { |
| 5491 | for (int i = 0; i < n; i++) |
| 5492 | { |
| 5493 | if (textures[i] != 0) |
| 5494 | { |
| 5495 | deleteTexture(textures[i]); |
| 5496 | } |
| 5497 | } |
| 5498 | } |
| 5499 | |
| 5500 | void Context::detachShader(GLuint program, GLuint shader) |
| 5501 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5502 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5503 | ASSERT(programObject); |
| 5504 | |
| 5505 | Shader *shaderObject = getShader(shader); |
| 5506 | ASSERT(shaderObject); |
| 5507 | |
| 5508 | programObject->detachShader(this, shaderObject); |
| 5509 | } |
| 5510 | |
| 5511 | void Context::genBuffers(GLsizei n, GLuint *buffers) |
| 5512 | { |
| 5513 | for (int i = 0; i < n; i++) |
| 5514 | { |
| 5515 | buffers[i] = createBuffer(); |
| 5516 | } |
| 5517 | } |
| 5518 | |
| 5519 | void Context::genFramebuffers(GLsizei n, GLuint *framebuffers) |
| 5520 | { |
| 5521 | for (int i = 0; i < n; i++) |
| 5522 | { |
| 5523 | framebuffers[i] = createFramebuffer(); |
| 5524 | } |
| 5525 | } |
| 5526 | |
| 5527 | void Context::genRenderbuffers(GLsizei n, GLuint *renderbuffers) |
| 5528 | { |
| 5529 | for (int i = 0; i < n; i++) |
| 5530 | { |
| 5531 | renderbuffers[i] = createRenderbuffer(); |
| 5532 | } |
| 5533 | } |
| 5534 | |
| 5535 | void Context::genTextures(GLsizei n, GLuint *textures) |
| 5536 | { |
| 5537 | for (int i = 0; i < n; i++) |
| 5538 | { |
| 5539 | textures[i] = createTexture(); |
| 5540 | } |
| 5541 | } |
| 5542 | |
| 5543 | void Context::getActiveAttrib(GLuint program, |
| 5544 | GLuint index, |
| 5545 | GLsizei bufsize, |
| 5546 | GLsizei *length, |
| 5547 | GLint *size, |
| 5548 | GLenum *type, |
| 5549 | GLchar *name) |
| 5550 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5551 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5552 | ASSERT(programObject); |
| 5553 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 5554 | } |
| 5555 | |
| 5556 | void Context::getActiveUniform(GLuint program, |
| 5557 | GLuint index, |
| 5558 | GLsizei bufsize, |
| 5559 | GLsizei *length, |
| 5560 | GLint *size, |
| 5561 | GLenum *type, |
| 5562 | GLchar *name) |
| 5563 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5564 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5565 | ASSERT(programObject); |
| 5566 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 5567 | } |
| 5568 | |
| 5569 | void Context::getAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) |
| 5570 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5571 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5572 | ASSERT(programObject); |
| 5573 | programObject->getAttachedShaders(maxcount, count, shaders); |
| 5574 | } |
| 5575 | |
| 5576 | GLint Context::getAttribLocation(GLuint program, const GLchar *name) |
| 5577 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5578 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5579 | ASSERT(programObject); |
| 5580 | return programObject->getAttributeLocation(name); |
| 5581 | } |
| 5582 | |
| 5583 | void Context::getBooleanv(GLenum pname, GLboolean *params) |
| 5584 | { |
| 5585 | GLenum nativeType; |
| 5586 | unsigned int numParams = 0; |
| 5587 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5588 | |
| 5589 | if (nativeType == GL_BOOL) |
| 5590 | { |
| 5591 | getBooleanvImpl(pname, params); |
| 5592 | } |
| 5593 | else |
| 5594 | { |
| 5595 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5596 | } |
| 5597 | } |
| 5598 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5599 | void Context::getBooleanvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLboolean *params) |
| 5600 | { |
| 5601 | getBooleanv(pname, params); |
| 5602 | } |
| 5603 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5604 | void Context::getFloatv(GLenum pname, GLfloat *params) |
| 5605 | { |
| 5606 | GLenum nativeType; |
| 5607 | unsigned int numParams = 0; |
| 5608 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5609 | |
| 5610 | if (nativeType == GL_FLOAT) |
| 5611 | { |
| 5612 | getFloatvImpl(pname, params); |
| 5613 | } |
| 5614 | else |
| 5615 | { |
| 5616 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5617 | } |
| 5618 | } |
| 5619 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5620 | void Context::getFloatvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLfloat *params) |
| 5621 | { |
| 5622 | getFloatv(pname, params); |
| 5623 | } |
| 5624 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5625 | void Context::getIntegerv(GLenum pname, GLint *params) |
| 5626 | { |
| 5627 | GLenum nativeType; |
| 5628 | unsigned int numParams = 0; |
| 5629 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5630 | |
| 5631 | if (nativeType == GL_INT) |
| 5632 | { |
| 5633 | getIntegervImpl(pname, params); |
| 5634 | } |
| 5635 | else |
| 5636 | { |
| 5637 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5638 | } |
| 5639 | } |
| 5640 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5641 | void Context::getIntegervRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint *data) |
| 5642 | { |
| 5643 | getIntegerv(pname, data); |
| 5644 | } |
| 5645 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5646 | void Context::getProgramiv(GLuint program, GLenum pname, GLint *params) |
| 5647 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5648 | // Don't resolve link if checking the link completion status. |
| 5649 | Program *programObject = (pname == GL_COMPLETION_STATUS_KHR ? getProgramNoResolveLink(program) |
| 5650 | : getProgramResolveLink(program)); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5651 | ASSERT(programObject); |
Jamie Madill | ffe00c0 | 2017-06-27 16:26:55 -0400 | [diff] [blame] | 5652 | QueryProgramiv(this, programObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5653 | } |
| 5654 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5655 | void Context::getProgramivRobust(GLuint program, |
| 5656 | GLenum pname, |
| 5657 | GLsizei bufSize, |
| 5658 | GLsizei *length, |
| 5659 | GLint *params) |
| 5660 | { |
| 5661 | getProgramiv(program, pname, params); |
| 5662 | } |
| 5663 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5664 | void Context::getProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params) |
| 5665 | { |
| 5666 | UNIMPLEMENTED(); |
| 5667 | } |
| 5668 | |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 5669 | void Context::getProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5670 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5671 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5672 | ASSERT(programObject); |
| 5673 | programObject->getInfoLog(bufsize, length, infolog); |
| 5674 | } |
| 5675 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5676 | void Context::getProgramPipelineInfoLog(GLuint pipeline, |
| 5677 | GLsizei bufSize, |
| 5678 | GLsizei *length, |
| 5679 | GLchar *infoLog) |
| 5680 | { |
| 5681 | UNIMPLEMENTED(); |
| 5682 | } |
| 5683 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5684 | void Context::getShaderiv(GLuint shader, GLenum pname, GLint *params) |
| 5685 | { |
| 5686 | Shader *shaderObject = getShader(shader); |
| 5687 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5688 | QueryShaderiv(shaderObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5689 | } |
| 5690 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5691 | void Context::getShaderivRobust(GLuint shader, |
| 5692 | GLenum pname, |
| 5693 | GLsizei bufSize, |
| 5694 | GLsizei *length, |
| 5695 | GLint *params) |
| 5696 | { |
| 5697 | getShaderiv(shader, pname, params); |
| 5698 | } |
| 5699 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5700 | void Context::getShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
| 5701 | { |
| 5702 | Shader *shaderObject = getShader(shader); |
| 5703 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5704 | shaderObject->getInfoLog(bufsize, length, infolog); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5705 | } |
| 5706 | |
| 5707 | void Context::getShaderPrecisionFormat(GLenum shadertype, |
| 5708 | GLenum precisiontype, |
| 5709 | GLint *range, |
| 5710 | GLint *precision) |
| 5711 | { |
| 5712 | // TODO(jmadill): Compute shaders. |
| 5713 | |
| 5714 | switch (shadertype) |
| 5715 | { |
| 5716 | case GL_VERTEX_SHADER: |
| 5717 | switch (precisiontype) |
| 5718 | { |
| 5719 | case GL_LOW_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5720 | mState.mCaps.vertexLowpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5721 | break; |
| 5722 | case GL_MEDIUM_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5723 | mState.mCaps.vertexMediumpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5724 | break; |
| 5725 | case GL_HIGH_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5726 | mState.mCaps.vertexHighpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5727 | break; |
| 5728 | |
| 5729 | case GL_LOW_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5730 | mState.mCaps.vertexLowpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5731 | break; |
| 5732 | case GL_MEDIUM_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5733 | mState.mCaps.vertexMediumpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5734 | break; |
| 5735 | case GL_HIGH_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5736 | mState.mCaps.vertexHighpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5737 | break; |
| 5738 | |
| 5739 | default: |
| 5740 | UNREACHABLE(); |
| 5741 | return; |
| 5742 | } |
| 5743 | break; |
| 5744 | |
| 5745 | case GL_FRAGMENT_SHADER: |
| 5746 | switch (precisiontype) |
| 5747 | { |
| 5748 | case GL_LOW_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5749 | mState.mCaps.fragmentLowpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5750 | break; |
| 5751 | case GL_MEDIUM_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5752 | mState.mCaps.fragmentMediumpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5753 | break; |
| 5754 | case GL_HIGH_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5755 | mState.mCaps.fragmentHighpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5756 | break; |
| 5757 | |
| 5758 | case GL_LOW_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5759 | mState.mCaps.fragmentLowpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5760 | break; |
| 5761 | case GL_MEDIUM_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5762 | mState.mCaps.fragmentMediumpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5763 | break; |
| 5764 | case GL_HIGH_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5765 | mState.mCaps.fragmentHighpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5766 | break; |
| 5767 | |
| 5768 | default: |
| 5769 | UNREACHABLE(); |
| 5770 | return; |
| 5771 | } |
| 5772 | break; |
| 5773 | |
| 5774 | default: |
| 5775 | UNREACHABLE(); |
| 5776 | return; |
| 5777 | } |
| 5778 | } |
| 5779 | |
| 5780 | void Context::getShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source) |
| 5781 | { |
| 5782 | Shader *shaderObject = getShader(shader); |
| 5783 | ASSERT(shaderObject); |
| 5784 | shaderObject->getSource(bufsize, length, source); |
| 5785 | } |
| 5786 | |
| 5787 | void Context::getUniformfv(GLuint program, GLint location, GLfloat *params) |
| 5788 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5789 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5790 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5791 | programObject->getUniformfv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5792 | } |
| 5793 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5794 | void Context::getUniformfvRobust(GLuint program, |
| 5795 | GLint location, |
| 5796 | GLsizei bufSize, |
| 5797 | GLsizei *length, |
| 5798 | GLfloat *params) |
| 5799 | { |
| 5800 | getUniformfv(program, location, params); |
| 5801 | } |
| 5802 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5803 | void Context::getUniformiv(GLuint program, GLint location, GLint *params) |
| 5804 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5805 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5806 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5807 | programObject->getUniformiv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5808 | } |
| 5809 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5810 | void Context::getUniformivRobust(GLuint program, |
| 5811 | GLint location, |
| 5812 | GLsizei bufSize, |
| 5813 | GLsizei *length, |
| 5814 | GLint *params) |
| 5815 | { |
| 5816 | getUniformiv(program, location, params); |
| 5817 | } |
| 5818 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5819 | GLint Context::getUniformLocation(GLuint program, const GLchar *name) |
| 5820 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5821 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5822 | ASSERT(programObject); |
| 5823 | return programObject->getUniformLocation(name); |
| 5824 | } |
| 5825 | |
| 5826 | GLboolean Context::isBuffer(GLuint buffer) |
| 5827 | { |
| 5828 | if (buffer == 0) |
| 5829 | { |
| 5830 | return GL_FALSE; |
| 5831 | } |
| 5832 | |
| 5833 | return (getBuffer(buffer) ? GL_TRUE : GL_FALSE); |
| 5834 | } |
| 5835 | |
| 5836 | GLboolean Context::isEnabled(GLenum cap) |
| 5837 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5838 | return mState.getEnableFeature(cap); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5839 | } |
| 5840 | |
| 5841 | GLboolean Context::isFramebuffer(GLuint framebuffer) |
| 5842 | { |
| 5843 | if (framebuffer == 0) |
| 5844 | { |
| 5845 | return GL_FALSE; |
| 5846 | } |
| 5847 | |
| 5848 | return (getFramebuffer(framebuffer) ? GL_TRUE : GL_FALSE); |
| 5849 | } |
| 5850 | |
| 5851 | GLboolean Context::isProgram(GLuint program) |
| 5852 | { |
| 5853 | if (program == 0) |
| 5854 | { |
| 5855 | return GL_FALSE; |
| 5856 | } |
| 5857 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5858 | return (getProgramNoResolveLink(program) ? GL_TRUE : GL_FALSE); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5859 | } |
| 5860 | |
| 5861 | GLboolean Context::isRenderbuffer(GLuint renderbuffer) |
| 5862 | { |
| 5863 | if (renderbuffer == 0) |
| 5864 | { |
| 5865 | return GL_FALSE; |
| 5866 | } |
| 5867 | |
| 5868 | return (getRenderbuffer(renderbuffer) ? GL_TRUE : GL_FALSE); |
| 5869 | } |
| 5870 | |
| 5871 | GLboolean Context::isShader(GLuint shader) |
| 5872 | { |
| 5873 | if (shader == 0) |
| 5874 | { |
| 5875 | return GL_FALSE; |
| 5876 | } |
| 5877 | |
| 5878 | return (getShader(shader) ? GL_TRUE : GL_FALSE); |
| 5879 | } |
| 5880 | |
| 5881 | GLboolean Context::isTexture(GLuint texture) |
| 5882 | { |
| 5883 | if (texture == 0) |
| 5884 | { |
| 5885 | return GL_FALSE; |
| 5886 | } |
| 5887 | |
| 5888 | return (getTexture(texture) ? GL_TRUE : GL_FALSE); |
| 5889 | } |
| 5890 | |
| 5891 | void Context::linkProgram(GLuint program) |
| 5892 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5893 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5894 | ASSERT(programObject); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5895 | ANGLE_CONTEXT_TRY(programObject->link(this)); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5896 | |
| 5897 | // Don't parallel link a program which is active in any GL contexts. With this assumption, we |
| 5898 | // don't need to worry that: |
| 5899 | // 1. Draw calls after link use the new executable code or the old one depending on the link |
| 5900 | // result. |
| 5901 | // 2. When a backend program, e.g., ProgramD3D is linking, other backend classes like |
| 5902 | // StateManager11, Renderer11, etc., may have a chance to make unexpected calls to |
| 5903 | // ProgramD3D. |
| 5904 | if (programObject->isInUse()) |
| 5905 | { |
Jamie Madill | 785e8a0 | 2018-10-04 17:42:00 -0400 | [diff] [blame] | 5906 | programObject->resolveLink(this); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 5907 | if (programObject->isLinked()) |
| 5908 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5909 | ANGLE_CONTEXT_TRY(mState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 5910 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5911 | mStateCache.onProgramExecutableChange(this); |
| 5912 | } |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5913 | } |
| 5914 | |
| 5915 | void Context::releaseShaderCompiler() |
| 5916 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5917 | mCompiler.set(this, nullptr); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5918 | } |
| 5919 | |
| 5920 | void Context::shaderBinary(GLsizei n, |
| 5921 | const GLuint *shaders, |
| 5922 | GLenum binaryformat, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 5923 | const void *binary, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5924 | GLsizei length) |
| 5925 | { |
| 5926 | // No binary shader formats are supported. |
| 5927 | UNIMPLEMENTED(); |
| 5928 | } |
| 5929 | |
Olli Etuaho | 0ca0975 | 2018-09-24 11:00:50 +0300 | [diff] [blame] | 5930 | void Context::bindFragDataLocationIndexed(GLuint program, |
| 5931 | GLuint colorNumber, |
| 5932 | GLuint index, |
| 5933 | const char *name) |
| 5934 | { |
| 5935 | Program *programObject = getProgramNoResolveLink(program); |
| 5936 | programObject->bindFragmentOutputLocation(colorNumber, name); |
| 5937 | programObject->bindFragmentOutputIndex(index, name); |
| 5938 | } |
| 5939 | |
| 5940 | void Context::bindFragDataLocation(GLuint program, GLuint colorNumber, const char *name) |
| 5941 | { |
| 5942 | bindFragDataLocationIndexed(program, colorNumber, 0u, name); |
| 5943 | } |
| 5944 | |
| 5945 | int Context::getFragDataIndex(GLuint program, const char *name) |
| 5946 | { |
| 5947 | Program *programObject = getProgramResolveLink(program); |
| 5948 | return programObject->getFragDataIndex(name); |
| 5949 | } |
| 5950 | |
| 5951 | int Context::getProgramResourceLocationIndex(GLuint program, |
| 5952 | GLenum programInterface, |
| 5953 | const char *name) |
| 5954 | { |
| 5955 | Program *programObject = getProgramResolveLink(program); |
| 5956 | ASSERT(programInterface == GL_PROGRAM_OUTPUT); |
| 5957 | return programObject->getFragDataIndex(name); |
| 5958 | } |
| 5959 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5960 | void Context::shaderSource(GLuint shader, |
| 5961 | GLsizei count, |
| 5962 | const GLchar *const *string, |
| 5963 | const GLint *length) |
| 5964 | { |
| 5965 | Shader *shaderObject = getShader(shader); |
| 5966 | ASSERT(shaderObject); |
| 5967 | shaderObject->setSource(count, string, length); |
| 5968 | } |
| 5969 | |
| 5970 | void Context::stencilFunc(GLenum func, GLint ref, GLuint mask) |
| 5971 | { |
| 5972 | stencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
| 5973 | } |
| 5974 | |
| 5975 | void Context::stencilMask(GLuint mask) |
| 5976 | { |
| 5977 | stencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 5978 | } |
| 5979 | |
| 5980 | void Context::stencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 5981 | { |
| 5982 | stencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 5983 | } |
| 5984 | |
| 5985 | void Context::uniform1f(GLint location, GLfloat x) |
| 5986 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5987 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5988 | program->setUniform1fv(location, 1, &x); |
| 5989 | } |
| 5990 | |
| 5991 | void Context::uniform1fv(GLint location, GLsizei count, const GLfloat *v) |
| 5992 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5993 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5994 | program->setUniform1fv(location, count, v); |
| 5995 | } |
| 5996 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 5997 | void Context::setUniform1iImpl(Program *program, GLint location, GLsizei count, const GLint *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5998 | { |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 5999 | program->setUniform1iv(this, location, count, v); |
| 6000 | } |
| 6001 | |
| 6002 | void Context::onSamplerUniformChange(size_t textureUnitIndex) |
| 6003 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6004 | mState.onActiveTextureChange(this, textureUnitIndex); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 6005 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6006 | } |
| 6007 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6008 | void Context::uniform1i(GLint location, GLint x) |
| 6009 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6010 | setUniform1iImpl(mState.getProgram(), location, 1, &x); |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6011 | } |
| 6012 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6013 | void Context::uniform1iv(GLint location, GLsizei count, const GLint *v) |
| 6014 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6015 | setUniform1iImpl(mState.getProgram(), location, count, v); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6016 | } |
| 6017 | |
| 6018 | void Context::uniform2f(GLint location, GLfloat x, GLfloat y) |
| 6019 | { |
| 6020 | GLfloat xy[2] = {x, y}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6021 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6022 | program->setUniform2fv(location, 1, xy); |
| 6023 | } |
| 6024 | |
| 6025 | void Context::uniform2fv(GLint location, GLsizei count, const GLfloat *v) |
| 6026 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6027 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6028 | program->setUniform2fv(location, count, v); |
| 6029 | } |
| 6030 | |
| 6031 | void Context::uniform2i(GLint location, GLint x, GLint y) |
| 6032 | { |
| 6033 | GLint xy[2] = {x, y}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6034 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6035 | program->setUniform2iv(location, 1, xy); |
| 6036 | } |
| 6037 | |
| 6038 | void Context::uniform2iv(GLint location, GLsizei count, const GLint *v) |
| 6039 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6040 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6041 | program->setUniform2iv(location, count, v); |
| 6042 | } |
| 6043 | |
| 6044 | void Context::uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 6045 | { |
| 6046 | GLfloat xyz[3] = {x, y, z}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6047 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6048 | program->setUniform3fv(location, 1, xyz); |
| 6049 | } |
| 6050 | |
| 6051 | void Context::uniform3fv(GLint location, GLsizei count, const GLfloat *v) |
| 6052 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6053 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6054 | program->setUniform3fv(location, count, v); |
| 6055 | } |
| 6056 | |
| 6057 | void Context::uniform3i(GLint location, GLint x, GLint y, GLint z) |
| 6058 | { |
| 6059 | GLint xyz[3] = {x, y, z}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6060 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6061 | program->setUniform3iv(location, 1, xyz); |
| 6062 | } |
| 6063 | |
| 6064 | void Context::uniform3iv(GLint location, GLsizei count, const GLint *v) |
| 6065 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6066 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6067 | program->setUniform3iv(location, count, v); |
| 6068 | } |
| 6069 | |
| 6070 | void Context::uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 6071 | { |
| 6072 | GLfloat xyzw[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6073 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6074 | program->setUniform4fv(location, 1, xyzw); |
| 6075 | } |
| 6076 | |
| 6077 | void Context::uniform4fv(GLint location, GLsizei count, const GLfloat *v) |
| 6078 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6079 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6080 | program->setUniform4fv(location, count, v); |
| 6081 | } |
| 6082 | |
| 6083 | void Context::uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 6084 | { |
| 6085 | GLint xyzw[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6086 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6087 | program->setUniform4iv(location, 1, xyzw); |
| 6088 | } |
| 6089 | |
| 6090 | void Context::uniform4iv(GLint location, GLsizei count, const GLint *v) |
| 6091 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6092 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6093 | program->setUniform4iv(location, count, v); |
| 6094 | } |
| 6095 | |
| 6096 | void Context::uniformMatrix2fv(GLint location, |
| 6097 | GLsizei count, |
| 6098 | GLboolean transpose, |
| 6099 | const GLfloat *value) |
| 6100 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6101 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6102 | program->setUniformMatrix2fv(location, count, transpose, value); |
| 6103 | } |
| 6104 | |
| 6105 | void Context::uniformMatrix3fv(GLint location, |
| 6106 | GLsizei count, |
| 6107 | GLboolean transpose, |
| 6108 | const GLfloat *value) |
| 6109 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6110 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6111 | program->setUniformMatrix3fv(location, count, transpose, value); |
| 6112 | } |
| 6113 | |
| 6114 | void Context::uniformMatrix4fv(GLint location, |
| 6115 | GLsizei count, |
| 6116 | GLboolean transpose, |
| 6117 | const GLfloat *value) |
| 6118 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6119 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6120 | program->setUniformMatrix4fv(location, count, transpose, value); |
| 6121 | } |
| 6122 | |
| 6123 | void Context::validateProgram(GLuint program) |
| 6124 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6125 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6126 | ASSERT(programObject); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6127 | programObject->validate(mState.mCaps); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6128 | } |
| 6129 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6130 | void Context::validateProgramPipeline(GLuint pipeline) |
| 6131 | { |
| 6132 | UNIMPLEMENTED(); |
| 6133 | } |
| 6134 | |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6135 | void Context::getProgramBinary(GLuint program, |
| 6136 | GLsizei bufSize, |
| 6137 | GLsizei *length, |
| 6138 | GLenum *binaryFormat, |
| 6139 | void *binary) |
| 6140 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6141 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6142 | ASSERT(programObject != nullptr); |
| 6143 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6144 | ANGLE_CONTEXT_TRY(programObject->saveBinary(this, binaryFormat, binary, bufSize, length)); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6145 | } |
| 6146 | |
| 6147 | void Context::programBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length) |
| 6148 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6149 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6150 | ASSERT(programObject != nullptr); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 6151 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6152 | ANGLE_CONTEXT_TRY(programObject->loadBinary(this, binaryFormat, binary, length)); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6153 | if (programObject->isInUse()) |
| 6154 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6155 | ANGLE_CONTEXT_TRY(mState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 6156 | mStateCache.onProgramExecutableChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6157 | } |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6158 | } |
| 6159 | |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6160 | void Context::uniform1ui(GLint location, GLuint v0) |
| 6161 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6162 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6163 | program->setUniform1uiv(location, 1, &v0); |
| 6164 | } |
| 6165 | |
| 6166 | void Context::uniform2ui(GLint location, GLuint v0, GLuint v1) |
| 6167 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6168 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6169 | const GLuint xy[] = {v0, v1}; |
| 6170 | program->setUniform2uiv(location, 1, xy); |
| 6171 | } |
| 6172 | |
| 6173 | void Context::uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6174 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6175 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6176 | const GLuint xyz[] = {v0, v1, v2}; |
| 6177 | program->setUniform3uiv(location, 1, xyz); |
| 6178 | } |
| 6179 | |
| 6180 | void Context::uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 6181 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6182 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6183 | const GLuint xyzw[] = {v0, v1, v2, v3}; |
| 6184 | program->setUniform4uiv(location, 1, xyzw); |
| 6185 | } |
| 6186 | |
| 6187 | void Context::uniform1uiv(GLint location, GLsizei count, const GLuint *value) |
| 6188 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6189 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6190 | program->setUniform1uiv(location, count, value); |
| 6191 | } |
| 6192 | void Context::uniform2uiv(GLint location, GLsizei count, const GLuint *value) |
| 6193 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6194 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6195 | program->setUniform2uiv(location, count, value); |
| 6196 | } |
| 6197 | |
| 6198 | void Context::uniform3uiv(GLint location, GLsizei count, const GLuint *value) |
| 6199 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6200 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6201 | program->setUniform3uiv(location, count, value); |
| 6202 | } |
| 6203 | |
| 6204 | void Context::uniform4uiv(GLint location, GLsizei count, const GLuint *value) |
| 6205 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6206 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6207 | program->setUniform4uiv(location, count, value); |
| 6208 | } |
| 6209 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6210 | void Context::genQueries(GLsizei n, GLuint *ids) |
| 6211 | { |
| 6212 | for (GLsizei i = 0; i < n; i++) |
| 6213 | { |
| 6214 | GLuint handle = mQueryHandleAllocator.allocate(); |
| 6215 | mQueryMap.assign(handle, nullptr); |
| 6216 | ids[i] = handle; |
| 6217 | } |
| 6218 | } |
| 6219 | |
| 6220 | void Context::deleteQueries(GLsizei n, const GLuint *ids) |
| 6221 | { |
| 6222 | for (int i = 0; i < n; i++) |
| 6223 | { |
| 6224 | GLuint query = ids[i]; |
| 6225 | |
| 6226 | Query *queryObject = nullptr; |
| 6227 | if (mQueryMap.erase(query, &queryObject)) |
| 6228 | { |
| 6229 | mQueryHandleAllocator.release(query); |
| 6230 | if (queryObject) |
| 6231 | { |
| 6232 | queryObject->release(this); |
| 6233 | } |
| 6234 | } |
| 6235 | } |
| 6236 | } |
| 6237 | |
| 6238 | GLboolean Context::isQuery(GLuint id) |
| 6239 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 6240 | return (getQuery(id, false, QueryType::InvalidEnum) != nullptr) ? GL_TRUE : GL_FALSE; |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6241 | } |
| 6242 | |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6243 | void Context::uniformMatrix2x3fv(GLint location, |
| 6244 | GLsizei count, |
| 6245 | GLboolean transpose, |
| 6246 | const GLfloat *value) |
| 6247 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6248 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6249 | program->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6250 | } |
| 6251 | |
| 6252 | void Context::uniformMatrix3x2fv(GLint location, |
| 6253 | GLsizei count, |
| 6254 | GLboolean transpose, |
| 6255 | const GLfloat *value) |
| 6256 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6257 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6258 | program->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6259 | } |
| 6260 | |
| 6261 | void Context::uniformMatrix2x4fv(GLint location, |
| 6262 | GLsizei count, |
| 6263 | GLboolean transpose, |
| 6264 | const GLfloat *value) |
| 6265 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6266 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6267 | program->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6268 | } |
| 6269 | |
| 6270 | void Context::uniformMatrix4x2fv(GLint location, |
| 6271 | GLsizei count, |
| 6272 | GLboolean transpose, |
| 6273 | const GLfloat *value) |
| 6274 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6275 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6276 | program->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6277 | } |
| 6278 | |
| 6279 | void Context::uniformMatrix3x4fv(GLint location, |
| 6280 | GLsizei count, |
| 6281 | GLboolean transpose, |
| 6282 | const GLfloat *value) |
| 6283 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6284 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6285 | program->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6286 | } |
| 6287 | |
| 6288 | void Context::uniformMatrix4x3fv(GLint location, |
| 6289 | GLsizei count, |
| 6290 | GLboolean transpose, |
| 6291 | const GLfloat *value) |
| 6292 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6293 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6294 | program->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6295 | } |
| 6296 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 6297 | void Context::deleteVertexArrays(GLsizei n, const GLuint *arrays) |
| 6298 | { |
| 6299 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6300 | { |
| 6301 | GLuint vertexArray = arrays[arrayIndex]; |
| 6302 | |
| 6303 | if (arrays[arrayIndex] != 0) |
| 6304 | { |
| 6305 | VertexArray *vertexArrayObject = nullptr; |
| 6306 | if (mVertexArrayMap.erase(vertexArray, &vertexArrayObject)) |
| 6307 | { |
| 6308 | if (vertexArrayObject != nullptr) |
| 6309 | { |
| 6310 | detachVertexArray(vertexArray); |
| 6311 | vertexArrayObject->onDestroy(this); |
| 6312 | } |
| 6313 | |
| 6314 | mVertexArrayHandleAllocator.release(vertexArray); |
| 6315 | } |
| 6316 | } |
| 6317 | } |
| 6318 | } |
| 6319 | |
| 6320 | void Context::genVertexArrays(GLsizei n, GLuint *arrays) |
| 6321 | { |
| 6322 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6323 | { |
| 6324 | GLuint vertexArray = mVertexArrayHandleAllocator.allocate(); |
| 6325 | mVertexArrayMap.assign(vertexArray, nullptr); |
| 6326 | arrays[arrayIndex] = vertexArray; |
| 6327 | } |
| 6328 | } |
| 6329 | |
| 6330 | bool Context::isVertexArray(GLuint array) |
| 6331 | { |
| 6332 | if (array == 0) |
| 6333 | { |
| 6334 | return GL_FALSE; |
| 6335 | } |
| 6336 | |
| 6337 | VertexArray *vao = getVertexArray(array); |
| 6338 | return (vao != nullptr ? GL_TRUE : GL_FALSE); |
| 6339 | } |
| 6340 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6341 | void Context::endTransformFeedback() |
| 6342 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6343 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6344 | ANGLE_CONTEXT_TRY(transformFeedback->end(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6345 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6346 | } |
| 6347 | |
| 6348 | void Context::transformFeedbackVaryings(GLuint program, |
| 6349 | GLsizei count, |
| 6350 | const GLchar *const *varyings, |
| 6351 | GLenum bufferMode) |
| 6352 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6353 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6354 | ASSERT(programObject); |
| 6355 | programObject->setTransformFeedbackVaryings(count, varyings, bufferMode); |
| 6356 | } |
| 6357 | |
| 6358 | void Context::getTransformFeedbackVarying(GLuint program, |
| 6359 | GLuint index, |
| 6360 | GLsizei bufSize, |
| 6361 | GLsizei *length, |
| 6362 | GLsizei *size, |
| 6363 | GLenum *type, |
| 6364 | GLchar *name) |
| 6365 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6366 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6367 | ASSERT(programObject); |
| 6368 | programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name); |
| 6369 | } |
| 6370 | |
| 6371 | void Context::deleteTransformFeedbacks(GLsizei n, const GLuint *ids) |
| 6372 | { |
| 6373 | for (int i = 0; i < n; i++) |
| 6374 | { |
| 6375 | GLuint transformFeedback = ids[i]; |
| 6376 | if (transformFeedback == 0) |
| 6377 | { |
| 6378 | continue; |
| 6379 | } |
| 6380 | |
| 6381 | TransformFeedback *transformFeedbackObject = nullptr; |
| 6382 | if (mTransformFeedbackMap.erase(transformFeedback, &transformFeedbackObject)) |
| 6383 | { |
| 6384 | if (transformFeedbackObject != nullptr) |
| 6385 | { |
| 6386 | detachTransformFeedback(transformFeedback); |
| 6387 | transformFeedbackObject->release(this); |
| 6388 | } |
| 6389 | |
| 6390 | mTransformFeedbackHandleAllocator.release(transformFeedback); |
| 6391 | } |
| 6392 | } |
| 6393 | } |
| 6394 | |
| 6395 | void Context::genTransformFeedbacks(GLsizei n, GLuint *ids) |
| 6396 | { |
| 6397 | for (int i = 0; i < n; i++) |
| 6398 | { |
| 6399 | GLuint transformFeedback = mTransformFeedbackHandleAllocator.allocate(); |
| 6400 | mTransformFeedbackMap.assign(transformFeedback, nullptr); |
| 6401 | ids[i] = transformFeedback; |
| 6402 | } |
| 6403 | } |
| 6404 | |
| 6405 | bool Context::isTransformFeedback(GLuint id) |
| 6406 | { |
| 6407 | if (id == 0) |
| 6408 | { |
| 6409 | // The 3.0.4 spec [section 6.1.11] states that if ID is zero, IsTransformFeedback |
| 6410 | // returns FALSE |
| 6411 | return GL_FALSE; |
| 6412 | } |
| 6413 | |
| 6414 | const TransformFeedback *transformFeedback = getTransformFeedback(id); |
| 6415 | return ((transformFeedback != nullptr) ? GL_TRUE : GL_FALSE); |
| 6416 | } |
| 6417 | |
| 6418 | void Context::pauseTransformFeedback() |
| 6419 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6420 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6421 | ANGLE_CONTEXT_TRY(transformFeedback->pause(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6422 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6423 | } |
| 6424 | |
| 6425 | void Context::resumeTransformFeedback() |
| 6426 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6427 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6428 | ANGLE_CONTEXT_TRY(transformFeedback->resume(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6429 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6430 | } |
| 6431 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6432 | void Context::getUniformuiv(GLuint program, GLint location, GLuint *params) |
| 6433 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6434 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 6435 | programObject->getUniformuiv(this, location, params); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6436 | } |
| 6437 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6438 | void Context::getUniformuivRobust(GLuint program, |
| 6439 | GLint location, |
| 6440 | GLsizei bufSize, |
| 6441 | GLsizei *length, |
| 6442 | GLuint *params) |
| 6443 | { |
| 6444 | getUniformuiv(program, location, params); |
| 6445 | } |
| 6446 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6447 | GLint Context::getFragDataLocation(GLuint program, const GLchar *name) |
| 6448 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6449 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6450 | return programObject->getFragDataLocation(name); |
| 6451 | } |
| 6452 | |
| 6453 | void Context::getUniformIndices(GLuint program, |
| 6454 | GLsizei uniformCount, |
| 6455 | const GLchar *const *uniformNames, |
| 6456 | GLuint *uniformIndices) |
| 6457 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6458 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6459 | if (!programObject->isLinked()) |
| 6460 | { |
| 6461 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6462 | { |
| 6463 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 6464 | } |
| 6465 | } |
| 6466 | else |
| 6467 | { |
| 6468 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6469 | { |
| 6470 | uniformIndices[uniformId] = programObject->getUniformIndex(uniformNames[uniformId]); |
| 6471 | } |
| 6472 | } |
| 6473 | } |
| 6474 | |
| 6475 | void Context::getActiveUniformsiv(GLuint program, |
| 6476 | GLsizei uniformCount, |
| 6477 | const GLuint *uniformIndices, |
| 6478 | GLenum pname, |
| 6479 | GLint *params) |
| 6480 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6481 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6482 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6483 | { |
| 6484 | const GLuint index = uniformIndices[uniformId]; |
jchen10 | baf5d94 | 2017-08-28 20:45:48 +0800 | [diff] [blame] | 6485 | params[uniformId] = GetUniformResourceProperty(programObject, index, pname); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6486 | } |
| 6487 | } |
| 6488 | |
| 6489 | GLuint Context::getUniformBlockIndex(GLuint program, const GLchar *uniformBlockName) |
| 6490 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6491 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6492 | return programObject->getUniformBlockIndex(uniformBlockName); |
| 6493 | } |
| 6494 | |
| 6495 | void Context::getActiveUniformBlockiv(GLuint program, |
| 6496 | GLuint uniformBlockIndex, |
| 6497 | GLenum pname, |
| 6498 | GLint *params) |
| 6499 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6500 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6501 | QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params); |
| 6502 | } |
| 6503 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6504 | void Context::getActiveUniformBlockivRobust(GLuint program, |
| 6505 | GLuint uniformBlockIndex, |
| 6506 | GLenum pname, |
| 6507 | GLsizei bufSize, |
| 6508 | GLsizei *length, |
| 6509 | GLint *params) |
| 6510 | { |
| 6511 | getActiveUniformBlockiv(program, uniformBlockIndex, pname, params); |
| 6512 | } |
| 6513 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6514 | void Context::getActiveUniformBlockName(GLuint program, |
| 6515 | GLuint uniformBlockIndex, |
| 6516 | GLsizei bufSize, |
| 6517 | GLsizei *length, |
| 6518 | GLchar *uniformBlockName) |
| 6519 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6520 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6521 | programObject->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 6522 | } |
| 6523 | |
| 6524 | void Context::uniformBlockBinding(GLuint program, |
| 6525 | GLuint uniformBlockIndex, |
| 6526 | GLuint uniformBlockBinding) |
| 6527 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6528 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6529 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6530 | |
Jamie Madill | 956ab4d | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 6531 | // Note: If the Program is shared between Contexts we would be better using Observer/Subject. |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6532 | if (programObject->isInUse()) |
| 6533 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6534 | mState.setObjectDirty(GL_PROGRAM); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 6535 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6536 | } |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6537 | } |
| 6538 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6539 | GLsync Context::fenceSync(GLenum condition, GLbitfield flags) |
| 6540 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6541 | GLuint handle = mState.mSyncManager->createSync(mImplementation.get()); |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6542 | GLsync syncHandle = reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6543 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6544 | Sync *syncObject = getSync(syncHandle); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 6545 | if (syncObject->set(this, condition, flags) == angle::Result::Stop) |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6546 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6547 | deleteSync(syncHandle); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6548 | return nullptr; |
| 6549 | } |
| 6550 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6551 | return syncHandle; |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6552 | } |
| 6553 | |
| 6554 | GLboolean Context::isSync(GLsync sync) |
| 6555 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6556 | return (getSync(sync) != nullptr); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6557 | } |
| 6558 | |
| 6559 | GLenum Context::clientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6560 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6561 | Sync *syncObject = getSync(sync); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6562 | |
| 6563 | GLenum result = GL_WAIT_FAILED; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 6564 | if (syncObject->clientWait(this, flags, timeout, &result) == angle::Result::Stop) |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6565 | { |
| 6566 | return GL_WAIT_FAILED; |
| 6567 | } |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6568 | return result; |
| 6569 | } |
| 6570 | |
| 6571 | void Context::waitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6572 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6573 | Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6574 | ANGLE_CONTEXT_TRY(syncObject->serverWait(this, flags, timeout)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6575 | } |
| 6576 | |
| 6577 | void Context::getInteger64v(GLenum pname, GLint64 *params) |
| 6578 | { |
| 6579 | GLenum nativeType = GL_NONE; |
| 6580 | unsigned int numParams = 0; |
| 6581 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 6582 | |
| 6583 | if (nativeType == GL_INT_64_ANGLEX) |
| 6584 | { |
| 6585 | getInteger64vImpl(pname, params); |
| 6586 | } |
| 6587 | else |
| 6588 | { |
| 6589 | CastStateValues(this, nativeType, pname, numParams, params); |
| 6590 | } |
| 6591 | } |
| 6592 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6593 | void Context::getInteger64vRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint64 *data) |
| 6594 | { |
| 6595 | getInteger64v(pname, data); |
| 6596 | } |
| 6597 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 6598 | void Context::getBufferParameteri64v(BufferBinding target, GLenum pname, GLint64 *params) |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6599 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6600 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6601 | QueryBufferParameteri64v(buffer, pname, params); |
| 6602 | } |
| 6603 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6604 | void Context::getBufferParameteri64vRobust(BufferBinding target, |
| 6605 | GLenum pname, |
| 6606 | GLsizei bufSize, |
| 6607 | GLsizei *length, |
| 6608 | GLint64 *params) |
| 6609 | { |
| 6610 | getBufferParameteri64v(target, pname, params); |
| 6611 | } |
| 6612 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6613 | void Context::genSamplers(GLsizei count, GLuint *samplers) |
| 6614 | { |
| 6615 | for (int i = 0; i < count; i++) |
| 6616 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6617 | samplers[i] = mState.mSamplerManager->createSampler(); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6618 | } |
| 6619 | } |
| 6620 | |
| 6621 | void Context::deleteSamplers(GLsizei count, const GLuint *samplers) |
| 6622 | { |
| 6623 | for (int i = 0; i < count; i++) |
| 6624 | { |
| 6625 | GLuint sampler = samplers[i]; |
| 6626 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6627 | if (mState.mSamplerManager->getSampler(sampler)) |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6628 | { |
| 6629 | detachSampler(sampler); |
| 6630 | } |
| 6631 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6632 | mState.mSamplerManager->deleteObject(this, sampler); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6633 | } |
| 6634 | } |
| 6635 | |
| 6636 | void Context::getInternalformativ(GLenum target, |
| 6637 | GLenum internalformat, |
| 6638 | GLenum pname, |
| 6639 | GLsizei bufSize, |
| 6640 | GLint *params) |
| 6641 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6642 | const TextureCaps &formatCaps = mState.mTextureCaps.get(internalformat); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6643 | QueryInternalFormativ(formatCaps, pname, bufSize, params); |
| 6644 | } |
| 6645 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6646 | void Context::getInternalformativRobust(GLenum target, |
| 6647 | GLenum internalformat, |
| 6648 | GLenum pname, |
| 6649 | GLsizei bufSize, |
| 6650 | GLsizei *length, |
| 6651 | GLint *params) |
| 6652 | { |
| 6653 | getInternalformativ(target, internalformat, pname, bufSize, params); |
| 6654 | } |
| 6655 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6656 | void Context::programUniform1i(GLuint program, GLint location, GLint v0) |
| 6657 | { |
| 6658 | programUniform1iv(program, location, 1, &v0); |
| 6659 | } |
| 6660 | |
| 6661 | void Context::programUniform2i(GLuint program, GLint location, GLint v0, GLint v1) |
| 6662 | { |
| 6663 | GLint xy[2] = {v0, v1}; |
| 6664 | programUniform2iv(program, location, 1, xy); |
| 6665 | } |
| 6666 | |
| 6667 | void Context::programUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2) |
| 6668 | { |
| 6669 | GLint xyz[3] = {v0, v1, v2}; |
| 6670 | programUniform3iv(program, location, 1, xyz); |
| 6671 | } |
| 6672 | |
| 6673 | void Context::programUniform4i(GLuint program, |
| 6674 | GLint location, |
| 6675 | GLint v0, |
| 6676 | GLint v1, |
| 6677 | GLint v2, |
| 6678 | GLint v3) |
| 6679 | { |
| 6680 | GLint xyzw[4] = {v0, v1, v2, v3}; |
| 6681 | programUniform4iv(program, location, 1, xyzw); |
| 6682 | } |
| 6683 | |
| 6684 | void Context::programUniform1ui(GLuint program, GLint location, GLuint v0) |
| 6685 | { |
| 6686 | programUniform1uiv(program, location, 1, &v0); |
| 6687 | } |
| 6688 | |
| 6689 | void Context::programUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1) |
| 6690 | { |
| 6691 | GLuint xy[2] = {v0, v1}; |
| 6692 | programUniform2uiv(program, location, 1, xy); |
| 6693 | } |
| 6694 | |
| 6695 | void Context::programUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6696 | { |
| 6697 | GLuint xyz[3] = {v0, v1, v2}; |
| 6698 | programUniform3uiv(program, location, 1, xyz); |
| 6699 | } |
| 6700 | |
| 6701 | void Context::programUniform4ui(GLuint program, |
| 6702 | GLint location, |
| 6703 | GLuint v0, |
| 6704 | GLuint v1, |
| 6705 | GLuint v2, |
| 6706 | GLuint v3) |
| 6707 | { |
| 6708 | GLuint xyzw[4] = {v0, v1, v2, v3}; |
| 6709 | programUniform4uiv(program, location, 1, xyzw); |
| 6710 | } |
| 6711 | |
| 6712 | void Context::programUniform1f(GLuint program, GLint location, GLfloat v0) |
| 6713 | { |
| 6714 | programUniform1fv(program, location, 1, &v0); |
| 6715 | } |
| 6716 | |
| 6717 | void Context::programUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1) |
| 6718 | { |
| 6719 | GLfloat xy[2] = {v0, v1}; |
| 6720 | programUniform2fv(program, location, 1, xy); |
| 6721 | } |
| 6722 | |
| 6723 | void Context::programUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) |
| 6724 | { |
| 6725 | GLfloat xyz[3] = {v0, v1, v2}; |
| 6726 | programUniform3fv(program, location, 1, xyz); |
| 6727 | } |
| 6728 | |
| 6729 | void Context::programUniform4f(GLuint program, |
| 6730 | GLint location, |
| 6731 | GLfloat v0, |
| 6732 | GLfloat v1, |
| 6733 | GLfloat v2, |
| 6734 | GLfloat v3) |
| 6735 | { |
| 6736 | GLfloat xyzw[4] = {v0, v1, v2, v3}; |
| 6737 | programUniform4fv(program, location, 1, xyzw); |
| 6738 | } |
| 6739 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6740 | void Context::programUniform1iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6741 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6742 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6743 | ASSERT(programObject); |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6744 | setUniform1iImpl(programObject, location, count, value); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6745 | } |
| 6746 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6747 | void Context::programUniform2iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6748 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6749 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6750 | ASSERT(programObject); |
| 6751 | programObject->setUniform2iv(location, count, value); |
| 6752 | } |
| 6753 | |
| 6754 | void Context::programUniform3iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6755 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6756 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6757 | ASSERT(programObject); |
| 6758 | programObject->setUniform3iv(location, count, value); |
| 6759 | } |
| 6760 | |
| 6761 | void Context::programUniform4iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6762 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6763 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6764 | ASSERT(programObject); |
| 6765 | programObject->setUniform4iv(location, count, value); |
| 6766 | } |
| 6767 | |
| 6768 | void Context::programUniform1uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6769 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6770 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6771 | ASSERT(programObject); |
| 6772 | programObject->setUniform1uiv(location, count, value); |
| 6773 | } |
| 6774 | |
| 6775 | void Context::programUniform2uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6776 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6777 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6778 | ASSERT(programObject); |
| 6779 | programObject->setUniform2uiv(location, count, value); |
| 6780 | } |
| 6781 | |
| 6782 | void Context::programUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6783 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6784 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6785 | ASSERT(programObject); |
| 6786 | programObject->setUniform3uiv(location, count, value); |
| 6787 | } |
| 6788 | |
| 6789 | void Context::programUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6790 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6791 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6792 | ASSERT(programObject); |
| 6793 | programObject->setUniform4uiv(location, count, value); |
| 6794 | } |
| 6795 | |
| 6796 | void Context::programUniform1fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6797 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6798 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6799 | ASSERT(programObject); |
| 6800 | programObject->setUniform1fv(location, count, value); |
| 6801 | } |
| 6802 | |
| 6803 | void Context::programUniform2fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6804 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6805 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6806 | ASSERT(programObject); |
| 6807 | programObject->setUniform2fv(location, count, value); |
| 6808 | } |
| 6809 | |
| 6810 | void Context::programUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6811 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6812 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6813 | ASSERT(programObject); |
| 6814 | programObject->setUniform3fv(location, count, value); |
| 6815 | } |
| 6816 | |
| 6817 | void Context::programUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6818 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6819 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6820 | ASSERT(programObject); |
| 6821 | programObject->setUniform4fv(location, count, value); |
| 6822 | } |
| 6823 | |
| 6824 | void Context::programUniformMatrix2fv(GLuint program, |
| 6825 | GLint location, |
| 6826 | GLsizei count, |
| 6827 | GLboolean transpose, |
| 6828 | const GLfloat *value) |
| 6829 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6830 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6831 | ASSERT(programObject); |
| 6832 | programObject->setUniformMatrix2fv(location, count, transpose, value); |
| 6833 | } |
| 6834 | |
| 6835 | void Context::programUniformMatrix3fv(GLuint program, |
| 6836 | GLint location, |
| 6837 | GLsizei count, |
| 6838 | GLboolean transpose, |
| 6839 | const GLfloat *value) |
| 6840 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6841 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6842 | ASSERT(programObject); |
| 6843 | programObject->setUniformMatrix3fv(location, count, transpose, value); |
| 6844 | } |
| 6845 | |
| 6846 | void Context::programUniformMatrix4fv(GLuint program, |
| 6847 | GLint location, |
| 6848 | GLsizei count, |
| 6849 | GLboolean transpose, |
| 6850 | const GLfloat *value) |
| 6851 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6852 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6853 | ASSERT(programObject); |
| 6854 | programObject->setUniformMatrix4fv(location, count, transpose, value); |
| 6855 | } |
| 6856 | |
| 6857 | void Context::programUniformMatrix2x3fv(GLuint program, |
| 6858 | GLint location, |
| 6859 | GLsizei count, |
| 6860 | GLboolean transpose, |
| 6861 | const GLfloat *value) |
| 6862 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6863 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6864 | ASSERT(programObject); |
| 6865 | programObject->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6866 | } |
| 6867 | |
| 6868 | void Context::programUniformMatrix3x2fv(GLuint program, |
| 6869 | GLint location, |
| 6870 | GLsizei count, |
| 6871 | GLboolean transpose, |
| 6872 | const GLfloat *value) |
| 6873 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6874 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6875 | ASSERT(programObject); |
| 6876 | programObject->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6877 | } |
| 6878 | |
| 6879 | void Context::programUniformMatrix2x4fv(GLuint program, |
| 6880 | GLint location, |
| 6881 | GLsizei count, |
| 6882 | GLboolean transpose, |
| 6883 | const GLfloat *value) |
| 6884 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6885 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6886 | ASSERT(programObject); |
| 6887 | programObject->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6888 | } |
| 6889 | |
| 6890 | void Context::programUniformMatrix4x2fv(GLuint program, |
| 6891 | GLint location, |
| 6892 | GLsizei count, |
| 6893 | GLboolean transpose, |
| 6894 | const GLfloat *value) |
| 6895 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6896 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6897 | ASSERT(programObject); |
| 6898 | programObject->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6899 | } |
| 6900 | |
| 6901 | void Context::programUniformMatrix3x4fv(GLuint program, |
| 6902 | GLint location, |
| 6903 | GLsizei count, |
| 6904 | GLboolean transpose, |
| 6905 | const GLfloat *value) |
| 6906 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6907 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6908 | ASSERT(programObject); |
| 6909 | programObject->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6910 | } |
| 6911 | |
| 6912 | void Context::programUniformMatrix4x3fv(GLuint program, |
| 6913 | GLint location, |
| 6914 | GLsizei count, |
| 6915 | GLboolean transpose, |
| 6916 | const GLfloat *value) |
| 6917 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6918 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6919 | ASSERT(programObject); |
| 6920 | programObject->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6921 | } |
| 6922 | |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6923 | bool Context::isCurrentTransformFeedback(const TransformFeedback *tf) const |
| 6924 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6925 | return mState.isCurrentTransformFeedback(tf); |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6926 | } |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6927 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 6928 | void Context::genProgramPipelines(GLsizei count, GLuint *pipelines) |
| 6929 | { |
| 6930 | for (int i = 0; i < count; i++) |
| 6931 | { |
| 6932 | pipelines[i] = createProgramPipeline(); |
| 6933 | } |
| 6934 | } |
| 6935 | |
| 6936 | void Context::deleteProgramPipelines(GLsizei count, const GLuint *pipelines) |
| 6937 | { |
| 6938 | for (int i = 0; i < count; i++) |
| 6939 | { |
| 6940 | if (pipelines[i] != 0) |
| 6941 | { |
| 6942 | deleteProgramPipeline(pipelines[i]); |
| 6943 | } |
| 6944 | } |
| 6945 | } |
| 6946 | |
| 6947 | GLboolean Context::isProgramPipeline(GLuint pipeline) |
| 6948 | { |
| 6949 | if (pipeline == 0) |
| 6950 | { |
| 6951 | return GL_FALSE; |
| 6952 | } |
| 6953 | |
| 6954 | return (getProgramPipeline(pipeline) ? GL_TRUE : GL_FALSE); |
| 6955 | } |
| 6956 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6957 | void Context::finishFenceNV(GLuint fence) |
| 6958 | { |
| 6959 | FenceNV *fenceObject = getFenceNV(fence); |
| 6960 | |
| 6961 | ASSERT(fenceObject && fenceObject->isSet()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6962 | ANGLE_CONTEXT_TRY(fenceObject->finish(this)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6963 | } |
| 6964 | |
| 6965 | void Context::getFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 6966 | { |
| 6967 | FenceNV *fenceObject = getFenceNV(fence); |
| 6968 | |
| 6969 | ASSERT(fenceObject && fenceObject->isSet()); |
| 6970 | |
| 6971 | switch (pname) |
| 6972 | { |
| 6973 | case GL_FENCE_STATUS_NV: |
| 6974 | { |
| 6975 | // GL_NV_fence spec: |
| 6976 | // Once the status of a fence has been finished (via FinishFenceNV) or tested and |
| 6977 | // the returned status is TRUE (via either TestFenceNV or GetFenceivNV querying the |
| 6978 | // FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence. |
| 6979 | GLboolean status = GL_TRUE; |
| 6980 | if (fenceObject->getStatus() != GL_TRUE) |
| 6981 | { |
Jamie Madill | a0691b7 | 2018-07-25 10:41:22 -0400 | [diff] [blame] | 6982 | ANGLE_CONTEXT_TRY(fenceObject->test(this, &status)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6983 | } |
| 6984 | *params = status; |
| 6985 | break; |
| 6986 | } |
| 6987 | |
| 6988 | case GL_FENCE_CONDITION_NV: |
| 6989 | { |
| 6990 | *params = static_cast<GLint>(fenceObject->getCondition()); |
| 6991 | break; |
| 6992 | } |
| 6993 | |
| 6994 | default: |
| 6995 | UNREACHABLE(); |
| 6996 | } |
| 6997 | } |
| 6998 | |
| 6999 | void Context::getTranslatedShaderSource(GLuint shader, |
| 7000 | GLsizei bufsize, |
| 7001 | GLsizei *length, |
| 7002 | GLchar *source) |
| 7003 | { |
| 7004 | Shader *shaderObject = getShader(shader); |
| 7005 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 7006 | shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7007 | } |
| 7008 | |
| 7009 | void Context::getnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params) |
| 7010 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7011 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7012 | ASSERT(programObject); |
| 7013 | |
| 7014 | programObject->getUniformfv(this, location, params); |
| 7015 | } |
| 7016 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7017 | void Context::getnUniformfvRobust(GLuint program, |
| 7018 | GLint location, |
| 7019 | GLsizei bufSize, |
| 7020 | GLsizei *length, |
| 7021 | GLfloat *params) |
| 7022 | { |
| 7023 | UNIMPLEMENTED(); |
| 7024 | } |
| 7025 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7026 | void Context::getnUniformiv(GLuint program, GLint location, GLsizei bufSize, GLint *params) |
| 7027 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7028 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7029 | ASSERT(programObject); |
| 7030 | |
| 7031 | programObject->getUniformiv(this, location, params); |
| 7032 | } |
| 7033 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7034 | void Context::getnUniformivRobust(GLuint program, |
| 7035 | GLint location, |
| 7036 | GLsizei bufSize, |
| 7037 | GLsizei *length, |
| 7038 | GLint *params) |
| 7039 | { |
| 7040 | UNIMPLEMENTED(); |
| 7041 | } |
| 7042 | |
| 7043 | void Context::getnUniformuivRobust(GLuint program, |
| 7044 | GLint location, |
| 7045 | GLsizei bufSize, |
| 7046 | GLsizei *length, |
| 7047 | GLuint *params) |
| 7048 | { |
| 7049 | UNIMPLEMENTED(); |
| 7050 | } |
| 7051 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7052 | GLboolean Context::isFenceNV(GLuint fence) |
| 7053 | { |
| 7054 | FenceNV *fenceObject = getFenceNV(fence); |
| 7055 | |
| 7056 | if (fenceObject == nullptr) |
| 7057 | { |
| 7058 | return GL_FALSE; |
| 7059 | } |
| 7060 | |
| 7061 | // GL_NV_fence spec: |
| 7062 | // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an |
| 7063 | // existing fence. |
| 7064 | return fenceObject->isSet(); |
| 7065 | } |
| 7066 | |
| 7067 | void Context::readnPixels(GLint x, |
| 7068 | GLint y, |
| 7069 | GLsizei width, |
| 7070 | GLsizei height, |
| 7071 | GLenum format, |
| 7072 | GLenum type, |
| 7073 | GLsizei bufSize, |
| 7074 | void *data) |
| 7075 | { |
| 7076 | return readPixels(x, y, width, height, format, type, data); |
| 7077 | } |
| 7078 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7079 | void Context::setFenceNV(GLuint fence, GLenum condition) |
| 7080 | { |
| 7081 | ASSERT(condition == GL_ALL_COMPLETED_NV); |
| 7082 | |
| 7083 | FenceNV *fenceObject = getFenceNV(fence); |
| 7084 | ASSERT(fenceObject != nullptr); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7085 | ANGLE_CONTEXT_TRY(fenceObject->set(this, condition)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7086 | } |
| 7087 | |
| 7088 | GLboolean Context::testFenceNV(GLuint fence) |
| 7089 | { |
| 7090 | FenceNV *fenceObject = getFenceNV(fence); |
| 7091 | |
| 7092 | ASSERT(fenceObject != nullptr); |
| 7093 | ASSERT(fenceObject->isSet() == GL_TRUE); |
| 7094 | |
| 7095 | GLboolean result = GL_TRUE; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 7096 | if (fenceObject->test(this, &result) == angle::Result::Stop) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7097 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7098 | return GL_TRUE; |
| 7099 | } |
| 7100 | |
| 7101 | return result; |
| 7102 | } |
| 7103 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 7104 | void Context::eGLImageTargetTexture2D(TextureType target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7105 | { |
| 7106 | Texture *texture = getTargetTexture(target); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7107 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7108 | ANGLE_CONTEXT_TRY(texture->setEGLImageTarget(this, target, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7109 | } |
| 7110 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7111 | void Context::eGLImageTargetRenderbufferStorage(GLenum target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7112 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7113 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7114 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7115 | ANGLE_CONTEXT_TRY(renderbuffer->setStorageEGLImageTarget(this, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7116 | } |
| 7117 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7118 | void Context::texStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width) |
| 7119 | { |
| 7120 | UNIMPLEMENTED(); |
| 7121 | } |
| 7122 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7123 | bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) |
| 7124 | { |
| 7125 | // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation |
| 7126 | // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due |
| 7127 | // to the fact that it is stored internally as a float, and so would require conversion |
| 7128 | // if returned from Context::getIntegerv. Since this conversion is already implemented |
| 7129 | // in the case that one calls glGetIntegerv to retrieve a float-typed state variable, we |
| 7130 | // place DEPTH_CLEAR_VALUE with the floats. This should make no difference to the calling |
| 7131 | // application. |
| 7132 | switch (pname) |
| 7133 | { |
| 7134 | case GL_COMPRESSED_TEXTURE_FORMATS: |
| 7135 | { |
| 7136 | *type = GL_INT; |
| 7137 | *numParams = static_cast<unsigned int>(getCaps().compressedTextureFormats.size()); |
| 7138 | return true; |
| 7139 | } |
| 7140 | case GL_SHADER_BINARY_FORMATS: |
| 7141 | { |
| 7142 | *type = GL_INT; |
| 7143 | *numParams = static_cast<unsigned int>(getCaps().shaderBinaryFormats.size()); |
| 7144 | return true; |
| 7145 | } |
| 7146 | |
| 7147 | case GL_MAX_VERTEX_ATTRIBS: |
| 7148 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 7149 | case GL_MAX_VARYING_VECTORS: |
| 7150 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 7151 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 7152 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
| 7153 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 7154 | case GL_MAX_RENDERBUFFER_SIZE: |
| 7155 | case GL_NUM_SHADER_BINARY_FORMATS: |
| 7156 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 7157 | case GL_ARRAY_BUFFER_BINDING: |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7158 | case GL_FRAMEBUFFER_BINDING: // GL_FRAMEBUFFER_BINDING now equivalent to |
| 7159 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7160 | case GL_RENDERBUFFER_BINDING: |
| 7161 | case GL_CURRENT_PROGRAM: |
| 7162 | case GL_PACK_ALIGNMENT: |
| 7163 | case GL_UNPACK_ALIGNMENT: |
| 7164 | case GL_GENERATE_MIPMAP_HINT: |
| 7165 | case GL_RED_BITS: |
| 7166 | case GL_GREEN_BITS: |
| 7167 | case GL_BLUE_BITS: |
| 7168 | case GL_ALPHA_BITS: |
| 7169 | case GL_DEPTH_BITS: |
| 7170 | case GL_STENCIL_BITS: |
| 7171 | case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 7172 | case GL_CULL_FACE_MODE: |
| 7173 | case GL_FRONT_FACE: |
| 7174 | case GL_ACTIVE_TEXTURE: |
| 7175 | case GL_STENCIL_FUNC: |
| 7176 | case GL_STENCIL_VALUE_MASK: |
| 7177 | case GL_STENCIL_REF: |
| 7178 | case GL_STENCIL_FAIL: |
| 7179 | case GL_STENCIL_PASS_DEPTH_FAIL: |
| 7180 | case GL_STENCIL_PASS_DEPTH_PASS: |
| 7181 | case GL_STENCIL_BACK_FUNC: |
| 7182 | case GL_STENCIL_BACK_VALUE_MASK: |
| 7183 | case GL_STENCIL_BACK_REF: |
| 7184 | case GL_STENCIL_BACK_FAIL: |
| 7185 | case GL_STENCIL_BACK_PASS_DEPTH_FAIL: |
| 7186 | case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
| 7187 | case GL_DEPTH_FUNC: |
| 7188 | case GL_BLEND_SRC_RGB: |
| 7189 | case GL_BLEND_SRC_ALPHA: |
| 7190 | case GL_BLEND_DST_RGB: |
| 7191 | case GL_BLEND_DST_ALPHA: |
| 7192 | case GL_BLEND_EQUATION_RGB: |
| 7193 | case GL_BLEND_EQUATION_ALPHA: |
| 7194 | case GL_STENCIL_WRITEMASK: |
| 7195 | case GL_STENCIL_BACK_WRITEMASK: |
| 7196 | case GL_STENCIL_CLEAR_VALUE: |
| 7197 | case GL_SUBPIXEL_BITS: |
| 7198 | case GL_MAX_TEXTURE_SIZE: |
| 7199 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 7200 | case GL_SAMPLE_BUFFERS: |
| 7201 | case GL_SAMPLES: |
| 7202 | case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 7203 | case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 7204 | case GL_TEXTURE_BINDING_2D: |
| 7205 | case GL_TEXTURE_BINDING_CUBE_MAP: |
| 7206 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 7207 | { |
| 7208 | *type = GL_INT; |
| 7209 | *numParams = 1; |
| 7210 | return true; |
| 7211 | } |
| 7212 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 7213 | { |
| 7214 | if (!getExtensions().packReverseRowOrder) |
| 7215 | { |
| 7216 | return false; |
| 7217 | } |
| 7218 | *type = GL_INT; |
| 7219 | *numParams = 1; |
| 7220 | return true; |
| 7221 | } |
| 7222 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
| 7223 | case GL_TEXTURE_BINDING_RECTANGLE_ANGLE: |
| 7224 | { |
| 7225 | if (!getExtensions().textureRectangle) |
| 7226 | { |
| 7227 | return false; |
| 7228 | } |
| 7229 | *type = GL_INT; |
| 7230 | *numParams = 1; |
| 7231 | return true; |
| 7232 | } |
| 7233 | case GL_MAX_DRAW_BUFFERS_EXT: |
| 7234 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
| 7235 | { |
| 7236 | if ((getClientMajorVersion() < 3) && !getExtensions().drawBuffers) |
| 7237 | { |
| 7238 | return false; |
| 7239 | } |
| 7240 | *type = GL_INT; |
| 7241 | *numParams = 1; |
| 7242 | return true; |
| 7243 | } |
| 7244 | case GL_MAX_VIEWPORT_DIMS: |
| 7245 | { |
| 7246 | *type = GL_INT; |
| 7247 | *numParams = 2; |
| 7248 | return true; |
| 7249 | } |
| 7250 | case GL_VIEWPORT: |
| 7251 | case GL_SCISSOR_BOX: |
| 7252 | { |
| 7253 | *type = GL_INT; |
| 7254 | *numParams = 4; |
| 7255 | return true; |
| 7256 | } |
| 7257 | case GL_SHADER_COMPILER: |
| 7258 | case GL_SAMPLE_COVERAGE_INVERT: |
| 7259 | case GL_DEPTH_WRITEMASK: |
| 7260 | case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled, |
| 7261 | case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries. |
| 7262 | case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as |
| 7263 | // bool-natural |
| 7264 | case GL_SAMPLE_COVERAGE: |
| 7265 | case GL_SCISSOR_TEST: |
| 7266 | case GL_STENCIL_TEST: |
| 7267 | case GL_DEPTH_TEST: |
| 7268 | case GL_BLEND: |
| 7269 | case GL_DITHER: |
| 7270 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 7271 | { |
| 7272 | *type = GL_BOOL; |
| 7273 | *numParams = 1; |
| 7274 | return true; |
| 7275 | } |
| 7276 | case GL_COLOR_WRITEMASK: |
| 7277 | { |
| 7278 | *type = GL_BOOL; |
| 7279 | *numParams = 4; |
| 7280 | return true; |
| 7281 | } |
| 7282 | case GL_POLYGON_OFFSET_FACTOR: |
| 7283 | case GL_POLYGON_OFFSET_UNITS: |
| 7284 | case GL_SAMPLE_COVERAGE_VALUE: |
| 7285 | case GL_DEPTH_CLEAR_VALUE: |
| 7286 | case GL_LINE_WIDTH: |
| 7287 | { |
| 7288 | *type = GL_FLOAT; |
| 7289 | *numParams = 1; |
| 7290 | return true; |
| 7291 | } |
| 7292 | case GL_ALIASED_LINE_WIDTH_RANGE: |
| 7293 | case GL_ALIASED_POINT_SIZE_RANGE: |
| 7294 | case GL_DEPTH_RANGE: |
| 7295 | { |
| 7296 | *type = GL_FLOAT; |
| 7297 | *numParams = 2; |
| 7298 | return true; |
| 7299 | } |
| 7300 | case GL_COLOR_CLEAR_VALUE: |
| 7301 | case GL_BLEND_COLOR: |
| 7302 | { |
| 7303 | *type = GL_FLOAT; |
| 7304 | *numParams = 4; |
| 7305 | return true; |
| 7306 | } |
| 7307 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7308 | if (!getExtensions().textureFilterAnisotropic) |
| 7309 | { |
| 7310 | return false; |
| 7311 | } |
| 7312 | *type = GL_FLOAT; |
| 7313 | *numParams = 1; |
| 7314 | return true; |
| 7315 | case GL_TIMESTAMP_EXT: |
| 7316 | if (!getExtensions().disjointTimerQuery) |
| 7317 | { |
| 7318 | return false; |
| 7319 | } |
| 7320 | *type = GL_INT_64_ANGLEX; |
| 7321 | *numParams = 1; |
| 7322 | return true; |
| 7323 | case GL_GPU_DISJOINT_EXT: |
| 7324 | if (!getExtensions().disjointTimerQuery) |
| 7325 | { |
| 7326 | return false; |
| 7327 | } |
| 7328 | *type = GL_INT; |
| 7329 | *numParams = 1; |
| 7330 | return true; |
| 7331 | case GL_COVERAGE_MODULATION_CHROMIUM: |
| 7332 | if (!getExtensions().framebufferMixedSamples) |
| 7333 | { |
| 7334 | return false; |
| 7335 | } |
| 7336 | *type = GL_INT; |
| 7337 | *numParams = 1; |
| 7338 | return true; |
| 7339 | case GL_TEXTURE_BINDING_EXTERNAL_OES: |
| 7340 | if (!getExtensions().eglStreamConsumerExternal && !getExtensions().eglImageExternal) |
| 7341 | { |
| 7342 | return false; |
| 7343 | } |
| 7344 | *type = GL_INT; |
| 7345 | *numParams = 1; |
| 7346 | return true; |
| 7347 | } |
| 7348 | |
| 7349 | if (getExtensions().debug) |
| 7350 | { |
| 7351 | switch (pname) |
| 7352 | { |
| 7353 | case GL_DEBUG_LOGGED_MESSAGES: |
| 7354 | case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: |
| 7355 | case GL_DEBUG_GROUP_STACK_DEPTH: |
| 7356 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 7357 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 7358 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 7359 | case GL_MAX_LABEL_LENGTH: |
| 7360 | *type = GL_INT; |
| 7361 | *numParams = 1; |
| 7362 | return true; |
| 7363 | |
| 7364 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 7365 | case GL_DEBUG_OUTPUT: |
| 7366 | *type = GL_BOOL; |
| 7367 | *numParams = 1; |
| 7368 | return true; |
| 7369 | } |
| 7370 | } |
| 7371 | |
| 7372 | if (getExtensions().multisampleCompatibility) |
| 7373 | { |
| 7374 | switch (pname) |
| 7375 | { |
| 7376 | case GL_MULTISAMPLE_EXT: |
| 7377 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 7378 | *type = GL_BOOL; |
| 7379 | *numParams = 1; |
| 7380 | return true; |
| 7381 | } |
| 7382 | } |
| 7383 | |
| 7384 | if (getExtensions().pathRendering) |
| 7385 | { |
| 7386 | switch (pname) |
| 7387 | { |
| 7388 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 7389 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 7390 | *type = GL_FLOAT; |
| 7391 | *numParams = 16; |
| 7392 | return true; |
| 7393 | } |
| 7394 | } |
| 7395 | |
| 7396 | if (getExtensions().bindGeneratesResource) |
| 7397 | { |
| 7398 | switch (pname) |
| 7399 | { |
| 7400 | case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 7401 | *type = GL_BOOL; |
| 7402 | *numParams = 1; |
| 7403 | return true; |
| 7404 | } |
| 7405 | } |
| 7406 | |
| 7407 | if (getExtensions().clientArrays) |
| 7408 | { |
| 7409 | switch (pname) |
| 7410 | { |
| 7411 | case GL_CLIENT_ARRAYS_ANGLE: |
| 7412 | *type = GL_BOOL; |
| 7413 | *numParams = 1; |
| 7414 | return true; |
| 7415 | } |
| 7416 | } |
| 7417 | |
| 7418 | if (getExtensions().sRGBWriteControl) |
| 7419 | { |
| 7420 | switch (pname) |
| 7421 | { |
| 7422 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 7423 | *type = GL_BOOL; |
| 7424 | *numParams = 1; |
| 7425 | return true; |
| 7426 | } |
| 7427 | } |
| 7428 | |
| 7429 | if (getExtensions().robustResourceInitialization && |
| 7430 | pname == GL_ROBUST_RESOURCE_INITIALIZATION_ANGLE) |
| 7431 | { |
| 7432 | *type = GL_BOOL; |
| 7433 | *numParams = 1; |
| 7434 | return true; |
| 7435 | } |
| 7436 | |
| 7437 | if (getExtensions().programCacheControl && pname == GL_PROGRAM_CACHE_ENABLED_ANGLE) |
| 7438 | { |
| 7439 | *type = GL_BOOL; |
| 7440 | *numParams = 1; |
| 7441 | return true; |
| 7442 | } |
| 7443 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7444 | if (getExtensions().parallelShaderCompile && pname == GL_MAX_SHADER_COMPILER_THREADS_KHR) |
| 7445 | { |
| 7446 | *type = GL_INT; |
| 7447 | *numParams = 1; |
| 7448 | return true; |
| 7449 | } |
| 7450 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 7451 | if (getExtensions().blendFuncExtended && pname == GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT) |
| 7452 | { |
| 7453 | *type = GL_INT; |
| 7454 | *numParams = 1; |
| 7455 | return true; |
| 7456 | } |
| 7457 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7458 | // Check for ES3.0+ parameter names which are also exposed as ES2 extensions |
| 7459 | switch (pname) |
| 7460 | { |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7461 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE equivalent to FRAMEBUFFER_BINDING |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7462 | case GL_READ_FRAMEBUFFER_BINDING_ANGLE: |
| 7463 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferBlit) |
| 7464 | { |
| 7465 | return false; |
| 7466 | } |
| 7467 | *type = GL_INT; |
| 7468 | *numParams = 1; |
| 7469 | return true; |
| 7470 | |
| 7471 | case GL_NUM_PROGRAM_BINARY_FORMATS_OES: |
| 7472 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7473 | { |
| 7474 | return false; |
| 7475 | } |
| 7476 | *type = GL_INT; |
| 7477 | *numParams = 1; |
| 7478 | return true; |
| 7479 | |
| 7480 | case GL_PROGRAM_BINARY_FORMATS_OES: |
| 7481 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7482 | { |
| 7483 | return false; |
| 7484 | } |
| 7485 | *type = GL_INT; |
| 7486 | *numParams = static_cast<unsigned int>(getCaps().programBinaryFormats.size()); |
| 7487 | return true; |
| 7488 | |
| 7489 | case GL_PACK_ROW_LENGTH: |
| 7490 | case GL_PACK_SKIP_ROWS: |
| 7491 | case GL_PACK_SKIP_PIXELS: |
| 7492 | if ((getClientMajorVersion() < 3) && !getExtensions().packSubimage) |
| 7493 | { |
| 7494 | return false; |
| 7495 | } |
| 7496 | *type = GL_INT; |
| 7497 | *numParams = 1; |
| 7498 | return true; |
| 7499 | case GL_UNPACK_ROW_LENGTH: |
| 7500 | case GL_UNPACK_SKIP_ROWS: |
| 7501 | case GL_UNPACK_SKIP_PIXELS: |
| 7502 | if ((getClientMajorVersion() < 3) && !getExtensions().unpackSubimage) |
| 7503 | { |
| 7504 | return false; |
| 7505 | } |
| 7506 | *type = GL_INT; |
| 7507 | *numParams = 1; |
| 7508 | return true; |
| 7509 | case GL_VERTEX_ARRAY_BINDING: |
| 7510 | if ((getClientMajorVersion() < 3) && !getExtensions().vertexArrayObject) |
| 7511 | { |
| 7512 | return false; |
| 7513 | } |
| 7514 | *type = GL_INT; |
| 7515 | *numParams = 1; |
| 7516 | return true; |
| 7517 | case GL_PIXEL_PACK_BUFFER_BINDING: |
| 7518 | case GL_PIXEL_UNPACK_BUFFER_BINDING: |
| 7519 | if ((getClientMajorVersion() < 3) && !getExtensions().pixelBufferObject) |
| 7520 | { |
| 7521 | return false; |
| 7522 | } |
| 7523 | *type = GL_INT; |
| 7524 | *numParams = 1; |
| 7525 | return true; |
| 7526 | case GL_MAX_SAMPLES: |
| 7527 | { |
| 7528 | static_assert(GL_MAX_SAMPLES_ANGLE == GL_MAX_SAMPLES, |
| 7529 | "GL_MAX_SAMPLES_ANGLE not equal to GL_MAX_SAMPLES"); |
| 7530 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferMultisample) |
| 7531 | { |
| 7532 | return false; |
| 7533 | } |
| 7534 | *type = GL_INT; |
| 7535 | *numParams = 1; |
| 7536 | return true; |
| 7537 | |
| 7538 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: |
| 7539 | if ((getClientMajorVersion() < 3) && !getExtensions().standardDerivatives) |
| 7540 | { |
| 7541 | return false; |
| 7542 | } |
| 7543 | *type = GL_INT; |
| 7544 | *numParams = 1; |
| 7545 | return true; |
| 7546 | } |
| 7547 | } |
| 7548 | |
| 7549 | if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT) |
| 7550 | { |
| 7551 | if ((getClientVersion() < Version(3, 0)) && !getExtensions().drawBuffers) |
| 7552 | { |
| 7553 | return false; |
| 7554 | } |
| 7555 | *type = GL_INT; |
| 7556 | *numParams = 1; |
| 7557 | return true; |
| 7558 | } |
| 7559 | |
| 7560 | if (getExtensions().multiview && pname == GL_MAX_VIEWS_ANGLE) |
| 7561 | { |
| 7562 | *type = GL_INT; |
| 7563 | *numParams = 1; |
| 7564 | return true; |
| 7565 | } |
| 7566 | |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7567 | if (getClientVersion() < Version(2, 0)) |
| 7568 | { |
| 7569 | switch (pname) |
| 7570 | { |
| 7571 | case GL_ALPHA_TEST_FUNC: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7572 | case GL_CLIENT_ACTIVE_TEXTURE: |
| 7573 | case GL_MATRIX_MODE: |
| 7574 | case GL_MAX_TEXTURE_UNITS: |
| 7575 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
| 7576 | case GL_MAX_PROJECTION_STACK_DEPTH: |
| 7577 | case GL_MAX_TEXTURE_STACK_DEPTH: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7578 | case GL_MAX_LIGHTS: |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 7579 | case GL_MAX_CLIP_PLANES: |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 7580 | case GL_VERTEX_ARRAY_STRIDE: |
| 7581 | case GL_NORMAL_ARRAY_STRIDE: |
| 7582 | case GL_COLOR_ARRAY_STRIDE: |
| 7583 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 7584 | case GL_VERTEX_ARRAY_SIZE: |
| 7585 | case GL_COLOR_ARRAY_SIZE: |
| 7586 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 7587 | case GL_VERTEX_ARRAY_TYPE: |
| 7588 | case GL_NORMAL_ARRAY_TYPE: |
| 7589 | case GL_COLOR_ARRAY_TYPE: |
| 7590 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 7591 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 7592 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 7593 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 7594 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 7595 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 7596 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 7597 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
Lingfeng Yang | a0cfa87 | 2018-05-30 21:12:17 -0700 | [diff] [blame] | 7598 | case GL_SHADE_MODEL: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7599 | case GL_MODELVIEW_STACK_DEPTH: |
| 7600 | case GL_PROJECTION_STACK_DEPTH: |
| 7601 | case GL_TEXTURE_STACK_DEPTH: |
| 7602 | case GL_LOGIC_OP_MODE: |
| 7603 | case GL_BLEND_SRC: |
| 7604 | case GL_BLEND_DST: |
| 7605 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 7606 | case GL_POINT_SMOOTH_HINT: |
| 7607 | case GL_LINE_SMOOTH_HINT: |
| 7608 | case GL_FOG_HINT: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7609 | *type = GL_INT; |
| 7610 | *numParams = 1; |
| 7611 | return true; |
| 7612 | case GL_ALPHA_TEST_REF: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7613 | case GL_FOG_DENSITY: |
| 7614 | case GL_FOG_START: |
| 7615 | case GL_FOG_END: |
| 7616 | case GL_FOG_MODE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7617 | case GL_POINT_SIZE: |
| 7618 | case GL_POINT_SIZE_MIN: |
| 7619 | case GL_POINT_SIZE_MAX: |
| 7620 | case GL_POINT_FADE_THRESHOLD_SIZE: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7621 | *type = GL_FLOAT; |
| 7622 | *numParams = 1; |
| 7623 | return true; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7624 | case GL_SMOOTH_POINT_SIZE_RANGE: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7625 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7626 | *type = GL_FLOAT; |
| 7627 | *numParams = 2; |
| 7628 | return true; |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7629 | case GL_CURRENT_COLOR: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7630 | case GL_CURRENT_TEXTURE_COORDS: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7631 | case GL_LIGHT_MODEL_AMBIENT: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7632 | case GL_FOG_COLOR: |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7633 | *type = GL_FLOAT; |
| 7634 | *numParams = 4; |
| 7635 | return true; |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7636 | case GL_CURRENT_NORMAL: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7637 | case GL_POINT_DISTANCE_ATTENUATION: |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7638 | *type = GL_FLOAT; |
| 7639 | *numParams = 3; |
| 7640 | return true; |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 7641 | case GL_MODELVIEW_MATRIX: |
| 7642 | case GL_PROJECTION_MATRIX: |
| 7643 | case GL_TEXTURE_MATRIX: |
| 7644 | *type = GL_FLOAT; |
| 7645 | *numParams = 16; |
| 7646 | return true; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7647 | case GL_LIGHT_MODEL_TWO_SIDE: |
| 7648 | *type = GL_BOOL; |
| 7649 | *numParams = 1; |
| 7650 | return true; |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7651 | } |
| 7652 | } |
| 7653 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7654 | if (getClientVersion() < Version(3, 0)) |
| 7655 | { |
| 7656 | return false; |
| 7657 | } |
| 7658 | |
| 7659 | // Check for ES3.0+ parameter names |
| 7660 | switch (pname) |
| 7661 | { |
| 7662 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 7663 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 7664 | case GL_UNIFORM_BUFFER_BINDING: |
| 7665 | case GL_TRANSFORM_FEEDBACK_BINDING: |
| 7666 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7667 | case GL_COPY_READ_BUFFER_BINDING: |
| 7668 | case GL_COPY_WRITE_BUFFER_BINDING: |
| 7669 | case GL_SAMPLER_BINDING: |
| 7670 | case GL_READ_BUFFER: |
| 7671 | case GL_TEXTURE_BINDING_3D: |
| 7672 | case GL_TEXTURE_BINDING_2D_ARRAY: |
| 7673 | case GL_MAX_3D_TEXTURE_SIZE: |
| 7674 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 7675 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
| 7676 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
| 7677 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 7678 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 7679 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 7680 | case GL_MAX_VARYING_COMPONENTS: |
| 7681 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
| 7682 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
| 7683 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 7684 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 7685 | case GL_NUM_EXTENSIONS: |
| 7686 | case GL_MAJOR_VERSION: |
| 7687 | case GL_MINOR_VERSION: |
| 7688 | case GL_MAX_ELEMENTS_INDICES: |
| 7689 | case GL_MAX_ELEMENTS_VERTICES: |
| 7690 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 7691 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 7692 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 7693 | case GL_UNPACK_IMAGE_HEIGHT: |
| 7694 | case GL_UNPACK_SKIP_IMAGES: |
| 7695 | { |
| 7696 | *type = GL_INT; |
| 7697 | *numParams = 1; |
| 7698 | return true; |
| 7699 | } |
| 7700 | |
| 7701 | case GL_MAX_ELEMENT_INDEX: |
| 7702 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 7703 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
| 7704 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
| 7705 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 7706 | { |
| 7707 | *type = GL_INT_64_ANGLEX; |
| 7708 | *numParams = 1; |
| 7709 | return true; |
| 7710 | } |
| 7711 | |
| 7712 | case GL_TRANSFORM_FEEDBACK_ACTIVE: |
| 7713 | case GL_TRANSFORM_FEEDBACK_PAUSED: |
| 7714 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 7715 | case GL_RASTERIZER_DISCARD: |
| 7716 | { |
| 7717 | *type = GL_BOOL; |
| 7718 | *numParams = 1; |
| 7719 | return true; |
| 7720 | } |
| 7721 | |
| 7722 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 7723 | { |
| 7724 | *type = GL_FLOAT; |
| 7725 | *numParams = 1; |
| 7726 | return true; |
| 7727 | } |
| 7728 | } |
| 7729 | |
| 7730 | if (getExtensions().requestExtension) |
| 7731 | { |
| 7732 | switch (pname) |
| 7733 | { |
| 7734 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 7735 | *type = GL_INT; |
| 7736 | *numParams = 1; |
| 7737 | return true; |
| 7738 | } |
| 7739 | } |
| 7740 | |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7741 | if (getExtensions().textureMultisample) |
| 7742 | { |
| 7743 | switch (pname) |
| 7744 | { |
| 7745 | case GL_MAX_COLOR_TEXTURE_SAMPLES_ANGLE: |
| 7746 | case GL_MAX_INTEGER_SAMPLES_ANGLE: |
| 7747 | case GL_MAX_DEPTH_TEXTURE_SAMPLES_ANGLE: |
| 7748 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ANGLE: |
Yizhou Jiang | 7310da3 | 2018-11-05 14:40:01 +0800 | [diff] [blame] | 7749 | case GL_MAX_SAMPLE_MASK_WORDS: |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7750 | *type = GL_INT; |
| 7751 | *numParams = 1; |
| 7752 | return true; |
| 7753 | } |
| 7754 | } |
| 7755 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7756 | if (getClientVersion() < Version(3, 1)) |
| 7757 | { |
| 7758 | return false; |
| 7759 | } |
| 7760 | |
| 7761 | switch (pname) |
| 7762 | { |
| 7763 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7764 | case GL_DRAW_INDIRECT_BUFFER_BINDING: |
| 7765 | case GL_DISPATCH_INDIRECT_BUFFER_BINDING: |
| 7766 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 7767 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 7768 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 7769 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 7770 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 7771 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 7772 | case GL_MAX_INTEGER_SAMPLES: |
| 7773 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 7774 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 7775 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 7776 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
| 7777 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
| 7778 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
| 7779 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
| 7780 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
| 7781 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
| 7782 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
| 7783 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
| 7784 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7785 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7786 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 7787 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
| 7788 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
| 7789 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 7790 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
| 7791 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
| 7792 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
| 7793 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
| 7794 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
| 7795 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
| 7796 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 7797 | case GL_MAX_UNIFORM_LOCATIONS: |
| 7798 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 7799 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7800 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 7801 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 7802 | case GL_MAX_IMAGE_UNITS: |
| 7803 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 7804 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 7805 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 7806 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7807 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 7808 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE: |
Olli Etuaho | dff32a0 | 2018-08-28 14:35:50 +0300 | [diff] [blame] | 7809 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7810 | *type = GL_INT; |
| 7811 | *numParams = 1; |
| 7812 | return true; |
| 7813 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 7814 | *type = GL_INT_64_ANGLEX; |
| 7815 | *numParams = 1; |
| 7816 | return true; |
| 7817 | case GL_SAMPLE_MASK: |
| 7818 | *type = GL_BOOL; |
| 7819 | *numParams = 1; |
| 7820 | return true; |
| 7821 | } |
| 7822 | |
| 7823 | if (getExtensions().geometryShader) |
| 7824 | { |
| 7825 | switch (pname) |
| 7826 | { |
| 7827 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
| 7828 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
| 7829 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7830 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
| 7831 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7832 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
| 7833 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
| 7834 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
| 7835 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
| 7836 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
| 7837 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
| 7838 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
| 7839 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
| 7840 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
| 7841 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
| 7842 | *type = GL_INT; |
| 7843 | *numParams = 1; |
| 7844 | return true; |
| 7845 | } |
| 7846 | } |
| 7847 | |
| 7848 | return false; |
| 7849 | } |
| 7850 | |
| 7851 | bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams) |
| 7852 | { |
| 7853 | if (getClientVersion() < Version(3, 0)) |
| 7854 | { |
| 7855 | return false; |
| 7856 | } |
| 7857 | |
| 7858 | switch (target) |
| 7859 | { |
| 7860 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7861 | case GL_UNIFORM_BUFFER_BINDING: |
| 7862 | { |
| 7863 | *type = GL_INT; |
| 7864 | *numParams = 1; |
| 7865 | return true; |
| 7866 | } |
| 7867 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 7868 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 7869 | case GL_UNIFORM_BUFFER_START: |
| 7870 | case GL_UNIFORM_BUFFER_SIZE: |
| 7871 | { |
| 7872 | *type = GL_INT_64_ANGLEX; |
| 7873 | *numParams = 1; |
| 7874 | return true; |
| 7875 | } |
| 7876 | } |
| 7877 | |
| 7878 | if (getClientVersion() < Version(3, 1)) |
| 7879 | { |
| 7880 | return false; |
| 7881 | } |
| 7882 | |
| 7883 | switch (target) |
| 7884 | { |
| 7885 | case GL_IMAGE_BINDING_LAYERED: |
| 7886 | { |
| 7887 | *type = GL_BOOL; |
| 7888 | *numParams = 1; |
| 7889 | return true; |
| 7890 | } |
| 7891 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 7892 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 7893 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7894 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7895 | case GL_VERTEX_BINDING_BUFFER: |
| 7896 | case GL_VERTEX_BINDING_DIVISOR: |
| 7897 | case GL_VERTEX_BINDING_OFFSET: |
| 7898 | case GL_VERTEX_BINDING_STRIDE: |
| 7899 | case GL_SAMPLE_MASK_VALUE: |
| 7900 | case GL_IMAGE_BINDING_NAME: |
| 7901 | case GL_IMAGE_BINDING_LEVEL: |
| 7902 | case GL_IMAGE_BINDING_LAYER: |
| 7903 | case GL_IMAGE_BINDING_ACCESS: |
| 7904 | case GL_IMAGE_BINDING_FORMAT: |
| 7905 | { |
| 7906 | *type = GL_INT; |
| 7907 | *numParams = 1; |
| 7908 | return true; |
| 7909 | } |
| 7910 | case GL_ATOMIC_COUNTER_BUFFER_START: |
| 7911 | case GL_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7912 | case GL_SHADER_STORAGE_BUFFER_START: |
| 7913 | case GL_SHADER_STORAGE_BUFFER_SIZE: |
| 7914 | { |
| 7915 | *type = GL_INT_64_ANGLEX; |
| 7916 | *numParams = 1; |
| 7917 | return true; |
| 7918 | } |
| 7919 | } |
| 7920 | |
| 7921 | return false; |
| 7922 | } |
| 7923 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7924 | Program *Context::getProgramNoResolveLink(GLuint handle) const |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7925 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7926 | return mState.mShaderProgramManager->getProgram(handle); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7927 | } |
| 7928 | |
| 7929 | Shader *Context::getShader(GLuint handle) const |
| 7930 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7931 | return mState.mShaderProgramManager->getShader(handle); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7932 | } |
| 7933 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7934 | bool Context::isRenderbufferGenerated(GLuint renderbuffer) const |
| 7935 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7936 | return mState.mRenderbufferManager->isHandleGenerated(renderbuffer); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7937 | } |
| 7938 | |
| 7939 | bool Context::isFramebufferGenerated(GLuint framebuffer) const |
| 7940 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7941 | return mState.mFramebufferManager->isHandleGenerated(framebuffer); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7942 | } |
| 7943 | |
| 7944 | bool Context::isProgramPipelineGenerated(GLuint pipeline) const |
| 7945 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7946 | return mState.mProgramPipelineManager->isHandleGenerated(pipeline); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7947 | } |
| 7948 | |
| 7949 | bool Context::usingDisplayTextureShareGroup() const |
| 7950 | { |
| 7951 | return mDisplayTextureShareGroup; |
| 7952 | } |
| 7953 | |
| 7954 | GLenum Context::getConvertedRenderbufferFormat(GLenum internalformat) const |
| 7955 | { |
| 7956 | return mState.mExtensions.webglCompatibility && mState.mClientVersion.major == 2 && |
| 7957 | internalformat == GL_DEPTH_STENCIL |
| 7958 | ? GL_DEPTH24_STENCIL8 |
| 7959 | : internalformat; |
| 7960 | } |
| 7961 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7962 | void Context::maxShaderCompilerThreads(GLuint count) |
| 7963 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7964 | GLuint oldCount = mState.getMaxShaderCompilerThreads(); |
| 7965 | mState.setMaxShaderCompilerThreads(count); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 7966 | // A count of zero specifies a request for no parallel compiling or linking. |
| 7967 | if ((oldCount == 0 || count == 0) && (oldCount != 0 || count != 0)) |
| 7968 | { |
| 7969 | mThreadPool = angle::WorkerThreadPool::Create(count > 0); |
| 7970 | } |
| 7971 | mThreadPool->setMaxThreads(count); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7972 | } |
| 7973 | |
Jamie Madill | 2eb6503 | 2018-07-30 10:25:57 -0400 | [diff] [blame] | 7974 | bool Context::isGLES1() const |
| 7975 | { |
| 7976 | return mState.getClientVersion() < Version(2, 0); |
| 7977 | } |
| 7978 | |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 7979 | void Context::onSubjectStateChange(const Context *context, |
| 7980 | angle::SubjectIndex index, |
| 7981 | angle::SubjectMessage message) |
| 7982 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 7983 | switch (index) |
| 7984 | { |
| 7985 | case kVertexArraySubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 7986 | switch (message) |
| 7987 | { |
| 7988 | case angle::SubjectMessage::CONTENTS_CHANGED: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7989 | mState.setObjectDirty(GL_VERTEX_ARRAY); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 7990 | mStateCache.onVertexArrayBufferContentsChange(this); |
| 7991 | break; |
| 7992 | case angle::SubjectMessage::RESOURCE_MAPPED: |
| 7993 | case angle::SubjectMessage::RESOURCE_UNMAPPED: |
| 7994 | case angle::SubjectMessage::BINDING_CHANGED: |
| 7995 | mStateCache.onVertexArrayBufferStateChange(this); |
| 7996 | break; |
| 7997 | default: |
| 7998 | break; |
| 7999 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8000 | break; |
| 8001 | |
| 8002 | case kReadFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8003 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8004 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8005 | mState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8006 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8007 | break; |
| 8008 | |
| 8009 | case kDrawFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8010 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8011 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8012 | mState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8013 | } |
| 8014 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8015 | break; |
| 8016 | |
| 8017 | default: |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8018 | if (index < kTextureMaxSubjectIndex) |
| 8019 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8020 | mState.onActiveTextureStateChange(this, index); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8021 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8022 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8023 | else if (index < kUniformBufferMaxSubjectIndex) |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8024 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8025 | mState.onUniformBufferStateChange(index - kUniformBuffer0SubjectIndex); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8026 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8027 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8028 | else |
| 8029 | { |
| 8030 | ASSERT(index < kSamplerMaxSubjectIndex); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8031 | mState.setSamplerDirty(index - kSampler0SubjectIndex); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8032 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8033 | break; |
| 8034 | } |
| 8035 | } |
| 8036 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8037 | // ErrorSet implementation. |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8038 | ErrorSet::ErrorSet(Context *context) : mContext(context) {} |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8039 | |
| 8040 | ErrorSet::~ErrorSet() = default; |
| 8041 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8042 | void ErrorSet::handleError(GLenum errorCode, |
| 8043 | const char *message, |
| 8044 | const char *file, |
| 8045 | const char *function, |
| 8046 | unsigned int line) |
| 8047 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8048 | if (errorCode == GL_OUT_OF_MEMORY && mContext->getWorkarounds().loseContextOnOutOfMemory) |
| 8049 | { |
| 8050 | mContext->markContextLost(); |
| 8051 | } |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8052 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8053 | std::stringstream errorStream; |
| 8054 | errorStream << "Error: " << gl::FmtHex(errorCode) << ", in " << file << ", " << function << ":" |
| 8055 | << line << ". " << message; |
| 8056 | |
Geoff Lang | 7139b43 | 2018-12-14 16:57:28 -0500 | [diff] [blame] | 8057 | std::string formattedMessage = errorStream.str(); |
| 8058 | |
| 8059 | // Always log a warning, this function is only called on unexpected internal errors. |
| 8060 | WARN() << formattedMessage; |
| 8061 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8062 | // validationError does the necessary work to process the error. |
Geoff Lang | 7139b43 | 2018-12-14 16:57:28 -0500 | [diff] [blame] | 8063 | validationError(errorCode, formattedMessage.c_str()); |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8064 | } |
| 8065 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8066 | void ErrorSet::validationError(GLenum errorCode, const char *message) |
| 8067 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8068 | ASSERT(errorCode != GL_NO_ERROR); |
| 8069 | mErrors.insert(errorCode); |
| 8070 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8071 | mContext->getState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, |
| 8072 | errorCode, GL_DEBUG_SEVERITY_HIGH, message); |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8073 | } |
| 8074 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8075 | bool ErrorSet::empty() const |
| 8076 | { |
| 8077 | return mErrors.empty(); |
| 8078 | } |
| 8079 | |
| 8080 | GLenum ErrorSet::popError() |
| 8081 | { |
| 8082 | ASSERT(!empty()); |
| 8083 | GLenum error = *mErrors.begin(); |
| 8084 | mErrors.erase(mErrors.begin()); |
| 8085 | return error; |
| 8086 | } |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8087 | |
| 8088 | // StateCache implementation. |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8089 | StateCache::StateCache() |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8090 | : mCachedHasAnyEnabledClientAttrib(false), |
| 8091 | mCachedNonInstancedVertexElementLimit(0), |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8092 | mCachedInstancedVertexElementLimit(0), |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8093 | mCachedBasicDrawStatesError(kInvalidPointer), |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8094 | mCachedBasicDrawElementsError(kInvalidPointer), |
| 8095 | mCachedTransformFeedbackActiveUnpaused(false) |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8096 | {} |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8097 | |
| 8098 | StateCache::~StateCache() = default; |
| 8099 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8100 | void StateCache::initialize(Context *context) |
| 8101 | { |
| 8102 | updateValidDrawModes(context); |
| 8103 | updateValidBindTextureTypes(context); |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8104 | updateValidDrawElementsTypes(context); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8105 | updateBasicDrawStatesError(); |
| 8106 | updateBasicDrawElementsError(); |
Jamie Madill | c8c7d40 | 2019-01-16 13:27:15 -0500 | [diff] [blame] | 8107 | updateVertexAttribTypesValidation(context); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8108 | } |
| 8109 | |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8110 | void StateCache::updateActiveAttribsMask(Context *context) |
| 8111 | { |
| 8112 | bool isGLES1 = context->isGLES1(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8113 | const State &glState = context->getState(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8114 | |
| 8115 | if (!isGLES1 && !glState.getProgram()) |
| 8116 | { |
| 8117 | mCachedActiveBufferedAttribsMask = AttributesMask(); |
| 8118 | mCachedActiveClientAttribsMask = AttributesMask(); |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8119 | mCachedActiveDefaultAttribsMask = AttributesMask(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8120 | return; |
| 8121 | } |
| 8122 | |
| 8123 | AttributesMask activeAttribs = isGLES1 ? glState.gles1().getVertexArraysAttributeMask() |
| 8124 | : glState.getProgram()->getActiveAttribLocationsMask(); |
| 8125 | |
| 8126 | const VertexArray *vao = glState.getVertexArray(); |
| 8127 | ASSERT(vao); |
| 8128 | |
| 8129 | const AttributesMask &clientAttribs = vao->getClientAttribsMask(); |
| 8130 | const AttributesMask &enabledAttribs = vao->getEnabledAttributesMask(); |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8131 | const AttributesMask &activeEnabled = activeAttribs & enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8132 | |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8133 | mCachedActiveClientAttribsMask = activeEnabled & clientAttribs; |
| 8134 | mCachedActiveBufferedAttribsMask = activeEnabled & ~clientAttribs; |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8135 | mCachedActiveDefaultAttribsMask = activeAttribs & ~enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8136 | mCachedHasAnyEnabledClientAttrib = (clientAttribs & enabledAttribs).any(); |
| 8137 | } |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8138 | |
| 8139 | void StateCache::updateVertexElementLimits(Context *context) |
| 8140 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8141 | const VertexArray *vao = context->getState().getVertexArray(); |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8142 | |
| 8143 | mCachedNonInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8144 | mCachedInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8145 | |
| 8146 | // VAO can be null on Context startup. If we make this computation lazier we could ASSERT. |
| 8147 | // If there are no buffered attributes then we should not limit the draw call count. |
| 8148 | if (!vao || !mCachedActiveBufferedAttribsMask.any()) |
| 8149 | { |
| 8150 | return; |
| 8151 | } |
| 8152 | |
| 8153 | const auto &vertexAttribs = vao->getVertexAttributes(); |
| 8154 | const auto &vertexBindings = vao->getVertexBindings(); |
| 8155 | |
| 8156 | for (size_t attributeIndex : mCachedActiveBufferedAttribsMask) |
| 8157 | { |
| 8158 | const VertexAttribute &attrib = vertexAttribs[attributeIndex]; |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8159 | |
| 8160 | const VertexBinding &binding = vertexBindings[attrib.bindingIndex]; |
| 8161 | ASSERT(context->isGLES1() || |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8162 | context->getState().getProgram()->isAttribLocationActive(attributeIndex)); |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8163 | |
| 8164 | GLint64 limit = attrib.getCachedElementLimit(); |
| 8165 | if (binding.getDivisor() > 0) |
| 8166 | { |
| 8167 | mCachedInstancedVertexElementLimit = |
| 8168 | std::min(mCachedInstancedVertexElementLimit, limit); |
| 8169 | } |
| 8170 | else |
| 8171 | { |
| 8172 | mCachedNonInstancedVertexElementLimit = |
| 8173 | std::min(mCachedNonInstancedVertexElementLimit, limit); |
| 8174 | } |
| 8175 | } |
| 8176 | } |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8177 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8178 | void StateCache::updateBasicDrawStatesError() |
| 8179 | { |
| 8180 | mCachedBasicDrawStatesError = kInvalidPointer; |
| 8181 | } |
| 8182 | |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8183 | void StateCache::updateBasicDrawElementsError() |
| 8184 | { |
| 8185 | mCachedBasicDrawElementsError = kInvalidPointer; |
| 8186 | } |
| 8187 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8188 | intptr_t StateCache::getBasicDrawStatesErrorImpl(Context *context) const |
| 8189 | { |
| 8190 | ASSERT(mCachedBasicDrawStatesError == kInvalidPointer); |
| 8191 | mCachedBasicDrawStatesError = reinterpret_cast<intptr_t>(ValidateDrawStates(context)); |
| 8192 | return mCachedBasicDrawStatesError; |
| 8193 | } |
| 8194 | |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8195 | intptr_t StateCache::getBasicDrawElementsErrorImpl(Context *context) const |
| 8196 | { |
| 8197 | ASSERT(mCachedBasicDrawElementsError == kInvalidPointer); |
| 8198 | mCachedBasicDrawElementsError = reinterpret_cast<intptr_t>(ValidateDrawElementsStates(context)); |
| 8199 | return mCachedBasicDrawElementsError; |
| 8200 | } |
| 8201 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8202 | void StateCache::onVertexArrayBindingChange(Context *context) |
| 8203 | { |
| 8204 | updateActiveAttribsMask(context); |
| 8205 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8206 | updateBasicDrawStatesError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8207 | } |
| 8208 | |
| 8209 | void StateCache::onProgramExecutableChange(Context *context) |
| 8210 | { |
| 8211 | updateActiveAttribsMask(context); |
| 8212 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8213 | updateBasicDrawStatesError(); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8214 | updateValidDrawModes(context); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8215 | } |
| 8216 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8217 | void StateCache::onVertexArrayFormatChange(Context *context) |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8218 | { |
| 8219 | updateVertexElementLimits(context); |
| 8220 | } |
| 8221 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8222 | void StateCache::onVertexArrayBufferContentsChange(Context *context) |
| 8223 | { |
| 8224 | updateVertexElementLimits(context); |
| 8225 | updateBasicDrawStatesError(); |
| 8226 | } |
| 8227 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8228 | void StateCache::onVertexArrayStateChange(Context *context) |
| 8229 | { |
| 8230 | updateActiveAttribsMask(context); |
| 8231 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8232 | updateBasicDrawStatesError(); |
| 8233 | } |
| 8234 | |
| 8235 | void StateCache::onVertexArrayBufferStateChange(Context *context) |
| 8236 | { |
| 8237 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8238 | updateBasicDrawElementsError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8239 | } |
| 8240 | |
| 8241 | void StateCache::onGLES1ClientStateChange(Context *context) |
| 8242 | { |
| 8243 | updateActiveAttribsMask(context); |
| 8244 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8245 | |
| 8246 | void StateCache::onDrawFramebufferChange(Context *context) |
| 8247 | { |
| 8248 | updateBasicDrawStatesError(); |
| 8249 | } |
| 8250 | |
| 8251 | void StateCache::onContextCapChange(Context *context) |
| 8252 | { |
| 8253 | updateBasicDrawStatesError(); |
| 8254 | } |
| 8255 | |
| 8256 | void StateCache::onStencilStateChange(Context *context) |
| 8257 | { |
| 8258 | updateBasicDrawStatesError(); |
| 8259 | } |
| 8260 | |
| 8261 | void StateCache::onDefaultVertexAttributeChange(Context *context) |
| 8262 | { |
| 8263 | updateBasicDrawStatesError(); |
| 8264 | } |
| 8265 | |
| 8266 | void StateCache::onActiveTextureChange(Context *context) |
| 8267 | { |
| 8268 | updateBasicDrawStatesError(); |
| 8269 | } |
| 8270 | |
| 8271 | void StateCache::onQueryChange(Context *context) |
| 8272 | { |
| 8273 | updateBasicDrawStatesError(); |
| 8274 | } |
| 8275 | |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 8276 | void StateCache::onActiveTransformFeedbackChange(Context *context) |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8277 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8278 | updateTransformFeedbackActiveUnpaused(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8279 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8280 | updateBasicDrawElementsError(); |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8281 | updateValidDrawModes(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8282 | } |
| 8283 | |
| 8284 | void StateCache::onUniformBufferStateChange(Context *context) |
| 8285 | { |
| 8286 | updateBasicDrawStatesError(); |
| 8287 | } |
| 8288 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8289 | void StateCache::setValidDrawModes(bool pointsOK, |
| 8290 | bool linesOK, |
| 8291 | bool trisOK, |
| 8292 | bool lineAdjOK, |
| 8293 | bool triAdjOK) |
| 8294 | { |
| 8295 | mCachedValidDrawModes[PrimitiveMode::Points] = pointsOK; |
| 8296 | mCachedValidDrawModes[PrimitiveMode::Lines] = linesOK; |
| 8297 | mCachedValidDrawModes[PrimitiveMode::LineStrip] = linesOK; |
| 8298 | mCachedValidDrawModes[PrimitiveMode::LineLoop] = linesOK; |
| 8299 | mCachedValidDrawModes[PrimitiveMode::Triangles] = trisOK; |
| 8300 | mCachedValidDrawModes[PrimitiveMode::TriangleFan] = trisOK; |
| 8301 | mCachedValidDrawModes[PrimitiveMode::TriangleStrip] = trisOK; |
| 8302 | mCachedValidDrawModes[PrimitiveMode::LinesAdjacency] = lineAdjOK; |
| 8303 | mCachedValidDrawModes[PrimitiveMode::LineStripAdjacency] = lineAdjOK; |
| 8304 | mCachedValidDrawModes[PrimitiveMode::TrianglesAdjacency] = triAdjOK; |
| 8305 | mCachedValidDrawModes[PrimitiveMode::TriangleStripAdjacency] = triAdjOK; |
| 8306 | } |
| 8307 | |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8308 | void StateCache::updateValidDrawModes(Context *context) |
| 8309 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8310 | const State &state = context->getState(); |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8311 | Program *program = state.getProgram(); |
| 8312 | |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8313 | if (mCachedTransformFeedbackActiveUnpaused) |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8314 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8315 | TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback(); |
| 8316 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8317 | // ES Spec 3.0 validation text: |
| 8318 | // When transform feedback is active and not paused, all geometric primitives generated must |
| 8319 | // match the value of primitiveMode passed to BeginTransformFeedback. The error |
| 8320 | // INVALID_OPERATION is generated by DrawArrays and DrawArraysInstanced if mode is not |
| 8321 | // identical to primitiveMode. The error INVALID_OPERATION is also generated by |
| 8322 | // DrawElements, DrawElementsInstanced, and DrawRangeElements while transform feedback is |
| 8323 | // active and not paused, regardless of mode. Any primitive type may be used while transform |
| 8324 | // feedback is paused. |
| 8325 | if (!context->getExtensions().geometryShader) |
| 8326 | { |
| 8327 | mCachedValidDrawModes.fill(false); |
| 8328 | mCachedValidDrawModes[curTransformFeedback->getPrimitiveMode()] = true; |
| 8329 | return; |
| 8330 | } |
| 8331 | |
| 8332 | // EXT_geometry_shader validation text: |
| 8333 | // When transform feedback is active and not paused, all geometric primitives generated must |
| 8334 | // be compatible with the value of <primitiveMode> passed to BeginTransformFeedback. If a |
| 8335 | // geometry shader is active, the type of primitive emitted by that shader is used instead |
| 8336 | // of the <mode> parameter passed to drawing commands for the purposes of this error check. |
| 8337 | // Any primitive type may be used while transform feedback is paused. |
| 8338 | bool pointsOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Points; |
| 8339 | bool linesOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Lines; |
| 8340 | bool trisOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Triangles; |
| 8341 | |
| 8342 | setValidDrawModes(pointsOK, linesOK, trisOK, false, false); |
| 8343 | return; |
| 8344 | } |
| 8345 | |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8346 | if (!program || !program->hasLinkedShaderStage(ShaderType::Geometry)) |
| 8347 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8348 | mCachedValidDrawModes = kValidBasicDrawModes; |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8349 | return; |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8350 | } |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8351 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8352 | ASSERT(program && program->hasLinkedShaderStage(ShaderType::Geometry)); |
| 8353 | PrimitiveMode gsMode = program->getGeometryShaderInputPrimitiveType(); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8354 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8355 | bool pointsOK = gsMode == PrimitiveMode::Points; |
| 8356 | bool linesOK = gsMode == PrimitiveMode::Lines; |
| 8357 | bool trisOK = gsMode == PrimitiveMode::Triangles; |
| 8358 | bool lineAdjOK = gsMode == PrimitiveMode::LinesAdjacency; |
| 8359 | bool triAdjOK = gsMode == PrimitiveMode::TrianglesAdjacency; |
| 8360 | |
| 8361 | setValidDrawModes(pointsOK, linesOK, trisOK, lineAdjOK, triAdjOK); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8362 | } |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8363 | |
| 8364 | void StateCache::updateValidBindTextureTypes(Context *context) |
| 8365 | { |
| 8366 | const Extensions &exts = context->getExtensions(); |
| 8367 | bool isGLES3 = context->getClientMajorVersion() >= 3; |
| 8368 | bool isGLES31 = context->getClientVersion() >= Version(3, 1); |
| 8369 | |
| 8370 | mCachedValidBindTextureTypes = {{ |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8371 | {TextureType::_2D, true}, |
| 8372 | {TextureType::_2DArray, isGLES3}, |
| 8373 | {TextureType::_2DMultisample, isGLES31 || exts.textureMultisample}, |
| 8374 | {TextureType::_2DMultisampleArray, exts.textureStorageMultisample2DArray}, |
| 8375 | {TextureType::_3D, isGLES3}, |
| 8376 | {TextureType::External, exts.eglImageExternal || exts.eglStreamConsumerExternal}, |
| 8377 | {TextureType::Rectangle, exts.textureRectangle}, |
| 8378 | {TextureType::CubeMap, true}, |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8379 | }}; |
| 8380 | } |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8381 | |
| 8382 | void StateCache::updateValidDrawElementsTypes(Context *context) |
| 8383 | { |
| 8384 | bool supportsUint = |
| 8385 | (context->getClientMajorVersion() >= 3 || context->getExtensions().elementIndexUint); |
| 8386 | |
| 8387 | mCachedValidDrawElementsTypes = {{ |
| 8388 | {DrawElementsType::UnsignedByte, true}, |
| 8389 | {DrawElementsType::UnsignedShort, true}, |
| 8390 | {DrawElementsType::UnsignedInt, supportsUint}, |
| 8391 | }}; |
| 8392 | } |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8393 | |
| 8394 | void StateCache::updateTransformFeedbackActiveUnpaused(Context *context) |
| 8395 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8396 | TransformFeedback *xfb = context->getState().getCurrentTransformFeedback(); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8397 | mCachedTransformFeedbackActiveUnpaused = xfb && xfb->isActive() && !xfb->isPaused(); |
| 8398 | } |
Jamie Madill | c8c7d40 | 2019-01-16 13:27:15 -0500 | [diff] [blame] | 8399 | |
| 8400 | void StateCache::updateVertexAttribTypesValidation(Context *context) |
| 8401 | { |
| 8402 | if (context->getClientMajorVersion() <= 2) |
| 8403 | { |
| 8404 | mCachedVertexAttribTypesValidation = {{ |
| 8405 | {VertexAttribType::Byte, VertexAttribTypeCase::Valid}, |
| 8406 | {VertexAttribType::Short, VertexAttribTypeCase::Valid}, |
| 8407 | {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid}, |
| 8408 | {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid}, |
| 8409 | {VertexAttribType::Float, VertexAttribTypeCase::Valid}, |
| 8410 | {VertexAttribType::Fixed, VertexAttribTypeCase::Valid}, |
| 8411 | }}; |
| 8412 | } |
| 8413 | else |
| 8414 | { |
| 8415 | mCachedVertexAttribTypesValidation = {{ |
| 8416 | {VertexAttribType::Byte, VertexAttribTypeCase::Valid}, |
| 8417 | {VertexAttribType::Short, VertexAttribTypeCase::Valid}, |
| 8418 | {VertexAttribType::Int, VertexAttribTypeCase::Valid}, |
| 8419 | {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid}, |
| 8420 | {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid}, |
| 8421 | {VertexAttribType::UnsignedInt, VertexAttribTypeCase::Valid}, |
| 8422 | {VertexAttribType::Float, VertexAttribTypeCase::Valid}, |
| 8423 | {VertexAttribType::HalfFloat, VertexAttribTypeCase::Valid}, |
| 8424 | {VertexAttribType::Fixed, VertexAttribTypeCase::Valid}, |
| 8425 | {VertexAttribType::Int2101010, VertexAttribTypeCase::ValidSize4Only}, |
| 8426 | {VertexAttribType::UnsignedInt2101010, VertexAttribTypeCase::ValidSize4Only}, |
| 8427 | }}; |
| 8428 | |
| 8429 | mCachedIntegerVertexAttribTypesValidation = {{ |
| 8430 | {VertexAttribType::Byte, VertexAttribTypeCase::Valid}, |
| 8431 | {VertexAttribType::Short, VertexAttribTypeCase::Valid}, |
| 8432 | {VertexAttribType::Int, VertexAttribTypeCase::Valid}, |
| 8433 | {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid}, |
| 8434 | {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid}, |
| 8435 | {VertexAttribType::UnsignedInt, VertexAttribTypeCase::Valid}, |
| 8436 | }}; |
| 8437 | } |
| 8438 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 8439 | } // namespace gl |