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 | 3adcf1e | 2019-01-16 00:40:38 +0000 | [diff] [blame] | 538 | zeroTexture->onDestroy(this); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 539 | zeroTexture.set(this, nullptr); |
| 540 | } |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 541 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 542 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 543 | releaseShaderCompiler(); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 544 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 545 | mState.reset(this); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 546 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 547 | mState.mBufferManager->release(this); |
| 548 | mState.mShaderProgramManager->release(this); |
| 549 | mState.mTextureManager->release(this); |
| 550 | mState.mRenderbufferManager->release(this); |
| 551 | mState.mSamplerManager->release(this); |
| 552 | mState.mSyncManager->release(this); |
| 553 | mState.mPathManager->release(this); |
| 554 | mState.mFramebufferManager->release(this); |
| 555 | mState.mProgramPipelineManager->release(this); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 556 | |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 557 | mThreadPool.reset(); |
| 558 | |
Jamie Madill | 76e471e | 2017-10-21 09:56:01 -0400 | [diff] [blame] | 559 | mImplementation->onDestroy(this); |
| 560 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 561 | return egl::NoError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 562 | } |
| 563 | |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 564 | Context::~Context() {} |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 565 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 566 | void Context::setLabel(EGLLabelKHR label) |
| 567 | { |
| 568 | mLabel = label; |
| 569 | } |
| 570 | |
| 571 | EGLLabelKHR Context::getLabel() const |
| 572 | { |
| 573 | return mLabel; |
| 574 | } |
| 575 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 576 | egl::Error Context::makeCurrent(egl::Display *display, egl::Surface *surface) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 577 | { |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 578 | mCurrentDisplay = display; |
| 579 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 580 | if (!mHasBeenCurrent) |
| 581 | { |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 582 | initialize(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 583 | initRendererString(); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 584 | initVersionStrings(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 585 | initExtensionStrings(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 586 | |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 587 | int width = 0; |
| 588 | int height = 0; |
| 589 | if (surface != nullptr) |
| 590 | { |
| 591 | width = surface->getWidth(); |
| 592 | height = surface->getHeight(); |
| 593 | } |
| 594 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 595 | mState.setViewportParams(0, 0, width, height); |
| 596 | mState.setScissorParams(0, 0, width, height); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 597 | |
| 598 | mHasBeenCurrent = true; |
| 599 | } |
| 600 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 601 | // TODO(jmadill): Rework this when we support ContextImpl |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 602 | mState.setAllDirtyBits(); |
| 603 | mState.setAllDirtyObjects(); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 604 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 605 | ANGLE_TRY(releaseSurface(display)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 606 | |
| 607 | Framebuffer *newDefault = nullptr; |
| 608 | if (surface != nullptr) |
| 609 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 610 | ANGLE_TRY(surface->setIsCurrent(this, true)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 611 | mCurrentSurface = surface; |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 612 | newDefault = surface->createDefaultFramebuffer(this); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 613 | } |
| 614 | else |
| 615 | { |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 616 | newDefault = new Framebuffer(mImplementation.get()); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 617 | } |
Jamie Madill | 18fdcbc | 2015-08-19 18:12:44 +0000 | [diff] [blame] | 618 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 619 | // Update default framebuffer, the binding of the previous default |
| 620 | // framebuffer (or lack of) will have a nullptr. |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 621 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 622 | mState.mFramebufferManager->setDefaultFramebuffer(newDefault); |
| 623 | if (mState.getReadFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 624 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 625 | bindReadFramebuffer(0); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 626 | } |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 627 | if (mState.getDrawFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 628 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 629 | bindDrawFramebuffer(0); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 630 | } |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 631 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 632 | |
Jamie Madill | 32643ce | 2018-10-19 11:38:03 -0400 | [diff] [blame] | 633 | // Notify the renderer of a context switch. |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 634 | return angle::ResultToEGL(mImplementation->onMakeCurrent(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 635 | } |
| 636 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 637 | egl::Error Context::releaseSurface(const egl::Display *display) |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 638 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 639 | gl::Framebuffer *defaultFramebuffer = mState.mFramebufferManager->getFramebuffer(0); |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 640 | |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 641 | // Remove the default framebuffer |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 642 | if (mState.getReadFramebuffer() == defaultFramebuffer) |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 643 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 644 | mState.setReadFramebufferBinding(nullptr); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 645 | mReadFramebufferObserverBinding.bind(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 646 | } |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 647 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 648 | if (mState.getDrawFramebuffer() == defaultFramebuffer) |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 649 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 650 | mState.setDrawFramebufferBinding(nullptr); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 651 | mDrawFramebufferObserverBinding.bind(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 652 | } |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 653 | |
| 654 | if (defaultFramebuffer) |
| 655 | { |
| 656 | defaultFramebuffer->onDestroy(this); |
| 657 | delete defaultFramebuffer; |
| 658 | } |
| 659 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 660 | mState.mFramebufferManager->setDefaultFramebuffer(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 661 | |
| 662 | if (mCurrentSurface) |
| 663 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 664 | ANGLE_TRY(mCurrentSurface->setIsCurrent(this, false)); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 665 | mCurrentSurface = nullptr; |
| 666 | } |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 667 | |
| 668 | return egl::NoError(); |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 669 | } |
| 670 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 671 | GLuint Context::createBuffer() |
| 672 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 673 | return mState.mBufferManager->createBuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | GLuint Context::createProgram() |
| 677 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 678 | return mState.mShaderProgramManager->createProgram(mImplementation.get()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 679 | } |
| 680 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 681 | GLuint Context::createShader(ShaderType type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 682 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 683 | return mState.mShaderProgramManager->createShader(mImplementation.get(), mState.mLimitations, |
| 684 | type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 685 | } |
| 686 | |
| 687 | GLuint Context::createTexture() |
| 688 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 689 | return mState.mTextureManager->createTexture(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | GLuint Context::createRenderbuffer() |
| 693 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 694 | return mState.mRenderbufferManager->createRenderbuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 695 | } |
| 696 | |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 697 | void Context::tryGenPaths(GLsizei range, GLuint *createdOut) |
| 698 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 699 | ANGLE_CONTEXT_TRY(mState.mPathManager->createPaths(this, range, createdOut)); |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 700 | } |
| 701 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 702 | GLuint Context::genPaths(GLsizei range) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 703 | { |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 704 | GLuint created = 0; |
| 705 | tryGenPaths(range, &created); |
| 706 | return created; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 707 | } |
| 708 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 709 | // Returns an unused framebuffer name |
| 710 | GLuint Context::createFramebuffer() |
| 711 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 712 | return mState.mFramebufferManager->createFramebuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 713 | } |
| 714 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 715 | void Context::genFencesNV(GLsizei n, GLuint *fences) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 716 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 717 | for (int i = 0; i < n; i++) |
| 718 | { |
| 719 | GLuint handle = mFenceNVHandleAllocator.allocate(); |
| 720 | mFenceNVMap.assign(handle, new FenceNV(mImplementation->createFenceNV())); |
| 721 | fences[i] = handle; |
| 722 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 723 | } |
| 724 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 725 | GLuint Context::createProgramPipeline() |
| 726 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 727 | return mState.mProgramPipelineManager->createProgramPipeline(); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 728 | } |
| 729 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 730 | GLuint Context::createShaderProgramv(ShaderType type, GLsizei count, const GLchar *const *strings) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 731 | { |
| 732 | UNIMPLEMENTED(); |
| 733 | return 0u; |
| 734 | } |
| 735 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 736 | void Context::deleteBuffer(GLuint bufferName) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 737 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 738 | Buffer *buffer = mState.mBufferManager->getBuffer(bufferName); |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 739 | if (buffer) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 740 | { |
| 741 | detachBuffer(buffer); |
| 742 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 743 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 744 | mState.mBufferManager->deleteObject(this, bufferName); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | void Context::deleteShader(GLuint shader) |
| 748 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 749 | mState.mShaderProgramManager->deleteShader(this, shader); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | void Context::deleteProgram(GLuint program) |
| 753 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 754 | mState.mShaderProgramManager->deleteProgram(this, program); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 755 | } |
| 756 | |
| 757 | void Context::deleteTexture(GLuint texture) |
| 758 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 759 | if (mState.mTextureManager->getTexture(texture)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 760 | { |
| 761 | detachTexture(texture); |
| 762 | } |
| 763 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 764 | mState.mTextureManager->deleteObject(this, texture); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | void Context::deleteRenderbuffer(GLuint renderbuffer) |
| 768 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 769 | if (mState.mRenderbufferManager->getRenderbuffer(renderbuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 770 | { |
| 771 | detachRenderbuffer(renderbuffer); |
| 772 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 773 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 774 | mState.mRenderbufferManager->deleteObject(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 775 | } |
| 776 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 777 | void Context::deleteSync(GLsync sync) |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 778 | { |
| 779 | // The spec specifies the underlying Fence object is not deleted until all current |
| 780 | // wait commands finish. However, since the name becomes invalid, we cannot query the fence, |
| 781 | // and since our API is currently designed for being called from a single thread, we can delete |
| 782 | // the fence immediately. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 783 | mState.mSyncManager->deleteObject(this, static_cast<GLuint>(reinterpret_cast<uintptr_t>(sync))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 784 | } |
| 785 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 786 | void Context::deleteProgramPipeline(GLuint pipeline) |
| 787 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 788 | if (mState.mProgramPipelineManager->getProgramPipeline(pipeline)) |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 789 | { |
| 790 | detachProgramPipeline(pipeline); |
| 791 | } |
| 792 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 793 | mState.mProgramPipelineManager->deleteObject(this, pipeline); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 794 | } |
| 795 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 796 | void Context::deletePaths(GLuint first, GLsizei range) |
| 797 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 798 | mState.mPathManager->deletePaths(first, range); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 799 | } |
| 800 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 801 | bool Context::isPath(GLuint path) const |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 802 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 803 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 804 | if (pathObj == nullptr) |
| 805 | return false; |
| 806 | |
| 807 | return pathObj->hasPathData(); |
| 808 | } |
| 809 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 810 | bool Context::isPathGenerated(GLuint path) const |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 811 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 812 | return mState.mPathManager->hasPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 813 | } |
| 814 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 815 | void Context::pathCommands(GLuint path, |
| 816 | GLsizei numCommands, |
| 817 | const GLubyte *commands, |
| 818 | GLsizei numCoords, |
| 819 | GLenum coordType, |
| 820 | const void *coords) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 821 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 822 | auto *pathObject = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 823 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 824 | ANGLE_CONTEXT_TRY(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords)); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 825 | } |
| 826 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 827 | void Context::pathParameterf(GLuint path, GLenum pname, GLfloat value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 828 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 829 | Path *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 830 | |
| 831 | switch (pname) |
| 832 | { |
| 833 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 834 | pathObj->setStrokeWidth(value); |
| 835 | break; |
| 836 | case GL_PATH_END_CAPS_CHROMIUM: |
| 837 | pathObj->setEndCaps(static_cast<GLenum>(value)); |
| 838 | break; |
| 839 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 840 | pathObj->setJoinStyle(static_cast<GLenum>(value)); |
| 841 | break; |
| 842 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 843 | pathObj->setMiterLimit(value); |
| 844 | break; |
| 845 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 846 | pathObj->setStrokeBound(value); |
| 847 | break; |
| 848 | default: |
| 849 | UNREACHABLE(); |
| 850 | break; |
| 851 | } |
| 852 | } |
| 853 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 854 | void Context::pathParameteri(GLuint path, GLenum pname, GLint value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 855 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 856 | // TODO(jmadill): Should use proper clamping/casting. |
| 857 | pathParameterf(path, pname, static_cast<GLfloat>(value)); |
| 858 | } |
| 859 | |
| 860 | void Context::getPathParameterfv(GLuint path, GLenum pname, GLfloat *value) |
| 861 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 862 | const Path *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 863 | |
| 864 | switch (pname) |
| 865 | { |
| 866 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 867 | *value = pathObj->getStrokeWidth(); |
| 868 | break; |
| 869 | case GL_PATH_END_CAPS_CHROMIUM: |
| 870 | *value = static_cast<GLfloat>(pathObj->getEndCaps()); |
| 871 | break; |
| 872 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 873 | *value = static_cast<GLfloat>(pathObj->getJoinStyle()); |
| 874 | break; |
| 875 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 876 | *value = pathObj->getMiterLimit(); |
| 877 | break; |
| 878 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 879 | *value = pathObj->getStrokeBound(); |
| 880 | break; |
| 881 | default: |
| 882 | UNREACHABLE(); |
| 883 | break; |
| 884 | } |
| 885 | } |
| 886 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 887 | void Context::getPathParameteriv(GLuint path, GLenum pname, GLint *value) |
| 888 | { |
| 889 | GLfloat val = 0.0f; |
| 890 | getPathParameterfv(path, pname, value != nullptr ? &val : nullptr); |
| 891 | if (value) |
| 892 | *value = static_cast<GLint>(val); |
| 893 | } |
| 894 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 895 | void Context::pathStencilFunc(GLenum func, GLint ref, GLuint mask) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 896 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 897 | mState.setPathStencilFunc(func, ref, mask); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 898 | } |
| 899 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 900 | void Context::deleteFramebuffer(GLuint framebuffer) |
| 901 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 902 | if (mState.mFramebufferManager->getFramebuffer(framebuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 903 | { |
| 904 | detachFramebuffer(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 905 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 906 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 907 | mState.mFramebufferManager->deleteObject(this, framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 908 | } |
| 909 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 910 | void Context::deleteFencesNV(GLsizei n, const GLuint *fences) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 911 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 912 | for (int i = 0; i < n; i++) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 913 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 914 | GLuint fence = fences[i]; |
| 915 | |
| 916 | FenceNV *fenceObject = nullptr; |
| 917 | if (mFenceNVMap.erase(fence, &fenceObject)) |
| 918 | { |
| 919 | mFenceNVHandleAllocator.release(fence); |
| 920 | delete fenceObject; |
| 921 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 922 | } |
| 923 | } |
| 924 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 925 | Buffer *Context::getBuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 926 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 927 | return mState.mBufferManager->getBuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 928 | } |
| 929 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 930 | Renderbuffer *Context::getRenderbuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 931 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 932 | return mState.mRenderbufferManager->getRenderbuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 933 | } |
| 934 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 935 | Sync *Context::getSync(GLsync handle) const |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 936 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 937 | return mState.mSyncManager->getSync(static_cast<GLuint>(reinterpret_cast<uintptr_t>(handle))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 938 | } |
| 939 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 940 | VertexArray *Context::getVertexArray(GLuint handle) const |
| 941 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 942 | return mVertexArrayMap.query(handle); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 943 | } |
| 944 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 945 | Sampler *Context::getSampler(GLuint handle) const |
| 946 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 947 | return mState.mSamplerManager->getSampler(handle); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 948 | } |
| 949 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 950 | TransformFeedback *Context::getTransformFeedback(GLuint handle) const |
| 951 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 952 | return mTransformFeedbackMap.query(handle); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 953 | } |
| 954 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 955 | ProgramPipeline *Context::getProgramPipeline(GLuint handle) const |
| 956 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 957 | return mState.mProgramPipelineManager->getProgramPipeline(handle); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 958 | } |
| 959 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 960 | gl::LabeledObject *Context::getLabeledObject(GLenum identifier, GLuint name) const |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 961 | { |
| 962 | switch (identifier) |
| 963 | { |
| 964 | case GL_BUFFER: |
| 965 | return getBuffer(name); |
| 966 | case GL_SHADER: |
| 967 | return getShader(name); |
| 968 | case GL_PROGRAM: |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 969 | return getProgramNoResolveLink(name); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 970 | case GL_VERTEX_ARRAY: |
| 971 | return getVertexArray(name); |
| 972 | case GL_QUERY: |
| 973 | return getQuery(name); |
| 974 | case GL_TRANSFORM_FEEDBACK: |
| 975 | return getTransformFeedback(name); |
| 976 | case GL_SAMPLER: |
| 977 | return getSampler(name); |
| 978 | case GL_TEXTURE: |
| 979 | return getTexture(name); |
| 980 | case GL_RENDERBUFFER: |
| 981 | return getRenderbuffer(name); |
| 982 | case GL_FRAMEBUFFER: |
| 983 | return getFramebuffer(name); |
| 984 | default: |
| 985 | UNREACHABLE(); |
| 986 | return nullptr; |
| 987 | } |
| 988 | } |
| 989 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 990 | gl::LabeledObject *Context::getLabeledObjectFromPtr(const void *ptr) const |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 991 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 992 | return getSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr))); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 993 | } |
| 994 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 995 | void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label) |
| 996 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 997 | gl::LabeledObject *object = getLabeledObject(identifier, name); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 998 | ASSERT(object != nullptr); |
| 999 | |
| 1000 | std::string labelName = GetObjectLabelFromPointer(length, label); |
Jamie Madill | e90d4ee | 2018-11-28 14:04:00 -0500 | [diff] [blame] | 1001 | object->setLabel(this, labelName); |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 1002 | |
| 1003 | // TODO(jmadill): Determine if the object is dirty based on 'name'. Conservatively assume the |
| 1004 | // specified object is active until we do this. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1005 | mState.setObjectDirty(identifier); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label) |
| 1009 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1010 | gl::LabeledObject *object = getLabeledObjectFromPtr(ptr); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1011 | ASSERT(object != nullptr); |
| 1012 | |
| 1013 | std::string labelName = GetObjectLabelFromPointer(length, label); |
Jamie Madill | e90d4ee | 2018-11-28 14:04:00 -0500 | [diff] [blame] | 1014 | object->setLabel(this, labelName); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1015 | } |
| 1016 | |
| 1017 | void Context::getObjectLabel(GLenum identifier, |
| 1018 | GLuint name, |
| 1019 | GLsizei bufSize, |
| 1020 | GLsizei *length, |
| 1021 | GLchar *label) const |
| 1022 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1023 | gl::LabeledObject *object = getLabeledObject(identifier, name); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1024 | ASSERT(object != nullptr); |
| 1025 | |
| 1026 | const std::string &objectLabel = object->getLabel(); |
| 1027 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 1028 | } |
| 1029 | |
| 1030 | void Context::getObjectPtrLabel(const void *ptr, |
| 1031 | GLsizei bufSize, |
| 1032 | GLsizei *length, |
| 1033 | GLchar *label) const |
| 1034 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1035 | gl::LabeledObject *object = getLabeledObjectFromPtr(ptr); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1036 | ASSERT(object != nullptr); |
| 1037 | |
| 1038 | const std::string &objectLabel = object->getLabel(); |
| 1039 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 1040 | } |
| 1041 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1042 | bool Context::isSampler(GLuint samplerName) const |
| 1043 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1044 | return mState.mSamplerManager->isSampler(samplerName); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1045 | } |
| 1046 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1047 | void Context::bindTexture(TextureType target, GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1048 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1049 | Texture *texture = nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1050 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 1051 | if (handle == 0) |
| 1052 | { |
| 1053 | texture = mZeroTextures[target].get(); |
| 1054 | } |
| 1055 | else |
| 1056 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1057 | texture = |
| 1058 | mState.mTextureManager->checkTextureAllocation(mImplementation.get(), handle, target); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 1059 | } |
| 1060 | |
| 1061 | ASSERT(texture); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1062 | mState.setSamplerTexture(this, target, texture); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1063 | mStateCache.onActiveTextureChange(this); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 1064 | } |
| 1065 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1066 | void Context::bindReadFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1067 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1068 | Framebuffer *framebuffer = mState.mFramebufferManager->checkFramebufferAllocation( |
| 1069 | mImplementation.get(), mState.mCaps, framebufferHandle); |
| 1070 | mState.setReadFramebufferBinding(framebuffer); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1071 | mReadFramebufferObserverBinding.bind(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1072 | } |
| 1073 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1074 | void Context::bindDrawFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1075 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1076 | Framebuffer *framebuffer = mState.mFramebufferManager->checkFramebufferAllocation( |
| 1077 | mImplementation.get(), mState.mCaps, framebufferHandle); |
| 1078 | mState.setDrawFramebufferBinding(framebuffer); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1079 | mDrawFramebufferObserverBinding.bind(framebuffer); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1080 | mStateCache.onDrawFramebufferChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1081 | } |
| 1082 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1083 | void Context::bindVertexArray(GLuint vertexArrayHandle) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1084 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1085 | VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1086 | mState.setVertexArrayBinding(this, vertexArray); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1087 | mVertexArrayObserverBinding.bind(vertexArray); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1088 | mStateCache.onVertexArrayBindingChange(this); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1089 | } |
| 1090 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1091 | void Context::bindVertexBuffer(GLuint bindingIndex, |
| 1092 | GLuint bufferHandle, |
| 1093 | GLintptr offset, |
| 1094 | GLsizei stride) |
| 1095 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1096 | Buffer *buffer = |
| 1097 | mState.mBufferManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
| 1098 | mState.bindVertexBuffer(this, bindingIndex, buffer, offset, stride); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1099 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1100 | } |
| 1101 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1102 | void Context::bindSampler(GLuint textureUnit, GLuint samplerHandle) |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1103 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1104 | ASSERT(textureUnit < mState.mCaps.maxCombinedTextureImageUnits); |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1105 | Sampler *sampler = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1106 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), samplerHandle); |
| 1107 | mState.setSamplerBinding(this, textureUnit, sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 1108 | mSamplerObserverBindings[textureUnit].bind(sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1109 | } |
| 1110 | |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1111 | void Context::bindImageTexture(GLuint unit, |
| 1112 | GLuint texture, |
| 1113 | GLint level, |
| 1114 | GLboolean layered, |
| 1115 | GLint layer, |
| 1116 | GLenum access, |
| 1117 | GLenum format) |
| 1118 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1119 | Texture *tex = mState.mTextureManager->getTexture(texture); |
| 1120 | mState.setImageUnit(this, unit, tex, level, layered, layer, access, format); |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1121 | } |
| 1122 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1123 | void Context::useProgram(GLuint program) |
| 1124 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1125 | ANGLE_CONTEXT_TRY(mState.setProgram(this, getProgramResolveLink(program))); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1126 | mStateCache.onProgramExecutableChange(this); |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 1127 | } |
| 1128 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 1129 | void Context::useProgramStages(GLuint pipeline, GLbitfield stages, GLuint program) |
| 1130 | { |
| 1131 | UNIMPLEMENTED(); |
| 1132 | } |
| 1133 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1134 | void Context::bindTransformFeedback(GLenum target, GLuint transformFeedbackHandle) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1135 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1136 | ASSERT(target == GL_TRANSFORM_FEEDBACK); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1137 | TransformFeedback *transformFeedback = |
| 1138 | checkTransformFeedbackAllocation(transformFeedbackHandle); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1139 | mState.setTransformFeedbackBinding(this, transformFeedback); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1140 | } |
| 1141 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1142 | void Context::bindProgramPipeline(GLuint pipelineHandle) |
| 1143 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1144 | ProgramPipeline *pipeline = mState.mProgramPipelineManager->checkProgramPipelineAllocation( |
| 1145 | mImplementation.get(), pipelineHandle); |
| 1146 | mState.setProgramPipelineBinding(this, pipeline); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1147 | } |
| 1148 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1149 | void Context::beginQuery(QueryType target, GLuint query) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1150 | { |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1151 | Query *queryObject = getQuery(query, true, target); |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1152 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1153 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1154 | // begin query |
Jamie Madill | 5188a27 | 2018-07-25 10:53:56 -0400 | [diff] [blame] | 1155 | ANGLE_CONTEXT_TRY(queryObject->begin(this)); |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1156 | |
| 1157 | // set query as active for specified target only if begin succeeded |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1158 | mState.setActiveQuery(this, target, queryObject); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1159 | mStateCache.onQueryChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1160 | } |
| 1161 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1162 | void Context::endQuery(QueryType target) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1163 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1164 | Query *queryObject = mState.getActiveQuery(target); |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1165 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1166 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1167 | // Intentionally don't call try here. We don't want an early return. |
| 1168 | (void)(queryObject->end(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1169 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1170 | // 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] | 1171 | mState.setActiveQuery(this, target, nullptr); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1172 | mStateCache.onQueryChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1173 | } |
| 1174 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1175 | void Context::queryCounter(GLuint id, QueryType target) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1176 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1177 | ASSERT(target == QueryType::Timestamp); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1178 | |
| 1179 | Query *queryObject = getQuery(id, true, target); |
| 1180 | ASSERT(queryObject); |
| 1181 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1182 | ANGLE_CONTEXT_TRY(queryObject->queryCounter(this)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1183 | } |
| 1184 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1185 | void Context::getQueryiv(QueryType target, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1186 | { |
| 1187 | switch (pname) |
| 1188 | { |
| 1189 | case GL_CURRENT_QUERY_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1190 | params[0] = mState.getActiveQueryId(target); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1191 | break; |
| 1192 | case GL_QUERY_COUNTER_BITS_EXT: |
| 1193 | switch (target) |
| 1194 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1195 | case QueryType::TimeElapsed: |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1196 | params[0] = getExtensions().queryCounterBitsTimeElapsed; |
| 1197 | break; |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1198 | case QueryType::Timestamp: |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1199 | params[0] = getExtensions().queryCounterBitsTimestamp; |
| 1200 | break; |
| 1201 | default: |
| 1202 | UNREACHABLE(); |
| 1203 | params[0] = 0; |
| 1204 | break; |
| 1205 | } |
| 1206 | break; |
| 1207 | default: |
| 1208 | UNREACHABLE(); |
| 1209 | return; |
| 1210 | } |
| 1211 | } |
| 1212 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1213 | void Context::getQueryivRobust(QueryType target, |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1214 | GLenum pname, |
| 1215 | GLsizei bufSize, |
| 1216 | GLsizei *length, |
| 1217 | GLint *params) |
| 1218 | { |
| 1219 | getQueryiv(target, pname, params); |
| 1220 | } |
| 1221 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1222 | void Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1223 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1224 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1225 | } |
| 1226 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1227 | void Context::getQueryObjectivRobust(GLuint id, |
| 1228 | GLenum pname, |
| 1229 | GLsizei bufSize, |
| 1230 | GLsizei *length, |
| 1231 | GLint *params) |
| 1232 | { |
| 1233 | getQueryObjectiv(id, pname, params); |
| 1234 | } |
| 1235 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1236 | void Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1237 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1238 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1239 | } |
| 1240 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1241 | void Context::getQueryObjectuivRobust(GLuint id, |
| 1242 | GLenum pname, |
| 1243 | GLsizei bufSize, |
| 1244 | GLsizei *length, |
| 1245 | GLuint *params) |
| 1246 | { |
| 1247 | getQueryObjectuiv(id, pname, params); |
| 1248 | } |
| 1249 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1250 | void Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1251 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1252 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1253 | } |
| 1254 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1255 | void Context::getQueryObjecti64vRobust(GLuint id, |
| 1256 | GLenum pname, |
| 1257 | GLsizei bufSize, |
| 1258 | GLsizei *length, |
| 1259 | GLint64 *params) |
| 1260 | { |
| 1261 | getQueryObjecti64v(id, pname, params); |
| 1262 | } |
| 1263 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1264 | void Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1265 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1266 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1267 | } |
| 1268 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1269 | void Context::getQueryObjectui64vRobust(GLuint id, |
| 1270 | GLenum pname, |
| 1271 | GLsizei bufSize, |
| 1272 | GLsizei *length, |
| 1273 | GLuint64 *params) |
| 1274 | { |
| 1275 | getQueryObjectui64v(id, pname, params); |
| 1276 | } |
| 1277 | |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1278 | Framebuffer *Context::getFramebuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1279 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1280 | return mState.mFramebufferManager->getFramebuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1281 | } |
| 1282 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1283 | FenceNV *Context::getFenceNV(GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1284 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1285 | return mFenceNVMap.query(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1286 | } |
| 1287 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1288 | Query *Context::getQuery(GLuint handle, bool create, QueryType type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1289 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1290 | if (!mQueryMap.contains(handle)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1291 | { |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 1292 | return nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1293 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1294 | |
| 1295 | Query *query = mQueryMap.query(handle); |
| 1296 | if (!query && create) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1297 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1298 | ASSERT(type != QueryType::InvalidEnum); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1299 | query = new Query(mImplementation->createQuery(type), handle); |
| 1300 | query->addRef(); |
| 1301 | mQueryMap.assign(handle, query); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1302 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1303 | return query; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1304 | } |
| 1305 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1306 | Query *Context::getQuery(GLuint handle) const |
| 1307 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1308 | return mQueryMap.query(handle); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1309 | } |
| 1310 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1311 | Texture *Context::getTargetTexture(TextureType type) const |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 1312 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1313 | ASSERT(ValidTextureTarget(this, type) || ValidTextureExternalTarget(this, type)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1314 | return mState.getTargetTexture(type); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1315 | } |
| 1316 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1317 | Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1318 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1319 | return mState.getSamplerTexture(sampler, type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1320 | } |
| 1321 | |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1322 | Compiler *Context::getCompiler() const |
| 1323 | { |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1324 | if (mCompiler.get() == nullptr) |
| 1325 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1326 | mCompiler.set(this, new Compiler(mImplementation.get(), mState)); |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1327 | } |
| 1328 | return mCompiler.get(); |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1329 | } |
| 1330 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1331 | void Context::getBooleanvImpl(GLenum pname, GLboolean *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1332 | { |
| 1333 | switch (pname) |
| 1334 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1335 | case GL_SHADER_COMPILER: |
| 1336 | *params = GL_TRUE; |
| 1337 | break; |
| 1338 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 1339 | *params = mRobustAccess ? GL_TRUE : GL_FALSE; |
| 1340 | break; |
Jeff Gilbert | 465d609 | 2019-01-02 16:21:18 -0800 | [diff] [blame^] | 1341 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1342 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1343 | mState.getBooleanv(pname, params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1344 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1345 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1346 | } |
| 1347 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1348 | void Context::getFloatvImpl(GLenum pname, GLfloat *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1349 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1350 | // Queries about context capabilities and maximums are answered by Context. |
| 1351 | // Queries about current GL state values are answered by State. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1352 | switch (pname) |
| 1353 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1354 | case GL_ALIASED_LINE_WIDTH_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1355 | params[0] = mState.mCaps.minAliasedLineWidth; |
| 1356 | params[1] = mState.mCaps.maxAliasedLineWidth; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1357 | break; |
| 1358 | case GL_ALIASED_POINT_SIZE_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1359 | params[0] = mState.mCaps.minAliasedPointSize; |
| 1360 | params[1] = mState.mCaps.maxAliasedPointSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1361 | break; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 1362 | case GL_SMOOTH_POINT_SIZE_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1363 | params[0] = mState.mCaps.minSmoothPointSize; |
| 1364 | params[1] = mState.mCaps.maxSmoothPointSize; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 1365 | break; |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 1366 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1367 | params[0] = mState.mCaps.minSmoothLineWidth; |
| 1368 | params[1] = mState.mCaps.maxSmoothLineWidth; |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 1369 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1370 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1371 | ASSERT(mState.mExtensions.textureFilterAnisotropic); |
| 1372 | *params = mState.mExtensions.maxTextureAnisotropy; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1373 | break; |
| 1374 | case GL_MAX_TEXTURE_LOD_BIAS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1375 | *params = mState.mCaps.maxLODBias; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1376 | break; |
| 1377 | |
| 1378 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 1379 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 1380 | { |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1381 | // GLES1 emulation: // GL_PATH_(MODELVIEW|PROJECTION)_MATRIX_CHROMIUM collides with the |
| 1382 | // GLES1 constants for modelview/projection matrix. |
| 1383 | if (getClientVersion() < Version(2, 0)) |
| 1384 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1385 | mState.getFloatv(pname, params); |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1386 | } |
| 1387 | else |
| 1388 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1389 | ASSERT(mState.mExtensions.pathRendering); |
| 1390 | const GLfloat *m = mState.getPathRenderingMatrix(pname); |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1391 | memcpy(params, m, 16 * sizeof(GLfloat)); |
| 1392 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1393 | } |
Geoff Lang | e6d4e12 | 2015-06-29 13:33:55 -0400 | [diff] [blame] | 1394 | break; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1395 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1396 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1397 | mState.getFloatv(pname, params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1398 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1399 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1400 | } |
| 1401 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1402 | void Context::getIntegervImpl(GLenum pname, GLint *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1403 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1404 | // Queries about context capabilities and maximums are answered by Context. |
| 1405 | // 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] | 1406 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1407 | switch (pname) |
| 1408 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1409 | case GL_MAX_VERTEX_ATTRIBS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1410 | *params = mState.mCaps.maxVertexAttributes; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1411 | break; |
| 1412 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1413 | *params = mState.mCaps.maxVertexUniformVectors; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1414 | break; |
| 1415 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1416 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1417 | break; |
| 1418 | case GL_MAX_VARYING_VECTORS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1419 | *params = mState.mCaps.maxVaryingVectors; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1420 | break; |
| 1421 | case GL_MAX_VARYING_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1422 | *params = mState.mCaps.maxVertexOutputComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1423 | break; |
| 1424 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1425 | *params = mState.mCaps.maxCombinedTextureImageUnits; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1426 | break; |
| 1427 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1428 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1429 | break; |
| 1430 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1431 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1432 | break; |
| 1433 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1434 | *params = mState.mCaps.maxFragmentUniformVectors; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1435 | break; |
| 1436 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1437 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1438 | break; |
| 1439 | case GL_MAX_RENDERBUFFER_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1440 | *params = mState.mCaps.maxRenderbufferSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1441 | break; |
| 1442 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1443 | *params = mState.mCaps.maxColorAttachments; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1444 | break; |
| 1445 | case GL_MAX_DRAW_BUFFERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1446 | *params = mState.mCaps.maxDrawBuffers; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1447 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1448 | case GL_SUBPIXEL_BITS: |
| 1449 | *params = 4; |
| 1450 | break; |
| 1451 | case GL_MAX_TEXTURE_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1452 | *params = mState.mCaps.max2DTextureSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1453 | break; |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1454 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1455 | *params = mState.mCaps.maxRectangleTextureSize; |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1456 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1457 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1458 | *params = mState.mCaps.maxCubeMapTextureSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1459 | break; |
| 1460 | case GL_MAX_3D_TEXTURE_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1461 | *params = mState.mCaps.max3DTextureSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1462 | break; |
| 1463 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1464 | *params = mState.mCaps.maxArrayTextureLayers; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1465 | break; |
| 1466 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1467 | *params = mState.mCaps.uniformBufferOffsetAlignment; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1468 | break; |
| 1469 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1470 | *params = mState.mCaps.maxUniformBufferBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1471 | break; |
| 1472 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1473 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1474 | break; |
| 1475 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1476 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1477 | break; |
| 1478 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1479 | *params = mState.mCaps.maxCombinedTextureImageUnits; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1480 | break; |
| 1481 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1482 | *params = mState.mCaps.maxVertexOutputComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1483 | break; |
| 1484 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1485 | *params = mState.mCaps.maxFragmentInputComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1486 | break; |
| 1487 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1488 | *params = mState.mCaps.minProgramTexelOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1489 | break; |
| 1490 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1491 | *params = mState.mCaps.maxProgramTexelOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1492 | break; |
| 1493 | case GL_MAJOR_VERSION: |
| 1494 | *params = getClientVersion().major; |
| 1495 | break; |
| 1496 | case GL_MINOR_VERSION: |
| 1497 | *params = getClientVersion().minor; |
| 1498 | break; |
| 1499 | case GL_MAX_ELEMENTS_INDICES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1500 | *params = mState.mCaps.maxElementsIndices; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1501 | break; |
| 1502 | case GL_MAX_ELEMENTS_VERTICES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1503 | *params = mState.mCaps.maxElementsVertices; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1504 | break; |
| 1505 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1506 | *params = mState.mCaps.maxTransformFeedbackInterleavedComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1507 | break; |
| 1508 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1509 | *params = mState.mCaps.maxTransformFeedbackSeparateAttributes; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1510 | break; |
| 1511 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1512 | *params = mState.mCaps.maxTransformFeedbackSeparateComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1513 | break; |
| 1514 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1515 | *params = static_cast<GLint>(mState.mCaps.compressedTextureFormats.size()); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1516 | break; |
| 1517 | case GL_MAX_SAMPLES_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1518 | *params = mState.mCaps.maxSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1519 | break; |
| 1520 | case GL_MAX_VIEWPORT_DIMS: |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1521 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1522 | params[0] = mState.mCaps.maxViewportWidth; |
| 1523 | params[1] = mState.mCaps.maxViewportHeight; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1524 | } |
| 1525 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1526 | case GL_COMPRESSED_TEXTURE_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1527 | std::copy(mState.mCaps.compressedTextureFormats.begin(), |
| 1528 | mState.mCaps.compressedTextureFormats.end(), params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1529 | break; |
| 1530 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 1531 | *params = mResetStrategy; |
| 1532 | break; |
| 1533 | case GL_NUM_SHADER_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1534 | *params = static_cast<GLint>(mState.mCaps.shaderBinaryFormats.size()); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1535 | break; |
| 1536 | case GL_SHADER_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1537 | std::copy(mState.mCaps.shaderBinaryFormats.begin(), |
| 1538 | mState.mCaps.shaderBinaryFormats.end(), params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1539 | break; |
| 1540 | case GL_NUM_PROGRAM_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1541 | *params = static_cast<GLint>(mState.mCaps.programBinaryFormats.size()); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1542 | break; |
| 1543 | case GL_PROGRAM_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1544 | std::copy(mState.mCaps.programBinaryFormats.begin(), |
| 1545 | mState.mCaps.programBinaryFormats.end(), params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1546 | break; |
| 1547 | case GL_NUM_EXTENSIONS: |
| 1548 | *params = static_cast<GLint>(mExtensionStrings.size()); |
| 1549 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1550 | |
Geoff Lang | 38f24ee | 2018-10-01 13:04:59 -0400 | [diff] [blame] | 1551 | // GL_ANGLE_request_extension |
| 1552 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 1553 | *params = static_cast<GLint>(mRequestableExtensionStrings.size()); |
| 1554 | break; |
| 1555 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1556 | // GL_KHR_debug |
| 1557 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1558 | *params = mState.mExtensions.maxDebugMessageLength; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1559 | break; |
| 1560 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1561 | *params = mState.mExtensions.maxDebugLoggedMessages; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1562 | break; |
| 1563 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1564 | *params = mState.mExtensions.maxDebugGroupStackDepth; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1565 | break; |
| 1566 | case GL_MAX_LABEL_LENGTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1567 | *params = mState.mExtensions.maxLabelLength; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1568 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1569 | |
Martin Radev | e5285d2 | 2017-07-14 16:23:53 +0300 | [diff] [blame] | 1570 | // GL_ANGLE_multiview |
| 1571 | case GL_MAX_VIEWS_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1572 | *params = mState.mExtensions.maxViews; |
Martin Radev | e5285d2 | 2017-07-14 16:23:53 +0300 | [diff] [blame] | 1573 | break; |
| 1574 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1575 | // GL_EXT_disjoint_timer_query |
| 1576 | case GL_GPU_DISJOINT_EXT: |
| 1577 | *params = mImplementation->getGPUDisjoint(); |
| 1578 | break; |
| 1579 | case GL_MAX_FRAMEBUFFER_WIDTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1580 | *params = mState.mCaps.maxFramebufferWidth; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1581 | break; |
| 1582 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1583 | *params = mState.mCaps.maxFramebufferHeight; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1584 | break; |
| 1585 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1586 | *params = mState.mCaps.maxFramebufferSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1587 | break; |
| 1588 | case GL_MAX_SAMPLE_MASK_WORDS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1589 | *params = mState.mCaps.maxSampleMaskWords; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1590 | break; |
| 1591 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1592 | *params = mState.mCaps.maxColorTextureSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1593 | break; |
| 1594 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1595 | *params = mState.mCaps.maxDepthTextureSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1596 | break; |
| 1597 | case GL_MAX_INTEGER_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1598 | *params = mState.mCaps.maxIntegerSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1599 | break; |
| 1600 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1601 | *params = mState.mCaps.maxVertexAttribRelativeOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1602 | break; |
| 1603 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1604 | *params = mState.mCaps.maxVertexAttribBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1605 | break; |
| 1606 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1607 | *params = mState.mCaps.maxVertexAttribStride; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1608 | break; |
| 1609 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1610 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1611 | break; |
| 1612 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1613 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1614 | break; |
| 1615 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1616 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1617 | break; |
| 1618 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1619 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1620 | break; |
| 1621 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1622 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1623 | break; |
| 1624 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1625 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1626 | break; |
| 1627 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1628 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1629 | break; |
| 1630 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1631 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1632 | break; |
| 1633 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1634 | *params = mState.mCaps.minProgramTextureGatherOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1635 | break; |
| 1636 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1637 | *params = mState.mCaps.maxProgramTextureGatherOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1638 | break; |
| 1639 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1640 | *params = mState.mCaps.maxComputeWorkGroupInvocations; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1641 | break; |
| 1642 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1643 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1644 | break; |
| 1645 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1646 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1647 | break; |
| 1648 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1649 | *params = mState.mCaps.maxComputeSharedMemorySize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1650 | break; |
| 1651 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1652 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1653 | break; |
| 1654 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1655 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1656 | break; |
| 1657 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1658 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1659 | break; |
| 1660 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1661 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1662 | break; |
| 1663 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1664 | *params = static_cast<GLint>( |
| 1665 | mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Compute]); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1666 | break; |
| 1667 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1668 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1669 | break; |
| 1670 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1671 | *params = mState.mCaps.maxCombinedShaderOutputResources; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1672 | break; |
| 1673 | case GL_MAX_UNIFORM_LOCATIONS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1674 | *params = mState.mCaps.maxUniformLocations; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1675 | break; |
| 1676 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1677 | *params = mState.mCaps.maxAtomicCounterBufferBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1678 | break; |
| 1679 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1680 | *params = mState.mCaps.maxAtomicCounterBufferSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1681 | break; |
| 1682 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1683 | *params = mState.mCaps.maxCombinedAtomicCounterBuffers; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1684 | break; |
| 1685 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1686 | *params = mState.mCaps.maxCombinedAtomicCounters; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1687 | break; |
| 1688 | case GL_MAX_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1689 | *params = mState.mCaps.maxImageUnits; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1690 | break; |
| 1691 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1692 | *params = mState.mCaps.maxCombinedImageUniforms; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1693 | break; |
| 1694 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1695 | *params = mState.mCaps.maxShaderStorageBufferBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1696 | break; |
| 1697 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1698 | *params = mState.mCaps.maxCombinedShaderStorageBlocks; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1699 | break; |
| 1700 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1701 | *params = mState.mCaps.shaderStorageBufferOffsetAlignment; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1702 | break; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1703 | |
| 1704 | // GL_EXT_geometry_shader |
| 1705 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1706 | *params = mState.mCaps.maxFramebufferLayers; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1707 | break; |
| 1708 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1709 | *params = mState.mCaps.layerProvokingVertex; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1710 | break; |
| 1711 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1712 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1713 | break; |
| 1714 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1715 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1716 | break; |
| 1717 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1718 | *params = static_cast<GLint>( |
| 1719 | mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Geometry]); |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1720 | break; |
| 1721 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1722 | *params = mState.mCaps.maxGeometryInputComponents; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1723 | break; |
| 1724 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1725 | *params = mState.mCaps.maxGeometryOutputComponents; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1726 | break; |
| 1727 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1728 | *params = mState.mCaps.maxGeometryOutputVertices; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1729 | break; |
| 1730 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1731 | *params = mState.mCaps.maxGeometryTotalOutputComponents; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1732 | break; |
| 1733 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1734 | *params = mState.mCaps.maxGeometryShaderInvocations; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1735 | break; |
| 1736 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1737 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1738 | break; |
| 1739 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1740 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1741 | break; |
| 1742 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1743 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1744 | break; |
| 1745 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1746 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1747 | break; |
| 1748 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1749 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1750 | break; |
Lingfeng Yang | 96310cd | 2018-03-28 11:56:28 -0700 | [diff] [blame] | 1751 | // GLES1 emulation: Caps queries |
| 1752 | case GL_MAX_TEXTURE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1753 | *params = mState.mCaps.maxMultitextureUnits; |
Lingfeng Yang | 96310cd | 2018-03-28 11:56:28 -0700 | [diff] [blame] | 1754 | break; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1755 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1756 | *params = mState.mCaps.maxModelviewMatrixStackDepth; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1757 | break; |
| 1758 | case GL_MAX_PROJECTION_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1759 | *params = mState.mCaps.maxProjectionMatrixStackDepth; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1760 | break; |
| 1761 | case GL_MAX_TEXTURE_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1762 | *params = mState.mCaps.maxTextureMatrixStackDepth; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1763 | break; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 1764 | case GL_MAX_LIGHTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1765 | *params = mState.mCaps.maxLights; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 1766 | break; |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 1767 | case GL_MAX_CLIP_PLANES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1768 | *params = mState.mCaps.maxClipPlanes; |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 1769 | break; |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 1770 | // GLES1 emulation: Vertex attribute queries |
| 1771 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 1772 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 1773 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 1774 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
| 1775 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 1776 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1777 | GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, params); |
| 1778 | break; |
| 1779 | case GL_VERTEX_ARRAY_STRIDE: |
| 1780 | case GL_NORMAL_ARRAY_STRIDE: |
| 1781 | case GL_COLOR_ARRAY_STRIDE: |
| 1782 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 1783 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 1784 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1785 | GL_VERTEX_ATTRIB_ARRAY_STRIDE, params); |
| 1786 | break; |
| 1787 | case GL_VERTEX_ARRAY_SIZE: |
| 1788 | case GL_COLOR_ARRAY_SIZE: |
| 1789 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 1790 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1791 | GL_VERTEX_ATTRIB_ARRAY_SIZE, params); |
| 1792 | break; |
| 1793 | case GL_VERTEX_ARRAY_TYPE: |
| 1794 | case GL_COLOR_ARRAY_TYPE: |
| 1795 | case GL_NORMAL_ARRAY_TYPE: |
| 1796 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 1797 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 1798 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1799 | GL_VERTEX_ATTRIB_ARRAY_TYPE, params); |
| 1800 | break; |
| 1801 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 1802 | // GL_KHR_parallel_shader_compile |
| 1803 | case GL_MAX_SHADER_COMPILER_THREADS_KHR: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1804 | *params = mState.getMaxShaderCompilerThreads(); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 1805 | break; |
| 1806 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 1807 | // GL_EXT_blend_func_extended |
| 1808 | case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1809 | *params = mState.mExtensions.maxDualSourceDrawBuffers; |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 1810 | break; |
| 1811 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1812 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1813 | ANGLE_CONTEXT_TRY(mState.getIntegerv(this, pname, params)); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1814 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1815 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1816 | } |
| 1817 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 1818 | void Context::getInteger64vImpl(GLenum pname, GLint64 *params) |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1819 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1820 | // Queries about context capabilities and maximums are answered by Context. |
| 1821 | // Queries about current GL state values are answered by State. |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1822 | switch (pname) |
| 1823 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1824 | case GL_MAX_ELEMENT_INDEX: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1825 | *params = mState.mCaps.maxElementIndex; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1826 | break; |
| 1827 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1828 | *params = mState.mCaps.maxUniformBlockSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1829 | break; |
| 1830 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1831 | *params = mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1832 | break; |
| 1833 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1834 | *params = mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1835 | break; |
| 1836 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1837 | *params = mState.mCaps.maxServerWaitTimeout; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1838 | break; |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 1839 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1840 | // GL_EXT_disjoint_timer_query |
| 1841 | case GL_TIMESTAMP_EXT: |
| 1842 | *params = mImplementation->getTimestamp(); |
| 1843 | break; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1844 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1845 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1846 | *params = mState.mCaps.maxShaderStorageBlockSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1847 | break; |
| 1848 | default: |
| 1849 | UNREACHABLE(); |
| 1850 | break; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1851 | } |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1852 | } |
| 1853 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1854 | void Context::getPointerv(GLenum pname, void **params) const |
| 1855 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1856 | mState.getPointerv(this, pname, params); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1857 | } |
| 1858 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 1859 | void Context::getPointervRobustANGLERobust(GLenum pname, |
| 1860 | GLsizei bufSize, |
| 1861 | GLsizei *length, |
| 1862 | void **params) |
| 1863 | { |
| 1864 | UNIMPLEMENTED(); |
| 1865 | } |
| 1866 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1867 | void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1868 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1869 | // Queries about context capabilities and maximums are answered by Context. |
| 1870 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1871 | |
| 1872 | GLenum nativeType; |
| 1873 | unsigned int numParams; |
| 1874 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1875 | ASSERT(queryStatus); |
| 1876 | |
| 1877 | if (nativeType == GL_INT) |
| 1878 | { |
| 1879 | switch (target) |
| 1880 | { |
| 1881 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 1882 | ASSERT(index < 3u); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1883 | *data = mState.mCaps.maxComputeWorkGroupCount[index]; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1884 | break; |
| 1885 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 1886 | ASSERT(index < 3u); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1887 | *data = mState.mCaps.maxComputeWorkGroupSize[index]; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1888 | break; |
| 1889 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1890 | mState.getIntegeri_v(target, index, data); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1891 | } |
| 1892 | } |
| 1893 | else |
| 1894 | { |
| 1895 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1896 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1897 | } |
| 1898 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1899 | void Context::getIntegeri_vRobust(GLenum target, |
| 1900 | GLuint index, |
| 1901 | GLsizei bufSize, |
| 1902 | GLsizei *length, |
| 1903 | GLint *data) |
| 1904 | { |
| 1905 | getIntegeri_v(target, index, data); |
| 1906 | } |
| 1907 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1908 | void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1909 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1910 | // Queries about context capabilities and maximums are answered by Context. |
| 1911 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1912 | |
| 1913 | GLenum nativeType; |
| 1914 | unsigned int numParams; |
| 1915 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1916 | ASSERT(queryStatus); |
| 1917 | |
| 1918 | if (nativeType == GL_INT_64_ANGLEX) |
| 1919 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1920 | mState.getInteger64i_v(target, index, data); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1921 | } |
| 1922 | else |
| 1923 | { |
| 1924 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1925 | } |
| 1926 | } |
| 1927 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1928 | void Context::getInteger64i_vRobust(GLenum target, |
| 1929 | GLuint index, |
| 1930 | GLsizei bufSize, |
| 1931 | GLsizei *length, |
| 1932 | GLint64 *data) |
| 1933 | { |
| 1934 | getInteger64i_v(target, index, data); |
| 1935 | } |
| 1936 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1937 | void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data) |
| 1938 | { |
| 1939 | // Queries about context capabilities and maximums are answered by Context. |
| 1940 | // Queries about current GL state values are answered by State. |
| 1941 | |
| 1942 | GLenum nativeType; |
| 1943 | unsigned int numParams; |
| 1944 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1945 | ASSERT(queryStatus); |
| 1946 | |
| 1947 | if (nativeType == GL_BOOL) |
| 1948 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1949 | mState.getBooleani_v(target, index, data); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1950 | } |
| 1951 | else |
| 1952 | { |
| 1953 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1954 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1955 | } |
| 1956 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1957 | void Context::getBooleani_vRobust(GLenum target, |
| 1958 | GLuint index, |
| 1959 | GLsizei bufSize, |
| 1960 | GLsizei *length, |
| 1961 | GLboolean *data) |
| 1962 | { |
| 1963 | getBooleani_v(target, index, data); |
| 1964 | } |
| 1965 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 1966 | void Context::getBufferParameteriv(BufferBinding target, GLenum pname, GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1967 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1968 | Buffer *buffer = mState.getTargetBuffer(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1969 | QueryBufferParameteriv(buffer, pname, params); |
| 1970 | } |
| 1971 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1972 | void Context::getBufferParameterivRobust(BufferBinding target, |
| 1973 | GLenum pname, |
| 1974 | GLsizei bufSize, |
| 1975 | GLsizei *length, |
| 1976 | GLint *params) |
| 1977 | { |
| 1978 | getBufferParameteriv(target, pname, params); |
| 1979 | } |
| 1980 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1981 | void Context::getFramebufferAttachmentParameteriv(GLenum target, |
| 1982 | GLenum attachment, |
| 1983 | GLenum pname, |
| 1984 | GLint *params) |
| 1985 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1986 | const Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 1987 | QueryFramebufferAttachmentParameteriv(this, framebuffer, attachment, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1988 | } |
| 1989 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1990 | void Context::getFramebufferAttachmentParameterivRobust(GLenum target, |
| 1991 | GLenum attachment, |
| 1992 | GLenum pname, |
| 1993 | GLsizei bufSize, |
| 1994 | GLsizei *length, |
| 1995 | GLint *params) |
| 1996 | { |
| 1997 | getFramebufferAttachmentParameteriv(target, attachment, pname, params); |
| 1998 | } |
| 1999 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2000 | void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 2001 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2002 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2003 | QueryRenderbufferiv(this, renderbuffer, pname, params); |
| 2004 | } |
| 2005 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2006 | void Context::getRenderbufferParameterivRobust(GLenum target, |
| 2007 | GLenum pname, |
| 2008 | GLsizei bufSize, |
| 2009 | GLsizei *length, |
| 2010 | GLint *params) |
| 2011 | { |
| 2012 | getRenderbufferParameteriv(target, pname, params); |
| 2013 | } |
| 2014 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2015 | void Context::getTexParameterfv(TextureType target, GLenum pname, GLfloat *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2016 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2017 | const Texture *const texture = getTargetTexture(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2018 | QueryTexParameterfv(texture, pname, params); |
| 2019 | } |
| 2020 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2021 | void Context::getTexParameterfvRobust(TextureType target, |
| 2022 | GLenum pname, |
| 2023 | GLsizei bufSize, |
| 2024 | GLsizei *length, |
| 2025 | GLfloat *params) |
| 2026 | { |
| 2027 | getTexParameterfv(target, pname, params); |
| 2028 | } |
| 2029 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2030 | void Context::getTexParameteriv(TextureType target, GLenum pname, GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2031 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2032 | const Texture *const texture = getTargetTexture(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2033 | QueryTexParameteriv(texture, pname, params); |
| 2034 | } |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2035 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2036 | void Context::getTexParameterIiv(TextureType target, GLenum pname, GLint *params) |
| 2037 | { |
| 2038 | const Texture *const texture = getTargetTexture(target); |
| 2039 | QueryTexParameterIiv(texture, pname, params); |
| 2040 | } |
| 2041 | |
| 2042 | void Context::getTexParameterIuiv(TextureType target, GLenum pname, GLuint *params) |
| 2043 | { |
| 2044 | const Texture *const texture = getTargetTexture(target); |
| 2045 | QueryTexParameterIuiv(texture, pname, params); |
| 2046 | } |
| 2047 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2048 | void Context::getTexParameterivRobust(TextureType target, |
| 2049 | GLenum pname, |
| 2050 | GLsizei bufSize, |
| 2051 | GLsizei *length, |
| 2052 | GLint *params) |
| 2053 | { |
| 2054 | getTexParameteriv(target, pname, params); |
| 2055 | } |
| 2056 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2057 | void Context::getTexParameterIivRobust(TextureType target, |
| 2058 | GLenum pname, |
| 2059 | GLsizei bufSize, |
| 2060 | GLsizei *length, |
| 2061 | GLint *params) |
| 2062 | { |
| 2063 | UNIMPLEMENTED(); |
| 2064 | } |
| 2065 | |
| 2066 | void Context::getTexParameterIuivRobust(TextureType target, |
| 2067 | GLenum pname, |
| 2068 | GLsizei bufSize, |
| 2069 | GLsizei *length, |
| 2070 | GLuint *params) |
| 2071 | { |
| 2072 | UNIMPLEMENTED(); |
| 2073 | } |
| 2074 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2075 | void Context::getTexLevelParameteriv(TextureTarget target, GLint level, GLenum pname, GLint *params) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2076 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2077 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 2078 | QueryTexLevelParameteriv(texture, target, level, pname, params); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2079 | } |
| 2080 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2081 | void Context::getTexLevelParameterivRobust(TextureTarget target, |
| 2082 | GLint level, |
| 2083 | GLenum pname, |
| 2084 | GLsizei bufSize, |
| 2085 | GLsizei *length, |
| 2086 | GLint *params) |
| 2087 | { |
| 2088 | UNIMPLEMENTED(); |
| 2089 | } |
| 2090 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2091 | void Context::getTexLevelParameterfv(TextureTarget target, |
| 2092 | GLint level, |
| 2093 | GLenum pname, |
| 2094 | GLfloat *params) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2095 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2096 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 2097 | QueryTexLevelParameterfv(texture, target, level, pname, params); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2098 | } |
| 2099 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2100 | void Context::getTexLevelParameterfvRobust(TextureTarget target, |
| 2101 | GLint level, |
| 2102 | GLenum pname, |
| 2103 | GLsizei bufSize, |
| 2104 | GLsizei *length, |
| 2105 | GLfloat *params) |
| 2106 | { |
| 2107 | UNIMPLEMENTED(); |
| 2108 | } |
| 2109 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2110 | void Context::texParameterf(TextureType target, GLenum pname, GLfloat param) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2111 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2112 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2113 | SetTexParameterf(this, texture, pname, param); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2114 | } |
| 2115 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2116 | void Context::texParameterfv(TextureType target, GLenum pname, const GLfloat *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2117 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2118 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2119 | SetTexParameterfv(this, texture, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2120 | } |
| 2121 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2122 | void Context::texParameterfvRobust(TextureType target, |
| 2123 | GLenum pname, |
| 2124 | GLsizei bufSize, |
| 2125 | const GLfloat *params) |
| 2126 | { |
| 2127 | texParameterfv(target, pname, params); |
| 2128 | } |
| 2129 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2130 | void Context::texParameteri(TextureType target, GLenum pname, GLint param) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2131 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2132 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2133 | SetTexParameteri(this, texture, pname, param); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2134 | } |
| 2135 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2136 | void Context::texParameteriv(TextureType target, GLenum pname, const GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2137 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2138 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2139 | SetTexParameteriv(this, texture, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2140 | } |
| 2141 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2142 | void Context::texParameterIiv(TextureType target, GLenum pname, const GLint *params) |
| 2143 | { |
| 2144 | Texture *const texture = getTargetTexture(target); |
| 2145 | SetTexParameterIiv(this, texture, pname, params); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2146 | } |
| 2147 | |
| 2148 | void Context::texParameterIuiv(TextureType target, GLenum pname, const GLuint *params) |
| 2149 | { |
| 2150 | Texture *const texture = getTargetTexture(target); |
| 2151 | SetTexParameterIuiv(this, texture, pname, params); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2152 | } |
| 2153 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2154 | void Context::texParameterivRobust(TextureType target, |
| 2155 | GLenum pname, |
| 2156 | GLsizei bufSize, |
| 2157 | const GLint *params) |
| 2158 | { |
| 2159 | texParameteriv(target, pname, params); |
| 2160 | } |
| 2161 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2162 | void Context::texParameterIivRobust(TextureType target, |
| 2163 | GLenum pname, |
| 2164 | GLsizei bufSize, |
| 2165 | const GLint *params) |
| 2166 | { |
| 2167 | UNIMPLEMENTED(); |
| 2168 | } |
| 2169 | |
| 2170 | void Context::texParameterIuivRobust(TextureType target, |
| 2171 | GLenum pname, |
| 2172 | GLsizei bufSize, |
| 2173 | const GLuint *params) |
| 2174 | { |
| 2175 | UNIMPLEMENTED(); |
| 2176 | } |
| 2177 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2178 | void Context::drawArraysInstanced(PrimitiveMode mode, |
| 2179 | GLint first, |
| 2180 | GLsizei count, |
| 2181 | GLsizei instanceCount) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2182 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2183 | // No-op if count draws no primitives for given mode |
| 2184 | if (noopDrawInstanced(mode, count, instanceCount)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2185 | { |
| 2186 | return; |
| 2187 | } |
| 2188 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2189 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2190 | ANGLE_CONTEXT_TRY( |
| 2191 | mImplementation->drawArraysInstanced(this, mode, first, count, instanceCount)); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 2192 | MarkTransformFeedbackBufferUsage(this, count, instanceCount); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2193 | } |
| 2194 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2195 | void Context::drawElementsInstanced(PrimitiveMode mode, |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2196 | GLsizei count, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2197 | DrawElementsType type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2198 | const void *indices, |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 2199 | GLsizei instances) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2200 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2201 | // No-op if count draws no primitives for given mode |
| 2202 | if (noopDrawInstanced(mode, count, instances)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2203 | { |
| 2204 | return; |
| 2205 | } |
| 2206 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2207 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2208 | ANGLE_CONTEXT_TRY( |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 2209 | mImplementation->drawElementsInstanced(this, mode, count, type, indices, instances)); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2210 | } |
| 2211 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2212 | void Context::drawRangeElements(PrimitiveMode mode, |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2213 | GLuint start, |
| 2214 | GLuint end, |
| 2215 | GLsizei count, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2216 | DrawElementsType type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2217 | const void *indices) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2218 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2219 | // No-op if count draws no primitives for given mode |
| 2220 | if (noopDraw(mode, count)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2221 | { |
| 2222 | return; |
| 2223 | } |
| 2224 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2225 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2226 | ANGLE_CONTEXT_TRY( |
| 2227 | mImplementation->drawRangeElements(this, mode, start, end, count, type, indices)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2228 | } |
| 2229 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2230 | void Context::drawArraysIndirect(PrimitiveMode mode, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2231 | { |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2232 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2233 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysIndirect(this, mode, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2234 | } |
| 2235 | |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2236 | void Context::drawElementsIndirect(PrimitiveMode mode, DrawElementsType type, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2237 | { |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2238 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2239 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsIndirect(this, mode, type, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2240 | } |
| 2241 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2242 | void Context::flush() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2243 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 2244 | ANGLE_CONTEXT_TRY(mImplementation->flush(this)); |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 2245 | } |
| 2246 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2247 | void Context::finish() |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 2248 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 2249 | ANGLE_CONTEXT_TRY(mImplementation->finish(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2250 | } |
| 2251 | |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2252 | void Context::insertEventMarker(GLsizei length, const char *marker) |
| 2253 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2254 | ASSERT(mImplementation); |
| 2255 | mImplementation->insertEventMarker(length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2256 | } |
| 2257 | |
| 2258 | void Context::pushGroupMarker(GLsizei length, const char *marker) |
| 2259 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2260 | ASSERT(mImplementation); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 2261 | |
| 2262 | if (marker == nullptr) |
| 2263 | { |
| 2264 | // From the EXT_debug_marker spec, |
| 2265 | // "If <marker> is null then an empty string is pushed on the stack." |
| 2266 | mImplementation->pushGroupMarker(length, ""); |
| 2267 | } |
| 2268 | else |
| 2269 | { |
| 2270 | mImplementation->pushGroupMarker(length, marker); |
| 2271 | } |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2272 | } |
| 2273 | |
| 2274 | void Context::popGroupMarker() |
| 2275 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2276 | ASSERT(mImplementation); |
| 2277 | mImplementation->popGroupMarker(); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2278 | } |
| 2279 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 2280 | void Context::bindUniformLocation(GLuint program, GLint location, const GLchar *name) |
| 2281 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2282 | Program *programObject = getProgramResolveLink(program); |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 2283 | ASSERT(programObject); |
| 2284 | |
| 2285 | programObject->bindUniformLocation(location, name); |
| 2286 | } |
| 2287 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2288 | void Context::coverageModulation(GLenum components) |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2289 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2290 | mState.setCoverageModulation(components); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2291 | } |
| 2292 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2293 | void Context::matrixLoadf(GLenum matrixMode, const GLfloat *matrix) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2294 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2295 | mState.loadPathRenderingMatrix(matrixMode, matrix); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2296 | } |
| 2297 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2298 | void Context::matrixLoadIdentity(GLenum matrixMode) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2299 | { |
| 2300 | GLfloat I[16]; |
| 2301 | angle::Matrix<GLfloat>::setToIdentity(I); |
| 2302 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2303 | mState.loadPathRenderingMatrix(matrixMode, I); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2304 | } |
| 2305 | |
| 2306 | void Context::stencilFillPath(GLuint path, GLenum fillMode, GLuint mask) |
| 2307 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2308 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2309 | if (!pathObj) |
| 2310 | return; |
| 2311 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2312 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2313 | |
| 2314 | mImplementation->stencilFillPath(pathObj, fillMode, mask); |
| 2315 | } |
| 2316 | |
| 2317 | void Context::stencilStrokePath(GLuint path, GLint reference, GLuint mask) |
| 2318 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2319 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2320 | if (!pathObj) |
| 2321 | return; |
| 2322 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2323 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2324 | |
| 2325 | mImplementation->stencilStrokePath(pathObj, reference, mask); |
| 2326 | } |
| 2327 | |
| 2328 | void Context::coverFillPath(GLuint path, GLenum coverMode) |
| 2329 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2330 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2331 | if (!pathObj) |
| 2332 | return; |
| 2333 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2334 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2335 | |
| 2336 | mImplementation->coverFillPath(pathObj, coverMode); |
| 2337 | } |
| 2338 | |
| 2339 | void Context::coverStrokePath(GLuint path, GLenum coverMode) |
| 2340 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2341 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2342 | if (!pathObj) |
| 2343 | return; |
| 2344 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2345 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2346 | |
| 2347 | mImplementation->coverStrokePath(pathObj, coverMode); |
| 2348 | } |
| 2349 | |
| 2350 | void Context::stencilThenCoverFillPath(GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode) |
| 2351 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2352 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2353 | if (!pathObj) |
| 2354 | return; |
| 2355 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2356 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2357 | |
| 2358 | mImplementation->stencilThenCoverFillPath(pathObj, fillMode, mask, coverMode); |
| 2359 | } |
| 2360 | |
| 2361 | void Context::stencilThenCoverStrokePath(GLuint path, |
| 2362 | GLint reference, |
| 2363 | GLuint mask, |
| 2364 | GLenum coverMode) |
| 2365 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2366 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2367 | if (!pathObj) |
| 2368 | return; |
| 2369 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2370 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2371 | |
| 2372 | mImplementation->stencilThenCoverStrokePath(pathObj, reference, mask, coverMode); |
| 2373 | } |
| 2374 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2375 | void Context::coverFillPathInstanced(GLsizei numPaths, |
| 2376 | GLenum pathNameType, |
| 2377 | const void *paths, |
| 2378 | GLuint pathBase, |
| 2379 | GLenum coverMode, |
| 2380 | GLenum transformType, |
| 2381 | const GLfloat *transformValues) |
| 2382 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2383 | const auto &pathObjects = |
| 2384 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2385 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2386 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2387 | |
| 2388 | mImplementation->coverFillPathInstanced(pathObjects, coverMode, transformType, transformValues); |
| 2389 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2390 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2391 | void Context::coverStrokePathInstanced(GLsizei numPaths, |
| 2392 | GLenum pathNameType, |
| 2393 | const void *paths, |
| 2394 | GLuint pathBase, |
| 2395 | GLenum coverMode, |
| 2396 | GLenum transformType, |
| 2397 | const GLfloat *transformValues) |
| 2398 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2399 | const auto &pathObjects = |
| 2400 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2401 | |
| 2402 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2403 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2404 | |
| 2405 | mImplementation->coverStrokePathInstanced(pathObjects, coverMode, transformType, |
| 2406 | transformValues); |
| 2407 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2408 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2409 | void Context::stencilFillPathInstanced(GLsizei numPaths, |
| 2410 | GLenum pathNameType, |
| 2411 | const void *paths, |
| 2412 | GLuint pathBase, |
| 2413 | GLenum fillMode, |
| 2414 | GLuint mask, |
| 2415 | GLenum transformType, |
| 2416 | const GLfloat *transformValues) |
| 2417 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2418 | const auto &pathObjects = |
| 2419 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2420 | |
| 2421 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2422 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2423 | |
| 2424 | mImplementation->stencilFillPathInstanced(pathObjects, fillMode, mask, transformType, |
| 2425 | transformValues); |
| 2426 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2427 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2428 | void Context::stencilStrokePathInstanced(GLsizei numPaths, |
| 2429 | GLenum pathNameType, |
| 2430 | const void *paths, |
| 2431 | GLuint pathBase, |
| 2432 | GLint reference, |
| 2433 | GLuint mask, |
| 2434 | GLenum transformType, |
| 2435 | const GLfloat *transformValues) |
| 2436 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2437 | const auto &pathObjects = |
| 2438 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2439 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2440 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2441 | |
| 2442 | mImplementation->stencilStrokePathInstanced(pathObjects, reference, mask, transformType, |
| 2443 | transformValues); |
| 2444 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2445 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2446 | void Context::stencilThenCoverFillPathInstanced(GLsizei numPaths, |
| 2447 | GLenum pathNameType, |
| 2448 | const void *paths, |
| 2449 | GLuint pathBase, |
| 2450 | GLenum fillMode, |
| 2451 | GLuint mask, |
| 2452 | GLenum coverMode, |
| 2453 | GLenum transformType, |
| 2454 | const GLfloat *transformValues) |
| 2455 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2456 | const auto &pathObjects = |
| 2457 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2458 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2459 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2460 | |
| 2461 | mImplementation->stencilThenCoverFillPathInstanced(pathObjects, coverMode, fillMode, mask, |
| 2462 | transformType, transformValues); |
| 2463 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2464 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2465 | void Context::stencilThenCoverStrokePathInstanced(GLsizei numPaths, |
| 2466 | GLenum pathNameType, |
| 2467 | const void *paths, |
| 2468 | GLuint pathBase, |
| 2469 | GLint reference, |
| 2470 | GLuint mask, |
| 2471 | GLenum coverMode, |
| 2472 | GLenum transformType, |
| 2473 | const GLfloat *transformValues) |
| 2474 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2475 | const auto &pathObjects = |
| 2476 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2477 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2478 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2479 | |
| 2480 | mImplementation->stencilThenCoverStrokePathInstanced(pathObjects, coverMode, reference, mask, |
| 2481 | transformType, transformValues); |
| 2482 | } |
| 2483 | |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2484 | void Context::bindFragmentInputLocation(GLuint program, GLint location, const GLchar *name) |
| 2485 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2486 | auto *programObject = getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2487 | |
| 2488 | programObject->bindFragmentInputLocation(location, name); |
| 2489 | } |
| 2490 | |
| 2491 | void Context::programPathFragmentInputGen(GLuint program, |
| 2492 | GLint location, |
| 2493 | GLenum genMode, |
| 2494 | GLint components, |
| 2495 | const GLfloat *coeffs) |
| 2496 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2497 | auto *programObject = getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2498 | |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 2499 | programObject->pathFragmentInputGen(location, genMode, components, coeffs); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2500 | } |
| 2501 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2502 | GLuint Context::getProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar *name) |
| 2503 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2504 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2505 | return QueryProgramResourceIndex(programObject, programInterface, name); |
| 2506 | } |
| 2507 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2508 | void Context::getProgramResourceName(GLuint program, |
| 2509 | GLenum programInterface, |
| 2510 | GLuint index, |
| 2511 | GLsizei bufSize, |
| 2512 | GLsizei *length, |
| 2513 | GLchar *name) |
| 2514 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2515 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2516 | QueryProgramResourceName(programObject, programInterface, index, bufSize, length, name); |
| 2517 | } |
| 2518 | |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2519 | GLint Context::getProgramResourceLocation(GLuint program, |
| 2520 | GLenum programInterface, |
| 2521 | const GLchar *name) |
| 2522 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2523 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2524 | return QueryProgramResourceLocation(programObject, programInterface, name); |
| 2525 | } |
| 2526 | |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2527 | void Context::getProgramResourceiv(GLuint program, |
| 2528 | GLenum programInterface, |
| 2529 | GLuint index, |
| 2530 | GLsizei propCount, |
| 2531 | const GLenum *props, |
| 2532 | GLsizei bufSize, |
| 2533 | GLsizei *length, |
| 2534 | GLint *params) |
| 2535 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2536 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2537 | QueryProgramResourceiv(programObject, programInterface, index, propCount, props, bufSize, |
| 2538 | length, params); |
| 2539 | } |
| 2540 | |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 2541 | void Context::getProgramInterfaceiv(GLuint program, |
| 2542 | GLenum programInterface, |
| 2543 | GLenum pname, |
| 2544 | GLint *params) |
| 2545 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2546 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 2547 | QueryProgramInterfaceiv(programObject, programInterface, pname, params); |
| 2548 | } |
| 2549 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2550 | void Context::getProgramInterfaceivRobust(GLuint program, |
| 2551 | GLenum programInterface, |
| 2552 | GLenum pname, |
| 2553 | GLsizei bufSize, |
| 2554 | GLsizei *length, |
| 2555 | GLint *params) |
| 2556 | { |
| 2557 | UNIMPLEMENTED(); |
| 2558 | } |
| 2559 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 2560 | void Context::handleError(GLenum errorCode, |
| 2561 | const char *message, |
| 2562 | const char *file, |
| 2563 | const char *function, |
| 2564 | unsigned int line) |
| 2565 | { |
| 2566 | mErrors.handleError(errorCode, message, file, function, line); |
| 2567 | } |
| 2568 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 2569 | void Context::validationError(GLenum errorCode, const char *message) |
| 2570 | { |
| 2571 | mErrors.validationError(errorCode, message); |
| 2572 | } |
| 2573 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2574 | // Get one of the recorded errors and clear its flag, if any. |
| 2575 | // [OpenGL ES 2.0.24] section 2.5 page 13. |
| 2576 | GLenum Context::getError() |
| 2577 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2578 | if (mErrors.empty()) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2579 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2580 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2581 | } |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2582 | else |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2583 | { |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 2584 | return mErrors.popError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2585 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2586 | } |
| 2587 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2588 | // NOTE: this function should not assume that this context is current! |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 2589 | void Context::markContextLost() |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2590 | { |
| 2591 | if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT) |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2592 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2593 | mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT; |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2594 | mContextLostForced = true; |
| 2595 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2596 | mContextLost = true; |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2597 | } |
| 2598 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 2599 | GLenum Context::getGraphicsResetStatus() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2600 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2601 | // Even if the application doesn't want to know about resets, we want to know |
| 2602 | // as it will allow us to skip all the calls. |
| 2603 | if (mResetStrategy == GL_NO_RESET_NOTIFICATION_EXT) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2604 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2605 | if (!mContextLost && mImplementation->getResetStatus() != GL_NO_ERROR) |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2606 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2607 | mContextLost = true; |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2608 | } |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2609 | |
| 2610 | // EXT_robustness, section 2.6: If the reset notification behavior is |
| 2611 | // NO_RESET_NOTIFICATION_EXT, then the implementation will never deliver notification of |
| 2612 | // reset events, and GetGraphicsResetStatusEXT will always return NO_ERROR. |
| 2613 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2614 | } |
| 2615 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2616 | // The GL_EXT_robustness spec says that if a reset is encountered, a reset |
| 2617 | // status should be returned at least once, and GL_NO_ERROR should be returned |
| 2618 | // once the device has finished resetting. |
| 2619 | if (!mContextLost) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2620 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2621 | ASSERT(mResetStatus == GL_NO_ERROR); |
| 2622 | mResetStatus = mImplementation->getResetStatus(); |
shannon.woods@transgaming.com | ddd6c80 | 2013-02-28 23:05:14 +0000 | [diff] [blame] | 2623 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2624 | if (mResetStatus != GL_NO_ERROR) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2625 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2626 | mContextLost = true; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2627 | } |
| 2628 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2629 | else if (!mContextLostForced && mResetStatus != GL_NO_ERROR) |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2630 | { |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2631 | // If markContextLost was used to mark the context lost then |
| 2632 | // assume that is not recoverable, and continue to report the |
| 2633 | // lost reset status for the lifetime of this context. |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2634 | mResetStatus = mImplementation->getResetStatus(); |
| 2635 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 2636 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2637 | return mResetStatus; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2638 | } |
| 2639 | |
| 2640 | bool Context::isResetNotificationEnabled() |
| 2641 | { |
| 2642 | return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
| 2643 | } |
| 2644 | |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2645 | const egl::Config *Context::getConfig() const |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2646 | { |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2647 | return mConfig; |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2648 | } |
| 2649 | |
| 2650 | EGLenum Context::getClientType() const |
| 2651 | { |
| 2652 | return mClientType; |
| 2653 | } |
| 2654 | |
| 2655 | EGLenum Context::getRenderBuffer() const |
| 2656 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2657 | const Framebuffer *framebuffer = mState.mFramebufferManager->getFramebuffer(0); |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2658 | if (framebuffer == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 2659 | { |
| 2660 | return EGL_NONE; |
| 2661 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2662 | |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 2663 | const FramebufferAttachment *backAttachment = framebuffer->getAttachment(this, GL_BACK); |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2664 | ASSERT(backAttachment != nullptr); |
| 2665 | return backAttachment->getSurface()->getRenderBuffer(); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2666 | } |
| 2667 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2668 | VertexArray *Context::checkVertexArrayAllocation(GLuint vertexArrayHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2669 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2670 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2671 | VertexArray *vertexArray = getVertexArray(vertexArrayHandle); |
| 2672 | if (!vertexArray) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2673 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2674 | vertexArray = |
| 2675 | new VertexArray(mImplementation.get(), vertexArrayHandle, |
| 2676 | mState.mCaps.maxVertexAttributes, mState.mCaps.maxVertexAttribBindings); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2677 | |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2678 | mVertexArrayMap.assign(vertexArrayHandle, vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2679 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2680 | |
| 2681 | return vertexArray; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2682 | } |
| 2683 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2684 | TransformFeedback *Context::checkTransformFeedbackAllocation(GLuint transformFeedbackHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2685 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2686 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2687 | TransformFeedback *transformFeedback = getTransformFeedback(transformFeedbackHandle); |
| 2688 | if (!transformFeedback) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2689 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2690 | transformFeedback = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2691 | new TransformFeedback(mImplementation.get(), transformFeedbackHandle, mState.mCaps); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2692 | transformFeedback->addRef(); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2693 | mTransformFeedbackMap.assign(transformFeedbackHandle, transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2694 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2695 | |
| 2696 | return transformFeedback; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2697 | } |
| 2698 | |
| 2699 | bool Context::isVertexArrayGenerated(GLuint vertexArray) |
| 2700 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2701 | ASSERT(mVertexArrayMap.contains(0)); |
| 2702 | return mVertexArrayMap.contains(vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2703 | } |
| 2704 | |
| 2705 | bool Context::isTransformFeedbackGenerated(GLuint transformFeedback) |
| 2706 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2707 | ASSERT(mTransformFeedbackMap.contains(0)); |
| 2708 | return mTransformFeedbackMap.contains(transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2709 | } |
| 2710 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2711 | void Context::detachTexture(GLuint texture) |
| 2712 | { |
| 2713 | // Simple pass-through to State's detachTexture method, as textures do not require |
| 2714 | // allocation map management either here or in the resource manager at detach time. |
| 2715 | // Zero textures are held by the Context, and we don't attempt to request them from |
| 2716 | // the State. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2717 | mState.detachTexture(this, mZeroTextures, texture); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2718 | } |
| 2719 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 2720 | void Context::detachBuffer(Buffer *buffer) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2721 | { |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2722 | // Simple pass-through to State's detachBuffer method, since |
| 2723 | // only buffer attachments to container objects that are bound to the current context |
| 2724 | // should be detached. And all those are available in State. |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2725 | |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2726 | // [OpenGL ES 3.2] section 5.1.2 page 45: |
| 2727 | // Attachments to unbound container objects, such as |
| 2728 | // deletion of a buffer attached to a vertex array object which is not bound to the context, |
| 2729 | // 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] | 2730 | ANGLE_CONTEXT_TRY(mState.detachBuffer(this, buffer)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2731 | } |
| 2732 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2733 | void Context::detachFramebuffer(GLuint framebuffer) |
| 2734 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2735 | // Framebuffer detachment is handled by Context, because 0 is a valid |
| 2736 | // Framebuffer object, and a pointer to it must be passed from Context |
| 2737 | // to State at binding time. |
| 2738 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2739 | // [OpenGL ES 2.0.24] section 4.4 page 107: |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2740 | // If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as |
| 2741 | // though BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of |
| 2742 | // zero. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2743 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2744 | if (mState.removeReadFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2745 | { |
| 2746 | bindReadFramebuffer(0); |
| 2747 | } |
| 2748 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2749 | if (mState.removeDrawFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2750 | { |
| 2751 | bindDrawFramebuffer(0); |
| 2752 | } |
| 2753 | } |
| 2754 | |
| 2755 | void Context::detachRenderbuffer(GLuint renderbuffer) |
| 2756 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2757 | mState.detachRenderbuffer(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2758 | } |
| 2759 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2760 | void Context::detachVertexArray(GLuint vertexArray) |
| 2761 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 2762 | // Vertex array detachment is handled by Context, because 0 is a valid |
| 2763 | // 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] | 2764 | // binding time. |
| 2765 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2766 | // [OpenGL ES 3.0.2] section 2.10 page 43: |
| 2767 | // If a vertex array object that is currently bound is deleted, the binding |
| 2768 | // 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] | 2769 | if (mState.removeVertexArrayBinding(this, vertexArray)) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2770 | { |
| 2771 | bindVertexArray(0); |
| 2772 | } |
| 2773 | } |
| 2774 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2775 | void Context::detachTransformFeedback(GLuint transformFeedback) |
| 2776 | { |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2777 | // Transform feedback detachment is handled by Context, because 0 is a valid |
| 2778 | // transform feedback, and a pointer to it must be passed from Context to State at |
| 2779 | // binding time. |
| 2780 | |
| 2781 | // The OpenGL specification doesn't mention what should happen when the currently bound |
| 2782 | // transform feedback object is deleted. Since it is a container object, we treat it like |
| 2783 | // 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] | 2784 | if (mState.removeTransformFeedbackBinding(this, transformFeedback)) |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2785 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 2786 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2787 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2788 | } |
| 2789 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2790 | void Context::detachSampler(GLuint sampler) |
| 2791 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2792 | mState.detachSampler(this, sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2793 | } |
| 2794 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 2795 | void Context::detachProgramPipeline(GLuint pipeline) |
| 2796 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2797 | mState.detachProgramPipeline(this, pipeline); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 2798 | } |
| 2799 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 2800 | void Context::vertexAttribDivisor(GLuint index, GLuint divisor) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2801 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2802 | mState.setVertexAttribDivisor(this, index, divisor); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 2803 | mStateCache.onVertexArrayStateChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2804 | } |
| 2805 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2806 | void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 2807 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2808 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2809 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2810 | SetSamplerParameteri(this, samplerObject, pname, param); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2811 | } |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2812 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2813 | void Context::samplerParameteriv(GLuint sampler, GLenum pname, const GLint *param) |
| 2814 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2815 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2816 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2817 | SetSamplerParameteriv(this, samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2818 | } |
| 2819 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2820 | void Context::samplerParameterIiv(GLuint sampler, GLenum pname, const GLint *param) |
| 2821 | { |
| 2822 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2823 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2824 | SetSamplerParameterIiv(this, samplerObject, pname, param); |
| 2825 | } |
| 2826 | |
| 2827 | void Context::samplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *param) |
| 2828 | { |
| 2829 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2830 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2831 | SetSamplerParameterIuiv(this, samplerObject, pname, param); |
| 2832 | } |
| 2833 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2834 | void Context::samplerParameterivRobust(GLuint sampler, |
| 2835 | GLenum pname, |
| 2836 | GLsizei bufSize, |
| 2837 | const GLint *param) |
| 2838 | { |
| 2839 | samplerParameteriv(sampler, pname, param); |
| 2840 | } |
| 2841 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2842 | void Context::samplerParameterIivRobust(GLuint sampler, |
| 2843 | GLenum pname, |
| 2844 | GLsizei bufSize, |
| 2845 | const GLint *param) |
| 2846 | { |
| 2847 | UNIMPLEMENTED(); |
| 2848 | } |
| 2849 | |
| 2850 | void Context::samplerParameterIuivRobust(GLuint sampler, |
| 2851 | GLenum pname, |
| 2852 | GLsizei bufSize, |
| 2853 | const GLuint *param) |
| 2854 | { |
| 2855 | UNIMPLEMENTED(); |
| 2856 | } |
| 2857 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2858 | void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 2859 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2860 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2861 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2862 | SetSamplerParameterf(this, samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2863 | } |
| 2864 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2865 | void Context::samplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2866 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2867 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2868 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2869 | SetSamplerParameterfv(this, samplerObject, pname, param); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2870 | } |
| 2871 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2872 | void Context::samplerParameterfvRobust(GLuint sampler, |
| 2873 | GLenum pname, |
| 2874 | GLsizei bufSize, |
| 2875 | const GLfloat *param) |
| 2876 | { |
| 2877 | samplerParameterfv(sampler, pname, param); |
| 2878 | } |
| 2879 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2880 | void Context::getSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2881 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2882 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2883 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2884 | QuerySamplerParameteriv(samplerObject, pname, params); |
| 2885 | } |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2886 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2887 | void Context::getSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) |
| 2888 | { |
| 2889 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2890 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2891 | QuerySamplerParameterIiv(samplerObject, pname, params); |
| 2892 | } |
| 2893 | |
| 2894 | void Context::getSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) |
| 2895 | { |
| 2896 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2897 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2898 | QuerySamplerParameterIuiv(samplerObject, pname, params); |
| 2899 | } |
| 2900 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2901 | void Context::getSamplerParameterivRobust(GLuint sampler, |
| 2902 | GLenum pname, |
| 2903 | GLsizei bufSize, |
| 2904 | GLsizei *length, |
| 2905 | GLint *params) |
| 2906 | { |
| 2907 | getSamplerParameteriv(sampler, pname, params); |
| 2908 | } |
| 2909 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2910 | void Context::getSamplerParameterIivRobust(GLuint sampler, |
| 2911 | GLenum pname, |
| 2912 | GLsizei bufSize, |
| 2913 | GLsizei *length, |
| 2914 | GLint *params) |
| 2915 | { |
| 2916 | UNIMPLEMENTED(); |
| 2917 | } |
| 2918 | |
| 2919 | void Context::getSamplerParameterIuivRobust(GLuint sampler, |
| 2920 | GLenum pname, |
| 2921 | GLsizei bufSize, |
| 2922 | GLsizei *length, |
| 2923 | GLuint *params) |
| 2924 | { |
| 2925 | UNIMPLEMENTED(); |
| 2926 | } |
| 2927 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2928 | void Context::getSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) |
| 2929 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2930 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2931 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2932 | QuerySamplerParameterfv(samplerObject, pname, params); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2933 | } |
| 2934 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2935 | void Context::getSamplerParameterfvRobust(GLuint sampler, |
| 2936 | GLenum pname, |
| 2937 | GLsizei bufSize, |
| 2938 | GLsizei *length, |
| 2939 | GLfloat *params) |
| 2940 | { |
| 2941 | getSamplerParameterfv(sampler, pname, params); |
| 2942 | } |
| 2943 | |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2944 | void Context::programParameteri(GLuint program, GLenum pname, GLint value) |
| 2945 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2946 | gl::Program *programObject = getProgramResolveLink(program); |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 2947 | SetProgramParameteri(programObject, pname, value); |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2948 | } |
| 2949 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2950 | void Context::initRendererString() |
| 2951 | { |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2952 | std::ostringstream rendererString; |
| 2953 | rendererString << "ANGLE ("; |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2954 | rendererString << mImplementation->getRendererDescription(); |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2955 | rendererString << ")"; |
| 2956 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2957 | mRendererString = MakeStaticString(rendererString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2958 | } |
| 2959 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2960 | void Context::initVersionStrings() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2961 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2962 | const Version &clientVersion = getClientVersion(); |
| 2963 | |
| 2964 | std::ostringstream versionString; |
| 2965 | versionString << "OpenGL ES " << clientVersion.major << "." << clientVersion.minor << " (ANGLE " |
| 2966 | << ANGLE_VERSION_STRING << ")"; |
| 2967 | mVersionString = MakeStaticString(versionString.str()); |
| 2968 | |
| 2969 | std::ostringstream shadingLanguageVersionString; |
| 2970 | shadingLanguageVersionString << "OpenGL ES GLSL ES " |
| 2971 | << (clientVersion.major == 2 ? 1 : clientVersion.major) << "." |
| 2972 | << clientVersion.minor << "0 (ANGLE " << ANGLE_VERSION_STRING |
| 2973 | << ")"; |
| 2974 | mShadingLanguageString = MakeStaticString(shadingLanguageVersionString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2975 | } |
| 2976 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2977 | void Context::initExtensionStrings() |
| 2978 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2979 | auto mergeExtensionStrings = [](const std::vector<const char *> &strings) { |
| 2980 | std::ostringstream combinedStringStream; |
| 2981 | std::copy(strings.begin(), strings.end(), |
| 2982 | std::ostream_iterator<const char *>(combinedStringStream, " ")); |
| 2983 | return MakeStaticString(combinedStringStream.str()); |
| 2984 | }; |
| 2985 | |
| 2986 | mExtensionStrings.clear(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2987 | for (const auto &extensionString : mState.mExtensions.getStrings()) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 2988 | { |
| 2989 | mExtensionStrings.push_back(MakeStaticString(extensionString)); |
| 2990 | } |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2991 | mExtensionString = mergeExtensionStrings(mExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2992 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2993 | mRequestableExtensionStrings.clear(); |
| 2994 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 2995 | { |
| 2996 | if (extensionInfo.second.Requestable && |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2997 | !(mState.mExtensions.*(extensionInfo.second.ExtensionsMember)) && |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 2998 | mSupportedExtensions.*(extensionInfo.second.ExtensionsMember)) |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2999 | { |
| 3000 | mRequestableExtensionStrings.push_back(MakeStaticString(extensionInfo.first)); |
| 3001 | } |
| 3002 | } |
| 3003 | mRequestableExtensionString = mergeExtensionStrings(mRequestableExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3004 | } |
| 3005 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3006 | const GLubyte *Context::getString(GLenum name) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3007 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3008 | switch (name) |
| 3009 | { |
| 3010 | case GL_VENDOR: |
| 3011 | return reinterpret_cast<const GLubyte *>("Google Inc."); |
| 3012 | |
| 3013 | case GL_RENDERER: |
| 3014 | return reinterpret_cast<const GLubyte *>(mRendererString); |
| 3015 | |
| 3016 | case GL_VERSION: |
| 3017 | return reinterpret_cast<const GLubyte *>(mVersionString); |
| 3018 | |
| 3019 | case GL_SHADING_LANGUAGE_VERSION: |
| 3020 | return reinterpret_cast<const GLubyte *>(mShadingLanguageString); |
| 3021 | |
| 3022 | case GL_EXTENSIONS: |
| 3023 | return reinterpret_cast<const GLubyte *>(mExtensionString); |
| 3024 | |
| 3025 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 3026 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionString); |
| 3027 | |
| 3028 | default: |
| 3029 | UNREACHABLE(); |
| 3030 | return nullptr; |
| 3031 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3032 | } |
| 3033 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3034 | const GLubyte *Context::getStringi(GLenum name, GLuint index) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3035 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3036 | switch (name) |
| 3037 | { |
| 3038 | case GL_EXTENSIONS: |
| 3039 | return reinterpret_cast<const GLubyte *>(mExtensionStrings[index]); |
| 3040 | |
| 3041 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 3042 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionStrings[index]); |
| 3043 | |
| 3044 | default: |
| 3045 | UNREACHABLE(); |
| 3046 | return nullptr; |
| 3047 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3048 | } |
| 3049 | |
| 3050 | size_t Context::getExtensionStringCount() const |
| 3051 | { |
| 3052 | return mExtensionStrings.size(); |
| 3053 | } |
| 3054 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3055 | bool Context::isExtensionRequestable(const char *name) |
| 3056 | { |
| 3057 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 3058 | auto extension = extensionInfos.find(name); |
| 3059 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3060 | return extension != extensionInfos.end() && extension->second.Requestable && |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3061 | mSupportedExtensions.*(extension->second.ExtensionsMember); |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3062 | } |
| 3063 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3064 | void Context::requestExtension(const char *name) |
| 3065 | { |
| 3066 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 3067 | ASSERT(extensionInfos.find(name) != extensionInfos.end()); |
| 3068 | const auto &extension = extensionInfos.at(name); |
| 3069 | ASSERT(extension.Requestable); |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3070 | ASSERT(isExtensionRequestable(name)); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3071 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3072 | if (mState.mExtensions.*(extension.ExtensionsMember)) |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3073 | { |
| 3074 | // Extension already enabled |
| 3075 | return; |
| 3076 | } |
| 3077 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3078 | mState.mExtensions.*(extension.ExtensionsMember) = true; |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3079 | updateCaps(); |
| 3080 | initExtensionStrings(); |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 3081 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 3082 | // Release the shader compiler so it will be re-created with the requested extensions enabled. |
| 3083 | releaseShaderCompiler(); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3084 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 3085 | // Invalidate all textures and framebuffer. Some extensions make new formats renderable or |
| 3086 | // sampleable. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3087 | mState.mTextureManager->signalAllTexturesDirty(this); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3088 | for (auto &zeroTexture : mZeroTextures) |
| 3089 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3090 | if (zeroTexture.get() != nullptr) |
| 3091 | { |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 3092 | zeroTexture->signalDirtyStorage(this, InitState::Initialized); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3093 | } |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3094 | } |
| 3095 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3096 | mState.mFramebufferManager->invalidateFramebufferComplenessCache(this); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3097 | } |
| 3098 | |
| 3099 | size_t Context::getRequestableExtensionStringCount() const |
| 3100 | { |
| 3101 | return mRequestableExtensionStrings.size(); |
| 3102 | } |
| 3103 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 3104 | void Context::beginTransformFeedback(PrimitiveMode primitiveMode) |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3105 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3106 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3107 | ASSERT(transformFeedback != nullptr); |
| 3108 | ASSERT(!transformFeedback->isPaused()); |
| 3109 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3110 | ANGLE_CONTEXT_TRY(transformFeedback->begin(this, primitiveMode, mState.getProgram())); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 3111 | mStateCache.onActiveTransformFeedbackChange(this); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3112 | } |
| 3113 | |
| 3114 | bool Context::hasActiveTransformFeedback(GLuint program) const |
| 3115 | { |
| 3116 | for (auto pair : mTransformFeedbackMap) |
| 3117 | { |
| 3118 | if (pair.second != nullptr && pair.second->hasBoundProgram(program)) |
| 3119 | { |
| 3120 | return true; |
| 3121 | } |
| 3122 | } |
| 3123 | return false; |
| 3124 | } |
| 3125 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3126 | Extensions Context::generateSupportedExtensions() const |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3127 | { |
| 3128 | Extensions supportedExtensions = mImplementation->getNativeExtensions(); |
| 3129 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 3130 | // Explicitly enable GL_KHR_parallel_shader_compile |
| 3131 | supportedExtensions.parallelShaderCompile = true; |
| 3132 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3133 | if (getClientVersion() < ES_2_0) |
| 3134 | { |
| 3135 | // Default extensions for GLES1 |
Lingfeng Yang | 0df813c | 2018-07-12 12:52:06 -0700 | [diff] [blame] | 3136 | supportedExtensions.pointSizeArray = true; |
| 3137 | supportedExtensions.textureCubeMap = true; |
| 3138 | supportedExtensions.pointSprite = true; |
| 3139 | supportedExtensions.drawTexture = true; |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 3140 | supportedExtensions.parallelShaderCompile = false; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3141 | } |
| 3142 | |
| 3143 | if (getClientVersion() < ES_3_0) |
| 3144 | { |
| 3145 | // Disable ES3+ extensions |
| 3146 | supportedExtensions.colorBufferFloat = false; |
| 3147 | supportedExtensions.eglImageExternalEssl3 = false; |
| 3148 | supportedExtensions.textureNorm16 = false; |
| 3149 | supportedExtensions.multiview = false; |
| 3150 | supportedExtensions.maxViews = 1u; |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 3151 | supportedExtensions.copyTexture3d = false; |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 3152 | supportedExtensions.textureMultisample = false; |
Geoff Lang | 7198ebc | 2018-11-22 14:36:06 -0500 | [diff] [blame] | 3153 | |
| 3154 | // Don't expose GL_EXT_texture_sRGB_decode without sRGB texture support |
| 3155 | if (!supportedExtensions.sRGB) |
| 3156 | { |
| 3157 | supportedExtensions.textureSRGBDecode = false; |
| 3158 | } |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3159 | } |
| 3160 | |
| 3161 | if (getClientVersion() < ES_3_1) |
| 3162 | { |
| 3163 | // Disable ES3.1+ extensions |
| 3164 | supportedExtensions.geometryShader = false; |
Olli Etuaho | d310a43 | 2018-08-24 15:40:23 +0300 | [diff] [blame] | 3165 | |
| 3166 | // TODO(http://anglebug.com/2775): Multisample arrays could be supported on ES 3.0 as well |
| 3167 | // once 2D multisample texture extension is exposed there. |
Olli Etuaho | 064458a | 2018-08-30 14:02:02 +0300 | [diff] [blame] | 3168 | supportedExtensions.textureStorageMultisample2DArray = false; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3169 | } |
| 3170 | |
| 3171 | if (getClientVersion() > ES_2_0) |
| 3172 | { |
| 3173 | // FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts |
| 3174 | // supportedExtensions.sRGB = false; |
| 3175 | } |
| 3176 | |
| 3177 | // Some extensions are always available because they are implemented in the GL layer. |
| 3178 | supportedExtensions.bindUniformLocation = true; |
| 3179 | supportedExtensions.vertexArrayObject = true; |
| 3180 | supportedExtensions.bindGeneratesResource = true; |
| 3181 | supportedExtensions.clientArrays = true; |
| 3182 | supportedExtensions.requestExtension = true; |
Austin Eng | 7cf9cd2 | 2018-10-09 15:27:32 -0700 | [diff] [blame] | 3183 | supportedExtensions.multiDraw = true; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3184 | |
| 3185 | // Enable the no error extension if the context was created with the flag. |
| 3186 | supportedExtensions.noError = mSkipValidation; |
| 3187 | |
| 3188 | // 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] | 3189 | supportedExtensions.surfacelessContext = mSurfacelessSupported; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3190 | |
| 3191 | // Explicitly enable GL_KHR_debug |
| 3192 | supportedExtensions.debug = true; |
| 3193 | supportedExtensions.maxDebugMessageLength = 1024; |
| 3194 | supportedExtensions.maxDebugLoggedMessages = 1024; |
| 3195 | supportedExtensions.maxDebugGroupStackDepth = 1024; |
| 3196 | supportedExtensions.maxLabelLength = 1024; |
| 3197 | |
| 3198 | // Explicitly enable GL_ANGLE_robust_client_memory |
| 3199 | supportedExtensions.robustClientMemory = true; |
| 3200 | |
| 3201 | // Determine robust resource init availability from EGL. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3202 | supportedExtensions.robustResourceInitialization = mState.isRobustResourceInitEnabled(); |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3203 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3204 | // mState.mExtensions.robustBufferAccessBehavior is true only if robust access is true and the |
| 3205 | // backend supports it. |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3206 | supportedExtensions.robustBufferAccessBehavior = |
| 3207 | mRobustAccess && supportedExtensions.robustBufferAccessBehavior; |
| 3208 | |
| 3209 | // Enable the cache control query unconditionally. |
| 3210 | supportedExtensions.programCacheControl = true; |
| 3211 | |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 3212 | // Enable EGL_ANGLE_explicit_context subextensions |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3213 | if (mExplicitContextAvailable) |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 3214 | { |
| 3215 | // GL_ANGLE_explicit_context_gles1 |
| 3216 | supportedExtensions.explicitContextGles1 = true; |
| 3217 | // GL_ANGLE_explicit_context |
| 3218 | supportedExtensions.explicitContext = true; |
| 3219 | } |
| 3220 | |
Geoff Lang | 79b9140 | 2018-10-04 15:11:30 -0400 | [diff] [blame] | 3221 | supportedExtensions.memorySize = true; |
| 3222 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3223 | return supportedExtensions; |
| 3224 | } |
| 3225 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3226 | void Context::initCaps() |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3227 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3228 | mState.mCaps = mImplementation->getNativeCaps(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3229 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3230 | mSupportedExtensions = generateSupportedExtensions(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3231 | mState.mExtensions = mSupportedExtensions; |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 3232 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3233 | mState.mLimitations = mImplementation->getNativeLimitations(); |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 3234 | |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3235 | // GLES1 emulation: Initialize caps (Table 6.20 / 6.22 in the ES 1.1 spec) |
| 3236 | if (getClientVersion() < Version(2, 0)) |
| 3237 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3238 | mState.mCaps.maxMultitextureUnits = 4; |
| 3239 | mState.mCaps.maxClipPlanes = 6; |
| 3240 | mState.mCaps.maxLights = 8; |
| 3241 | mState.mCaps.maxModelviewMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3242 | mState.mCaps.maxProjectionMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3243 | mState.mCaps.maxTextureMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3244 | mState.mCaps.minSmoothPointSize = 1.0f; |
| 3245 | mState.mCaps.maxSmoothPointSize = 1.0f; |
| 3246 | mState.mCaps.minSmoothLineWidth = 1.0f; |
| 3247 | mState.mCaps.maxSmoothLineWidth = 1.0f; |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3248 | } |
| 3249 | |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3250 | // Apply/Verify implementation limits |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3251 | LimitCap(&mState.mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 3252 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3253 | ASSERT(mState.mCaps.minAliasedPointSize >= 1.0f); |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3254 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3255 | if (getClientVersion() < ES_3_1) |
| 3256 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3257 | mState.mCaps.maxVertexAttribBindings = mState.mCaps.maxVertexAttributes; |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3258 | } |
| 3259 | else |
| 3260 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3261 | LimitCap(&mState.mCaps.maxVertexAttribBindings, MAX_VERTEX_ATTRIB_BINDINGS); |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3262 | } |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 3263 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3264 | LimitCap(&mState.mCaps.maxShaderUniformBlocks[ShaderType::Vertex], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3265 | IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3266 | LimitCap(&mState.mCaps.maxUniformBufferBindings, IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 3267 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3268 | LimitCap(&mState.mCaps.maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
| 3269 | LimitCap(&mState.mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3270 | |
| 3271 | // 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] | 3272 | LimitCap(&mState.mCaps.maxCombinedTextureImageUnits, IMPLEMENTATION_MAX_ACTIVE_TEXTURES); |
| 3273 | LimitCap(&mState.mCaps.maxShaderTextureImageUnits[ShaderType::Vertex], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3274 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3275 | LimitCap(&mState.mCaps.maxShaderTextureImageUnits[ShaderType::Fragment], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3276 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 3277 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3278 | LimitCap(&mState.mCaps.maxImageUnits, IMPLEMENTATION_MAX_IMAGE_UNITS); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 3279 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3280 | mState.mCaps.maxSampleMaskWords = |
| 3281 | std::min<GLuint>(mState.mCaps.maxSampleMaskWords, MAX_SAMPLE_MASK_WORDS); |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 3282 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3283 | // WebGL compatibility |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3284 | mState.mExtensions.webglCompatibility = mWebGLContext; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3285 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 3286 | { |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 3287 | // If the user has requested that extensions start disabled and they are requestable, |
| 3288 | // disable them. |
| 3289 | if (!mExtensionsEnabled && extensionInfo.second.Requestable) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3290 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3291 | mState.mExtensions.*(extensionInfo.second.ExtensionsMember) = false; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3292 | } |
| 3293 | } |
| 3294 | |
| 3295 | // Generate texture caps |
| 3296 | updateCaps(); |
| 3297 | } |
| 3298 | |
| 3299 | void Context::updateCaps() |
| 3300 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3301 | mState.mCaps.compressedTextureFormats.clear(); |
| 3302 | mState.mTextureCaps.clear(); |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3303 | |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3304 | for (GLenum sizedInternalFormat : GetAllSizedInternalFormats()) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3305 | { |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3306 | TextureCaps formatCaps = mImplementation->getNativeTextureCaps().get(sizedInternalFormat); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3307 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3308 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 3309 | // Update the format caps based on the client version and extensions. |
| 3310 | // Caps are AND'd with the renderer caps because some core formats are still unsupported in |
| 3311 | // ES3. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3312 | formatCaps.texturable = formatCaps.texturable && |
| 3313 | formatInfo.textureSupport(getClientVersion(), mState.mExtensions); |
| 3314 | formatCaps.filterable = formatCaps.filterable && |
| 3315 | formatInfo.filterSupport(getClientVersion(), mState.mExtensions); |
Yuly Novikov | f15f886 | 2018-06-04 18:59:41 -0400 | [diff] [blame] | 3316 | formatCaps.textureAttachment = |
| 3317 | formatCaps.textureAttachment && |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3318 | formatInfo.textureAttachmentSupport(getClientVersion(), mState.mExtensions); |
| 3319 | formatCaps.renderbuffer = |
| 3320 | formatCaps.renderbuffer && |
| 3321 | formatInfo.renderbufferSupport(getClientVersion(), mState.mExtensions); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3322 | |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3323 | // OpenGL ES does not support multisampling with non-rendererable formats |
| 3324 | // 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] | 3325 | if (!formatCaps.renderbuffer || |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3326 | (getClientVersion() < ES_3_1 && !mSupportedExtensions.textureMultisample && |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3327 | (formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT))) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3328 | { |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3329 | formatCaps.sampleCounts.clear(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3330 | } |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3331 | else |
| 3332 | { |
| 3333 | // We may have limited the max samples for some required renderbuffer formats due to |
| 3334 | // non-conformant formats. In this case MAX_SAMPLES needs to be lowered accordingly. |
| 3335 | GLuint formatMaxSamples = formatCaps.getMaxSamples(); |
| 3336 | |
| 3337 | // GLES 3.0.5 section 4.4.2.2: "Implementations must support creation of renderbuffers |
| 3338 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with the |
| 3339 | // exception of signed and unsigned integer formats." |
| 3340 | if (formatInfo.componentType != GL_INT && formatInfo.componentType != GL_UNSIGNED_INT && |
| 3341 | formatInfo.isRequiredRenderbufferFormat(getClientVersion())) |
| 3342 | { |
| 3343 | ASSERT(getClientVersion() < ES_3_0 || formatMaxSamples >= 4); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3344 | mState.mCaps.maxSamples = std::min(mState.mCaps.maxSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3345 | } |
| 3346 | |
| 3347 | // Handle GLES 3.1 MAX_*_SAMPLES values similarly to MAX_SAMPLES. |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3348 | if (getClientVersion() >= ES_3_1 || mSupportedExtensions.textureMultisample) |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3349 | { |
| 3350 | // GLES 3.1 section 9.2.5: "Implementations must support creation of renderbuffers |
| 3351 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with |
| 3352 | // the exception that the signed and unsigned integer formats are required only to |
| 3353 | // support creation of renderbuffers with up to the value of MAX_INTEGER_SAMPLES |
| 3354 | // multisamples, which must be at least one." |
| 3355 | if (formatInfo.componentType == GL_INT || |
| 3356 | formatInfo.componentType == GL_UNSIGNED_INT) |
| 3357 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3358 | mState.mCaps.maxIntegerSamples = |
| 3359 | std::min(mState.mCaps.maxIntegerSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3360 | } |
| 3361 | |
| 3362 | // GLES 3.1 section 19.3.1. |
| 3363 | if (formatCaps.texturable) |
| 3364 | { |
| 3365 | if (formatInfo.depthBits > 0) |
| 3366 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3367 | mState.mCaps.maxDepthTextureSamples = |
| 3368 | std::min(mState.mCaps.maxDepthTextureSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3369 | } |
| 3370 | else if (formatInfo.redBits > 0) |
| 3371 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3372 | mState.mCaps.maxColorTextureSamples = |
| 3373 | std::min(mState.mCaps.maxColorTextureSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3374 | } |
| 3375 | } |
| 3376 | } |
| 3377 | } |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3378 | |
| 3379 | if (formatCaps.texturable && formatInfo.compressed) |
| 3380 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3381 | mState.mCaps.compressedTextureFormats.push_back(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3382 | } |
| 3383 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3384 | mState.mTextureCaps.insert(sizedInternalFormat, formatCaps); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3385 | } |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3386 | |
| 3387 | // If program binary is disabled, blank out the memory cache pointer. |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3388 | if (!mSupportedExtensions.getProgramBinary) |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3389 | { |
| 3390 | mMemoryProgramCache = nullptr; |
| 3391 | } |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3392 | |
| 3393 | // Compute which buffer types are allowed |
| 3394 | mValidBufferBindings.reset(); |
| 3395 | mValidBufferBindings.set(BufferBinding::ElementArray); |
| 3396 | mValidBufferBindings.set(BufferBinding::Array); |
| 3397 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3398 | if (mState.mExtensions.pixelBufferObject || getClientVersion() >= ES_3_0) |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3399 | { |
| 3400 | mValidBufferBindings.set(BufferBinding::PixelPack); |
| 3401 | mValidBufferBindings.set(BufferBinding::PixelUnpack); |
| 3402 | } |
| 3403 | |
| 3404 | if (getClientVersion() >= ES_3_0) |
| 3405 | { |
| 3406 | mValidBufferBindings.set(BufferBinding::CopyRead); |
| 3407 | mValidBufferBindings.set(BufferBinding::CopyWrite); |
| 3408 | mValidBufferBindings.set(BufferBinding::TransformFeedback); |
| 3409 | mValidBufferBindings.set(BufferBinding::Uniform); |
| 3410 | } |
| 3411 | |
| 3412 | if (getClientVersion() >= ES_3_1) |
| 3413 | { |
| 3414 | mValidBufferBindings.set(BufferBinding::AtomicCounter); |
| 3415 | mValidBufferBindings.set(BufferBinding::ShaderStorage); |
| 3416 | mValidBufferBindings.set(BufferBinding::DrawIndirect); |
| 3417 | mValidBufferBindings.set(BufferBinding::DispatchIndirect); |
| 3418 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 3419 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3420 | mThreadPool = angle::WorkerThreadPool::Create(mState.mExtensions.parallelShaderCompile); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3421 | |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3422 | // Reinitialize some dirty bits that depend on extensions. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3423 | bool robustInit = mState.isRobustResourceInitEnabled(); |
Jamie Madill | 132d15c | 2018-11-30 15:25:38 -0500 | [diff] [blame] | 3424 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, robustInit); |
| 3425 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES_INIT, robustInit); |
| 3426 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_IMAGES_INIT, robustInit); |
| 3427 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, robustInit); |
| 3428 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES_INIT, robustInit); |
| 3429 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_IMAGES_INIT, robustInit); |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3430 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3431 | // Reinitialize state cache after extension changes. |
| 3432 | mStateCache.initialize(this); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3433 | } |
| 3434 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3435 | void Context::initWorkarounds() |
| 3436 | { |
Jamie Madill | 761b02c | 2017-06-23 16:27:06 -0400 | [diff] [blame] | 3437 | // Apply back-end workarounds. |
| 3438 | mImplementation->applyNativeWorkarounds(&mWorkarounds); |
| 3439 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3440 | // Lose the context upon out of memory error if the application is |
| 3441 | // expecting to watch for those events. |
| 3442 | mWorkarounds.loseContextOnOutOfMemory = (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
Jamie Madill | d4f0776 | 2018-10-19 19:24:07 -0400 | [diff] [blame] | 3443 | |
| 3444 | if (mWorkarounds.syncFramebufferBindingsOnTexImage) |
| 3445 | { |
| 3446 | // Update the Framebuffer bindings on TexImage to work around an Intel bug. |
| 3447 | mTexImageDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 3448 | mTexImageDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
| 3449 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3450 | } |
| 3451 | |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 3452 | bool Context::noopDrawInstanced(PrimitiveMode mode, GLsizei count, GLsizei instanceCount) |
| 3453 | { |
| 3454 | return (instanceCount == 0) || noopDraw(mode, count); |
| 3455 | } |
| 3456 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3457 | angle::Result Context::prepareForClear(GLbitfield mask) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3458 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3459 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3460 | ANGLE_TRY(mState.getDrawFramebuffer()->ensureClearAttachmentsInitialized(this, mask)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3461 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3462 | return angle::Result::Continue; |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3463 | } |
| 3464 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3465 | angle::Result Context::prepareForClearBuffer(GLenum buffer, GLint drawbuffer) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3466 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3467 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3468 | ANGLE_TRY(mState.getDrawFramebuffer()->ensureClearBufferAttachmentsInitialized(this, buffer, |
| 3469 | drawbuffer)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3470 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3471 | return angle::Result::Continue; |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3472 | } |
| 3473 | |
Jamie Madill | 132d15c | 2018-11-30 15:25:38 -0500 | [diff] [blame] | 3474 | ANGLE_INLINE angle::Result Context::prepareForDispatch() |
| 3475 | { |
| 3476 | ANGLE_TRY(syncDirtyObjects(mComputeDirtyObjects)); |
| 3477 | return syncDirtyBits(mComputeDirtyBits); |
| 3478 | } |
| 3479 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3480 | angle::Result Context::syncState(const State::DirtyBits &bitMask, |
| 3481 | const State::DirtyObjects &objectMask) |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 3482 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3483 | ANGLE_TRY(syncDirtyObjects(objectMask)); |
| 3484 | ANGLE_TRY(syncDirtyBits(bitMask)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3485 | return angle::Result::Continue; |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3486 | } |
| 3487 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3488 | void Context::blitFramebuffer(GLint srcX0, |
| 3489 | GLint srcY0, |
| 3490 | GLint srcX1, |
| 3491 | GLint srcY1, |
| 3492 | GLint dstX0, |
| 3493 | GLint dstY0, |
| 3494 | GLint dstX1, |
| 3495 | GLint dstY1, |
| 3496 | GLbitfield mask, |
| 3497 | GLenum filter) |
| 3498 | { |
Qin Jiajia | aef9216 | 2018-02-27 13:51:44 +0800 | [diff] [blame] | 3499 | if (mask == 0) |
| 3500 | { |
| 3501 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 3502 | // buffers are copied. |
| 3503 | return; |
| 3504 | } |
| 3505 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3506 | Framebuffer *drawFramebuffer = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3507 | ASSERT(drawFramebuffer); |
| 3508 | |
| 3509 | Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0); |
| 3510 | Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0); |
| 3511 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3512 | ANGLE_CONTEXT_TRY(syncStateForBlit()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3513 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3514 | ANGLE_CONTEXT_TRY(drawFramebuffer->blit(this, srcArea, dstArea, mask, filter)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3515 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3516 | |
| 3517 | void Context::clear(GLbitfield mask) |
| 3518 | { |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3519 | ANGLE_CONTEXT_TRY(prepareForClear(mask)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3520 | ANGLE_CONTEXT_TRY(mState.getDrawFramebuffer()->clear(this, mask)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3521 | } |
| 3522 | |
| 3523 | void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values) |
| 3524 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3525 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3526 | const FramebufferAttachment *attachment = nullptr; |
| 3527 | if (buffer == GL_DEPTH) |
| 3528 | { |
| 3529 | attachment = framebufferObject->getDepthbuffer(); |
| 3530 | } |
| 3531 | if (buffer == GL_COLOR && |
| 3532 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3533 | { |
| 3534 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3535 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3536 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3537 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3538 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3539 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3540 | return; |
| 3541 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3542 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3543 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3544 | } |
| 3545 | |
| 3546 | void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values) |
| 3547 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3548 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3549 | const FramebufferAttachment *attachment = nullptr; |
| 3550 | if (buffer == GL_COLOR && |
| 3551 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3552 | { |
| 3553 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3554 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3555 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3556 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3557 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3558 | { |
| 3559 | return; |
| 3560 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3561 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3562 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferuiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3563 | } |
| 3564 | |
| 3565 | void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values) |
| 3566 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3567 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3568 | const FramebufferAttachment *attachment = nullptr; |
| 3569 | if (buffer == GL_STENCIL) |
| 3570 | { |
| 3571 | attachment = framebufferObject->getStencilbuffer(); |
| 3572 | } |
| 3573 | if (buffer == GL_COLOR && |
| 3574 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3575 | { |
| 3576 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3577 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3578 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3579 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3580 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3581 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3582 | return; |
| 3583 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3584 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3585 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3586 | } |
| 3587 | |
| 3588 | void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 3589 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3590 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3591 | ASSERT(framebufferObject); |
| 3592 | |
| 3593 | // If a buffer is not present, the clear has no effect |
| 3594 | if (framebufferObject->getDepthbuffer() == nullptr && |
| 3595 | framebufferObject->getStencilbuffer() == nullptr) |
| 3596 | { |
| 3597 | return; |
| 3598 | } |
| 3599 | |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3600 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
| 3601 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfi(this, buffer, drawbuffer, depth, stencil)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3602 | } |
| 3603 | |
| 3604 | void Context::readPixels(GLint x, |
| 3605 | GLint y, |
| 3606 | GLsizei width, |
| 3607 | GLsizei height, |
| 3608 | GLenum format, |
| 3609 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3610 | void *pixels) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3611 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3612 | if (width == 0 || height == 0) |
| 3613 | { |
| 3614 | return; |
| 3615 | } |
| 3616 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3617 | ANGLE_CONTEXT_TRY(syncStateForReadPixels()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3618 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3619 | Framebuffer *readFBO = mState.getReadFramebuffer(); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 3620 | ASSERT(readFBO); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3621 | |
| 3622 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3623 | ANGLE_CONTEXT_TRY(readFBO->readPixels(this, area, format, type, pixels)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3624 | } |
| 3625 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3626 | void Context::readPixelsRobust(GLint x, |
| 3627 | GLint y, |
| 3628 | GLsizei width, |
| 3629 | GLsizei height, |
| 3630 | GLenum format, |
| 3631 | GLenum type, |
| 3632 | GLsizei bufSize, |
| 3633 | GLsizei *length, |
| 3634 | GLsizei *columns, |
| 3635 | GLsizei *rows, |
| 3636 | void *pixels) |
| 3637 | { |
| 3638 | readPixels(x, y, width, height, format, type, pixels); |
| 3639 | } |
| 3640 | |
| 3641 | void Context::readnPixelsRobust(GLint x, |
| 3642 | GLint y, |
| 3643 | GLsizei width, |
| 3644 | GLsizei height, |
| 3645 | GLenum format, |
| 3646 | GLenum type, |
| 3647 | GLsizei bufSize, |
| 3648 | GLsizei *length, |
| 3649 | GLsizei *columns, |
| 3650 | GLsizei *rows, |
| 3651 | void *data) |
| 3652 | { |
| 3653 | readPixels(x, y, width, height, format, type, data); |
| 3654 | } |
| 3655 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3656 | void Context::copyTexImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3657 | GLint level, |
| 3658 | GLenum internalformat, |
| 3659 | GLint x, |
| 3660 | GLint y, |
| 3661 | GLsizei width, |
| 3662 | GLsizei height, |
| 3663 | GLint border) |
| 3664 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3665 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3666 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3667 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3668 | Rectangle sourceArea(x, y, width, height); |
| 3669 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3670 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3671 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3672 | ANGLE_CONTEXT_TRY( |
| 3673 | texture->copyImage(this, target, level, sourceArea, internalformat, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3674 | } |
| 3675 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3676 | void Context::copyTexSubImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3677 | GLint level, |
| 3678 | GLint xoffset, |
| 3679 | GLint yoffset, |
| 3680 | GLint x, |
| 3681 | GLint y, |
| 3682 | GLsizei width, |
| 3683 | GLsizei height) |
| 3684 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3685 | if (width == 0 || height == 0) |
| 3686 | { |
| 3687 | return; |
| 3688 | } |
| 3689 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3690 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3691 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3692 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3693 | Offset destOffset(xoffset, yoffset, 0); |
| 3694 | Rectangle sourceArea(x, y, width, height); |
| 3695 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3696 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3697 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3698 | ANGLE_CONTEXT_TRY( |
| 3699 | texture->copySubImage(this, target, level, destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3700 | } |
| 3701 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3702 | void Context::copyTexSubImage3D(TextureType target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3703 | GLint level, |
| 3704 | GLint xoffset, |
| 3705 | GLint yoffset, |
| 3706 | GLint zoffset, |
| 3707 | GLint x, |
| 3708 | GLint y, |
| 3709 | GLsizei width, |
| 3710 | GLsizei height) |
| 3711 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3712 | if (width == 0 || height == 0) |
| 3713 | { |
| 3714 | return; |
| 3715 | } |
| 3716 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3717 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3718 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3719 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3720 | Offset destOffset(xoffset, yoffset, zoffset); |
| 3721 | Rectangle sourceArea(x, y, width, height); |
| 3722 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3723 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3724 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3725 | ANGLE_CONTEXT_TRY(texture->copySubImage(this, NonCubeTextureTypeToTarget(target), level, |
| 3726 | destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3727 | } |
| 3728 | |
| 3729 | void Context::framebufferTexture2D(GLenum target, |
| 3730 | GLenum attachment, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3731 | TextureTarget textarget, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3732 | GLuint texture, |
| 3733 | GLint level) |
| 3734 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3735 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3736 | ASSERT(framebuffer); |
| 3737 | |
| 3738 | if (texture != 0) |
| 3739 | { |
| 3740 | Texture *textureObj = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3741 | ImageIndex index = ImageIndex::MakeFromTarget(textarget, level); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3742 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3743 | } |
| 3744 | else |
| 3745 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3746 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3747 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3748 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3749 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3750 | } |
| 3751 | |
| 3752 | void Context::framebufferRenderbuffer(GLenum target, |
| 3753 | GLenum attachment, |
| 3754 | GLenum renderbuffertarget, |
| 3755 | GLuint renderbuffer) |
| 3756 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3757 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3758 | ASSERT(framebuffer); |
| 3759 | |
| 3760 | if (renderbuffer != 0) |
| 3761 | { |
| 3762 | Renderbuffer *renderbufferObject = getRenderbuffer(renderbuffer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3763 | |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3764 | framebuffer->setAttachment(this, GL_RENDERBUFFER, attachment, gl::ImageIndex(), |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3765 | renderbufferObject); |
| 3766 | } |
| 3767 | else |
| 3768 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3769 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3770 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3771 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3772 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3773 | } |
| 3774 | |
| 3775 | void Context::framebufferTextureLayer(GLenum target, |
| 3776 | GLenum attachment, |
| 3777 | GLuint texture, |
| 3778 | GLint level, |
| 3779 | GLint layer) |
| 3780 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3781 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3782 | ASSERT(framebuffer); |
| 3783 | |
| 3784 | if (texture != 0) |
| 3785 | { |
| 3786 | Texture *textureObject = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3787 | ImageIndex index = ImageIndex::MakeFromType(textureObject->getType(), level, layer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3788 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObject); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3789 | } |
| 3790 | else |
| 3791 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3792 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3793 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3794 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3795 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3796 | } |
| 3797 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3798 | void Context::framebufferTextureMultiviewLayered(GLenum target, |
| 3799 | GLenum attachment, |
| 3800 | GLuint texture, |
| 3801 | GLint level, |
| 3802 | GLint baseViewIndex, |
| 3803 | GLsizei numViews) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3804 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3805 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3806 | ASSERT(framebuffer); |
| 3807 | |
| 3808 | if (texture != 0) |
| 3809 | { |
| 3810 | Texture *textureObj = getTexture(texture); |
| 3811 | |
Olli Etuaho | 2c8f084 | 2018-09-12 14:44:55 +0300 | [diff] [blame] | 3812 | ImageIndex index; |
| 3813 | if (textureObj->getType() == TextureType::_2DArray) |
| 3814 | { |
| 3815 | index = ImageIndex::Make2DArrayRange(level, baseViewIndex, numViews); |
| 3816 | } |
| 3817 | else |
| 3818 | { |
| 3819 | ASSERT(textureObj->getType() == TextureType::_2DMultisampleArray); |
| 3820 | ASSERT(level == 0); |
| 3821 | index = ImageIndex::Make2DMultisampleArrayRange(baseViewIndex, numViews); |
| 3822 | } |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3823 | framebuffer->setAttachmentMultiviewLayered(this, GL_TEXTURE, attachment, index, textureObj, |
| 3824 | numViews, baseViewIndex); |
| 3825 | } |
| 3826 | else |
| 3827 | { |
| 3828 | framebuffer->resetAttachment(this, attachment); |
| 3829 | } |
| 3830 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3831 | mState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3832 | } |
| 3833 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3834 | void Context::framebufferTextureMultiviewSideBySide(GLenum target, |
| 3835 | GLenum attachment, |
| 3836 | GLuint texture, |
| 3837 | GLint level, |
| 3838 | GLsizei numViews, |
| 3839 | const GLint *viewportOffsets) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3840 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3841 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 3842 | ASSERT(framebuffer); |
| 3843 | |
| 3844 | if (texture != 0) |
| 3845 | { |
| 3846 | Texture *textureObj = getTexture(texture); |
| 3847 | |
| 3848 | ImageIndex index = ImageIndex::Make2D(level); |
| 3849 | framebuffer->setAttachmentMultiviewSideBySide(this, GL_TEXTURE, attachment, index, |
| 3850 | textureObj, numViews, viewportOffsets); |
| 3851 | } |
| 3852 | else |
| 3853 | { |
| 3854 | framebuffer->resetAttachment(this, attachment); |
| 3855 | } |
| 3856 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3857 | mState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3858 | } |
| 3859 | |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3860 | void Context::framebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level) |
| 3861 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3862 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jiawei Shao | a880247 | 2018-05-28 11:17:47 +0800 | [diff] [blame] | 3863 | ASSERT(framebuffer); |
| 3864 | |
| 3865 | if (texture != 0) |
| 3866 | { |
| 3867 | Texture *textureObj = getTexture(texture); |
| 3868 | |
| 3869 | ImageIndex index = ImageIndex::MakeFromType( |
| 3870 | textureObj->getType(), level, ImageIndex::kEntireLevel, ImageIndex::kEntireLevel); |
| 3871 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
| 3872 | } |
| 3873 | else |
| 3874 | { |
| 3875 | framebuffer->resetAttachment(this, attachment); |
| 3876 | } |
| 3877 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3878 | mState.setObjectDirty(target); |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3879 | } |
| 3880 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3881 | void Context::drawBuffers(GLsizei n, const GLenum *bufs) |
| 3882 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3883 | Framebuffer *framebuffer = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3884 | ASSERT(framebuffer); |
| 3885 | framebuffer->setDrawBuffers(n, bufs); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3886 | mState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 3887 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3888 | } |
| 3889 | |
| 3890 | void Context::readBuffer(GLenum mode) |
| 3891 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3892 | Framebuffer *readFBO = mState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3893 | readFBO->setReadBuffer(mode); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3894 | mState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3895 | } |
| 3896 | |
| 3897 | void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) |
| 3898 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3899 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3900 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3901 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3902 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3903 | ASSERT(framebuffer); |
| 3904 | |
| 3905 | // The specification isn't clear what should be done when the framebuffer isn't complete. |
| 3906 | // 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] | 3907 | ANGLE_CONTEXT_TRY(framebuffer->discard(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3908 | } |
| 3909 | |
| 3910 | void Context::invalidateFramebuffer(GLenum target, |
| 3911 | GLsizei numAttachments, |
| 3912 | const GLenum *attachments) |
| 3913 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3914 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3915 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3916 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3917 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3918 | ASSERT(framebuffer); |
| 3919 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 3920 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3921 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3922 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3923 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3924 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3925 | ANGLE_CONTEXT_TRY(framebuffer->invalidate(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3926 | } |
| 3927 | |
| 3928 | void Context::invalidateSubFramebuffer(GLenum target, |
| 3929 | GLsizei numAttachments, |
| 3930 | const GLenum *attachments, |
| 3931 | GLint x, |
| 3932 | GLint y, |
| 3933 | GLsizei width, |
| 3934 | GLsizei height) |
| 3935 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3936 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3937 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3938 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3939 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3940 | ASSERT(framebuffer); |
| 3941 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 3942 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3943 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3944 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3945 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3946 | |
| 3947 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3948 | ANGLE_CONTEXT_TRY(framebuffer->invalidateSub(this, numAttachments, attachments, area)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3949 | } |
| 3950 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3951 | void Context::texImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3952 | GLint level, |
| 3953 | GLint internalformat, |
| 3954 | GLsizei width, |
| 3955 | GLsizei height, |
| 3956 | GLint border, |
| 3957 | GLenum format, |
| 3958 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3959 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3960 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3961 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3962 | |
| 3963 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3964 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3965 | ANGLE_CONTEXT_TRY(texture->setImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3966 | internalformat, size, format, type, |
| 3967 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3968 | } |
| 3969 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3970 | void Context::texImage2DRobust(TextureTarget target, |
| 3971 | GLint level, |
| 3972 | GLint internalformat, |
| 3973 | GLsizei width, |
| 3974 | GLsizei height, |
| 3975 | GLint border, |
| 3976 | GLenum format, |
| 3977 | GLenum type, |
| 3978 | GLsizei bufSize, |
| 3979 | const void *pixels) |
| 3980 | { |
| 3981 | texImage2D(target, level, internalformat, width, height, border, format, type, pixels); |
| 3982 | } |
| 3983 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3984 | void Context::texImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3985 | GLint level, |
| 3986 | GLint internalformat, |
| 3987 | GLsizei width, |
| 3988 | GLsizei height, |
| 3989 | GLsizei depth, |
| 3990 | GLint border, |
| 3991 | GLenum format, |
| 3992 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3993 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3994 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3995 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3996 | |
| 3997 | Extents size(width, height, depth); |
| 3998 | Texture *texture = getTargetTexture(target); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3999 | ANGLE_CONTEXT_TRY(texture->setImage(this, mState.getUnpackState(), |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4000 | NonCubeTextureTypeToTarget(target), level, internalformat, |
| 4001 | size, format, type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4002 | } |
| 4003 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4004 | void Context::texImage3DRobust(TextureType target, |
| 4005 | GLint level, |
| 4006 | GLint internalformat, |
| 4007 | GLsizei width, |
| 4008 | GLsizei height, |
| 4009 | GLsizei depth, |
| 4010 | GLint border, |
| 4011 | GLenum format, |
| 4012 | GLenum type, |
| 4013 | GLsizei bufSize, |
| 4014 | const void *pixels) |
| 4015 | { |
| 4016 | texImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 4017 | } |
| 4018 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4019 | void Context::texSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4020 | GLint level, |
| 4021 | GLint xoffset, |
| 4022 | GLint yoffset, |
| 4023 | GLsizei width, |
| 4024 | GLsizei height, |
| 4025 | GLenum format, |
| 4026 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4027 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4028 | { |
| 4029 | // Zero sized uploads are valid but no-ops |
| 4030 | if (width == 0 || height == 0) |
| 4031 | { |
| 4032 | return; |
| 4033 | } |
| 4034 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4035 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4036 | |
| 4037 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4038 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4039 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4040 | gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4041 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4042 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mState.getUnpackState(), unpackBuffer, target, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4043 | level, area, format, type, |
| 4044 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4045 | } |
| 4046 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4047 | void Context::texSubImage2DRobust(TextureTarget target, |
| 4048 | GLint level, |
| 4049 | GLint xoffset, |
| 4050 | GLint yoffset, |
| 4051 | GLsizei width, |
| 4052 | GLsizei height, |
| 4053 | GLenum format, |
| 4054 | GLenum type, |
| 4055 | GLsizei bufSize, |
| 4056 | const void *pixels) |
| 4057 | { |
| 4058 | texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 4059 | } |
| 4060 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4061 | void Context::texSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4062 | GLint level, |
| 4063 | GLint xoffset, |
| 4064 | GLint yoffset, |
| 4065 | GLint zoffset, |
| 4066 | GLsizei width, |
| 4067 | GLsizei height, |
| 4068 | GLsizei depth, |
| 4069 | GLenum format, |
| 4070 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4071 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4072 | { |
| 4073 | // Zero sized uploads are valid but no-ops |
| 4074 | if (width == 0 || height == 0 || depth == 0) |
| 4075 | { |
| 4076 | return; |
| 4077 | } |
| 4078 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4079 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4080 | |
| 4081 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4082 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4083 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4084 | gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4085 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4086 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mState.getUnpackState(), unpackBuffer, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4087 | NonCubeTextureTypeToTarget(target), level, area, format, |
| 4088 | type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4089 | } |
| 4090 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4091 | void Context::texSubImage3DRobust(TextureType target, |
| 4092 | GLint level, |
| 4093 | GLint xoffset, |
| 4094 | GLint yoffset, |
| 4095 | GLint zoffset, |
| 4096 | GLsizei width, |
| 4097 | GLsizei height, |
| 4098 | GLsizei depth, |
| 4099 | GLenum format, |
| 4100 | GLenum type, |
| 4101 | GLsizei bufSize, |
| 4102 | const void *pixels) |
| 4103 | { |
| 4104 | texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, |
| 4105 | pixels); |
| 4106 | } |
| 4107 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4108 | void Context::compressedTexImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4109 | GLint level, |
| 4110 | GLenum internalformat, |
| 4111 | GLsizei width, |
| 4112 | GLsizei height, |
| 4113 | GLint border, |
| 4114 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4115 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4116 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4117 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4118 | |
| 4119 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4120 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4121 | ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4122 | internalformat, size, imageSize, |
| 4123 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4124 | } |
| 4125 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4126 | void Context::compressedTexImage2DRobust(TextureTarget target, |
| 4127 | GLint level, |
| 4128 | GLenum internalformat, |
| 4129 | GLsizei width, |
| 4130 | GLsizei height, |
| 4131 | GLint border, |
| 4132 | GLsizei imageSize, |
| 4133 | GLsizei dataSize, |
| 4134 | const GLvoid *data) |
| 4135 | { |
| 4136 | compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); |
| 4137 | } |
| 4138 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4139 | void Context::compressedTexImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4140 | GLint level, |
| 4141 | GLenum internalformat, |
| 4142 | GLsizei width, |
| 4143 | GLsizei height, |
| 4144 | GLsizei depth, |
| 4145 | GLint border, |
| 4146 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4147 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4148 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4149 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4150 | |
| 4151 | Extents size(width, height, depth); |
| 4152 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4153 | ANGLE_CONTEXT_TRY(texture->setCompressedImage( |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4154 | this, mState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, internalformat, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4155 | size, imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4156 | } |
| 4157 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4158 | void Context::compressedTexImage3DRobust(TextureType target, |
| 4159 | GLint level, |
| 4160 | GLenum internalformat, |
| 4161 | GLsizei width, |
| 4162 | GLsizei height, |
| 4163 | GLsizei depth, |
| 4164 | GLint border, |
| 4165 | GLsizei imageSize, |
| 4166 | GLsizei dataSize, |
| 4167 | const GLvoid *data) |
| 4168 | { |
| 4169 | compressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, |
| 4170 | data); |
| 4171 | } |
| 4172 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4173 | void Context::compressedTexSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4174 | GLint level, |
| 4175 | GLint xoffset, |
| 4176 | GLint yoffset, |
| 4177 | GLsizei width, |
| 4178 | GLsizei height, |
| 4179 | GLenum format, |
| 4180 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4181 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4182 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4183 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4184 | |
| 4185 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4186 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4187 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4188 | area, format, imageSize, |
| 4189 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4190 | } |
| 4191 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4192 | void Context::compressedTexSubImage2DRobust(TextureTarget target, |
| 4193 | GLint level, |
| 4194 | GLint xoffset, |
| 4195 | GLint yoffset, |
| 4196 | GLsizei width, |
| 4197 | GLsizei height, |
| 4198 | GLenum format, |
| 4199 | GLsizei imageSize, |
| 4200 | GLsizei dataSize, |
| 4201 | const GLvoid *data) |
| 4202 | { |
| 4203 | compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, |
| 4204 | data); |
| 4205 | } |
| 4206 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4207 | void Context::compressedTexSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4208 | GLint level, |
| 4209 | GLint xoffset, |
| 4210 | GLint yoffset, |
| 4211 | GLint zoffset, |
| 4212 | GLsizei width, |
| 4213 | GLsizei height, |
| 4214 | GLsizei depth, |
| 4215 | GLenum format, |
| 4216 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4217 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4218 | { |
| 4219 | // Zero sized uploads are valid but no-ops |
| 4220 | if (width == 0 || height == 0) |
| 4221 | { |
| 4222 | return; |
| 4223 | } |
| 4224 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4225 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4226 | |
| 4227 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4228 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4229 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage( |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4230 | this, mState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, area, format, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4231 | imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4232 | } |
| 4233 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4234 | void Context::compressedTexSubImage3DRobust(TextureType target, |
| 4235 | GLint level, |
| 4236 | GLint xoffset, |
| 4237 | GLint yoffset, |
| 4238 | GLint zoffset, |
| 4239 | GLsizei width, |
| 4240 | GLsizei height, |
| 4241 | GLsizei depth, |
| 4242 | GLenum format, |
| 4243 | GLsizei imageSize, |
| 4244 | GLsizei dataSize, |
| 4245 | const GLvoid *data) |
| 4246 | { |
| 4247 | compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, |
| 4248 | imageSize, data); |
| 4249 | } |
| 4250 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4251 | void Context::generateMipmap(TextureType target) |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4252 | { |
| 4253 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4254 | ANGLE_CONTEXT_TRY(texture->generateMipmap(this)); |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4255 | } |
| 4256 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4257 | void Context::copyTexture(GLuint sourceId, |
| 4258 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4259 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4260 | GLuint destId, |
| 4261 | GLint destLevel, |
| 4262 | GLint internalFormat, |
| 4263 | GLenum destType, |
| 4264 | GLboolean unpackFlipY, |
| 4265 | GLboolean unpackPremultiplyAlpha, |
| 4266 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4267 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4268 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4269 | |
| 4270 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4271 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4272 | ANGLE_CONTEXT_TRY( |
| 4273 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4274 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4275 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4276 | } |
| 4277 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4278 | void Context::copySubTexture(GLuint sourceId, |
| 4279 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4280 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4281 | GLuint destId, |
| 4282 | GLint destLevel, |
| 4283 | GLint xoffset, |
| 4284 | GLint yoffset, |
| 4285 | GLint x, |
| 4286 | GLint y, |
| 4287 | GLsizei width, |
| 4288 | GLsizei height, |
| 4289 | GLboolean unpackFlipY, |
| 4290 | GLboolean unpackPremultiplyAlpha, |
| 4291 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4292 | { |
| 4293 | // Zero sized copies are valid but no-ops |
| 4294 | if (width == 0 || height == 0) |
| 4295 | { |
| 4296 | return; |
| 4297 | } |
| 4298 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4299 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4300 | |
| 4301 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4302 | gl::Texture *destTexture = getTexture(destId); |
| 4303 | Offset offset(xoffset, yoffset, 0); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4304 | Box box(x, y, 0, width, height, 1); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4305 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4306 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4307 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4308 | sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4309 | } |
| 4310 | |
| 4311 | void Context::copyTexture3D(GLuint sourceId, |
| 4312 | GLint sourceLevel, |
| 4313 | TextureTarget destTarget, |
| 4314 | GLuint destId, |
| 4315 | GLint destLevel, |
| 4316 | GLint internalFormat, |
| 4317 | GLenum destType, |
| 4318 | GLboolean unpackFlipY, |
| 4319 | GLboolean unpackPremultiplyAlpha, |
| 4320 | GLboolean unpackUnmultiplyAlpha) |
| 4321 | { |
| 4322 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4323 | |
| 4324 | Texture *sourceTexture = getTexture(sourceId); |
| 4325 | Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4326 | ANGLE_CONTEXT_TRY( |
| 4327 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4328 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4329 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4330 | } |
| 4331 | |
| 4332 | void Context::copySubTexture3D(GLuint sourceId, |
| 4333 | GLint sourceLevel, |
| 4334 | TextureTarget destTarget, |
| 4335 | GLuint destId, |
| 4336 | GLint destLevel, |
| 4337 | GLint xoffset, |
| 4338 | GLint yoffset, |
| 4339 | GLint zoffset, |
| 4340 | GLint x, |
| 4341 | GLint y, |
| 4342 | GLint z, |
| 4343 | GLsizei width, |
| 4344 | GLsizei height, |
| 4345 | GLsizei depth, |
| 4346 | GLboolean unpackFlipY, |
| 4347 | GLboolean unpackPremultiplyAlpha, |
| 4348 | GLboolean unpackUnmultiplyAlpha) |
| 4349 | { |
| 4350 | // Zero sized copies are valid but no-ops |
| 4351 | if (width == 0 || height == 0 || depth == 0) |
| 4352 | { |
| 4353 | return; |
| 4354 | } |
| 4355 | |
| 4356 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4357 | |
| 4358 | Texture *sourceTexture = getTexture(sourceId); |
| 4359 | Texture *destTexture = getTexture(destId); |
| 4360 | Offset offset(xoffset, yoffset, zoffset); |
| 4361 | Box box(x, y, z, width, height, depth); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4362 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4363 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4364 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4365 | sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4366 | } |
| 4367 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4368 | void Context::compressedCopyTexture(GLuint sourceId, GLuint destId) |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4369 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4370 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4371 | |
| 4372 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4373 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4374 | ANGLE_CONTEXT_TRY(destTexture->copyCompressedTexture(this, sourceTexture)); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4375 | } |
| 4376 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4377 | void Context::getBufferPointerv(BufferBinding target, GLenum pname, void **params) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4378 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4379 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4380 | ASSERT(buffer); |
| 4381 | |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 4382 | QueryBufferPointerv(buffer, pname, params); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4383 | } |
| 4384 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4385 | void Context::getBufferPointervRobust(BufferBinding target, |
| 4386 | GLenum pname, |
| 4387 | GLsizei bufSize, |
| 4388 | GLsizei *length, |
| 4389 | void **params) |
| 4390 | { |
| 4391 | getBufferPointerv(target, pname, params); |
| 4392 | } |
| 4393 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4394 | void *Context::mapBuffer(BufferBinding target, GLenum access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4395 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4396 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4397 | ASSERT(buffer); |
| 4398 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4399 | if (buffer->map(this, access) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4400 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4401 | return nullptr; |
| 4402 | } |
| 4403 | |
| 4404 | return buffer->getMapPointer(); |
| 4405 | } |
| 4406 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4407 | GLboolean Context::unmapBuffer(BufferBinding target) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4408 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4409 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4410 | ASSERT(buffer); |
| 4411 | |
| 4412 | GLboolean result; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4413 | if (buffer->unmap(this, &result) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4414 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4415 | return GL_FALSE; |
| 4416 | } |
| 4417 | |
| 4418 | return result; |
| 4419 | } |
| 4420 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4421 | void *Context::mapBufferRange(BufferBinding target, |
| 4422 | GLintptr offset, |
| 4423 | GLsizeiptr length, |
| 4424 | GLbitfield access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4425 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4426 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4427 | ASSERT(buffer); |
| 4428 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4429 | if (buffer->mapRange(this, offset, length, access) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4430 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4431 | return nullptr; |
| 4432 | } |
| 4433 | |
| 4434 | return buffer->getMapPointer(); |
| 4435 | } |
| 4436 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4437 | void Context::flushMappedBufferRange(BufferBinding /*target*/, |
| 4438 | GLintptr /*offset*/, |
| 4439 | GLsizeiptr /*length*/) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4440 | { |
| 4441 | // We do not currently support a non-trivial implementation of FlushMappedBufferRange |
| 4442 | } |
| 4443 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4444 | angle::Result Context::syncStateForReadPixels() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4445 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4446 | return syncState(mReadPixelsDirtyBits, mReadPixelsDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4447 | } |
| 4448 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4449 | angle::Result Context::syncStateForTexImage() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4450 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4451 | return syncState(mTexImageDirtyBits, mTexImageDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4452 | } |
| 4453 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4454 | angle::Result Context::syncStateForBlit() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4455 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4456 | return syncState(mBlitDirtyBits, mBlitDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4457 | } |
| 4458 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4459 | angle::Result Context::syncStateForPathOperation() |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4460 | { |
| 4461 | ANGLE_TRY(syncDirtyObjects(mPathOperationDirtyObjects)); |
| 4462 | |
| 4463 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 4464 | ANGLE_TRY(syncDirtyBits()); |
| 4465 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4466 | return angle::Result::Continue; |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4467 | } |
| 4468 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4469 | void Context::activeShaderProgram(GLuint pipeline, GLuint program) |
| 4470 | { |
| 4471 | UNIMPLEMENTED(); |
| 4472 | } |
| 4473 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4474 | void Context::activeTexture(GLenum texture) |
| 4475 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4476 | mState.setActiveSampler(texture - GL_TEXTURE0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4477 | } |
| 4478 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4479 | void Context::blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4480 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4481 | mState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4482 | } |
| 4483 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4484 | void Context::blendEquation(GLenum mode) |
| 4485 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4486 | mState.setBlendEquation(mode, mode); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4487 | } |
| 4488 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4489 | void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 4490 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4491 | mState.setBlendEquation(modeRGB, modeAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4492 | } |
| 4493 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4494 | void Context::blendFunc(GLenum sfactor, GLenum dfactor) |
| 4495 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4496 | mState.setBlendFactors(sfactor, dfactor, sfactor, dfactor); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4497 | } |
| 4498 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4499 | void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 4500 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4501 | mState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4502 | } |
| 4503 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4504 | void Context::clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4505 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4506 | mState.setColorClearValue(red, green, blue, alpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4507 | } |
| 4508 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4509 | void Context::clearDepthf(GLfloat depth) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4510 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4511 | mState.setDepthClearValue(clamp01(depth)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4512 | } |
| 4513 | |
| 4514 | void Context::clearStencil(GLint s) |
| 4515 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4516 | mState.setStencilClearValue(s); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4517 | } |
| 4518 | |
| 4519 | void Context::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 4520 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4521 | mState.setColorMask(ConvertToBool(red), ConvertToBool(green), ConvertToBool(blue), |
| 4522 | ConvertToBool(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4523 | } |
| 4524 | |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 4525 | void Context::cullFace(CullFaceMode mode) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4526 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4527 | mState.setCullMode(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4528 | } |
| 4529 | |
| 4530 | void Context::depthFunc(GLenum func) |
| 4531 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4532 | mState.setDepthFunc(func); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4533 | } |
| 4534 | |
| 4535 | void Context::depthMask(GLboolean flag) |
| 4536 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4537 | mState.setDepthMask(ConvertToBool(flag)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4538 | } |
| 4539 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4540 | void Context::depthRangef(GLfloat zNear, GLfloat zFar) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4541 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4542 | mState.setDepthRange(clamp01(zNear), clamp01(zFar)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4543 | } |
| 4544 | |
| 4545 | void Context::disable(GLenum cap) |
| 4546 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4547 | mState.setEnableFeature(cap, false); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4548 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4549 | } |
| 4550 | |
| 4551 | void Context::disableVertexAttribArray(GLuint index) |
| 4552 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4553 | mState.setEnableVertexAttribArray(index, false); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4554 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4555 | } |
| 4556 | |
| 4557 | void Context::enable(GLenum cap) |
| 4558 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4559 | mState.setEnableFeature(cap, true); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4560 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4561 | } |
| 4562 | |
| 4563 | void Context::enableVertexAttribArray(GLuint index) |
| 4564 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4565 | mState.setEnableVertexAttribArray(index, true); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4566 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4567 | } |
| 4568 | |
| 4569 | void Context::frontFace(GLenum mode) |
| 4570 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4571 | mState.setFrontFace(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4572 | } |
| 4573 | |
| 4574 | void Context::hint(GLenum target, GLenum mode) |
| 4575 | { |
| 4576 | switch (target) |
| 4577 | { |
| 4578 | case GL_GENERATE_MIPMAP_HINT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4579 | mState.setGenerateMipmapHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4580 | break; |
| 4581 | |
| 4582 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4583 | mState.setFragmentShaderDerivativeHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4584 | break; |
| 4585 | |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 4586 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 4587 | case GL_POINT_SMOOTH_HINT: |
| 4588 | case GL_LINE_SMOOTH_HINT: |
| 4589 | case GL_FOG_HINT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4590 | mState.gles1().setHint(target, mode); |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 4591 | break; |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4592 | default: |
| 4593 | UNREACHABLE(); |
| 4594 | return; |
| 4595 | } |
| 4596 | } |
| 4597 | |
| 4598 | void Context::lineWidth(GLfloat width) |
| 4599 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4600 | mState.setLineWidth(width); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4601 | } |
| 4602 | |
| 4603 | void Context::pixelStorei(GLenum pname, GLint param) |
| 4604 | { |
| 4605 | switch (pname) |
| 4606 | { |
| 4607 | case GL_UNPACK_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4608 | mState.setUnpackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4609 | break; |
| 4610 | |
| 4611 | case GL_PACK_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4612 | mState.setPackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4613 | break; |
| 4614 | |
| 4615 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4616 | mState.setPackReverseRowOrder(param != 0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4617 | break; |
| 4618 | |
| 4619 | case GL_UNPACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4620 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4621 | mState.setUnpackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4622 | break; |
| 4623 | |
| 4624 | case GL_UNPACK_IMAGE_HEIGHT: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4625 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4626 | mState.setUnpackImageHeight(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4627 | break; |
| 4628 | |
| 4629 | case GL_UNPACK_SKIP_IMAGES: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4630 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4631 | mState.setUnpackSkipImages(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4632 | break; |
| 4633 | |
| 4634 | case GL_UNPACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4635 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4636 | mState.setUnpackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4637 | break; |
| 4638 | |
| 4639 | case GL_UNPACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4640 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4641 | mState.setUnpackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4642 | break; |
| 4643 | |
| 4644 | case GL_PACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4645 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4646 | mState.setPackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4647 | break; |
| 4648 | |
| 4649 | case GL_PACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4650 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4651 | mState.setPackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4652 | break; |
| 4653 | |
| 4654 | case GL_PACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4655 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4656 | mState.setPackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4657 | break; |
| 4658 | |
| 4659 | default: |
| 4660 | UNREACHABLE(); |
| 4661 | return; |
| 4662 | } |
| 4663 | } |
| 4664 | |
| 4665 | void Context::polygonOffset(GLfloat factor, GLfloat units) |
| 4666 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4667 | mState.setPolygonOffsetParams(factor, units); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4668 | } |
| 4669 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4670 | void Context::sampleCoverage(GLfloat value, GLboolean invert) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4671 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4672 | mState.setSampleCoverageParams(clamp01(value), ConvertToBool(invert)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4673 | } |
| 4674 | |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 4675 | void Context::sampleMaski(GLuint maskNumber, GLbitfield mask) |
| 4676 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4677 | mState.setSampleMaskParams(maskNumber, mask); |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 4678 | } |
| 4679 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4680 | void Context::scissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4681 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4682 | mState.setScissorParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4683 | } |
| 4684 | |
| 4685 | void Context::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 4686 | { |
| 4687 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4688 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4689 | mState.setStencilParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4690 | } |
| 4691 | |
| 4692 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4693 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4694 | mState.setStencilBackParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4695 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4696 | |
| 4697 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4698 | } |
| 4699 | |
| 4700 | void Context::stencilMaskSeparate(GLenum face, GLuint mask) |
| 4701 | { |
| 4702 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4703 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4704 | mState.setStencilWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4705 | } |
| 4706 | |
| 4707 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4708 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4709 | mState.setStencilBackWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4710 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4711 | |
| 4712 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4713 | } |
| 4714 | |
| 4715 | void Context::stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 4716 | { |
| 4717 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4718 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4719 | mState.setStencilOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4720 | } |
| 4721 | |
| 4722 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4723 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4724 | mState.setStencilBackOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4725 | } |
| 4726 | } |
| 4727 | |
| 4728 | void Context::vertexAttrib1f(GLuint index, GLfloat x) |
| 4729 | { |
| 4730 | GLfloat vals[4] = {x, 0, 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4731 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4732 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4733 | } |
| 4734 | |
| 4735 | void Context::vertexAttrib1fv(GLuint index, const GLfloat *values) |
| 4736 | { |
| 4737 | GLfloat vals[4] = {values[0], 0, 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4738 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4739 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4740 | } |
| 4741 | |
| 4742 | void Context::vertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 4743 | { |
| 4744 | GLfloat vals[4] = {x, y, 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4745 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4746 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4747 | } |
| 4748 | |
| 4749 | void Context::vertexAttrib2fv(GLuint index, const GLfloat *values) |
| 4750 | { |
| 4751 | GLfloat vals[4] = {values[0], values[1], 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4752 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4753 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4754 | } |
| 4755 | |
| 4756 | void Context::vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 4757 | { |
| 4758 | GLfloat vals[4] = {x, y, z, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4759 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4760 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4761 | } |
| 4762 | |
| 4763 | void Context::vertexAttrib3fv(GLuint index, const GLfloat *values) |
| 4764 | { |
| 4765 | GLfloat vals[4] = {values[0], values[1], values[2], 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4766 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4767 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4768 | } |
| 4769 | |
| 4770 | void Context::vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4771 | { |
| 4772 | GLfloat vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4773 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4774 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4775 | } |
| 4776 | |
| 4777 | void Context::vertexAttrib4fv(GLuint index, const GLfloat *values) |
| 4778 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4779 | mState.setVertexAttribf(index, values); |
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::vertexAttribPointer(GLuint index, |
| 4784 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4785 | VertexAttribType type, |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4786 | GLboolean normalized, |
| 4787 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4788 | const void *ptr) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4789 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4790 | mState.setVertexAttribPointer(this, index, mState.getTargetBuffer(BufferBinding::Array), size, |
Jamie Madill | 6e18a23 | 2019-01-16 13:27:14 -0500 | [diff] [blame] | 4791 | type, ConvertToBool(normalized), stride, ptr); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4792 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4793 | } |
| 4794 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4795 | void Context::vertexAttribFormat(GLuint attribIndex, |
| 4796 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4797 | VertexAttribType type, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4798 | GLboolean normalized, |
| 4799 | GLuint relativeOffset) |
| 4800 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4801 | mState.setVertexAttribFormat(attribIndex, size, type, ConvertToBool(normalized), false, |
| 4802 | relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4803 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4804 | } |
| 4805 | |
| 4806 | void Context::vertexAttribIFormat(GLuint attribIndex, |
| 4807 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4808 | VertexAttribType type, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4809 | GLuint relativeOffset) |
| 4810 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4811 | mState.setVertexAttribFormat(attribIndex, size, type, false, true, relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4812 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4813 | } |
| 4814 | |
| 4815 | void Context::vertexAttribBinding(GLuint attribIndex, GLuint bindingIndex) |
| 4816 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4817 | mState.setVertexAttribBinding(this, attribIndex, bindingIndex); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4818 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4819 | } |
| 4820 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4821 | void Context::vertexBindingDivisor(GLuint bindingIndex, GLuint divisor) |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4822 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4823 | mState.setVertexBindingDivisor(bindingIndex, divisor); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4824 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4825 | } |
| 4826 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4827 | void Context::viewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4828 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4829 | mState.setViewportParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4830 | } |
| 4831 | |
| 4832 | void Context::vertexAttribIPointer(GLuint index, |
| 4833 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4834 | VertexAttribType type, |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4835 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4836 | const void *pointer) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4837 | { |
Jamie Madill | 6e18a23 | 2019-01-16 13:27:14 -0500 | [diff] [blame] | 4838 | mState.setVertexAttribIPointer(this, index, mState.getTargetBuffer(BufferBinding::Array), size, |
| 4839 | type, stride, pointer); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4840 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4841 | } |
| 4842 | |
| 4843 | void Context::vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 4844 | { |
| 4845 | GLint vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4846 | mState.setVertexAttribi(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4847 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4848 | } |
| 4849 | |
| 4850 | void Context::vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 4851 | { |
| 4852 | GLuint vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4853 | mState.setVertexAttribu(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4854 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4855 | } |
| 4856 | |
| 4857 | void Context::vertexAttribI4iv(GLuint index, const GLint *v) |
| 4858 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4859 | mState.setVertexAttribi(index, v); |
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::vertexAttribI4uiv(GLuint index, const GLuint *v) |
| 4864 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4865 | mState.setVertexAttribu(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 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4869 | void Context::getVertexAttribiv(GLuint index, GLenum pname, GLint *params) |
| 4870 | { |
| 4871 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4872 | getState().getVertexAttribCurrentValue(index); |
| 4873 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4874 | QueryVertexAttribiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4875 | currentValues, pname, params); |
| 4876 | } |
| 4877 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4878 | void Context::getVertexAttribivRobust(GLuint index, |
| 4879 | GLenum pname, |
| 4880 | GLsizei bufSize, |
| 4881 | GLsizei *length, |
| 4882 | GLint *params) |
| 4883 | { |
| 4884 | getVertexAttribiv(index, pname, params); |
| 4885 | } |
| 4886 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4887 | void Context::getVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) |
| 4888 | { |
| 4889 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4890 | getState().getVertexAttribCurrentValue(index); |
| 4891 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4892 | QueryVertexAttribfv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4893 | currentValues, pname, params); |
| 4894 | } |
| 4895 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4896 | void Context::getVertexAttribfvRobust(GLuint index, |
| 4897 | GLenum pname, |
| 4898 | GLsizei bufSize, |
| 4899 | GLsizei *length, |
| 4900 | GLfloat *params) |
| 4901 | { |
| 4902 | getVertexAttribfv(index, pname, params); |
| 4903 | } |
| 4904 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4905 | void Context::getVertexAttribIiv(GLuint index, GLenum pname, GLint *params) |
| 4906 | { |
| 4907 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4908 | getState().getVertexAttribCurrentValue(index); |
| 4909 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4910 | QueryVertexAttribIiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4911 | currentValues, pname, params); |
| 4912 | } |
| 4913 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4914 | void Context::getVertexAttribIivRobust(GLuint index, |
| 4915 | GLenum pname, |
| 4916 | GLsizei bufSize, |
| 4917 | GLsizei *length, |
| 4918 | GLint *params) |
| 4919 | { |
| 4920 | getVertexAttribIiv(index, pname, params); |
| 4921 | } |
| 4922 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4923 | void Context::getVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) |
| 4924 | { |
| 4925 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4926 | getState().getVertexAttribCurrentValue(index); |
| 4927 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4928 | QueryVertexAttribIuiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4929 | currentValues, pname, params); |
| 4930 | } |
| 4931 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4932 | void Context::getVertexAttribIuivRobust(GLuint index, |
| 4933 | GLenum pname, |
| 4934 | GLsizei bufSize, |
| 4935 | GLsizei *length, |
| 4936 | GLuint *params) |
| 4937 | { |
| 4938 | getVertexAttribIuiv(index, pname, params); |
| 4939 | } |
| 4940 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4941 | void Context::getVertexAttribPointerv(GLuint index, GLenum pname, void **pointer) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4942 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4943 | const VertexAttribute &attrib = getState().getVertexArray()->getVertexAttribute(index); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4944 | QueryVertexAttribPointerv(attrib, pname, pointer); |
| 4945 | } |
| 4946 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4947 | void Context::getVertexAttribPointervRobust(GLuint index, |
| 4948 | GLenum pname, |
| 4949 | GLsizei bufSize, |
| 4950 | GLsizei *length, |
| 4951 | void **pointer) |
| 4952 | { |
| 4953 | getVertexAttribPointerv(index, pname, pointer); |
| 4954 | } |
| 4955 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4956 | void Context::debugMessageControl(GLenum source, |
| 4957 | GLenum type, |
| 4958 | GLenum severity, |
| 4959 | GLsizei count, |
| 4960 | const GLuint *ids, |
| 4961 | GLboolean enabled) |
| 4962 | { |
| 4963 | std::vector<GLuint> idVector(ids, ids + count); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4964 | mState.getDebug().setMessageControl(source, type, severity, std::move(idVector), |
| 4965 | ConvertToBool(enabled)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4966 | } |
| 4967 | |
| 4968 | void Context::debugMessageInsert(GLenum source, |
| 4969 | GLenum type, |
| 4970 | GLuint id, |
| 4971 | GLenum severity, |
| 4972 | GLsizei length, |
| 4973 | const GLchar *buf) |
| 4974 | { |
| 4975 | 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] | 4976 | mState.getDebug().insertMessage(source, type, id, severity, std::move(msg)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4977 | } |
| 4978 | |
| 4979 | void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam) |
| 4980 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4981 | mState.getDebug().setCallback(callback, userParam); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4982 | } |
| 4983 | |
| 4984 | GLuint Context::getDebugMessageLog(GLuint count, |
| 4985 | GLsizei bufSize, |
| 4986 | GLenum *sources, |
| 4987 | GLenum *types, |
| 4988 | GLuint *ids, |
| 4989 | GLenum *severities, |
| 4990 | GLsizei *lengths, |
| 4991 | GLchar *messageLog) |
| 4992 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4993 | return static_cast<GLuint>(mState.getDebug().getMessages(count, bufSize, sources, types, ids, |
| 4994 | severities, lengths, messageLog)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4995 | } |
| 4996 | |
| 4997 | void Context::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) |
| 4998 | { |
| 4999 | 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] | 5000 | mState.getDebug().pushGroup(source, id, std::move(msg)); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5001 | mImplementation->pushDebugGroup(source, id, length, message); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5002 | } |
| 5003 | |
| 5004 | void Context::popDebugGroup() |
| 5005 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5006 | mState.getDebug().popGroup(); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5007 | mImplementation->popDebugGroup(); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5008 | } |
| 5009 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5010 | void Context::bufferData(BufferBinding target, GLsizeiptr size, const void *data, BufferUsage usage) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5011 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5012 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5013 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5014 | ANGLE_CONTEXT_TRY(buffer->bufferData(this, target, data, size, usage)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5015 | } |
| 5016 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5017 | void Context::bufferSubData(BufferBinding target, |
| 5018 | GLintptr offset, |
| 5019 | GLsizeiptr size, |
| 5020 | const void *data) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5021 | { |
Courtney Goeltzenleuchter | 62114aa | 2018-08-28 09:36:46 -0600 | [diff] [blame] | 5022 | if (data == nullptr || size == 0) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5023 | { |
| 5024 | return; |
| 5025 | } |
| 5026 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5027 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5028 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5029 | ANGLE_CONTEXT_TRY(buffer->bufferSubData(this, target, data, size, offset)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5030 | } |
| 5031 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5032 | void Context::attachShader(GLuint program, GLuint shader) |
| 5033 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5034 | Program *programObject = mState.mShaderProgramManager->getProgram(program); |
| 5035 | Shader *shaderObject = mState.mShaderProgramManager->getShader(shader); |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5036 | ASSERT(programObject && shaderObject); |
| 5037 | programObject->attachShader(shaderObject); |
| 5038 | } |
| 5039 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 5040 | const Workarounds &Context::getWorkarounds() const |
| 5041 | { |
| 5042 | return mWorkarounds; |
| 5043 | } |
| 5044 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5045 | void Context::copyBufferSubData(BufferBinding readTarget, |
| 5046 | BufferBinding writeTarget, |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5047 | GLintptr readOffset, |
| 5048 | GLintptr writeOffset, |
| 5049 | GLsizeiptr size) |
| 5050 | { |
| 5051 | // if size is zero, the copy is a successful no-op |
| 5052 | if (size == 0) |
| 5053 | { |
| 5054 | return; |
| 5055 | } |
| 5056 | |
| 5057 | // TODO(jmadill): cache these. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5058 | Buffer *readBuffer = mState.getTargetBuffer(readTarget); |
| 5059 | Buffer *writeBuffer = mState.getTargetBuffer(writeTarget); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5060 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5061 | ANGLE_CONTEXT_TRY( |
| 5062 | writeBuffer->copyBufferSubData(this, readBuffer, readOffset, writeOffset, size)); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5063 | } |
| 5064 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5065 | void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *name) |
| 5066 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5067 | // Ideally we could share the program query with the validation layer if possible. |
| 5068 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5069 | ASSERT(programObject); |
| 5070 | programObject->bindAttributeLocation(index, name); |
| 5071 | } |
| 5072 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5073 | void Context::bindBufferBase(BufferBinding target, GLuint index, GLuint buffer) |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5074 | { |
| 5075 | bindBufferRange(target, index, buffer, 0, 0); |
| 5076 | } |
| 5077 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5078 | void Context::bindBufferRange(BufferBinding target, |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5079 | GLuint index, |
| 5080 | GLuint buffer, |
| 5081 | GLintptr offset, |
| 5082 | GLsizeiptr size) |
| 5083 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5084 | Buffer *object = mState.mBufferManager->checkBufferAllocation(mImplementation.get(), buffer); |
| 5085 | ANGLE_CONTEXT_TRY(mState.setIndexedBufferBinding(this, target, index, object, offset, size)); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5086 | if (target == BufferBinding::Uniform) |
| 5087 | { |
Jamie Madill | 472ddc8 | 2018-10-18 18:41:56 -0400 | [diff] [blame] | 5088 | mUniformBufferObserverBindings[index].bind(object); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 5089 | mStateCache.onUniformBufferStateChange(this); |
| 5090 | } |
| 5091 | else |
| 5092 | { |
| 5093 | mStateCache.onBufferBindingChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5094 | } |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5095 | } |
| 5096 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5097 | void Context::bindFramebuffer(GLenum target, GLuint framebuffer) |
| 5098 | { |
| 5099 | if (target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5100 | { |
| 5101 | bindReadFramebuffer(framebuffer); |
| 5102 | } |
| 5103 | |
| 5104 | if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5105 | { |
| 5106 | bindDrawFramebuffer(framebuffer); |
| 5107 | } |
| 5108 | } |
| 5109 | |
| 5110 | void Context::bindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 5111 | { |
| 5112 | ASSERT(target == GL_RENDERBUFFER); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5113 | Renderbuffer *object = mState.mRenderbufferManager->checkRenderbufferAllocation( |
| 5114 | mImplementation.get(), renderbuffer); |
| 5115 | mState.setRenderbufferBinding(this, object); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5116 | } |
| 5117 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5118 | void Context::texStorage2DMultisample(TextureType target, |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5119 | GLsizei samples, |
| 5120 | GLenum internalformat, |
| 5121 | GLsizei width, |
| 5122 | GLsizei height, |
| 5123 | GLboolean fixedsamplelocations) |
| 5124 | { |
| 5125 | Extents size(width, height, 1); |
| 5126 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5127 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5128 | ConvertToBool(fixedsamplelocations))); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5129 | } |
| 5130 | |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5131 | void Context::texStorage3DMultisample(TextureType target, |
| 5132 | GLsizei samples, |
| 5133 | GLenum internalformat, |
| 5134 | GLsizei width, |
| 5135 | GLsizei height, |
| 5136 | GLsizei depth, |
| 5137 | GLboolean fixedsamplelocations) |
| 5138 | { |
Olli Etuaho | 0c5a9e2 | 2018-08-27 14:36:23 +0300 | [diff] [blame] | 5139 | Extents size(width, height, depth); |
| 5140 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5141 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5142 | ConvertToBool(fixedsamplelocations))); |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5143 | } |
| 5144 | |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5145 | void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val) |
| 5146 | { |
JiangYizhou | 5b03f47 | 2017-01-09 10:22:53 +0800 | [diff] [blame] | 5147 | // According to spec 3.1 Table 20.49: Framebuffer Dependent Values, |
| 5148 | // the sample position should be queried by DRAW_FRAMEBUFFER. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5149 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_DRAW_FRAMEBUFFER)); |
| 5150 | const Framebuffer *framebuffer = mState.getDrawFramebuffer(); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5151 | |
| 5152 | switch (pname) |
| 5153 | { |
| 5154 | case GL_SAMPLE_POSITION: |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5155 | ANGLE_CONTEXT_TRY(framebuffer->getSamplePosition(this, index, val)); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5156 | break; |
| 5157 | default: |
| 5158 | UNREACHABLE(); |
| 5159 | } |
| 5160 | } |
| 5161 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5162 | void Context::getMultisamplefvRobust(GLenum pname, |
| 5163 | GLuint index, |
| 5164 | GLsizei bufSize, |
| 5165 | GLsizei *length, |
| 5166 | GLfloat *val) |
| 5167 | { |
| 5168 | UNIMPLEMENTED(); |
| 5169 | } |
| 5170 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5171 | void Context::renderbufferStorage(GLenum target, |
| 5172 | GLenum internalformat, |
| 5173 | GLsizei width, |
| 5174 | GLsizei height) |
| 5175 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5176 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5177 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
| 5178 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5179 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5180 | ANGLE_CONTEXT_TRY(renderbuffer->setStorage(this, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5181 | } |
| 5182 | |
| 5183 | void Context::renderbufferStorageMultisample(GLenum target, |
| 5184 | GLsizei samples, |
| 5185 | GLenum internalformat, |
| 5186 | GLsizei width, |
| 5187 | GLsizei height) |
| 5188 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5189 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5190 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5191 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5192 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5193 | ANGLE_CONTEXT_TRY( |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5194 | renderbuffer->setStorageMultisample(this, samples, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5195 | } |
| 5196 | |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5197 | void Context::getSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) |
| 5198 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 5199 | const Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5200 | ANGLE_CONTEXT_TRY(QuerySynciv(this, syncObject, pname, bufSize, length, values)); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5201 | } |
| 5202 | |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5203 | void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 5204 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5205 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5206 | QueryFramebufferParameteriv(framebuffer, pname, params); |
| 5207 | } |
| 5208 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5209 | void Context::getFramebufferParameterivRobust(GLenum target, |
| 5210 | GLenum pname, |
| 5211 | GLsizei bufSize, |
| 5212 | GLsizei *length, |
| 5213 | GLint *params) |
| 5214 | { |
| 5215 | UNIMPLEMENTED(); |
| 5216 | } |
| 5217 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5218 | void Context::framebufferParameteri(GLenum target, GLenum pname, GLint param) |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5219 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5220 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | b983a4b | 2018-08-01 11:34:51 -0400 | [diff] [blame] | 5221 | SetFramebufferParameteri(this, framebuffer, pname, param); |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5222 | } |
| 5223 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5224 | bool Context::getScratchBuffer(size_t requstedSizeBytes, |
| 5225 | angle::MemoryBuffer **scratchBufferOut) const |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5226 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5227 | return mScratchBuffer.get(requstedSizeBytes, scratchBufferOut); |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5228 | } |
| 5229 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5230 | bool Context::getZeroFilledBuffer(size_t requstedSizeBytes, |
| 5231 | angle::MemoryBuffer **zeroBufferOut) const |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5232 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5233 | return mZeroFilledBuffer.getInitialized(requstedSizeBytes, zeroBufferOut, 0); |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5234 | } |
| 5235 | |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5236 | void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) |
| 5237 | { |
| 5238 | if (numGroupsX == 0u || numGroupsY == 0u || numGroupsZ == 0u) |
| 5239 | { |
| 5240 | return; |
| 5241 | } |
| 5242 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 5243 | ANGLE_CONTEXT_TRY(prepareForDispatch()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5244 | ANGLE_CONTEXT_TRY(mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ)); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5245 | } |
| 5246 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5247 | void Context::dispatchComputeIndirect(GLintptr indirect) |
| 5248 | { |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +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->dispatchComputeIndirect(this, indirect)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5251 | } |
| 5252 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5253 | void Context::texStorage2D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5254 | GLsizei levels, |
| 5255 | GLenum internalFormat, |
| 5256 | GLsizei width, |
| 5257 | GLsizei height) |
| 5258 | { |
| 5259 | Extents size(width, height, 1); |
| 5260 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5261 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5262 | } |
| 5263 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5264 | void Context::texStorage3D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5265 | GLsizei levels, |
| 5266 | GLenum internalFormat, |
| 5267 | GLsizei width, |
| 5268 | GLsizei height, |
| 5269 | GLsizei depth) |
| 5270 | { |
| 5271 | Extents size(width, height, depth); |
| 5272 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5273 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5274 | } |
| 5275 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5276 | void Context::memoryBarrier(GLbitfield barriers) |
| 5277 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5278 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrier(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5279 | } |
| 5280 | |
| 5281 | void Context::memoryBarrierByRegion(GLbitfield barriers) |
| 5282 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5283 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrierByRegion(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5284 | } |
| 5285 | |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5286 | void Context::multiDrawArrays(PrimitiveMode mode, |
| 5287 | const GLint *firsts, |
| 5288 | const GLsizei *counts, |
| 5289 | GLsizei drawcount) |
| 5290 | { |
| 5291 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5292 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5293 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5294 | if (hasDrawID) |
| 5295 | { |
| 5296 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5297 | { |
| 5298 | if (noopDraw(mode, counts[drawID])) |
| 5299 | { |
| 5300 | continue; |
| 5301 | } |
| 5302 | programObject->setDrawIDUniform(drawID); |
| 5303 | ANGLE_CONTEXT_TRY( |
| 5304 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5305 | MarkTransformFeedbackBufferUsage(this, counts[drawID], 1); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5306 | } |
| 5307 | } |
| 5308 | else |
| 5309 | { |
| 5310 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5311 | { |
| 5312 | if (noopDraw(mode, counts[drawID])) |
| 5313 | { |
| 5314 | continue; |
| 5315 | } |
| 5316 | ANGLE_CONTEXT_TRY( |
| 5317 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5318 | MarkTransformFeedbackBufferUsage(this, counts[drawID], 1); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5319 | } |
| 5320 | } |
| 5321 | } |
| 5322 | |
| 5323 | void Context::multiDrawArraysInstanced(PrimitiveMode mode, |
| 5324 | const GLint *firsts, |
| 5325 | const GLsizei *counts, |
| 5326 | const GLsizei *instanceCounts, |
| 5327 | GLsizei drawcount) |
| 5328 | { |
| 5329 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5330 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5331 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5332 | if (hasDrawID) |
| 5333 | { |
| 5334 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5335 | { |
| 5336 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5337 | { |
| 5338 | continue; |
| 5339 | } |
| 5340 | programObject->setDrawIDUniform(drawID); |
| 5341 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5342 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5343 | MarkTransformFeedbackBufferUsage(this, counts[drawID], instanceCounts[drawID]); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5344 | } |
| 5345 | } |
| 5346 | else |
| 5347 | { |
| 5348 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5349 | { |
| 5350 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5351 | { |
| 5352 | continue; |
| 5353 | } |
| 5354 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5355 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5356 | MarkTransformFeedbackBufferUsage(this, counts[drawID], instanceCounts[drawID]); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5357 | } |
| 5358 | } |
| 5359 | } |
| 5360 | |
| 5361 | void Context::multiDrawElements(PrimitiveMode mode, |
| 5362 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5363 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5364 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5365 | GLsizei drawcount) |
| 5366 | { |
| 5367 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5368 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5369 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5370 | if (hasDrawID) |
| 5371 | { |
| 5372 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5373 | { |
| 5374 | if (noopDraw(mode, counts[drawID])) |
| 5375 | { |
| 5376 | continue; |
| 5377 | } |
| 5378 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5379 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5380 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5381 | } |
| 5382 | } |
| 5383 | else |
| 5384 | { |
| 5385 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5386 | { |
| 5387 | if (noopDraw(mode, counts[drawID])) |
| 5388 | { |
| 5389 | continue; |
| 5390 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5391 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5392 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5393 | } |
| 5394 | } |
| 5395 | } |
| 5396 | |
| 5397 | void Context::multiDrawElementsInstanced(PrimitiveMode mode, |
| 5398 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5399 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5400 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5401 | const GLsizei *instanceCounts, |
| 5402 | GLsizei drawcount) |
| 5403 | { |
| 5404 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5405 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5406 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5407 | if (hasDrawID) |
| 5408 | { |
| 5409 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5410 | { |
| 5411 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5412 | { |
| 5413 | continue; |
| 5414 | } |
| 5415 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5416 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5417 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5418 | } |
| 5419 | } |
| 5420 | else |
| 5421 | { |
| 5422 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5423 | { |
| 5424 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5425 | { |
| 5426 | continue; |
| 5427 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5428 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5429 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5430 | } |
| 5431 | } |
| 5432 | } |
| 5433 | |
Jeff Gilbert | 465d609 | 2019-01-02 16:21:18 -0800 | [diff] [blame^] | 5434 | void Context::provokingVertex(ProvokingVertex provokeMode) |
| 5435 | { |
| 5436 | mState.setProvokingVertex(provokeMode); |
| 5437 | } |
| 5438 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5439 | GLenum Context::checkFramebufferStatus(GLenum target) |
| 5440 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5441 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5442 | ASSERT(framebuffer); |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 5443 | return framebuffer->checkStatus(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5444 | } |
| 5445 | |
| 5446 | void Context::compileShader(GLuint shader) |
| 5447 | { |
| 5448 | Shader *shaderObject = GetValidShader(this, shader); |
| 5449 | if (!shaderObject) |
| 5450 | { |
| 5451 | return; |
| 5452 | } |
| 5453 | shaderObject->compile(this); |
| 5454 | } |
| 5455 | |
| 5456 | void Context::deleteBuffers(GLsizei n, const GLuint *buffers) |
| 5457 | { |
| 5458 | for (int i = 0; i < n; i++) |
| 5459 | { |
| 5460 | deleteBuffer(buffers[i]); |
| 5461 | } |
| 5462 | } |
| 5463 | |
| 5464 | void Context::deleteFramebuffers(GLsizei n, const GLuint *framebuffers) |
| 5465 | { |
| 5466 | for (int i = 0; i < n; i++) |
| 5467 | { |
| 5468 | if (framebuffers[i] != 0) |
| 5469 | { |
| 5470 | deleteFramebuffer(framebuffers[i]); |
| 5471 | } |
| 5472 | } |
| 5473 | } |
| 5474 | |
| 5475 | void Context::deleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) |
| 5476 | { |
| 5477 | for (int i = 0; i < n; i++) |
| 5478 | { |
| 5479 | deleteRenderbuffer(renderbuffers[i]); |
| 5480 | } |
| 5481 | } |
| 5482 | |
| 5483 | void Context::deleteTextures(GLsizei n, const GLuint *textures) |
| 5484 | { |
| 5485 | for (int i = 0; i < n; i++) |
| 5486 | { |
| 5487 | if (textures[i] != 0) |
| 5488 | { |
| 5489 | deleteTexture(textures[i]); |
| 5490 | } |
| 5491 | } |
| 5492 | } |
| 5493 | |
| 5494 | void Context::detachShader(GLuint program, GLuint shader) |
| 5495 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5496 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5497 | ASSERT(programObject); |
| 5498 | |
| 5499 | Shader *shaderObject = getShader(shader); |
| 5500 | ASSERT(shaderObject); |
| 5501 | |
| 5502 | programObject->detachShader(this, shaderObject); |
| 5503 | } |
| 5504 | |
| 5505 | void Context::genBuffers(GLsizei n, GLuint *buffers) |
| 5506 | { |
| 5507 | for (int i = 0; i < n; i++) |
| 5508 | { |
| 5509 | buffers[i] = createBuffer(); |
| 5510 | } |
| 5511 | } |
| 5512 | |
| 5513 | void Context::genFramebuffers(GLsizei n, GLuint *framebuffers) |
| 5514 | { |
| 5515 | for (int i = 0; i < n; i++) |
| 5516 | { |
| 5517 | framebuffers[i] = createFramebuffer(); |
| 5518 | } |
| 5519 | } |
| 5520 | |
| 5521 | void Context::genRenderbuffers(GLsizei n, GLuint *renderbuffers) |
| 5522 | { |
| 5523 | for (int i = 0; i < n; i++) |
| 5524 | { |
| 5525 | renderbuffers[i] = createRenderbuffer(); |
| 5526 | } |
| 5527 | } |
| 5528 | |
| 5529 | void Context::genTextures(GLsizei n, GLuint *textures) |
| 5530 | { |
| 5531 | for (int i = 0; i < n; i++) |
| 5532 | { |
| 5533 | textures[i] = createTexture(); |
| 5534 | } |
| 5535 | } |
| 5536 | |
| 5537 | void Context::getActiveAttrib(GLuint program, |
| 5538 | GLuint index, |
| 5539 | GLsizei bufsize, |
| 5540 | GLsizei *length, |
| 5541 | GLint *size, |
| 5542 | GLenum *type, |
| 5543 | GLchar *name) |
| 5544 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5545 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5546 | ASSERT(programObject); |
| 5547 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 5548 | } |
| 5549 | |
| 5550 | void Context::getActiveUniform(GLuint program, |
| 5551 | GLuint index, |
| 5552 | GLsizei bufsize, |
| 5553 | GLsizei *length, |
| 5554 | GLint *size, |
| 5555 | GLenum *type, |
| 5556 | GLchar *name) |
| 5557 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5558 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5559 | ASSERT(programObject); |
| 5560 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 5561 | } |
| 5562 | |
| 5563 | void Context::getAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) |
| 5564 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5565 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5566 | ASSERT(programObject); |
| 5567 | programObject->getAttachedShaders(maxcount, count, shaders); |
| 5568 | } |
| 5569 | |
| 5570 | GLint Context::getAttribLocation(GLuint program, const GLchar *name) |
| 5571 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5572 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5573 | ASSERT(programObject); |
| 5574 | return programObject->getAttributeLocation(name); |
| 5575 | } |
| 5576 | |
| 5577 | void Context::getBooleanv(GLenum pname, GLboolean *params) |
| 5578 | { |
| 5579 | GLenum nativeType; |
| 5580 | unsigned int numParams = 0; |
| 5581 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5582 | |
| 5583 | if (nativeType == GL_BOOL) |
| 5584 | { |
| 5585 | getBooleanvImpl(pname, params); |
| 5586 | } |
| 5587 | else |
| 5588 | { |
| 5589 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5590 | } |
| 5591 | } |
| 5592 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5593 | void Context::getBooleanvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLboolean *params) |
| 5594 | { |
| 5595 | getBooleanv(pname, params); |
| 5596 | } |
| 5597 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5598 | void Context::getFloatv(GLenum pname, GLfloat *params) |
| 5599 | { |
| 5600 | GLenum nativeType; |
| 5601 | unsigned int numParams = 0; |
| 5602 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5603 | |
| 5604 | if (nativeType == GL_FLOAT) |
| 5605 | { |
| 5606 | getFloatvImpl(pname, params); |
| 5607 | } |
| 5608 | else |
| 5609 | { |
| 5610 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5611 | } |
| 5612 | } |
| 5613 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5614 | void Context::getFloatvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLfloat *params) |
| 5615 | { |
| 5616 | getFloatv(pname, params); |
| 5617 | } |
| 5618 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5619 | void Context::getIntegerv(GLenum pname, GLint *params) |
| 5620 | { |
| 5621 | GLenum nativeType; |
| 5622 | unsigned int numParams = 0; |
| 5623 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5624 | |
| 5625 | if (nativeType == GL_INT) |
| 5626 | { |
| 5627 | getIntegervImpl(pname, params); |
| 5628 | } |
| 5629 | else |
| 5630 | { |
| 5631 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5632 | } |
| 5633 | } |
| 5634 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5635 | void Context::getIntegervRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint *data) |
| 5636 | { |
| 5637 | getIntegerv(pname, data); |
| 5638 | } |
| 5639 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5640 | void Context::getProgramiv(GLuint program, GLenum pname, GLint *params) |
| 5641 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5642 | // Don't resolve link if checking the link completion status. |
| 5643 | Program *programObject = (pname == GL_COMPLETION_STATUS_KHR ? getProgramNoResolveLink(program) |
| 5644 | : getProgramResolveLink(program)); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5645 | ASSERT(programObject); |
Jamie Madill | ffe00c0 | 2017-06-27 16:26:55 -0400 | [diff] [blame] | 5646 | QueryProgramiv(this, programObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5647 | } |
| 5648 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5649 | void Context::getProgramivRobust(GLuint program, |
| 5650 | GLenum pname, |
| 5651 | GLsizei bufSize, |
| 5652 | GLsizei *length, |
| 5653 | GLint *params) |
| 5654 | { |
| 5655 | getProgramiv(program, pname, params); |
| 5656 | } |
| 5657 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5658 | void Context::getProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params) |
| 5659 | { |
| 5660 | UNIMPLEMENTED(); |
| 5661 | } |
| 5662 | |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 5663 | void Context::getProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5664 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5665 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5666 | ASSERT(programObject); |
| 5667 | programObject->getInfoLog(bufsize, length, infolog); |
| 5668 | } |
| 5669 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5670 | void Context::getProgramPipelineInfoLog(GLuint pipeline, |
| 5671 | GLsizei bufSize, |
| 5672 | GLsizei *length, |
| 5673 | GLchar *infoLog) |
| 5674 | { |
| 5675 | UNIMPLEMENTED(); |
| 5676 | } |
| 5677 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5678 | void Context::getShaderiv(GLuint shader, GLenum pname, GLint *params) |
| 5679 | { |
| 5680 | Shader *shaderObject = getShader(shader); |
| 5681 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5682 | QueryShaderiv(shaderObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5683 | } |
| 5684 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5685 | void Context::getShaderivRobust(GLuint shader, |
| 5686 | GLenum pname, |
| 5687 | GLsizei bufSize, |
| 5688 | GLsizei *length, |
| 5689 | GLint *params) |
| 5690 | { |
| 5691 | getShaderiv(shader, pname, params); |
| 5692 | } |
| 5693 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5694 | void Context::getShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
| 5695 | { |
| 5696 | Shader *shaderObject = getShader(shader); |
| 5697 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5698 | shaderObject->getInfoLog(bufsize, length, infolog); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5699 | } |
| 5700 | |
| 5701 | void Context::getShaderPrecisionFormat(GLenum shadertype, |
| 5702 | GLenum precisiontype, |
| 5703 | GLint *range, |
| 5704 | GLint *precision) |
| 5705 | { |
| 5706 | // TODO(jmadill): Compute shaders. |
| 5707 | |
| 5708 | switch (shadertype) |
| 5709 | { |
| 5710 | case GL_VERTEX_SHADER: |
| 5711 | switch (precisiontype) |
| 5712 | { |
| 5713 | case GL_LOW_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5714 | mState.mCaps.vertexLowpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5715 | break; |
| 5716 | case GL_MEDIUM_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5717 | mState.mCaps.vertexMediumpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5718 | break; |
| 5719 | case GL_HIGH_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5720 | mState.mCaps.vertexHighpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5721 | break; |
| 5722 | |
| 5723 | case GL_LOW_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5724 | mState.mCaps.vertexLowpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5725 | break; |
| 5726 | case GL_MEDIUM_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5727 | mState.mCaps.vertexMediumpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5728 | break; |
| 5729 | case GL_HIGH_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5730 | mState.mCaps.vertexHighpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5731 | break; |
| 5732 | |
| 5733 | default: |
| 5734 | UNREACHABLE(); |
| 5735 | return; |
| 5736 | } |
| 5737 | break; |
| 5738 | |
| 5739 | case GL_FRAGMENT_SHADER: |
| 5740 | switch (precisiontype) |
| 5741 | { |
| 5742 | case GL_LOW_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5743 | mState.mCaps.fragmentLowpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5744 | break; |
| 5745 | case GL_MEDIUM_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5746 | mState.mCaps.fragmentMediumpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5747 | break; |
| 5748 | case GL_HIGH_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5749 | mState.mCaps.fragmentHighpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5750 | break; |
| 5751 | |
| 5752 | case GL_LOW_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5753 | mState.mCaps.fragmentLowpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5754 | break; |
| 5755 | case GL_MEDIUM_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5756 | mState.mCaps.fragmentMediumpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5757 | break; |
| 5758 | case GL_HIGH_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5759 | mState.mCaps.fragmentHighpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5760 | break; |
| 5761 | |
| 5762 | default: |
| 5763 | UNREACHABLE(); |
| 5764 | return; |
| 5765 | } |
| 5766 | break; |
| 5767 | |
| 5768 | default: |
| 5769 | UNREACHABLE(); |
| 5770 | return; |
| 5771 | } |
| 5772 | } |
| 5773 | |
| 5774 | void Context::getShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source) |
| 5775 | { |
| 5776 | Shader *shaderObject = getShader(shader); |
| 5777 | ASSERT(shaderObject); |
| 5778 | shaderObject->getSource(bufsize, length, source); |
| 5779 | } |
| 5780 | |
| 5781 | void Context::getUniformfv(GLuint program, GLint location, GLfloat *params) |
| 5782 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5783 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5784 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5785 | programObject->getUniformfv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5786 | } |
| 5787 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5788 | void Context::getUniformfvRobust(GLuint program, |
| 5789 | GLint location, |
| 5790 | GLsizei bufSize, |
| 5791 | GLsizei *length, |
| 5792 | GLfloat *params) |
| 5793 | { |
| 5794 | getUniformfv(program, location, params); |
| 5795 | } |
| 5796 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5797 | void Context::getUniformiv(GLuint program, GLint location, GLint *params) |
| 5798 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5799 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5800 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5801 | programObject->getUniformiv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5802 | } |
| 5803 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5804 | void Context::getUniformivRobust(GLuint program, |
| 5805 | GLint location, |
| 5806 | GLsizei bufSize, |
| 5807 | GLsizei *length, |
| 5808 | GLint *params) |
| 5809 | { |
| 5810 | getUniformiv(program, location, params); |
| 5811 | } |
| 5812 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5813 | GLint Context::getUniformLocation(GLuint program, const GLchar *name) |
| 5814 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5815 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5816 | ASSERT(programObject); |
| 5817 | return programObject->getUniformLocation(name); |
| 5818 | } |
| 5819 | |
| 5820 | GLboolean Context::isBuffer(GLuint buffer) |
| 5821 | { |
| 5822 | if (buffer == 0) |
| 5823 | { |
| 5824 | return GL_FALSE; |
| 5825 | } |
| 5826 | |
| 5827 | return (getBuffer(buffer) ? GL_TRUE : GL_FALSE); |
| 5828 | } |
| 5829 | |
| 5830 | GLboolean Context::isEnabled(GLenum cap) |
| 5831 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5832 | return mState.getEnableFeature(cap); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5833 | } |
| 5834 | |
| 5835 | GLboolean Context::isFramebuffer(GLuint framebuffer) |
| 5836 | { |
| 5837 | if (framebuffer == 0) |
| 5838 | { |
| 5839 | return GL_FALSE; |
| 5840 | } |
| 5841 | |
| 5842 | return (getFramebuffer(framebuffer) ? GL_TRUE : GL_FALSE); |
| 5843 | } |
| 5844 | |
| 5845 | GLboolean Context::isProgram(GLuint program) |
| 5846 | { |
| 5847 | if (program == 0) |
| 5848 | { |
| 5849 | return GL_FALSE; |
| 5850 | } |
| 5851 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5852 | return (getProgramNoResolveLink(program) ? GL_TRUE : GL_FALSE); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5853 | } |
| 5854 | |
| 5855 | GLboolean Context::isRenderbuffer(GLuint renderbuffer) |
| 5856 | { |
| 5857 | if (renderbuffer == 0) |
| 5858 | { |
| 5859 | return GL_FALSE; |
| 5860 | } |
| 5861 | |
| 5862 | return (getRenderbuffer(renderbuffer) ? GL_TRUE : GL_FALSE); |
| 5863 | } |
| 5864 | |
| 5865 | GLboolean Context::isShader(GLuint shader) |
| 5866 | { |
| 5867 | if (shader == 0) |
| 5868 | { |
| 5869 | return GL_FALSE; |
| 5870 | } |
| 5871 | |
| 5872 | return (getShader(shader) ? GL_TRUE : GL_FALSE); |
| 5873 | } |
| 5874 | |
| 5875 | GLboolean Context::isTexture(GLuint texture) |
| 5876 | { |
| 5877 | if (texture == 0) |
| 5878 | { |
| 5879 | return GL_FALSE; |
| 5880 | } |
| 5881 | |
| 5882 | return (getTexture(texture) ? GL_TRUE : GL_FALSE); |
| 5883 | } |
| 5884 | |
| 5885 | void Context::linkProgram(GLuint program) |
| 5886 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5887 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5888 | ASSERT(programObject); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5889 | ANGLE_CONTEXT_TRY(programObject->link(this)); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5890 | |
| 5891 | // Don't parallel link a program which is active in any GL contexts. With this assumption, we |
| 5892 | // don't need to worry that: |
| 5893 | // 1. Draw calls after link use the new executable code or the old one depending on the link |
| 5894 | // result. |
| 5895 | // 2. When a backend program, e.g., ProgramD3D is linking, other backend classes like |
| 5896 | // StateManager11, Renderer11, etc., may have a chance to make unexpected calls to |
| 5897 | // ProgramD3D. |
| 5898 | if (programObject->isInUse()) |
| 5899 | { |
Jamie Madill | 785e8a0 | 2018-10-04 17:42:00 -0400 | [diff] [blame] | 5900 | programObject->resolveLink(this); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 5901 | if (programObject->isLinked()) |
| 5902 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5903 | ANGLE_CONTEXT_TRY(mState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 5904 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5905 | mStateCache.onProgramExecutableChange(this); |
| 5906 | } |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5907 | } |
| 5908 | |
| 5909 | void Context::releaseShaderCompiler() |
| 5910 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5911 | mCompiler.set(this, nullptr); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5912 | } |
| 5913 | |
| 5914 | void Context::shaderBinary(GLsizei n, |
| 5915 | const GLuint *shaders, |
| 5916 | GLenum binaryformat, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 5917 | const void *binary, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5918 | GLsizei length) |
| 5919 | { |
| 5920 | // No binary shader formats are supported. |
| 5921 | UNIMPLEMENTED(); |
| 5922 | } |
| 5923 | |
Olli Etuaho | 0ca0975 | 2018-09-24 11:00:50 +0300 | [diff] [blame] | 5924 | void Context::bindFragDataLocationIndexed(GLuint program, |
| 5925 | GLuint colorNumber, |
| 5926 | GLuint index, |
| 5927 | const char *name) |
| 5928 | { |
| 5929 | Program *programObject = getProgramNoResolveLink(program); |
| 5930 | programObject->bindFragmentOutputLocation(colorNumber, name); |
| 5931 | programObject->bindFragmentOutputIndex(index, name); |
| 5932 | } |
| 5933 | |
| 5934 | void Context::bindFragDataLocation(GLuint program, GLuint colorNumber, const char *name) |
| 5935 | { |
| 5936 | bindFragDataLocationIndexed(program, colorNumber, 0u, name); |
| 5937 | } |
| 5938 | |
| 5939 | int Context::getFragDataIndex(GLuint program, const char *name) |
| 5940 | { |
| 5941 | Program *programObject = getProgramResolveLink(program); |
| 5942 | return programObject->getFragDataIndex(name); |
| 5943 | } |
| 5944 | |
| 5945 | int Context::getProgramResourceLocationIndex(GLuint program, |
| 5946 | GLenum programInterface, |
| 5947 | const char *name) |
| 5948 | { |
| 5949 | Program *programObject = getProgramResolveLink(program); |
| 5950 | ASSERT(programInterface == GL_PROGRAM_OUTPUT); |
| 5951 | return programObject->getFragDataIndex(name); |
| 5952 | } |
| 5953 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5954 | void Context::shaderSource(GLuint shader, |
| 5955 | GLsizei count, |
| 5956 | const GLchar *const *string, |
| 5957 | const GLint *length) |
| 5958 | { |
| 5959 | Shader *shaderObject = getShader(shader); |
| 5960 | ASSERT(shaderObject); |
| 5961 | shaderObject->setSource(count, string, length); |
| 5962 | } |
| 5963 | |
| 5964 | void Context::stencilFunc(GLenum func, GLint ref, GLuint mask) |
| 5965 | { |
| 5966 | stencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
| 5967 | } |
| 5968 | |
| 5969 | void Context::stencilMask(GLuint mask) |
| 5970 | { |
| 5971 | stencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 5972 | } |
| 5973 | |
| 5974 | void Context::stencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 5975 | { |
| 5976 | stencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 5977 | } |
| 5978 | |
| 5979 | void Context::uniform1f(GLint location, GLfloat x) |
| 5980 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5981 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5982 | program->setUniform1fv(location, 1, &x); |
| 5983 | } |
| 5984 | |
| 5985 | void Context::uniform1fv(GLint location, GLsizei count, const GLfloat *v) |
| 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, count, v); |
| 5989 | } |
| 5990 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 5991 | void Context::setUniform1iImpl(Program *program, GLint location, GLsizei count, const GLint *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5992 | { |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 5993 | program->setUniform1iv(this, location, count, v); |
| 5994 | } |
| 5995 | |
| 5996 | void Context::onSamplerUniformChange(size_t textureUnitIndex) |
| 5997 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5998 | mState.onActiveTextureChange(this, textureUnitIndex); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 5999 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6000 | } |
| 6001 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6002 | void Context::uniform1i(GLint location, GLint x) |
| 6003 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6004 | setUniform1iImpl(mState.getProgram(), location, 1, &x); |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6005 | } |
| 6006 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6007 | void Context::uniform1iv(GLint location, GLsizei count, const GLint *v) |
| 6008 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6009 | setUniform1iImpl(mState.getProgram(), location, count, v); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6010 | } |
| 6011 | |
| 6012 | void Context::uniform2f(GLint location, GLfloat x, GLfloat y) |
| 6013 | { |
| 6014 | GLfloat xy[2] = {x, y}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6015 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6016 | program->setUniform2fv(location, 1, xy); |
| 6017 | } |
| 6018 | |
| 6019 | void Context::uniform2fv(GLint location, GLsizei count, const GLfloat *v) |
| 6020 | { |
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, count, v); |
| 6023 | } |
| 6024 | |
| 6025 | void Context::uniform2i(GLint location, GLint x, GLint y) |
| 6026 | { |
| 6027 | GLint xy[2] = {x, y}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6028 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6029 | program->setUniform2iv(location, 1, xy); |
| 6030 | } |
| 6031 | |
| 6032 | void Context::uniform2iv(GLint location, GLsizei count, const GLint *v) |
| 6033 | { |
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, count, v); |
| 6036 | } |
| 6037 | |
| 6038 | void Context::uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 6039 | { |
| 6040 | GLfloat xyz[3] = {x, y, z}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6041 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6042 | program->setUniform3fv(location, 1, xyz); |
| 6043 | } |
| 6044 | |
| 6045 | void Context::uniform3fv(GLint location, GLsizei count, const GLfloat *v) |
| 6046 | { |
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, count, v); |
| 6049 | } |
| 6050 | |
| 6051 | void Context::uniform3i(GLint location, GLint x, GLint y, GLint z) |
| 6052 | { |
| 6053 | GLint xyz[3] = {x, y, z}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6054 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6055 | program->setUniform3iv(location, 1, xyz); |
| 6056 | } |
| 6057 | |
| 6058 | void Context::uniform3iv(GLint location, GLsizei count, const GLint *v) |
| 6059 | { |
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, count, v); |
| 6062 | } |
| 6063 | |
| 6064 | void Context::uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 6065 | { |
| 6066 | GLfloat xyzw[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6067 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6068 | program->setUniform4fv(location, 1, xyzw); |
| 6069 | } |
| 6070 | |
| 6071 | void Context::uniform4fv(GLint location, GLsizei count, const GLfloat *v) |
| 6072 | { |
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, count, v); |
| 6075 | } |
| 6076 | |
| 6077 | void Context::uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 6078 | { |
| 6079 | GLint xyzw[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6080 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6081 | program->setUniform4iv(location, 1, xyzw); |
| 6082 | } |
| 6083 | |
| 6084 | void Context::uniform4iv(GLint location, GLsizei count, const GLint *v) |
| 6085 | { |
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, count, v); |
| 6088 | } |
| 6089 | |
| 6090 | void Context::uniformMatrix2fv(GLint location, |
| 6091 | GLsizei count, |
| 6092 | GLboolean transpose, |
| 6093 | const GLfloat *value) |
| 6094 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6095 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6096 | program->setUniformMatrix2fv(location, count, transpose, value); |
| 6097 | } |
| 6098 | |
| 6099 | void Context::uniformMatrix3fv(GLint location, |
| 6100 | GLsizei count, |
| 6101 | GLboolean transpose, |
| 6102 | const GLfloat *value) |
| 6103 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6104 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6105 | program->setUniformMatrix3fv(location, count, transpose, value); |
| 6106 | } |
| 6107 | |
| 6108 | void Context::uniformMatrix4fv(GLint location, |
| 6109 | GLsizei count, |
| 6110 | GLboolean transpose, |
| 6111 | const GLfloat *value) |
| 6112 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6113 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6114 | program->setUniformMatrix4fv(location, count, transpose, value); |
| 6115 | } |
| 6116 | |
| 6117 | void Context::validateProgram(GLuint program) |
| 6118 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6119 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6120 | ASSERT(programObject); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6121 | programObject->validate(mState.mCaps); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6122 | } |
| 6123 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6124 | void Context::validateProgramPipeline(GLuint pipeline) |
| 6125 | { |
| 6126 | UNIMPLEMENTED(); |
| 6127 | } |
| 6128 | |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6129 | void Context::getProgramBinary(GLuint program, |
| 6130 | GLsizei bufSize, |
| 6131 | GLsizei *length, |
| 6132 | GLenum *binaryFormat, |
| 6133 | void *binary) |
| 6134 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6135 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6136 | ASSERT(programObject != nullptr); |
| 6137 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6138 | ANGLE_CONTEXT_TRY(programObject->saveBinary(this, binaryFormat, binary, bufSize, length)); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6139 | } |
| 6140 | |
| 6141 | void Context::programBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length) |
| 6142 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6143 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6144 | ASSERT(programObject != nullptr); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 6145 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6146 | ANGLE_CONTEXT_TRY(programObject->loadBinary(this, binaryFormat, binary, length)); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6147 | if (programObject->isInUse()) |
| 6148 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6149 | ANGLE_CONTEXT_TRY(mState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 6150 | mStateCache.onProgramExecutableChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6151 | } |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6152 | } |
| 6153 | |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6154 | void Context::uniform1ui(GLint location, GLuint v0) |
| 6155 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6156 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6157 | program->setUniform1uiv(location, 1, &v0); |
| 6158 | } |
| 6159 | |
| 6160 | void Context::uniform2ui(GLint location, GLuint v0, GLuint v1) |
| 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 | const GLuint xy[] = {v0, v1}; |
| 6164 | program->setUniform2uiv(location, 1, xy); |
| 6165 | } |
| 6166 | |
| 6167 | void Context::uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6168 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6169 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6170 | const GLuint xyz[] = {v0, v1, v2}; |
| 6171 | program->setUniform3uiv(location, 1, xyz); |
| 6172 | } |
| 6173 | |
| 6174 | void Context::uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 6175 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6176 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6177 | const GLuint xyzw[] = {v0, v1, v2, v3}; |
| 6178 | program->setUniform4uiv(location, 1, xyzw); |
| 6179 | } |
| 6180 | |
| 6181 | void Context::uniform1uiv(GLint location, GLsizei count, const GLuint *value) |
| 6182 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6183 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6184 | program->setUniform1uiv(location, count, value); |
| 6185 | } |
| 6186 | void Context::uniform2uiv(GLint location, GLsizei count, const GLuint *value) |
| 6187 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6188 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6189 | program->setUniform2uiv(location, count, value); |
| 6190 | } |
| 6191 | |
| 6192 | void Context::uniform3uiv(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->setUniform3uiv(location, count, value); |
| 6196 | } |
| 6197 | |
| 6198 | void Context::uniform4uiv(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->setUniform4uiv(location, count, value); |
| 6202 | } |
| 6203 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6204 | void Context::genQueries(GLsizei n, GLuint *ids) |
| 6205 | { |
| 6206 | for (GLsizei i = 0; i < n; i++) |
| 6207 | { |
| 6208 | GLuint handle = mQueryHandleAllocator.allocate(); |
| 6209 | mQueryMap.assign(handle, nullptr); |
| 6210 | ids[i] = handle; |
| 6211 | } |
| 6212 | } |
| 6213 | |
| 6214 | void Context::deleteQueries(GLsizei n, const GLuint *ids) |
| 6215 | { |
| 6216 | for (int i = 0; i < n; i++) |
| 6217 | { |
| 6218 | GLuint query = ids[i]; |
| 6219 | |
| 6220 | Query *queryObject = nullptr; |
| 6221 | if (mQueryMap.erase(query, &queryObject)) |
| 6222 | { |
| 6223 | mQueryHandleAllocator.release(query); |
| 6224 | if (queryObject) |
| 6225 | { |
| 6226 | queryObject->release(this); |
| 6227 | } |
| 6228 | } |
| 6229 | } |
| 6230 | } |
| 6231 | |
| 6232 | GLboolean Context::isQuery(GLuint id) |
| 6233 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 6234 | return (getQuery(id, false, QueryType::InvalidEnum) != nullptr) ? GL_TRUE : GL_FALSE; |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6235 | } |
| 6236 | |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6237 | void Context::uniformMatrix2x3fv(GLint location, |
| 6238 | GLsizei count, |
| 6239 | GLboolean transpose, |
| 6240 | const GLfloat *value) |
| 6241 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6242 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6243 | program->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6244 | } |
| 6245 | |
| 6246 | void Context::uniformMatrix3x2fv(GLint location, |
| 6247 | GLsizei count, |
| 6248 | GLboolean transpose, |
| 6249 | const GLfloat *value) |
| 6250 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6251 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6252 | program->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6253 | } |
| 6254 | |
| 6255 | void Context::uniformMatrix2x4fv(GLint location, |
| 6256 | GLsizei count, |
| 6257 | GLboolean transpose, |
| 6258 | const GLfloat *value) |
| 6259 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6260 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6261 | program->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6262 | } |
| 6263 | |
| 6264 | void Context::uniformMatrix4x2fv(GLint location, |
| 6265 | GLsizei count, |
| 6266 | GLboolean transpose, |
| 6267 | const GLfloat *value) |
| 6268 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6269 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6270 | program->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6271 | } |
| 6272 | |
| 6273 | void Context::uniformMatrix3x4fv(GLint location, |
| 6274 | GLsizei count, |
| 6275 | GLboolean transpose, |
| 6276 | const GLfloat *value) |
| 6277 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6278 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6279 | program->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6280 | } |
| 6281 | |
| 6282 | void Context::uniformMatrix4x3fv(GLint location, |
| 6283 | GLsizei count, |
| 6284 | GLboolean transpose, |
| 6285 | const GLfloat *value) |
| 6286 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6287 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6288 | program->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6289 | } |
| 6290 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 6291 | void Context::deleteVertexArrays(GLsizei n, const GLuint *arrays) |
| 6292 | { |
| 6293 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6294 | { |
| 6295 | GLuint vertexArray = arrays[arrayIndex]; |
| 6296 | |
| 6297 | if (arrays[arrayIndex] != 0) |
| 6298 | { |
| 6299 | VertexArray *vertexArrayObject = nullptr; |
| 6300 | if (mVertexArrayMap.erase(vertexArray, &vertexArrayObject)) |
| 6301 | { |
| 6302 | if (vertexArrayObject != nullptr) |
| 6303 | { |
| 6304 | detachVertexArray(vertexArray); |
| 6305 | vertexArrayObject->onDestroy(this); |
| 6306 | } |
| 6307 | |
| 6308 | mVertexArrayHandleAllocator.release(vertexArray); |
| 6309 | } |
| 6310 | } |
| 6311 | } |
| 6312 | } |
| 6313 | |
| 6314 | void Context::genVertexArrays(GLsizei n, GLuint *arrays) |
| 6315 | { |
| 6316 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6317 | { |
| 6318 | GLuint vertexArray = mVertexArrayHandleAllocator.allocate(); |
| 6319 | mVertexArrayMap.assign(vertexArray, nullptr); |
| 6320 | arrays[arrayIndex] = vertexArray; |
| 6321 | } |
| 6322 | } |
| 6323 | |
| 6324 | bool Context::isVertexArray(GLuint array) |
| 6325 | { |
| 6326 | if (array == 0) |
| 6327 | { |
| 6328 | return GL_FALSE; |
| 6329 | } |
| 6330 | |
| 6331 | VertexArray *vao = getVertexArray(array); |
| 6332 | return (vao != nullptr ? GL_TRUE : GL_FALSE); |
| 6333 | } |
| 6334 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6335 | void Context::endTransformFeedback() |
| 6336 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6337 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6338 | ANGLE_CONTEXT_TRY(transformFeedback->end(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6339 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6340 | } |
| 6341 | |
| 6342 | void Context::transformFeedbackVaryings(GLuint program, |
| 6343 | GLsizei count, |
| 6344 | const GLchar *const *varyings, |
| 6345 | GLenum bufferMode) |
| 6346 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6347 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6348 | ASSERT(programObject); |
| 6349 | programObject->setTransformFeedbackVaryings(count, varyings, bufferMode); |
| 6350 | } |
| 6351 | |
| 6352 | void Context::getTransformFeedbackVarying(GLuint program, |
| 6353 | GLuint index, |
| 6354 | GLsizei bufSize, |
| 6355 | GLsizei *length, |
| 6356 | GLsizei *size, |
| 6357 | GLenum *type, |
| 6358 | GLchar *name) |
| 6359 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6360 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6361 | ASSERT(programObject); |
| 6362 | programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name); |
| 6363 | } |
| 6364 | |
| 6365 | void Context::deleteTransformFeedbacks(GLsizei n, const GLuint *ids) |
| 6366 | { |
| 6367 | for (int i = 0; i < n; i++) |
| 6368 | { |
| 6369 | GLuint transformFeedback = ids[i]; |
| 6370 | if (transformFeedback == 0) |
| 6371 | { |
| 6372 | continue; |
| 6373 | } |
| 6374 | |
| 6375 | TransformFeedback *transformFeedbackObject = nullptr; |
| 6376 | if (mTransformFeedbackMap.erase(transformFeedback, &transformFeedbackObject)) |
| 6377 | { |
| 6378 | if (transformFeedbackObject != nullptr) |
| 6379 | { |
| 6380 | detachTransformFeedback(transformFeedback); |
| 6381 | transformFeedbackObject->release(this); |
| 6382 | } |
| 6383 | |
| 6384 | mTransformFeedbackHandleAllocator.release(transformFeedback); |
| 6385 | } |
| 6386 | } |
| 6387 | } |
| 6388 | |
| 6389 | void Context::genTransformFeedbacks(GLsizei n, GLuint *ids) |
| 6390 | { |
| 6391 | for (int i = 0; i < n; i++) |
| 6392 | { |
| 6393 | GLuint transformFeedback = mTransformFeedbackHandleAllocator.allocate(); |
| 6394 | mTransformFeedbackMap.assign(transformFeedback, nullptr); |
| 6395 | ids[i] = transformFeedback; |
| 6396 | } |
| 6397 | } |
| 6398 | |
| 6399 | bool Context::isTransformFeedback(GLuint id) |
| 6400 | { |
| 6401 | if (id == 0) |
| 6402 | { |
| 6403 | // The 3.0.4 spec [section 6.1.11] states that if ID is zero, IsTransformFeedback |
| 6404 | // returns FALSE |
| 6405 | return GL_FALSE; |
| 6406 | } |
| 6407 | |
| 6408 | const TransformFeedback *transformFeedback = getTransformFeedback(id); |
| 6409 | return ((transformFeedback != nullptr) ? GL_TRUE : GL_FALSE); |
| 6410 | } |
| 6411 | |
| 6412 | void Context::pauseTransformFeedback() |
| 6413 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6414 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6415 | ANGLE_CONTEXT_TRY(transformFeedback->pause(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6416 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6417 | } |
| 6418 | |
| 6419 | void Context::resumeTransformFeedback() |
| 6420 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6421 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6422 | ANGLE_CONTEXT_TRY(transformFeedback->resume(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6423 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6424 | } |
| 6425 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6426 | void Context::getUniformuiv(GLuint program, GLint location, GLuint *params) |
| 6427 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6428 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 6429 | programObject->getUniformuiv(this, location, params); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6430 | } |
| 6431 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6432 | void Context::getUniformuivRobust(GLuint program, |
| 6433 | GLint location, |
| 6434 | GLsizei bufSize, |
| 6435 | GLsizei *length, |
| 6436 | GLuint *params) |
| 6437 | { |
| 6438 | getUniformuiv(program, location, params); |
| 6439 | } |
| 6440 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6441 | GLint Context::getFragDataLocation(GLuint program, const GLchar *name) |
| 6442 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6443 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6444 | return programObject->getFragDataLocation(name); |
| 6445 | } |
| 6446 | |
| 6447 | void Context::getUniformIndices(GLuint program, |
| 6448 | GLsizei uniformCount, |
| 6449 | const GLchar *const *uniformNames, |
| 6450 | GLuint *uniformIndices) |
| 6451 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6452 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6453 | if (!programObject->isLinked()) |
| 6454 | { |
| 6455 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6456 | { |
| 6457 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 6458 | } |
| 6459 | } |
| 6460 | else |
| 6461 | { |
| 6462 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6463 | { |
| 6464 | uniformIndices[uniformId] = programObject->getUniformIndex(uniformNames[uniformId]); |
| 6465 | } |
| 6466 | } |
| 6467 | } |
| 6468 | |
| 6469 | void Context::getActiveUniformsiv(GLuint program, |
| 6470 | GLsizei uniformCount, |
| 6471 | const GLuint *uniformIndices, |
| 6472 | GLenum pname, |
| 6473 | GLint *params) |
| 6474 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6475 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6476 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6477 | { |
| 6478 | const GLuint index = uniformIndices[uniformId]; |
jchen10 | baf5d94 | 2017-08-28 20:45:48 +0800 | [diff] [blame] | 6479 | params[uniformId] = GetUniformResourceProperty(programObject, index, pname); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6480 | } |
| 6481 | } |
| 6482 | |
| 6483 | GLuint Context::getUniformBlockIndex(GLuint program, const GLchar *uniformBlockName) |
| 6484 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6485 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6486 | return programObject->getUniformBlockIndex(uniformBlockName); |
| 6487 | } |
| 6488 | |
| 6489 | void Context::getActiveUniformBlockiv(GLuint program, |
| 6490 | GLuint uniformBlockIndex, |
| 6491 | GLenum pname, |
| 6492 | GLint *params) |
| 6493 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6494 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6495 | QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params); |
| 6496 | } |
| 6497 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6498 | void Context::getActiveUniformBlockivRobust(GLuint program, |
| 6499 | GLuint uniformBlockIndex, |
| 6500 | GLenum pname, |
| 6501 | GLsizei bufSize, |
| 6502 | GLsizei *length, |
| 6503 | GLint *params) |
| 6504 | { |
| 6505 | getActiveUniformBlockiv(program, uniformBlockIndex, pname, params); |
| 6506 | } |
| 6507 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6508 | void Context::getActiveUniformBlockName(GLuint program, |
| 6509 | GLuint uniformBlockIndex, |
| 6510 | GLsizei bufSize, |
| 6511 | GLsizei *length, |
| 6512 | GLchar *uniformBlockName) |
| 6513 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6514 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6515 | programObject->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 6516 | } |
| 6517 | |
| 6518 | void Context::uniformBlockBinding(GLuint program, |
| 6519 | GLuint uniformBlockIndex, |
| 6520 | GLuint uniformBlockBinding) |
| 6521 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6522 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6523 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6524 | |
Jamie Madill | 956ab4d | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 6525 | // 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] | 6526 | if (programObject->isInUse()) |
| 6527 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6528 | mState.setObjectDirty(GL_PROGRAM); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 6529 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6530 | } |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6531 | } |
| 6532 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6533 | GLsync Context::fenceSync(GLenum condition, GLbitfield flags) |
| 6534 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6535 | GLuint handle = mState.mSyncManager->createSync(mImplementation.get()); |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6536 | GLsync syncHandle = reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6537 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6538 | Sync *syncObject = getSync(syncHandle); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 6539 | if (syncObject->set(this, condition, flags) == angle::Result::Stop) |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6540 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6541 | deleteSync(syncHandle); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6542 | return nullptr; |
| 6543 | } |
| 6544 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6545 | return syncHandle; |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6546 | } |
| 6547 | |
| 6548 | GLboolean Context::isSync(GLsync sync) |
| 6549 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6550 | return (getSync(sync) != nullptr); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6551 | } |
| 6552 | |
| 6553 | GLenum Context::clientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6554 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6555 | Sync *syncObject = getSync(sync); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6556 | |
| 6557 | GLenum result = GL_WAIT_FAILED; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 6558 | if (syncObject->clientWait(this, flags, timeout, &result) == angle::Result::Stop) |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6559 | { |
| 6560 | return GL_WAIT_FAILED; |
| 6561 | } |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6562 | return result; |
| 6563 | } |
| 6564 | |
| 6565 | void Context::waitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6566 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6567 | Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6568 | ANGLE_CONTEXT_TRY(syncObject->serverWait(this, flags, timeout)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6569 | } |
| 6570 | |
| 6571 | void Context::getInteger64v(GLenum pname, GLint64 *params) |
| 6572 | { |
| 6573 | GLenum nativeType = GL_NONE; |
| 6574 | unsigned int numParams = 0; |
| 6575 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 6576 | |
| 6577 | if (nativeType == GL_INT_64_ANGLEX) |
| 6578 | { |
| 6579 | getInteger64vImpl(pname, params); |
| 6580 | } |
| 6581 | else |
| 6582 | { |
| 6583 | CastStateValues(this, nativeType, pname, numParams, params); |
| 6584 | } |
| 6585 | } |
| 6586 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6587 | void Context::getInteger64vRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint64 *data) |
| 6588 | { |
| 6589 | getInteger64v(pname, data); |
| 6590 | } |
| 6591 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 6592 | void Context::getBufferParameteri64v(BufferBinding target, GLenum pname, GLint64 *params) |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6593 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6594 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6595 | QueryBufferParameteri64v(buffer, pname, params); |
| 6596 | } |
| 6597 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6598 | void Context::getBufferParameteri64vRobust(BufferBinding target, |
| 6599 | GLenum pname, |
| 6600 | GLsizei bufSize, |
| 6601 | GLsizei *length, |
| 6602 | GLint64 *params) |
| 6603 | { |
| 6604 | getBufferParameteri64v(target, pname, params); |
| 6605 | } |
| 6606 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6607 | void Context::genSamplers(GLsizei count, GLuint *samplers) |
| 6608 | { |
| 6609 | for (int i = 0; i < count; i++) |
| 6610 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6611 | samplers[i] = mState.mSamplerManager->createSampler(); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6612 | } |
| 6613 | } |
| 6614 | |
| 6615 | void Context::deleteSamplers(GLsizei count, const GLuint *samplers) |
| 6616 | { |
| 6617 | for (int i = 0; i < count; i++) |
| 6618 | { |
| 6619 | GLuint sampler = samplers[i]; |
| 6620 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6621 | if (mState.mSamplerManager->getSampler(sampler)) |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6622 | { |
| 6623 | detachSampler(sampler); |
| 6624 | } |
| 6625 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6626 | mState.mSamplerManager->deleteObject(this, sampler); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6627 | } |
| 6628 | } |
| 6629 | |
| 6630 | void Context::getInternalformativ(GLenum target, |
| 6631 | GLenum internalformat, |
| 6632 | GLenum pname, |
| 6633 | GLsizei bufSize, |
| 6634 | GLint *params) |
| 6635 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6636 | const TextureCaps &formatCaps = mState.mTextureCaps.get(internalformat); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6637 | QueryInternalFormativ(formatCaps, pname, bufSize, params); |
| 6638 | } |
| 6639 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6640 | void Context::getInternalformativRobust(GLenum target, |
| 6641 | GLenum internalformat, |
| 6642 | GLenum pname, |
| 6643 | GLsizei bufSize, |
| 6644 | GLsizei *length, |
| 6645 | GLint *params) |
| 6646 | { |
| 6647 | getInternalformativ(target, internalformat, pname, bufSize, params); |
| 6648 | } |
| 6649 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6650 | void Context::programUniform1i(GLuint program, GLint location, GLint v0) |
| 6651 | { |
| 6652 | programUniform1iv(program, location, 1, &v0); |
| 6653 | } |
| 6654 | |
| 6655 | void Context::programUniform2i(GLuint program, GLint location, GLint v0, GLint v1) |
| 6656 | { |
| 6657 | GLint xy[2] = {v0, v1}; |
| 6658 | programUniform2iv(program, location, 1, xy); |
| 6659 | } |
| 6660 | |
| 6661 | void Context::programUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2) |
| 6662 | { |
| 6663 | GLint xyz[3] = {v0, v1, v2}; |
| 6664 | programUniform3iv(program, location, 1, xyz); |
| 6665 | } |
| 6666 | |
| 6667 | void Context::programUniform4i(GLuint program, |
| 6668 | GLint location, |
| 6669 | GLint v0, |
| 6670 | GLint v1, |
| 6671 | GLint v2, |
| 6672 | GLint v3) |
| 6673 | { |
| 6674 | GLint xyzw[4] = {v0, v1, v2, v3}; |
| 6675 | programUniform4iv(program, location, 1, xyzw); |
| 6676 | } |
| 6677 | |
| 6678 | void Context::programUniform1ui(GLuint program, GLint location, GLuint v0) |
| 6679 | { |
| 6680 | programUniform1uiv(program, location, 1, &v0); |
| 6681 | } |
| 6682 | |
| 6683 | void Context::programUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1) |
| 6684 | { |
| 6685 | GLuint xy[2] = {v0, v1}; |
| 6686 | programUniform2uiv(program, location, 1, xy); |
| 6687 | } |
| 6688 | |
| 6689 | void Context::programUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6690 | { |
| 6691 | GLuint xyz[3] = {v0, v1, v2}; |
| 6692 | programUniform3uiv(program, location, 1, xyz); |
| 6693 | } |
| 6694 | |
| 6695 | void Context::programUniform4ui(GLuint program, |
| 6696 | GLint location, |
| 6697 | GLuint v0, |
| 6698 | GLuint v1, |
| 6699 | GLuint v2, |
| 6700 | GLuint v3) |
| 6701 | { |
| 6702 | GLuint xyzw[4] = {v0, v1, v2, v3}; |
| 6703 | programUniform4uiv(program, location, 1, xyzw); |
| 6704 | } |
| 6705 | |
| 6706 | void Context::programUniform1f(GLuint program, GLint location, GLfloat v0) |
| 6707 | { |
| 6708 | programUniform1fv(program, location, 1, &v0); |
| 6709 | } |
| 6710 | |
| 6711 | void Context::programUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1) |
| 6712 | { |
| 6713 | GLfloat xy[2] = {v0, v1}; |
| 6714 | programUniform2fv(program, location, 1, xy); |
| 6715 | } |
| 6716 | |
| 6717 | void Context::programUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) |
| 6718 | { |
| 6719 | GLfloat xyz[3] = {v0, v1, v2}; |
| 6720 | programUniform3fv(program, location, 1, xyz); |
| 6721 | } |
| 6722 | |
| 6723 | void Context::programUniform4f(GLuint program, |
| 6724 | GLint location, |
| 6725 | GLfloat v0, |
| 6726 | GLfloat v1, |
| 6727 | GLfloat v2, |
| 6728 | GLfloat v3) |
| 6729 | { |
| 6730 | GLfloat xyzw[4] = {v0, v1, v2, v3}; |
| 6731 | programUniform4fv(program, location, 1, xyzw); |
| 6732 | } |
| 6733 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6734 | void Context::programUniform1iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6735 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6736 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6737 | ASSERT(programObject); |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6738 | setUniform1iImpl(programObject, location, count, value); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6739 | } |
| 6740 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6741 | void Context::programUniform2iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6742 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6743 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6744 | ASSERT(programObject); |
| 6745 | programObject->setUniform2iv(location, count, value); |
| 6746 | } |
| 6747 | |
| 6748 | void Context::programUniform3iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6749 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6750 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6751 | ASSERT(programObject); |
| 6752 | programObject->setUniform3iv(location, count, value); |
| 6753 | } |
| 6754 | |
| 6755 | void Context::programUniform4iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6756 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6757 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6758 | ASSERT(programObject); |
| 6759 | programObject->setUniform4iv(location, count, value); |
| 6760 | } |
| 6761 | |
| 6762 | void Context::programUniform1uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6763 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6764 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6765 | ASSERT(programObject); |
| 6766 | programObject->setUniform1uiv(location, count, value); |
| 6767 | } |
| 6768 | |
| 6769 | void Context::programUniform2uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6770 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6771 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6772 | ASSERT(programObject); |
| 6773 | programObject->setUniform2uiv(location, count, value); |
| 6774 | } |
| 6775 | |
| 6776 | void Context::programUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6777 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6778 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6779 | ASSERT(programObject); |
| 6780 | programObject->setUniform3uiv(location, count, value); |
| 6781 | } |
| 6782 | |
| 6783 | void Context::programUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6784 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6785 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6786 | ASSERT(programObject); |
| 6787 | programObject->setUniform4uiv(location, count, value); |
| 6788 | } |
| 6789 | |
| 6790 | void Context::programUniform1fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6791 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6792 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6793 | ASSERT(programObject); |
| 6794 | programObject->setUniform1fv(location, count, value); |
| 6795 | } |
| 6796 | |
| 6797 | void Context::programUniform2fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6798 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6799 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6800 | ASSERT(programObject); |
| 6801 | programObject->setUniform2fv(location, count, value); |
| 6802 | } |
| 6803 | |
| 6804 | void Context::programUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6805 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6806 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6807 | ASSERT(programObject); |
| 6808 | programObject->setUniform3fv(location, count, value); |
| 6809 | } |
| 6810 | |
| 6811 | void Context::programUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6812 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6813 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6814 | ASSERT(programObject); |
| 6815 | programObject->setUniform4fv(location, count, value); |
| 6816 | } |
| 6817 | |
| 6818 | void Context::programUniformMatrix2fv(GLuint program, |
| 6819 | GLint location, |
| 6820 | GLsizei count, |
| 6821 | GLboolean transpose, |
| 6822 | const GLfloat *value) |
| 6823 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6824 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6825 | ASSERT(programObject); |
| 6826 | programObject->setUniformMatrix2fv(location, count, transpose, value); |
| 6827 | } |
| 6828 | |
| 6829 | void Context::programUniformMatrix3fv(GLuint program, |
| 6830 | GLint location, |
| 6831 | GLsizei count, |
| 6832 | GLboolean transpose, |
| 6833 | const GLfloat *value) |
| 6834 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6835 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6836 | ASSERT(programObject); |
| 6837 | programObject->setUniformMatrix3fv(location, count, transpose, value); |
| 6838 | } |
| 6839 | |
| 6840 | void Context::programUniformMatrix4fv(GLuint program, |
| 6841 | GLint location, |
| 6842 | GLsizei count, |
| 6843 | GLboolean transpose, |
| 6844 | const GLfloat *value) |
| 6845 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6846 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6847 | ASSERT(programObject); |
| 6848 | programObject->setUniformMatrix4fv(location, count, transpose, value); |
| 6849 | } |
| 6850 | |
| 6851 | void Context::programUniformMatrix2x3fv(GLuint program, |
| 6852 | GLint location, |
| 6853 | GLsizei count, |
| 6854 | GLboolean transpose, |
| 6855 | const GLfloat *value) |
| 6856 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6857 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6858 | ASSERT(programObject); |
| 6859 | programObject->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6860 | } |
| 6861 | |
| 6862 | void Context::programUniformMatrix3x2fv(GLuint program, |
| 6863 | GLint location, |
| 6864 | GLsizei count, |
| 6865 | GLboolean transpose, |
| 6866 | const GLfloat *value) |
| 6867 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6868 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6869 | ASSERT(programObject); |
| 6870 | programObject->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6871 | } |
| 6872 | |
| 6873 | void Context::programUniformMatrix2x4fv(GLuint program, |
| 6874 | GLint location, |
| 6875 | GLsizei count, |
| 6876 | GLboolean transpose, |
| 6877 | const GLfloat *value) |
| 6878 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6879 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6880 | ASSERT(programObject); |
| 6881 | programObject->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6882 | } |
| 6883 | |
| 6884 | void Context::programUniformMatrix4x2fv(GLuint program, |
| 6885 | GLint location, |
| 6886 | GLsizei count, |
| 6887 | GLboolean transpose, |
| 6888 | const GLfloat *value) |
| 6889 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6890 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6891 | ASSERT(programObject); |
| 6892 | programObject->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6893 | } |
| 6894 | |
| 6895 | void Context::programUniformMatrix3x4fv(GLuint program, |
| 6896 | GLint location, |
| 6897 | GLsizei count, |
| 6898 | GLboolean transpose, |
| 6899 | const GLfloat *value) |
| 6900 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6901 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6902 | ASSERT(programObject); |
| 6903 | programObject->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6904 | } |
| 6905 | |
| 6906 | void Context::programUniformMatrix4x3fv(GLuint program, |
| 6907 | GLint location, |
| 6908 | GLsizei count, |
| 6909 | GLboolean transpose, |
| 6910 | const GLfloat *value) |
| 6911 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6912 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6913 | ASSERT(programObject); |
| 6914 | programObject->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6915 | } |
| 6916 | |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6917 | bool Context::isCurrentTransformFeedback(const TransformFeedback *tf) const |
| 6918 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6919 | return mState.isCurrentTransformFeedback(tf); |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6920 | } |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6921 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 6922 | void Context::genProgramPipelines(GLsizei count, GLuint *pipelines) |
| 6923 | { |
| 6924 | for (int i = 0; i < count; i++) |
| 6925 | { |
| 6926 | pipelines[i] = createProgramPipeline(); |
| 6927 | } |
| 6928 | } |
| 6929 | |
| 6930 | void Context::deleteProgramPipelines(GLsizei count, const GLuint *pipelines) |
| 6931 | { |
| 6932 | for (int i = 0; i < count; i++) |
| 6933 | { |
| 6934 | if (pipelines[i] != 0) |
| 6935 | { |
| 6936 | deleteProgramPipeline(pipelines[i]); |
| 6937 | } |
| 6938 | } |
| 6939 | } |
| 6940 | |
| 6941 | GLboolean Context::isProgramPipeline(GLuint pipeline) |
| 6942 | { |
| 6943 | if (pipeline == 0) |
| 6944 | { |
| 6945 | return GL_FALSE; |
| 6946 | } |
| 6947 | |
| 6948 | return (getProgramPipeline(pipeline) ? GL_TRUE : GL_FALSE); |
| 6949 | } |
| 6950 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6951 | void Context::finishFenceNV(GLuint fence) |
| 6952 | { |
| 6953 | FenceNV *fenceObject = getFenceNV(fence); |
| 6954 | |
| 6955 | ASSERT(fenceObject && fenceObject->isSet()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6956 | ANGLE_CONTEXT_TRY(fenceObject->finish(this)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6957 | } |
| 6958 | |
| 6959 | void Context::getFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 6960 | { |
| 6961 | FenceNV *fenceObject = getFenceNV(fence); |
| 6962 | |
| 6963 | ASSERT(fenceObject && fenceObject->isSet()); |
| 6964 | |
| 6965 | switch (pname) |
| 6966 | { |
| 6967 | case GL_FENCE_STATUS_NV: |
| 6968 | { |
| 6969 | // GL_NV_fence spec: |
| 6970 | // Once the status of a fence has been finished (via FinishFenceNV) or tested and |
| 6971 | // the returned status is TRUE (via either TestFenceNV or GetFenceivNV querying the |
| 6972 | // FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence. |
| 6973 | GLboolean status = GL_TRUE; |
| 6974 | if (fenceObject->getStatus() != GL_TRUE) |
| 6975 | { |
Jamie Madill | a0691b7 | 2018-07-25 10:41:22 -0400 | [diff] [blame] | 6976 | ANGLE_CONTEXT_TRY(fenceObject->test(this, &status)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6977 | } |
| 6978 | *params = status; |
| 6979 | break; |
| 6980 | } |
| 6981 | |
| 6982 | case GL_FENCE_CONDITION_NV: |
| 6983 | { |
| 6984 | *params = static_cast<GLint>(fenceObject->getCondition()); |
| 6985 | break; |
| 6986 | } |
| 6987 | |
| 6988 | default: |
| 6989 | UNREACHABLE(); |
| 6990 | } |
| 6991 | } |
| 6992 | |
| 6993 | void Context::getTranslatedShaderSource(GLuint shader, |
| 6994 | GLsizei bufsize, |
| 6995 | GLsizei *length, |
| 6996 | GLchar *source) |
| 6997 | { |
| 6998 | Shader *shaderObject = getShader(shader); |
| 6999 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 7000 | shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7001 | } |
| 7002 | |
| 7003 | void Context::getnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params) |
| 7004 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7005 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7006 | ASSERT(programObject); |
| 7007 | |
| 7008 | programObject->getUniformfv(this, location, params); |
| 7009 | } |
| 7010 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7011 | void Context::getnUniformfvRobust(GLuint program, |
| 7012 | GLint location, |
| 7013 | GLsizei bufSize, |
| 7014 | GLsizei *length, |
| 7015 | GLfloat *params) |
| 7016 | { |
| 7017 | UNIMPLEMENTED(); |
| 7018 | } |
| 7019 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7020 | void Context::getnUniformiv(GLuint program, GLint location, GLsizei bufSize, GLint *params) |
| 7021 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7022 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7023 | ASSERT(programObject); |
| 7024 | |
| 7025 | programObject->getUniformiv(this, location, params); |
| 7026 | } |
| 7027 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7028 | void Context::getnUniformivRobust(GLuint program, |
| 7029 | GLint location, |
| 7030 | GLsizei bufSize, |
| 7031 | GLsizei *length, |
| 7032 | GLint *params) |
| 7033 | { |
| 7034 | UNIMPLEMENTED(); |
| 7035 | } |
| 7036 | |
| 7037 | void Context::getnUniformuivRobust(GLuint program, |
| 7038 | GLint location, |
| 7039 | GLsizei bufSize, |
| 7040 | GLsizei *length, |
| 7041 | GLuint *params) |
| 7042 | { |
| 7043 | UNIMPLEMENTED(); |
| 7044 | } |
| 7045 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7046 | GLboolean Context::isFenceNV(GLuint fence) |
| 7047 | { |
| 7048 | FenceNV *fenceObject = getFenceNV(fence); |
| 7049 | |
| 7050 | if (fenceObject == nullptr) |
| 7051 | { |
| 7052 | return GL_FALSE; |
| 7053 | } |
| 7054 | |
| 7055 | // GL_NV_fence spec: |
| 7056 | // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an |
| 7057 | // existing fence. |
| 7058 | return fenceObject->isSet(); |
| 7059 | } |
| 7060 | |
| 7061 | void Context::readnPixels(GLint x, |
| 7062 | GLint y, |
| 7063 | GLsizei width, |
| 7064 | GLsizei height, |
| 7065 | GLenum format, |
| 7066 | GLenum type, |
| 7067 | GLsizei bufSize, |
| 7068 | void *data) |
| 7069 | { |
| 7070 | return readPixels(x, y, width, height, format, type, data); |
| 7071 | } |
| 7072 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7073 | void Context::setFenceNV(GLuint fence, GLenum condition) |
| 7074 | { |
| 7075 | ASSERT(condition == GL_ALL_COMPLETED_NV); |
| 7076 | |
| 7077 | FenceNV *fenceObject = getFenceNV(fence); |
| 7078 | ASSERT(fenceObject != nullptr); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7079 | ANGLE_CONTEXT_TRY(fenceObject->set(this, condition)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7080 | } |
| 7081 | |
| 7082 | GLboolean Context::testFenceNV(GLuint fence) |
| 7083 | { |
| 7084 | FenceNV *fenceObject = getFenceNV(fence); |
| 7085 | |
| 7086 | ASSERT(fenceObject != nullptr); |
| 7087 | ASSERT(fenceObject->isSet() == GL_TRUE); |
| 7088 | |
| 7089 | GLboolean result = GL_TRUE; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 7090 | if (fenceObject->test(this, &result) == angle::Result::Stop) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7091 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7092 | return GL_TRUE; |
| 7093 | } |
| 7094 | |
| 7095 | return result; |
| 7096 | } |
| 7097 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 7098 | void Context::eGLImageTargetTexture2D(TextureType target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7099 | { |
| 7100 | Texture *texture = getTargetTexture(target); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7101 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7102 | ANGLE_CONTEXT_TRY(texture->setEGLImageTarget(this, target, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7103 | } |
| 7104 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7105 | void Context::eGLImageTargetRenderbufferStorage(GLenum target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7106 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7107 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7108 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7109 | ANGLE_CONTEXT_TRY(renderbuffer->setStorageEGLImageTarget(this, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7110 | } |
| 7111 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7112 | void Context::texStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width) |
| 7113 | { |
| 7114 | UNIMPLEMENTED(); |
| 7115 | } |
| 7116 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7117 | bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) |
| 7118 | { |
| 7119 | // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation |
| 7120 | // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due |
| 7121 | // to the fact that it is stored internally as a float, and so would require conversion |
| 7122 | // if returned from Context::getIntegerv. Since this conversion is already implemented |
| 7123 | // in the case that one calls glGetIntegerv to retrieve a float-typed state variable, we |
| 7124 | // place DEPTH_CLEAR_VALUE with the floats. This should make no difference to the calling |
| 7125 | // application. |
| 7126 | switch (pname) |
| 7127 | { |
| 7128 | case GL_COMPRESSED_TEXTURE_FORMATS: |
| 7129 | { |
| 7130 | *type = GL_INT; |
| 7131 | *numParams = static_cast<unsigned int>(getCaps().compressedTextureFormats.size()); |
| 7132 | return true; |
| 7133 | } |
| 7134 | case GL_SHADER_BINARY_FORMATS: |
| 7135 | { |
| 7136 | *type = GL_INT; |
| 7137 | *numParams = static_cast<unsigned int>(getCaps().shaderBinaryFormats.size()); |
| 7138 | return true; |
| 7139 | } |
| 7140 | |
| 7141 | case GL_MAX_VERTEX_ATTRIBS: |
| 7142 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 7143 | case GL_MAX_VARYING_VECTORS: |
| 7144 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 7145 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 7146 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
| 7147 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 7148 | case GL_MAX_RENDERBUFFER_SIZE: |
| 7149 | case GL_NUM_SHADER_BINARY_FORMATS: |
| 7150 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 7151 | case GL_ARRAY_BUFFER_BINDING: |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7152 | case GL_FRAMEBUFFER_BINDING: // GL_FRAMEBUFFER_BINDING now equivalent to |
| 7153 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7154 | case GL_RENDERBUFFER_BINDING: |
| 7155 | case GL_CURRENT_PROGRAM: |
| 7156 | case GL_PACK_ALIGNMENT: |
| 7157 | case GL_UNPACK_ALIGNMENT: |
| 7158 | case GL_GENERATE_MIPMAP_HINT: |
| 7159 | case GL_RED_BITS: |
| 7160 | case GL_GREEN_BITS: |
| 7161 | case GL_BLUE_BITS: |
| 7162 | case GL_ALPHA_BITS: |
| 7163 | case GL_DEPTH_BITS: |
| 7164 | case GL_STENCIL_BITS: |
| 7165 | case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 7166 | case GL_CULL_FACE_MODE: |
| 7167 | case GL_FRONT_FACE: |
| 7168 | case GL_ACTIVE_TEXTURE: |
| 7169 | case GL_STENCIL_FUNC: |
| 7170 | case GL_STENCIL_VALUE_MASK: |
| 7171 | case GL_STENCIL_REF: |
| 7172 | case GL_STENCIL_FAIL: |
| 7173 | case GL_STENCIL_PASS_DEPTH_FAIL: |
| 7174 | case GL_STENCIL_PASS_DEPTH_PASS: |
| 7175 | case GL_STENCIL_BACK_FUNC: |
| 7176 | case GL_STENCIL_BACK_VALUE_MASK: |
| 7177 | case GL_STENCIL_BACK_REF: |
| 7178 | case GL_STENCIL_BACK_FAIL: |
| 7179 | case GL_STENCIL_BACK_PASS_DEPTH_FAIL: |
| 7180 | case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
| 7181 | case GL_DEPTH_FUNC: |
| 7182 | case GL_BLEND_SRC_RGB: |
| 7183 | case GL_BLEND_SRC_ALPHA: |
| 7184 | case GL_BLEND_DST_RGB: |
| 7185 | case GL_BLEND_DST_ALPHA: |
| 7186 | case GL_BLEND_EQUATION_RGB: |
| 7187 | case GL_BLEND_EQUATION_ALPHA: |
| 7188 | case GL_STENCIL_WRITEMASK: |
| 7189 | case GL_STENCIL_BACK_WRITEMASK: |
| 7190 | case GL_STENCIL_CLEAR_VALUE: |
| 7191 | case GL_SUBPIXEL_BITS: |
| 7192 | case GL_MAX_TEXTURE_SIZE: |
| 7193 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 7194 | case GL_SAMPLE_BUFFERS: |
| 7195 | case GL_SAMPLES: |
| 7196 | case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 7197 | case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 7198 | case GL_TEXTURE_BINDING_2D: |
| 7199 | case GL_TEXTURE_BINDING_CUBE_MAP: |
| 7200 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 7201 | { |
| 7202 | *type = GL_INT; |
| 7203 | *numParams = 1; |
| 7204 | return true; |
| 7205 | } |
| 7206 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 7207 | { |
| 7208 | if (!getExtensions().packReverseRowOrder) |
| 7209 | { |
| 7210 | return false; |
| 7211 | } |
| 7212 | *type = GL_INT; |
| 7213 | *numParams = 1; |
| 7214 | return true; |
| 7215 | } |
| 7216 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
| 7217 | case GL_TEXTURE_BINDING_RECTANGLE_ANGLE: |
| 7218 | { |
| 7219 | if (!getExtensions().textureRectangle) |
| 7220 | { |
| 7221 | return false; |
| 7222 | } |
| 7223 | *type = GL_INT; |
| 7224 | *numParams = 1; |
| 7225 | return true; |
| 7226 | } |
| 7227 | case GL_MAX_DRAW_BUFFERS_EXT: |
| 7228 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
| 7229 | { |
| 7230 | if ((getClientMajorVersion() < 3) && !getExtensions().drawBuffers) |
| 7231 | { |
| 7232 | return false; |
| 7233 | } |
| 7234 | *type = GL_INT; |
| 7235 | *numParams = 1; |
| 7236 | return true; |
| 7237 | } |
| 7238 | case GL_MAX_VIEWPORT_DIMS: |
| 7239 | { |
| 7240 | *type = GL_INT; |
| 7241 | *numParams = 2; |
| 7242 | return true; |
| 7243 | } |
| 7244 | case GL_VIEWPORT: |
| 7245 | case GL_SCISSOR_BOX: |
| 7246 | { |
| 7247 | *type = GL_INT; |
| 7248 | *numParams = 4; |
| 7249 | return true; |
| 7250 | } |
| 7251 | case GL_SHADER_COMPILER: |
| 7252 | case GL_SAMPLE_COVERAGE_INVERT: |
| 7253 | case GL_DEPTH_WRITEMASK: |
| 7254 | case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled, |
| 7255 | case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries. |
| 7256 | case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as |
| 7257 | // bool-natural |
| 7258 | case GL_SAMPLE_COVERAGE: |
| 7259 | case GL_SCISSOR_TEST: |
| 7260 | case GL_STENCIL_TEST: |
| 7261 | case GL_DEPTH_TEST: |
| 7262 | case GL_BLEND: |
| 7263 | case GL_DITHER: |
| 7264 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 7265 | { |
| 7266 | *type = GL_BOOL; |
| 7267 | *numParams = 1; |
| 7268 | return true; |
| 7269 | } |
| 7270 | case GL_COLOR_WRITEMASK: |
| 7271 | { |
| 7272 | *type = GL_BOOL; |
| 7273 | *numParams = 4; |
| 7274 | return true; |
| 7275 | } |
| 7276 | case GL_POLYGON_OFFSET_FACTOR: |
| 7277 | case GL_POLYGON_OFFSET_UNITS: |
| 7278 | case GL_SAMPLE_COVERAGE_VALUE: |
| 7279 | case GL_DEPTH_CLEAR_VALUE: |
| 7280 | case GL_LINE_WIDTH: |
| 7281 | { |
| 7282 | *type = GL_FLOAT; |
| 7283 | *numParams = 1; |
| 7284 | return true; |
| 7285 | } |
| 7286 | case GL_ALIASED_LINE_WIDTH_RANGE: |
| 7287 | case GL_ALIASED_POINT_SIZE_RANGE: |
| 7288 | case GL_DEPTH_RANGE: |
| 7289 | { |
| 7290 | *type = GL_FLOAT; |
| 7291 | *numParams = 2; |
| 7292 | return true; |
| 7293 | } |
| 7294 | case GL_COLOR_CLEAR_VALUE: |
| 7295 | case GL_BLEND_COLOR: |
| 7296 | { |
| 7297 | *type = GL_FLOAT; |
| 7298 | *numParams = 4; |
| 7299 | return true; |
| 7300 | } |
| 7301 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7302 | if (!getExtensions().textureFilterAnisotropic) |
| 7303 | { |
| 7304 | return false; |
| 7305 | } |
| 7306 | *type = GL_FLOAT; |
| 7307 | *numParams = 1; |
| 7308 | return true; |
| 7309 | case GL_TIMESTAMP_EXT: |
| 7310 | if (!getExtensions().disjointTimerQuery) |
| 7311 | { |
| 7312 | return false; |
| 7313 | } |
| 7314 | *type = GL_INT_64_ANGLEX; |
| 7315 | *numParams = 1; |
| 7316 | return true; |
| 7317 | case GL_GPU_DISJOINT_EXT: |
| 7318 | if (!getExtensions().disjointTimerQuery) |
| 7319 | { |
| 7320 | return false; |
| 7321 | } |
| 7322 | *type = GL_INT; |
| 7323 | *numParams = 1; |
| 7324 | return true; |
| 7325 | case GL_COVERAGE_MODULATION_CHROMIUM: |
| 7326 | if (!getExtensions().framebufferMixedSamples) |
| 7327 | { |
| 7328 | return false; |
| 7329 | } |
| 7330 | *type = GL_INT; |
| 7331 | *numParams = 1; |
| 7332 | return true; |
| 7333 | case GL_TEXTURE_BINDING_EXTERNAL_OES: |
| 7334 | if (!getExtensions().eglStreamConsumerExternal && !getExtensions().eglImageExternal) |
| 7335 | { |
| 7336 | return false; |
| 7337 | } |
| 7338 | *type = GL_INT; |
| 7339 | *numParams = 1; |
| 7340 | return true; |
| 7341 | } |
| 7342 | |
| 7343 | if (getExtensions().debug) |
| 7344 | { |
| 7345 | switch (pname) |
| 7346 | { |
| 7347 | case GL_DEBUG_LOGGED_MESSAGES: |
| 7348 | case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: |
| 7349 | case GL_DEBUG_GROUP_STACK_DEPTH: |
| 7350 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 7351 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 7352 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 7353 | case GL_MAX_LABEL_LENGTH: |
| 7354 | *type = GL_INT; |
| 7355 | *numParams = 1; |
| 7356 | return true; |
| 7357 | |
| 7358 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 7359 | case GL_DEBUG_OUTPUT: |
| 7360 | *type = GL_BOOL; |
| 7361 | *numParams = 1; |
| 7362 | return true; |
| 7363 | } |
| 7364 | } |
| 7365 | |
| 7366 | if (getExtensions().multisampleCompatibility) |
| 7367 | { |
| 7368 | switch (pname) |
| 7369 | { |
| 7370 | case GL_MULTISAMPLE_EXT: |
| 7371 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 7372 | *type = GL_BOOL; |
| 7373 | *numParams = 1; |
| 7374 | return true; |
| 7375 | } |
| 7376 | } |
| 7377 | |
| 7378 | if (getExtensions().pathRendering) |
| 7379 | { |
| 7380 | switch (pname) |
| 7381 | { |
| 7382 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 7383 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 7384 | *type = GL_FLOAT; |
| 7385 | *numParams = 16; |
| 7386 | return true; |
| 7387 | } |
| 7388 | } |
| 7389 | |
| 7390 | if (getExtensions().bindGeneratesResource) |
| 7391 | { |
| 7392 | switch (pname) |
| 7393 | { |
| 7394 | case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 7395 | *type = GL_BOOL; |
| 7396 | *numParams = 1; |
| 7397 | return true; |
| 7398 | } |
| 7399 | } |
| 7400 | |
| 7401 | if (getExtensions().clientArrays) |
| 7402 | { |
| 7403 | switch (pname) |
| 7404 | { |
| 7405 | case GL_CLIENT_ARRAYS_ANGLE: |
| 7406 | *type = GL_BOOL; |
| 7407 | *numParams = 1; |
| 7408 | return true; |
| 7409 | } |
| 7410 | } |
| 7411 | |
| 7412 | if (getExtensions().sRGBWriteControl) |
| 7413 | { |
| 7414 | switch (pname) |
| 7415 | { |
| 7416 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 7417 | *type = GL_BOOL; |
| 7418 | *numParams = 1; |
| 7419 | return true; |
| 7420 | } |
| 7421 | } |
| 7422 | |
| 7423 | if (getExtensions().robustResourceInitialization && |
| 7424 | pname == GL_ROBUST_RESOURCE_INITIALIZATION_ANGLE) |
| 7425 | { |
| 7426 | *type = GL_BOOL; |
| 7427 | *numParams = 1; |
| 7428 | return true; |
| 7429 | } |
| 7430 | |
| 7431 | if (getExtensions().programCacheControl && pname == GL_PROGRAM_CACHE_ENABLED_ANGLE) |
| 7432 | { |
| 7433 | *type = GL_BOOL; |
| 7434 | *numParams = 1; |
| 7435 | return true; |
| 7436 | } |
| 7437 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7438 | if (getExtensions().parallelShaderCompile && pname == GL_MAX_SHADER_COMPILER_THREADS_KHR) |
| 7439 | { |
| 7440 | *type = GL_INT; |
| 7441 | *numParams = 1; |
| 7442 | return true; |
| 7443 | } |
| 7444 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 7445 | if (getExtensions().blendFuncExtended && pname == GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT) |
| 7446 | { |
| 7447 | *type = GL_INT; |
| 7448 | *numParams = 1; |
| 7449 | return true; |
| 7450 | } |
| 7451 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7452 | // Check for ES3.0+ parameter names which are also exposed as ES2 extensions |
| 7453 | switch (pname) |
| 7454 | { |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7455 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE equivalent to FRAMEBUFFER_BINDING |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7456 | case GL_READ_FRAMEBUFFER_BINDING_ANGLE: |
| 7457 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferBlit) |
| 7458 | { |
| 7459 | return false; |
| 7460 | } |
| 7461 | *type = GL_INT; |
| 7462 | *numParams = 1; |
| 7463 | return true; |
| 7464 | |
| 7465 | case GL_NUM_PROGRAM_BINARY_FORMATS_OES: |
| 7466 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7467 | { |
| 7468 | return false; |
| 7469 | } |
| 7470 | *type = GL_INT; |
| 7471 | *numParams = 1; |
| 7472 | return true; |
| 7473 | |
| 7474 | case GL_PROGRAM_BINARY_FORMATS_OES: |
| 7475 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7476 | { |
| 7477 | return false; |
| 7478 | } |
| 7479 | *type = GL_INT; |
| 7480 | *numParams = static_cast<unsigned int>(getCaps().programBinaryFormats.size()); |
| 7481 | return true; |
| 7482 | |
| 7483 | case GL_PACK_ROW_LENGTH: |
| 7484 | case GL_PACK_SKIP_ROWS: |
| 7485 | case GL_PACK_SKIP_PIXELS: |
| 7486 | if ((getClientMajorVersion() < 3) && !getExtensions().packSubimage) |
| 7487 | { |
| 7488 | return false; |
| 7489 | } |
| 7490 | *type = GL_INT; |
| 7491 | *numParams = 1; |
| 7492 | return true; |
| 7493 | case GL_UNPACK_ROW_LENGTH: |
| 7494 | case GL_UNPACK_SKIP_ROWS: |
| 7495 | case GL_UNPACK_SKIP_PIXELS: |
| 7496 | if ((getClientMajorVersion() < 3) && !getExtensions().unpackSubimage) |
| 7497 | { |
| 7498 | return false; |
| 7499 | } |
| 7500 | *type = GL_INT; |
| 7501 | *numParams = 1; |
| 7502 | return true; |
| 7503 | case GL_VERTEX_ARRAY_BINDING: |
| 7504 | if ((getClientMajorVersion() < 3) && !getExtensions().vertexArrayObject) |
| 7505 | { |
| 7506 | return false; |
| 7507 | } |
| 7508 | *type = GL_INT; |
| 7509 | *numParams = 1; |
| 7510 | return true; |
| 7511 | case GL_PIXEL_PACK_BUFFER_BINDING: |
| 7512 | case GL_PIXEL_UNPACK_BUFFER_BINDING: |
| 7513 | if ((getClientMajorVersion() < 3) && !getExtensions().pixelBufferObject) |
| 7514 | { |
| 7515 | return false; |
| 7516 | } |
| 7517 | *type = GL_INT; |
| 7518 | *numParams = 1; |
| 7519 | return true; |
| 7520 | case GL_MAX_SAMPLES: |
| 7521 | { |
| 7522 | static_assert(GL_MAX_SAMPLES_ANGLE == GL_MAX_SAMPLES, |
| 7523 | "GL_MAX_SAMPLES_ANGLE not equal to GL_MAX_SAMPLES"); |
| 7524 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferMultisample) |
| 7525 | { |
| 7526 | return false; |
| 7527 | } |
| 7528 | *type = GL_INT; |
| 7529 | *numParams = 1; |
| 7530 | return true; |
| 7531 | |
| 7532 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: |
| 7533 | if ((getClientMajorVersion() < 3) && !getExtensions().standardDerivatives) |
| 7534 | { |
| 7535 | return false; |
| 7536 | } |
| 7537 | *type = GL_INT; |
| 7538 | *numParams = 1; |
| 7539 | return true; |
| 7540 | } |
| 7541 | } |
| 7542 | |
| 7543 | if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT) |
| 7544 | { |
| 7545 | if ((getClientVersion() < Version(3, 0)) && !getExtensions().drawBuffers) |
| 7546 | { |
| 7547 | return false; |
| 7548 | } |
| 7549 | *type = GL_INT; |
| 7550 | *numParams = 1; |
| 7551 | return true; |
| 7552 | } |
| 7553 | |
| 7554 | if (getExtensions().multiview && pname == GL_MAX_VIEWS_ANGLE) |
| 7555 | { |
| 7556 | *type = GL_INT; |
| 7557 | *numParams = 1; |
| 7558 | return true; |
| 7559 | } |
| 7560 | |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7561 | if (getClientVersion() < Version(2, 0)) |
| 7562 | { |
| 7563 | switch (pname) |
| 7564 | { |
| 7565 | case GL_ALPHA_TEST_FUNC: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7566 | case GL_CLIENT_ACTIVE_TEXTURE: |
| 7567 | case GL_MATRIX_MODE: |
| 7568 | case GL_MAX_TEXTURE_UNITS: |
| 7569 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
| 7570 | case GL_MAX_PROJECTION_STACK_DEPTH: |
| 7571 | case GL_MAX_TEXTURE_STACK_DEPTH: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7572 | case GL_MAX_LIGHTS: |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 7573 | case GL_MAX_CLIP_PLANES: |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 7574 | case GL_VERTEX_ARRAY_STRIDE: |
| 7575 | case GL_NORMAL_ARRAY_STRIDE: |
| 7576 | case GL_COLOR_ARRAY_STRIDE: |
| 7577 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 7578 | case GL_VERTEX_ARRAY_SIZE: |
| 7579 | case GL_COLOR_ARRAY_SIZE: |
| 7580 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 7581 | case GL_VERTEX_ARRAY_TYPE: |
| 7582 | case GL_NORMAL_ARRAY_TYPE: |
| 7583 | case GL_COLOR_ARRAY_TYPE: |
| 7584 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 7585 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 7586 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 7587 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 7588 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 7589 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 7590 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 7591 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
Lingfeng Yang | a0cfa87 | 2018-05-30 21:12:17 -0700 | [diff] [blame] | 7592 | case GL_SHADE_MODEL: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7593 | case GL_MODELVIEW_STACK_DEPTH: |
| 7594 | case GL_PROJECTION_STACK_DEPTH: |
| 7595 | case GL_TEXTURE_STACK_DEPTH: |
| 7596 | case GL_LOGIC_OP_MODE: |
| 7597 | case GL_BLEND_SRC: |
| 7598 | case GL_BLEND_DST: |
| 7599 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 7600 | case GL_POINT_SMOOTH_HINT: |
| 7601 | case GL_LINE_SMOOTH_HINT: |
| 7602 | case GL_FOG_HINT: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7603 | *type = GL_INT; |
| 7604 | *numParams = 1; |
| 7605 | return true; |
| 7606 | case GL_ALPHA_TEST_REF: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7607 | case GL_FOG_DENSITY: |
| 7608 | case GL_FOG_START: |
| 7609 | case GL_FOG_END: |
| 7610 | case GL_FOG_MODE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7611 | case GL_POINT_SIZE: |
| 7612 | case GL_POINT_SIZE_MIN: |
| 7613 | case GL_POINT_SIZE_MAX: |
| 7614 | case GL_POINT_FADE_THRESHOLD_SIZE: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7615 | *type = GL_FLOAT; |
| 7616 | *numParams = 1; |
| 7617 | return true; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7618 | case GL_SMOOTH_POINT_SIZE_RANGE: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7619 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7620 | *type = GL_FLOAT; |
| 7621 | *numParams = 2; |
| 7622 | return true; |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7623 | case GL_CURRENT_COLOR: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7624 | case GL_CURRENT_TEXTURE_COORDS: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7625 | case GL_LIGHT_MODEL_AMBIENT: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7626 | case GL_FOG_COLOR: |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7627 | *type = GL_FLOAT; |
| 7628 | *numParams = 4; |
| 7629 | return true; |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7630 | case GL_CURRENT_NORMAL: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7631 | case GL_POINT_DISTANCE_ATTENUATION: |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7632 | *type = GL_FLOAT; |
| 7633 | *numParams = 3; |
| 7634 | return true; |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 7635 | case GL_MODELVIEW_MATRIX: |
| 7636 | case GL_PROJECTION_MATRIX: |
| 7637 | case GL_TEXTURE_MATRIX: |
| 7638 | *type = GL_FLOAT; |
| 7639 | *numParams = 16; |
| 7640 | return true; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7641 | case GL_LIGHT_MODEL_TWO_SIDE: |
| 7642 | *type = GL_BOOL; |
| 7643 | *numParams = 1; |
| 7644 | return true; |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7645 | } |
| 7646 | } |
| 7647 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7648 | if (getClientVersion() < Version(3, 0)) |
| 7649 | { |
| 7650 | return false; |
| 7651 | } |
| 7652 | |
| 7653 | // Check for ES3.0+ parameter names |
| 7654 | switch (pname) |
| 7655 | { |
| 7656 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 7657 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 7658 | case GL_UNIFORM_BUFFER_BINDING: |
| 7659 | case GL_TRANSFORM_FEEDBACK_BINDING: |
| 7660 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7661 | case GL_COPY_READ_BUFFER_BINDING: |
| 7662 | case GL_COPY_WRITE_BUFFER_BINDING: |
| 7663 | case GL_SAMPLER_BINDING: |
| 7664 | case GL_READ_BUFFER: |
| 7665 | case GL_TEXTURE_BINDING_3D: |
| 7666 | case GL_TEXTURE_BINDING_2D_ARRAY: |
| 7667 | case GL_MAX_3D_TEXTURE_SIZE: |
| 7668 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 7669 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
| 7670 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
| 7671 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 7672 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 7673 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 7674 | case GL_MAX_VARYING_COMPONENTS: |
| 7675 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
| 7676 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
| 7677 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 7678 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 7679 | case GL_NUM_EXTENSIONS: |
| 7680 | case GL_MAJOR_VERSION: |
| 7681 | case GL_MINOR_VERSION: |
| 7682 | case GL_MAX_ELEMENTS_INDICES: |
| 7683 | case GL_MAX_ELEMENTS_VERTICES: |
| 7684 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 7685 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 7686 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 7687 | case GL_UNPACK_IMAGE_HEIGHT: |
| 7688 | case GL_UNPACK_SKIP_IMAGES: |
| 7689 | { |
| 7690 | *type = GL_INT; |
| 7691 | *numParams = 1; |
| 7692 | return true; |
| 7693 | } |
| 7694 | |
| 7695 | case GL_MAX_ELEMENT_INDEX: |
| 7696 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 7697 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
| 7698 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
| 7699 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 7700 | { |
| 7701 | *type = GL_INT_64_ANGLEX; |
| 7702 | *numParams = 1; |
| 7703 | return true; |
| 7704 | } |
| 7705 | |
| 7706 | case GL_TRANSFORM_FEEDBACK_ACTIVE: |
| 7707 | case GL_TRANSFORM_FEEDBACK_PAUSED: |
| 7708 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 7709 | case GL_RASTERIZER_DISCARD: |
| 7710 | { |
| 7711 | *type = GL_BOOL; |
| 7712 | *numParams = 1; |
| 7713 | return true; |
| 7714 | } |
| 7715 | |
| 7716 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 7717 | { |
| 7718 | *type = GL_FLOAT; |
| 7719 | *numParams = 1; |
| 7720 | return true; |
| 7721 | } |
| 7722 | } |
| 7723 | |
| 7724 | if (getExtensions().requestExtension) |
| 7725 | { |
| 7726 | switch (pname) |
| 7727 | { |
| 7728 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 7729 | *type = GL_INT; |
| 7730 | *numParams = 1; |
| 7731 | return true; |
| 7732 | } |
| 7733 | } |
| 7734 | |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7735 | if (getExtensions().textureMultisample) |
| 7736 | { |
| 7737 | switch (pname) |
| 7738 | { |
| 7739 | case GL_MAX_COLOR_TEXTURE_SAMPLES_ANGLE: |
| 7740 | case GL_MAX_INTEGER_SAMPLES_ANGLE: |
| 7741 | case GL_MAX_DEPTH_TEXTURE_SAMPLES_ANGLE: |
| 7742 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ANGLE: |
Yizhou Jiang | 7310da3 | 2018-11-05 14:40:01 +0800 | [diff] [blame] | 7743 | case GL_MAX_SAMPLE_MASK_WORDS: |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7744 | *type = GL_INT; |
| 7745 | *numParams = 1; |
| 7746 | return true; |
| 7747 | } |
| 7748 | } |
| 7749 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7750 | if (getClientVersion() < Version(3, 1)) |
| 7751 | { |
| 7752 | return false; |
| 7753 | } |
| 7754 | |
| 7755 | switch (pname) |
| 7756 | { |
| 7757 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7758 | case GL_DRAW_INDIRECT_BUFFER_BINDING: |
| 7759 | case GL_DISPATCH_INDIRECT_BUFFER_BINDING: |
| 7760 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 7761 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 7762 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 7763 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 7764 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 7765 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 7766 | case GL_MAX_INTEGER_SAMPLES: |
| 7767 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 7768 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 7769 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 7770 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
| 7771 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
| 7772 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
| 7773 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
| 7774 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
| 7775 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
| 7776 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
| 7777 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
| 7778 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7779 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7780 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 7781 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
| 7782 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
| 7783 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 7784 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
| 7785 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
| 7786 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
| 7787 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
| 7788 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
| 7789 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
| 7790 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 7791 | case GL_MAX_UNIFORM_LOCATIONS: |
| 7792 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 7793 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7794 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 7795 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 7796 | case GL_MAX_IMAGE_UNITS: |
| 7797 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 7798 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 7799 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 7800 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7801 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 7802 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE: |
Olli Etuaho | dff32a0 | 2018-08-28 14:35:50 +0300 | [diff] [blame] | 7803 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7804 | *type = GL_INT; |
| 7805 | *numParams = 1; |
| 7806 | return true; |
| 7807 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 7808 | *type = GL_INT_64_ANGLEX; |
| 7809 | *numParams = 1; |
| 7810 | return true; |
| 7811 | case GL_SAMPLE_MASK: |
| 7812 | *type = GL_BOOL; |
| 7813 | *numParams = 1; |
| 7814 | return true; |
| 7815 | } |
| 7816 | |
| 7817 | if (getExtensions().geometryShader) |
| 7818 | { |
| 7819 | switch (pname) |
| 7820 | { |
| 7821 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
| 7822 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
| 7823 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7824 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
| 7825 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7826 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
| 7827 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
| 7828 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
| 7829 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
| 7830 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
| 7831 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
| 7832 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
| 7833 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
| 7834 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
| 7835 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
| 7836 | *type = GL_INT; |
| 7837 | *numParams = 1; |
| 7838 | return true; |
| 7839 | } |
| 7840 | } |
| 7841 | |
| 7842 | return false; |
| 7843 | } |
| 7844 | |
| 7845 | bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams) |
| 7846 | { |
| 7847 | if (getClientVersion() < Version(3, 0)) |
| 7848 | { |
| 7849 | return false; |
| 7850 | } |
| 7851 | |
| 7852 | switch (target) |
| 7853 | { |
| 7854 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7855 | case GL_UNIFORM_BUFFER_BINDING: |
| 7856 | { |
| 7857 | *type = GL_INT; |
| 7858 | *numParams = 1; |
| 7859 | return true; |
| 7860 | } |
| 7861 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 7862 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 7863 | case GL_UNIFORM_BUFFER_START: |
| 7864 | case GL_UNIFORM_BUFFER_SIZE: |
| 7865 | { |
| 7866 | *type = GL_INT_64_ANGLEX; |
| 7867 | *numParams = 1; |
| 7868 | return true; |
| 7869 | } |
| 7870 | } |
| 7871 | |
| 7872 | if (getClientVersion() < Version(3, 1)) |
| 7873 | { |
| 7874 | return false; |
| 7875 | } |
| 7876 | |
| 7877 | switch (target) |
| 7878 | { |
| 7879 | case GL_IMAGE_BINDING_LAYERED: |
| 7880 | { |
| 7881 | *type = GL_BOOL; |
| 7882 | *numParams = 1; |
| 7883 | return true; |
| 7884 | } |
| 7885 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 7886 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 7887 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7888 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7889 | case GL_VERTEX_BINDING_BUFFER: |
| 7890 | case GL_VERTEX_BINDING_DIVISOR: |
| 7891 | case GL_VERTEX_BINDING_OFFSET: |
| 7892 | case GL_VERTEX_BINDING_STRIDE: |
| 7893 | case GL_SAMPLE_MASK_VALUE: |
| 7894 | case GL_IMAGE_BINDING_NAME: |
| 7895 | case GL_IMAGE_BINDING_LEVEL: |
| 7896 | case GL_IMAGE_BINDING_LAYER: |
| 7897 | case GL_IMAGE_BINDING_ACCESS: |
| 7898 | case GL_IMAGE_BINDING_FORMAT: |
| 7899 | { |
| 7900 | *type = GL_INT; |
| 7901 | *numParams = 1; |
| 7902 | return true; |
| 7903 | } |
| 7904 | case GL_ATOMIC_COUNTER_BUFFER_START: |
| 7905 | case GL_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7906 | case GL_SHADER_STORAGE_BUFFER_START: |
| 7907 | case GL_SHADER_STORAGE_BUFFER_SIZE: |
| 7908 | { |
| 7909 | *type = GL_INT_64_ANGLEX; |
| 7910 | *numParams = 1; |
| 7911 | return true; |
| 7912 | } |
| 7913 | } |
| 7914 | |
| 7915 | return false; |
| 7916 | } |
| 7917 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7918 | Program *Context::getProgramNoResolveLink(GLuint handle) const |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7919 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7920 | return mState.mShaderProgramManager->getProgram(handle); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7921 | } |
| 7922 | |
| 7923 | Shader *Context::getShader(GLuint handle) const |
| 7924 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7925 | return mState.mShaderProgramManager->getShader(handle); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7926 | } |
| 7927 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7928 | bool Context::isRenderbufferGenerated(GLuint renderbuffer) const |
| 7929 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7930 | return mState.mRenderbufferManager->isHandleGenerated(renderbuffer); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7931 | } |
| 7932 | |
| 7933 | bool Context::isFramebufferGenerated(GLuint framebuffer) const |
| 7934 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7935 | return mState.mFramebufferManager->isHandleGenerated(framebuffer); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7936 | } |
| 7937 | |
| 7938 | bool Context::isProgramPipelineGenerated(GLuint pipeline) const |
| 7939 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7940 | return mState.mProgramPipelineManager->isHandleGenerated(pipeline); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7941 | } |
| 7942 | |
| 7943 | bool Context::usingDisplayTextureShareGroup() const |
| 7944 | { |
| 7945 | return mDisplayTextureShareGroup; |
| 7946 | } |
| 7947 | |
| 7948 | GLenum Context::getConvertedRenderbufferFormat(GLenum internalformat) const |
| 7949 | { |
| 7950 | return mState.mExtensions.webglCompatibility && mState.mClientVersion.major == 2 && |
| 7951 | internalformat == GL_DEPTH_STENCIL |
| 7952 | ? GL_DEPTH24_STENCIL8 |
| 7953 | : internalformat; |
| 7954 | } |
| 7955 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7956 | void Context::maxShaderCompilerThreads(GLuint count) |
| 7957 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7958 | GLuint oldCount = mState.getMaxShaderCompilerThreads(); |
| 7959 | mState.setMaxShaderCompilerThreads(count); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 7960 | // A count of zero specifies a request for no parallel compiling or linking. |
| 7961 | if ((oldCount == 0 || count == 0) && (oldCount != 0 || count != 0)) |
| 7962 | { |
| 7963 | mThreadPool = angle::WorkerThreadPool::Create(count > 0); |
| 7964 | } |
| 7965 | mThreadPool->setMaxThreads(count); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7966 | } |
| 7967 | |
Jamie Madill | 2eb6503 | 2018-07-30 10:25:57 -0400 | [diff] [blame] | 7968 | bool Context::isGLES1() const |
| 7969 | { |
| 7970 | return mState.getClientVersion() < Version(2, 0); |
| 7971 | } |
| 7972 | |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 7973 | void Context::onSubjectStateChange(const Context *context, |
| 7974 | angle::SubjectIndex index, |
| 7975 | angle::SubjectMessage message) |
| 7976 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 7977 | switch (index) |
| 7978 | { |
| 7979 | case kVertexArraySubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 7980 | switch (message) |
| 7981 | { |
| 7982 | case angle::SubjectMessage::CONTENTS_CHANGED: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7983 | mState.setObjectDirty(GL_VERTEX_ARRAY); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 7984 | mStateCache.onVertexArrayBufferContentsChange(this); |
| 7985 | break; |
| 7986 | case angle::SubjectMessage::RESOURCE_MAPPED: |
| 7987 | case angle::SubjectMessage::RESOURCE_UNMAPPED: |
| 7988 | case angle::SubjectMessage::BINDING_CHANGED: |
| 7989 | mStateCache.onVertexArrayBufferStateChange(this); |
| 7990 | break; |
| 7991 | default: |
| 7992 | break; |
| 7993 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 7994 | break; |
| 7995 | |
| 7996 | case kReadFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 7997 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 7998 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7999 | mState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8000 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8001 | break; |
| 8002 | |
| 8003 | case kDrawFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8004 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8005 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8006 | mState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8007 | } |
| 8008 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8009 | break; |
| 8010 | |
| 8011 | default: |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8012 | if (index < kTextureMaxSubjectIndex) |
| 8013 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8014 | mState.onActiveTextureStateChange(this, index); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8015 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8016 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8017 | else if (index < kUniformBufferMaxSubjectIndex) |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8018 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8019 | mState.onUniformBufferStateChange(index - kUniformBuffer0SubjectIndex); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8020 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8021 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8022 | else |
| 8023 | { |
| 8024 | ASSERT(index < kSamplerMaxSubjectIndex); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8025 | mState.setSamplerDirty(index - kSampler0SubjectIndex); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8026 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8027 | break; |
| 8028 | } |
| 8029 | } |
| 8030 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8031 | // ErrorSet implementation. |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8032 | ErrorSet::ErrorSet(Context *context) : mContext(context) {} |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8033 | |
| 8034 | ErrorSet::~ErrorSet() = default; |
| 8035 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8036 | void ErrorSet::handleError(GLenum errorCode, |
| 8037 | const char *message, |
| 8038 | const char *file, |
| 8039 | const char *function, |
| 8040 | unsigned int line) |
| 8041 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8042 | if (errorCode == GL_OUT_OF_MEMORY && mContext->getWorkarounds().loseContextOnOutOfMemory) |
| 8043 | { |
| 8044 | mContext->markContextLost(); |
| 8045 | } |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8046 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8047 | std::stringstream errorStream; |
| 8048 | errorStream << "Error: " << gl::FmtHex(errorCode) << ", in " << file << ", " << function << ":" |
| 8049 | << line << ". " << message; |
| 8050 | |
Geoff Lang | 7139b43 | 2018-12-14 16:57:28 -0500 | [diff] [blame] | 8051 | std::string formattedMessage = errorStream.str(); |
| 8052 | |
| 8053 | // Always log a warning, this function is only called on unexpected internal errors. |
| 8054 | WARN() << formattedMessage; |
| 8055 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8056 | // validationError does the necessary work to process the error. |
Geoff Lang | 7139b43 | 2018-12-14 16:57:28 -0500 | [diff] [blame] | 8057 | validationError(errorCode, formattedMessage.c_str()); |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8058 | } |
| 8059 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8060 | void ErrorSet::validationError(GLenum errorCode, const char *message) |
| 8061 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8062 | ASSERT(errorCode != GL_NO_ERROR); |
| 8063 | mErrors.insert(errorCode); |
| 8064 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8065 | mContext->getState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, |
| 8066 | errorCode, GL_DEBUG_SEVERITY_HIGH, message); |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8067 | } |
| 8068 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8069 | bool ErrorSet::empty() const |
| 8070 | { |
| 8071 | return mErrors.empty(); |
| 8072 | } |
| 8073 | |
| 8074 | GLenum ErrorSet::popError() |
| 8075 | { |
| 8076 | ASSERT(!empty()); |
| 8077 | GLenum error = *mErrors.begin(); |
| 8078 | mErrors.erase(mErrors.begin()); |
| 8079 | return error; |
| 8080 | } |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8081 | |
| 8082 | // StateCache implementation. |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8083 | StateCache::StateCache() |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8084 | : mCachedHasAnyEnabledClientAttrib(false), |
| 8085 | mCachedNonInstancedVertexElementLimit(0), |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8086 | mCachedInstancedVertexElementLimit(0), |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8087 | mCachedBasicDrawStatesError(kInvalidPointer), |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8088 | mCachedBasicDrawElementsError(kInvalidPointer), |
| 8089 | mCachedTransformFeedbackActiveUnpaused(false) |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8090 | {} |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8091 | |
| 8092 | StateCache::~StateCache() = default; |
| 8093 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8094 | void StateCache::initialize(Context *context) |
| 8095 | { |
| 8096 | updateValidDrawModes(context); |
| 8097 | updateValidBindTextureTypes(context); |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8098 | updateValidDrawElementsTypes(context); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8099 | updateBasicDrawStatesError(); |
| 8100 | updateBasicDrawElementsError(); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8101 | } |
| 8102 | |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8103 | void StateCache::updateActiveAttribsMask(Context *context) |
| 8104 | { |
| 8105 | bool isGLES1 = context->isGLES1(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8106 | const State &glState = context->getState(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8107 | |
| 8108 | if (!isGLES1 && !glState.getProgram()) |
| 8109 | { |
| 8110 | mCachedActiveBufferedAttribsMask = AttributesMask(); |
| 8111 | mCachedActiveClientAttribsMask = AttributesMask(); |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8112 | mCachedActiveDefaultAttribsMask = AttributesMask(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8113 | return; |
| 8114 | } |
| 8115 | |
| 8116 | AttributesMask activeAttribs = isGLES1 ? glState.gles1().getVertexArraysAttributeMask() |
| 8117 | : glState.getProgram()->getActiveAttribLocationsMask(); |
| 8118 | |
| 8119 | const VertexArray *vao = glState.getVertexArray(); |
| 8120 | ASSERT(vao); |
| 8121 | |
| 8122 | const AttributesMask &clientAttribs = vao->getClientAttribsMask(); |
| 8123 | const AttributesMask &enabledAttribs = vao->getEnabledAttributesMask(); |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8124 | const AttributesMask &activeEnabled = activeAttribs & enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8125 | |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8126 | mCachedActiveClientAttribsMask = activeEnabled & clientAttribs; |
| 8127 | mCachedActiveBufferedAttribsMask = activeEnabled & ~clientAttribs; |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8128 | mCachedActiveDefaultAttribsMask = activeAttribs & ~enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8129 | mCachedHasAnyEnabledClientAttrib = (clientAttribs & enabledAttribs).any(); |
| 8130 | } |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8131 | |
| 8132 | void StateCache::updateVertexElementLimits(Context *context) |
| 8133 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8134 | const VertexArray *vao = context->getState().getVertexArray(); |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8135 | |
| 8136 | mCachedNonInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8137 | mCachedInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8138 | |
| 8139 | // VAO can be null on Context startup. If we make this computation lazier we could ASSERT. |
| 8140 | // If there are no buffered attributes then we should not limit the draw call count. |
| 8141 | if (!vao || !mCachedActiveBufferedAttribsMask.any()) |
| 8142 | { |
| 8143 | return; |
| 8144 | } |
| 8145 | |
| 8146 | const auto &vertexAttribs = vao->getVertexAttributes(); |
| 8147 | const auto &vertexBindings = vao->getVertexBindings(); |
| 8148 | |
| 8149 | for (size_t attributeIndex : mCachedActiveBufferedAttribsMask) |
| 8150 | { |
| 8151 | const VertexAttribute &attrib = vertexAttribs[attributeIndex]; |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8152 | |
| 8153 | const VertexBinding &binding = vertexBindings[attrib.bindingIndex]; |
| 8154 | ASSERT(context->isGLES1() || |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8155 | context->getState().getProgram()->isAttribLocationActive(attributeIndex)); |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8156 | |
| 8157 | GLint64 limit = attrib.getCachedElementLimit(); |
| 8158 | if (binding.getDivisor() > 0) |
| 8159 | { |
| 8160 | mCachedInstancedVertexElementLimit = |
| 8161 | std::min(mCachedInstancedVertexElementLimit, limit); |
| 8162 | } |
| 8163 | else |
| 8164 | { |
| 8165 | mCachedNonInstancedVertexElementLimit = |
| 8166 | std::min(mCachedNonInstancedVertexElementLimit, limit); |
| 8167 | } |
| 8168 | } |
| 8169 | } |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8170 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8171 | void StateCache::updateBasicDrawStatesError() |
| 8172 | { |
| 8173 | mCachedBasicDrawStatesError = kInvalidPointer; |
| 8174 | } |
| 8175 | |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8176 | void StateCache::updateBasicDrawElementsError() |
| 8177 | { |
| 8178 | mCachedBasicDrawElementsError = kInvalidPointer; |
| 8179 | } |
| 8180 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8181 | intptr_t StateCache::getBasicDrawStatesErrorImpl(Context *context) const |
| 8182 | { |
| 8183 | ASSERT(mCachedBasicDrawStatesError == kInvalidPointer); |
| 8184 | mCachedBasicDrawStatesError = reinterpret_cast<intptr_t>(ValidateDrawStates(context)); |
| 8185 | return mCachedBasicDrawStatesError; |
| 8186 | } |
| 8187 | |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8188 | intptr_t StateCache::getBasicDrawElementsErrorImpl(Context *context) const |
| 8189 | { |
| 8190 | ASSERT(mCachedBasicDrawElementsError == kInvalidPointer); |
| 8191 | mCachedBasicDrawElementsError = reinterpret_cast<intptr_t>(ValidateDrawElementsStates(context)); |
| 8192 | return mCachedBasicDrawElementsError; |
| 8193 | } |
| 8194 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8195 | void StateCache::onVertexArrayBindingChange(Context *context) |
| 8196 | { |
| 8197 | updateActiveAttribsMask(context); |
| 8198 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8199 | updateBasicDrawStatesError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8200 | } |
| 8201 | |
| 8202 | void StateCache::onProgramExecutableChange(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 | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8207 | updateValidDrawModes(context); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8208 | } |
| 8209 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8210 | void StateCache::onVertexArrayFormatChange(Context *context) |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8211 | { |
| 8212 | updateVertexElementLimits(context); |
| 8213 | } |
| 8214 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8215 | void StateCache::onVertexArrayBufferContentsChange(Context *context) |
| 8216 | { |
| 8217 | updateVertexElementLimits(context); |
| 8218 | updateBasicDrawStatesError(); |
| 8219 | } |
| 8220 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8221 | void StateCache::onVertexArrayStateChange(Context *context) |
| 8222 | { |
| 8223 | updateActiveAttribsMask(context); |
| 8224 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8225 | updateBasicDrawStatesError(); |
| 8226 | } |
| 8227 | |
| 8228 | void StateCache::onVertexArrayBufferStateChange(Context *context) |
| 8229 | { |
| 8230 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8231 | updateBasicDrawElementsError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8232 | } |
| 8233 | |
| 8234 | void StateCache::onGLES1ClientStateChange(Context *context) |
| 8235 | { |
| 8236 | updateActiveAttribsMask(context); |
| 8237 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8238 | |
| 8239 | void StateCache::onDrawFramebufferChange(Context *context) |
| 8240 | { |
| 8241 | updateBasicDrawStatesError(); |
| 8242 | } |
| 8243 | |
| 8244 | void StateCache::onContextCapChange(Context *context) |
| 8245 | { |
| 8246 | updateBasicDrawStatesError(); |
| 8247 | } |
| 8248 | |
| 8249 | void StateCache::onStencilStateChange(Context *context) |
| 8250 | { |
| 8251 | updateBasicDrawStatesError(); |
| 8252 | } |
| 8253 | |
| 8254 | void StateCache::onDefaultVertexAttributeChange(Context *context) |
| 8255 | { |
| 8256 | updateBasicDrawStatesError(); |
| 8257 | } |
| 8258 | |
| 8259 | void StateCache::onActiveTextureChange(Context *context) |
| 8260 | { |
| 8261 | updateBasicDrawStatesError(); |
| 8262 | } |
| 8263 | |
| 8264 | void StateCache::onQueryChange(Context *context) |
| 8265 | { |
| 8266 | updateBasicDrawStatesError(); |
| 8267 | } |
| 8268 | |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 8269 | void StateCache::onActiveTransformFeedbackChange(Context *context) |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8270 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8271 | updateTransformFeedbackActiveUnpaused(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8272 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8273 | updateBasicDrawElementsError(); |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8274 | updateValidDrawModes(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8275 | } |
| 8276 | |
| 8277 | void StateCache::onUniformBufferStateChange(Context *context) |
| 8278 | { |
| 8279 | updateBasicDrawStatesError(); |
| 8280 | } |
| 8281 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8282 | void StateCache::setValidDrawModes(bool pointsOK, |
| 8283 | bool linesOK, |
| 8284 | bool trisOK, |
| 8285 | bool lineAdjOK, |
| 8286 | bool triAdjOK) |
| 8287 | { |
| 8288 | mCachedValidDrawModes[PrimitiveMode::Points] = pointsOK; |
| 8289 | mCachedValidDrawModes[PrimitiveMode::Lines] = linesOK; |
| 8290 | mCachedValidDrawModes[PrimitiveMode::LineStrip] = linesOK; |
| 8291 | mCachedValidDrawModes[PrimitiveMode::LineLoop] = linesOK; |
| 8292 | mCachedValidDrawModes[PrimitiveMode::Triangles] = trisOK; |
| 8293 | mCachedValidDrawModes[PrimitiveMode::TriangleFan] = trisOK; |
| 8294 | mCachedValidDrawModes[PrimitiveMode::TriangleStrip] = trisOK; |
| 8295 | mCachedValidDrawModes[PrimitiveMode::LinesAdjacency] = lineAdjOK; |
| 8296 | mCachedValidDrawModes[PrimitiveMode::LineStripAdjacency] = lineAdjOK; |
| 8297 | mCachedValidDrawModes[PrimitiveMode::TrianglesAdjacency] = triAdjOK; |
| 8298 | mCachedValidDrawModes[PrimitiveMode::TriangleStripAdjacency] = triAdjOK; |
| 8299 | } |
| 8300 | |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8301 | void StateCache::updateValidDrawModes(Context *context) |
| 8302 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8303 | const State &state = context->getState(); |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8304 | Program *program = state.getProgram(); |
| 8305 | |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8306 | if (mCachedTransformFeedbackActiveUnpaused) |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8307 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8308 | TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback(); |
| 8309 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8310 | // ES Spec 3.0 validation text: |
| 8311 | // When transform feedback is active and not paused, all geometric primitives generated must |
| 8312 | // match the value of primitiveMode passed to BeginTransformFeedback. The error |
| 8313 | // INVALID_OPERATION is generated by DrawArrays and DrawArraysInstanced if mode is not |
| 8314 | // identical to primitiveMode. The error INVALID_OPERATION is also generated by |
| 8315 | // DrawElements, DrawElementsInstanced, and DrawRangeElements while transform feedback is |
| 8316 | // active and not paused, regardless of mode. Any primitive type may be used while transform |
| 8317 | // feedback is paused. |
| 8318 | if (!context->getExtensions().geometryShader) |
| 8319 | { |
| 8320 | mCachedValidDrawModes.fill(false); |
| 8321 | mCachedValidDrawModes[curTransformFeedback->getPrimitiveMode()] = true; |
| 8322 | return; |
| 8323 | } |
| 8324 | |
| 8325 | // EXT_geometry_shader validation text: |
| 8326 | // When transform feedback is active and not paused, all geometric primitives generated must |
| 8327 | // be compatible with the value of <primitiveMode> passed to BeginTransformFeedback. If a |
| 8328 | // geometry shader is active, the type of primitive emitted by that shader is used instead |
| 8329 | // of the <mode> parameter passed to drawing commands for the purposes of this error check. |
| 8330 | // Any primitive type may be used while transform feedback is paused. |
| 8331 | bool pointsOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Points; |
| 8332 | bool linesOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Lines; |
| 8333 | bool trisOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Triangles; |
| 8334 | |
| 8335 | setValidDrawModes(pointsOK, linesOK, trisOK, false, false); |
| 8336 | return; |
| 8337 | } |
| 8338 | |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8339 | if (!program || !program->hasLinkedShaderStage(ShaderType::Geometry)) |
| 8340 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8341 | mCachedValidDrawModes = kValidBasicDrawModes; |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8342 | return; |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8343 | } |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8344 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8345 | ASSERT(program && program->hasLinkedShaderStage(ShaderType::Geometry)); |
| 8346 | PrimitiveMode gsMode = program->getGeometryShaderInputPrimitiveType(); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8347 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8348 | bool pointsOK = gsMode == PrimitiveMode::Points; |
| 8349 | bool linesOK = gsMode == PrimitiveMode::Lines; |
| 8350 | bool trisOK = gsMode == PrimitiveMode::Triangles; |
| 8351 | bool lineAdjOK = gsMode == PrimitiveMode::LinesAdjacency; |
| 8352 | bool triAdjOK = gsMode == PrimitiveMode::TrianglesAdjacency; |
| 8353 | |
| 8354 | setValidDrawModes(pointsOK, linesOK, trisOK, lineAdjOK, triAdjOK); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8355 | } |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8356 | |
| 8357 | void StateCache::updateValidBindTextureTypes(Context *context) |
| 8358 | { |
| 8359 | const Extensions &exts = context->getExtensions(); |
| 8360 | bool isGLES3 = context->getClientMajorVersion() >= 3; |
| 8361 | bool isGLES31 = context->getClientVersion() >= Version(3, 1); |
| 8362 | |
| 8363 | mCachedValidBindTextureTypes = {{ |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8364 | {TextureType::_2D, true}, |
| 8365 | {TextureType::_2DArray, isGLES3}, |
| 8366 | {TextureType::_2DMultisample, isGLES31 || exts.textureMultisample}, |
| 8367 | {TextureType::_2DMultisampleArray, exts.textureStorageMultisample2DArray}, |
| 8368 | {TextureType::_3D, isGLES3}, |
| 8369 | {TextureType::External, exts.eglImageExternal || exts.eglStreamConsumerExternal}, |
| 8370 | {TextureType::Rectangle, exts.textureRectangle}, |
| 8371 | {TextureType::CubeMap, true}, |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8372 | }}; |
| 8373 | } |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8374 | |
| 8375 | void StateCache::updateValidDrawElementsTypes(Context *context) |
| 8376 | { |
| 8377 | bool supportsUint = |
| 8378 | (context->getClientMajorVersion() >= 3 || context->getExtensions().elementIndexUint); |
| 8379 | |
| 8380 | mCachedValidDrawElementsTypes = {{ |
| 8381 | {DrawElementsType::UnsignedByte, true}, |
| 8382 | {DrawElementsType::UnsignedShort, true}, |
| 8383 | {DrawElementsType::UnsignedInt, supportsUint}, |
| 8384 | }}; |
| 8385 | } |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8386 | |
| 8387 | void StateCache::updateTransformFeedbackActiveUnpaused(Context *context) |
| 8388 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8389 | TransformFeedback *xfb = context->getState().getCurrentTransformFeedback(); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8390 | mCachedTransformFeedbackActiveUnpaused = xfb && xfb->isActive() && !xfb->isPaused(); |
| 8391 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 8392 | } // namespace gl |