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)), |
Jamie Madill | d51fbe3 | 2019-01-25 15:03:39 -0500 | [diff] [blame^] | 309 | mBufferAccessValidationEnabled(false), |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 310 | mExtensionsEnabled(GetExtensionsEnabled(attribs, mWebGLContext)), |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 311 | mMemoryProgramCache(memoryProgramCache), |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 312 | mVertexArrayObserverBinding(this, kVertexArraySubjectIndex), |
| 313 | mDrawFramebufferObserverBinding(this, kDrawFramebufferSubjectIndex), |
| 314 | mReadFramebufferObserverBinding(this, kReadFramebufferSubjectIndex), |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 315 | mScratchBuffer(1000u), |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 316 | mZeroFilledBuffer(1000u), |
| 317 | mThreadPool(nullptr) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 318 | { |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 319 | for (angle::SubjectIndex uboIndex = kUniformBuffer0SubjectIndex; |
| 320 | uboIndex < kUniformBufferMaxSubjectIndex; ++uboIndex) |
| 321 | { |
| 322 | mUniformBufferObserverBindings.emplace_back(this, uboIndex); |
| 323 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 324 | |
| 325 | for (angle::SubjectIndex samplerIndex = kSampler0SubjectIndex; |
| 326 | samplerIndex < kSamplerMaxSubjectIndex; ++samplerIndex) |
| 327 | { |
| 328 | mSamplerObserverBindings.emplace_back(this, samplerIndex); |
| 329 | } |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 330 | } |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 331 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 332 | void Context::initialize() |
| 333 | { |
| 334 | mImplementation->setMemoryProgramCache(mMemoryProgramCache); |
Jamie Madill | 14bbb3f | 2017-09-12 15:23:01 -0400 | [diff] [blame] | 335 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 336 | initCaps(); |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 337 | initWorkarounds(); |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 338 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 339 | mState.initialize(this); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 340 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 341 | mFenceNVHandleAllocator.setBaseHandle(0); |
Geoff Lang | 7dca186 | 2013-07-30 16:30:46 -0400 | [diff] [blame] | 342 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 343 | // [OpenGL ES 2.0.24] section 3.7 page 83: |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 344 | // 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] | 345 | // and cube map texture state vectors respectively associated with them. |
| 346 | // In order that access to these initial textures not be lost, they are treated as texture |
| 347 | // objects all of whose names are 0. |
| 348 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 349 | Texture *zeroTexture2D = new Texture(mImplementation.get(), 0, TextureType::_2D); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 350 | mZeroTextures[TextureType::_2D].set(this, zeroTexture2D); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 351 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 352 | Texture *zeroTextureCube = new Texture(mImplementation.get(), 0, TextureType::CubeMap); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 353 | mZeroTextures[TextureType::CubeMap].set(this, zeroTextureCube); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 354 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 355 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 356 | { |
| 357 | // TODO: These could also be enabled via extension |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 358 | Texture *zeroTexture3D = new Texture(mImplementation.get(), 0, TextureType::_3D); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 359 | mZeroTextures[TextureType::_3D].set(this, zeroTexture3D); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 360 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 361 | Texture *zeroTexture2DArray = new Texture(mImplementation.get(), 0, TextureType::_2DArray); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 362 | mZeroTextures[TextureType::_2DArray].set(this, zeroTexture2DArray); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 363 | } |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 364 | if (getClientVersion() >= Version(3, 1) || mSupportedExtensions.textureMultisample) |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 365 | { |
| 366 | Texture *zeroTexture2DMultisample = |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 367 | new Texture(mImplementation.get(), 0, TextureType::_2DMultisample); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 368 | mZeroTextures[TextureType::_2DMultisample].set(this, zeroTexture2DMultisample); |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 369 | } |
| 370 | if (getClientVersion() >= Version(3, 1)) |
| 371 | { |
Olli Etuaho | d310a43 | 2018-08-24 15:40:23 +0300 | [diff] [blame] | 372 | Texture *zeroTexture2DMultisampleArray = |
| 373 | new Texture(mImplementation.get(), 0, TextureType::_2DMultisampleArray); |
| 374 | mZeroTextures[TextureType::_2DMultisampleArray].set(this, zeroTexture2DMultisampleArray); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 375 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 376 | for (unsigned int i = 0; i < mState.mCaps.maxAtomicCounterBufferBindings; i++) |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 377 | { |
Qin Jiajia | 339f65b | 2018-02-27 12:52:48 +0800 | [diff] [blame] | 378 | bindBufferRange(BufferBinding::AtomicCounter, i, 0, 0, 0); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 379 | } |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 380 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 381 | for (unsigned int i = 0; i < mState.mCaps.maxShaderStorageBufferBindings; i++) |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 382 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 383 | bindBufferRange(BufferBinding::ShaderStorage, i, 0, 0, 0); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 384 | } |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 385 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 386 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 387 | if (mSupportedExtensions.textureRectangle) |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 388 | { |
| 389 | Texture *zeroTextureRectangle = |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 390 | new Texture(mImplementation.get(), 0, TextureType::Rectangle); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 391 | mZeroTextures[TextureType::Rectangle].set(this, zeroTextureRectangle); |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 392 | } |
| 393 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 394 | if (mSupportedExtensions.eglImageExternal || mSupportedExtensions.eglStreamConsumerExternal) |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 395 | { |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 396 | Texture *zeroTextureExternal = new Texture(mImplementation.get(), 0, TextureType::External); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 397 | mZeroTextures[TextureType::External].set(this, zeroTextureExternal); |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 398 | } |
| 399 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 400 | mState.initializeZeroTextures(this, mZeroTextures); |
Jamie Madill | e6382c3 | 2014-11-07 15:05:26 -0500 | [diff] [blame] | 401 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 402 | bindVertexArray(0); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 403 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 404 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 405 | { |
| 406 | // [OpenGL ES 3.0.2] section 2.14.1 pg 85: |
| 407 | // In the initial state, a default transform feedback object is bound and treated as |
| 408 | // a transform feedback object with a name of zero. That object is bound any time |
| 409 | // BindTransformFeedback is called with id of zero |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 410 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 411 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 412 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 413 | for (auto type : angle::AllEnums<BufferBinding>()) |
| 414 | { |
| 415 | bindBuffer(type, 0); |
| 416 | } |
| 417 | |
| 418 | bindRenderbuffer(GL_RENDERBUFFER, 0); |
| 419 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 420 | for (unsigned int i = 0; i < mState.mCaps.maxUniformBufferBindings; i++) |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 421 | { |
| 422 | bindBufferRange(BufferBinding::Uniform, i, 0, 0, -1); |
| 423 | } |
| 424 | |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 425 | // Initialize GLES1 renderer if appropriate. |
| 426 | if (getClientVersion() < Version(2, 0)) |
| 427 | { |
| 428 | mGLES1Renderer.reset(new GLES1Renderer()); |
| 429 | } |
| 430 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 431 | // Initialize dirty bit masks |
Jamie Madill | 9d0bb3d | 2018-10-09 20:29:13 -0400 | [diff] [blame] | 432 | mAllDirtyBits.set(); |
| 433 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 434 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 435 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 436 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 437 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 438 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 439 | |
| 440 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 441 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 442 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 443 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 444 | |
Jamie Madill | c67323a | 2017-11-02 23:11:41 -0400 | [diff] [blame] | 445 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_STATE); |
Corentin Wallez | 29a2099 | 2017-11-06 18:23:16 -0500 | [diff] [blame] | 446 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_BUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 447 | // No dirty objects. |
| 448 | |
| 449 | // Readpixels uses the pack state and read FBO |
Jamie Madill | c67323a | 2017-11-02 23:11:41 -0400 | [diff] [blame] | 450 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_STATE); |
Corentin Wallez | 29a2099 | 2017-11-06 18:23:16 -0500 | [diff] [blame] | 451 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_BUFFER_BINDING); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 452 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 453 | mReadPixelsDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 454 | |
| 455 | mClearDirtyBits.set(State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED); |
| 456 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 457 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
| 458 | mClearDirtyBits.set(State::DIRTY_BIT_VIEWPORT); |
| 459 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_COLOR); |
| 460 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_DEPTH); |
| 461 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_STENCIL); |
| 462 | mClearDirtyBits.set(State::DIRTY_BIT_COLOR_MASK); |
| 463 | mClearDirtyBits.set(State::DIRTY_BIT_DEPTH_MASK); |
| 464 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT); |
| 465 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_BACK); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 466 | mClearDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 467 | mClearDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 468 | |
| 469 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 470 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 471 | mBlitDirtyBits.set(State::DIRTY_BIT_FRAMEBUFFER_SRGB); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 472 | mBlitDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 473 | mBlitDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 474 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 475 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 476 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 477 | mComputeDirtyBits.set(State::DIRTY_BIT_SHADER_STORAGE_BUFFER_BINDING); |
jchen10 | 99118c1 | 2018-09-10 16:28:51 +0800 | [diff] [blame] | 478 | mComputeDirtyBits.set(State::DIRTY_BIT_UNIFORM_BUFFER_BINDINGS); |
| 479 | mComputeDirtyBits.set(State::DIRTY_BIT_ATOMIC_COUNTER_BUFFER_BINDING); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 480 | mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_BINDING); |
| 481 | mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_EXECUTABLE); |
| 482 | mComputeDirtyBits.set(State::DIRTY_BIT_TEXTURE_BINDINGS); |
| 483 | mComputeDirtyBits.set(State::DIRTY_BIT_SAMPLER_BINDINGS); |
jchen10 | 99118c1 | 2018-09-10 16:28:51 +0800 | [diff] [blame] | 484 | mComputeDirtyBits.set(State::DIRTY_BIT_IMAGE_BINDINGS); |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 485 | mComputeDirtyBits.set(State::DIRTY_BIT_DISPATCH_INDIRECT_BUFFER_BINDING); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 486 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 487 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 488 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 489 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 490 | ANGLE_CONTEXT_TRY(mImplementation->initialize()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 491 | } |
| 492 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 493 | egl::Error Context::onDestroy(const egl::Display *display) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 494 | { |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 495 | if (mGLES1Renderer) |
| 496 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 497 | mGLES1Renderer->onDestroy(this, &mState); |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 498 | } |
| 499 | |
Jamie Madill | e7b3fe2 | 2018-04-05 09:42:46 -0400 | [diff] [blame] | 500 | ANGLE_TRY(releaseSurface(display)); |
| 501 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 502 | for (auto fence : mFenceNVMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 503 | { |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 504 | SafeDelete(fence.second); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 505 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 506 | mFenceNVMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 507 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 508 | for (auto query : mQueryMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 509 | { |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 510 | if (query.second != nullptr) |
| 511 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 512 | query.second->release(this); |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 513 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 514 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 515 | mQueryMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 516 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 517 | for (auto vertexArray : mVertexArrayMap) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 518 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 519 | if (vertexArray.second) |
| 520 | { |
| 521 | vertexArray.second->onDestroy(this); |
| 522 | } |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 523 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 524 | mVertexArrayMap.clear(); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 525 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 526 | for (auto transformFeedback : mTransformFeedbackMap) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 527 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 528 | if (transformFeedback.second != nullptr) |
| 529 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 530 | transformFeedback.second->release(this); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 531 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 532 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 533 | mTransformFeedbackMap.clear(); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 534 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 535 | for (BindingPointer<Texture> &zeroTexture : mZeroTextures) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 536 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 537 | if (zeroTexture.get() != nullptr) |
| 538 | { |
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 | |
Shahbaz Youssefi | 5313c8a | 2019-01-14 17:02:52 -0500 | [diff] [blame] | 3221 | // If EGL_KHR_fence_sync is not enabled, don't expose GL_OES_EGL_sync. |
| 3222 | ASSERT(mCurrentDisplay); |
| 3223 | if (!mCurrentDisplay->getExtensions().fenceSync) |
| 3224 | { |
| 3225 | supportedExtensions.eglSync = false; |
| 3226 | } |
| 3227 | |
Geoff Lang | 79b9140 | 2018-10-04 15:11:30 -0400 | [diff] [blame] | 3228 | supportedExtensions.memorySize = true; |
| 3229 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3230 | return supportedExtensions; |
| 3231 | } |
| 3232 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3233 | void Context::initCaps() |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3234 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3235 | mState.mCaps = mImplementation->getNativeCaps(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3236 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3237 | mSupportedExtensions = generateSupportedExtensions(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3238 | mState.mExtensions = mSupportedExtensions; |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 3239 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3240 | mState.mLimitations = mImplementation->getNativeLimitations(); |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 3241 | |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3242 | // GLES1 emulation: Initialize caps (Table 6.20 / 6.22 in the ES 1.1 spec) |
| 3243 | if (getClientVersion() < Version(2, 0)) |
| 3244 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3245 | mState.mCaps.maxMultitextureUnits = 4; |
| 3246 | mState.mCaps.maxClipPlanes = 6; |
| 3247 | mState.mCaps.maxLights = 8; |
| 3248 | mState.mCaps.maxModelviewMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3249 | mState.mCaps.maxProjectionMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3250 | mState.mCaps.maxTextureMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3251 | mState.mCaps.minSmoothPointSize = 1.0f; |
| 3252 | mState.mCaps.maxSmoothPointSize = 1.0f; |
| 3253 | mState.mCaps.minSmoothLineWidth = 1.0f; |
| 3254 | mState.mCaps.maxSmoothLineWidth = 1.0f; |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3255 | } |
| 3256 | |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3257 | // Apply/Verify implementation limits |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3258 | LimitCap(&mState.mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 3259 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3260 | ASSERT(mState.mCaps.minAliasedPointSize >= 1.0f); |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3261 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3262 | if (getClientVersion() < ES_3_1) |
| 3263 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3264 | mState.mCaps.maxVertexAttribBindings = mState.mCaps.maxVertexAttributes; |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3265 | } |
| 3266 | else |
| 3267 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3268 | LimitCap(&mState.mCaps.maxVertexAttribBindings, MAX_VERTEX_ATTRIB_BINDINGS); |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3269 | } |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 3270 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3271 | LimitCap(&mState.mCaps.maxShaderUniformBlocks[ShaderType::Vertex], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3272 | IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3273 | LimitCap(&mState.mCaps.maxUniformBufferBindings, IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 3274 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3275 | LimitCap(&mState.mCaps.maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
| 3276 | LimitCap(&mState.mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3277 | |
| 3278 | // 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] | 3279 | LimitCap(&mState.mCaps.maxCombinedTextureImageUnits, IMPLEMENTATION_MAX_ACTIVE_TEXTURES); |
| 3280 | LimitCap(&mState.mCaps.maxShaderTextureImageUnits[ShaderType::Vertex], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3281 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3282 | LimitCap(&mState.mCaps.maxShaderTextureImageUnits[ShaderType::Fragment], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3283 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 3284 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3285 | LimitCap(&mState.mCaps.maxImageUnits, IMPLEMENTATION_MAX_IMAGE_UNITS); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 3286 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3287 | mState.mCaps.maxSampleMaskWords = |
| 3288 | std::min<GLuint>(mState.mCaps.maxSampleMaskWords, MAX_SAMPLE_MASK_WORDS); |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 3289 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3290 | // WebGL compatibility |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3291 | mState.mExtensions.webglCompatibility = mWebGLContext; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3292 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 3293 | { |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 3294 | // If the user has requested that extensions start disabled and they are requestable, |
| 3295 | // disable them. |
| 3296 | if (!mExtensionsEnabled && extensionInfo.second.Requestable) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3297 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3298 | mState.mExtensions.*(extensionInfo.second.ExtensionsMember) = false; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3299 | } |
| 3300 | } |
| 3301 | |
| 3302 | // Generate texture caps |
| 3303 | updateCaps(); |
| 3304 | } |
| 3305 | |
| 3306 | void Context::updateCaps() |
| 3307 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3308 | mState.mCaps.compressedTextureFormats.clear(); |
| 3309 | mState.mTextureCaps.clear(); |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3310 | |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3311 | for (GLenum sizedInternalFormat : GetAllSizedInternalFormats()) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3312 | { |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3313 | TextureCaps formatCaps = mImplementation->getNativeTextureCaps().get(sizedInternalFormat); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3314 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3315 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 3316 | // Update the format caps based on the client version and extensions. |
| 3317 | // Caps are AND'd with the renderer caps because some core formats are still unsupported in |
| 3318 | // ES3. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3319 | formatCaps.texturable = formatCaps.texturable && |
| 3320 | formatInfo.textureSupport(getClientVersion(), mState.mExtensions); |
| 3321 | formatCaps.filterable = formatCaps.filterable && |
| 3322 | formatInfo.filterSupport(getClientVersion(), mState.mExtensions); |
Yuly Novikov | f15f886 | 2018-06-04 18:59:41 -0400 | [diff] [blame] | 3323 | formatCaps.textureAttachment = |
| 3324 | formatCaps.textureAttachment && |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3325 | formatInfo.textureAttachmentSupport(getClientVersion(), mState.mExtensions); |
| 3326 | formatCaps.renderbuffer = |
| 3327 | formatCaps.renderbuffer && |
| 3328 | formatInfo.renderbufferSupport(getClientVersion(), mState.mExtensions); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3329 | |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3330 | // OpenGL ES does not support multisampling with non-rendererable formats |
| 3331 | // 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] | 3332 | if (!formatCaps.renderbuffer || |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3333 | (getClientVersion() < ES_3_1 && !mSupportedExtensions.textureMultisample && |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3334 | (formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT))) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3335 | { |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3336 | formatCaps.sampleCounts.clear(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3337 | } |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3338 | else |
| 3339 | { |
| 3340 | // We may have limited the max samples for some required renderbuffer formats due to |
| 3341 | // non-conformant formats. In this case MAX_SAMPLES needs to be lowered accordingly. |
| 3342 | GLuint formatMaxSamples = formatCaps.getMaxSamples(); |
| 3343 | |
| 3344 | // GLES 3.0.5 section 4.4.2.2: "Implementations must support creation of renderbuffers |
| 3345 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with the |
| 3346 | // exception of signed and unsigned integer formats." |
| 3347 | if (formatInfo.componentType != GL_INT && formatInfo.componentType != GL_UNSIGNED_INT && |
| 3348 | formatInfo.isRequiredRenderbufferFormat(getClientVersion())) |
| 3349 | { |
| 3350 | ASSERT(getClientVersion() < ES_3_0 || formatMaxSamples >= 4); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3351 | mState.mCaps.maxSamples = std::min(mState.mCaps.maxSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3352 | } |
| 3353 | |
| 3354 | // Handle GLES 3.1 MAX_*_SAMPLES values similarly to MAX_SAMPLES. |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3355 | if (getClientVersion() >= ES_3_1 || mSupportedExtensions.textureMultisample) |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3356 | { |
| 3357 | // GLES 3.1 section 9.2.5: "Implementations must support creation of renderbuffers |
| 3358 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with |
| 3359 | // the exception that the signed and unsigned integer formats are required only to |
| 3360 | // support creation of renderbuffers with up to the value of MAX_INTEGER_SAMPLES |
| 3361 | // multisamples, which must be at least one." |
| 3362 | if (formatInfo.componentType == GL_INT || |
| 3363 | formatInfo.componentType == GL_UNSIGNED_INT) |
| 3364 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3365 | mState.mCaps.maxIntegerSamples = |
| 3366 | std::min(mState.mCaps.maxIntegerSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3367 | } |
| 3368 | |
| 3369 | // GLES 3.1 section 19.3.1. |
| 3370 | if (formatCaps.texturable) |
| 3371 | { |
| 3372 | if (formatInfo.depthBits > 0) |
| 3373 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3374 | mState.mCaps.maxDepthTextureSamples = |
| 3375 | std::min(mState.mCaps.maxDepthTextureSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3376 | } |
| 3377 | else if (formatInfo.redBits > 0) |
| 3378 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3379 | mState.mCaps.maxColorTextureSamples = |
| 3380 | std::min(mState.mCaps.maxColorTextureSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3381 | } |
| 3382 | } |
| 3383 | } |
| 3384 | } |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3385 | |
| 3386 | if (formatCaps.texturable && formatInfo.compressed) |
| 3387 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3388 | mState.mCaps.compressedTextureFormats.push_back(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3389 | } |
| 3390 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3391 | mState.mTextureCaps.insert(sizedInternalFormat, formatCaps); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3392 | } |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3393 | |
| 3394 | // If program binary is disabled, blank out the memory cache pointer. |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3395 | if (!mSupportedExtensions.getProgramBinary) |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3396 | { |
| 3397 | mMemoryProgramCache = nullptr; |
| 3398 | } |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3399 | |
| 3400 | // Compute which buffer types are allowed |
| 3401 | mValidBufferBindings.reset(); |
| 3402 | mValidBufferBindings.set(BufferBinding::ElementArray); |
| 3403 | mValidBufferBindings.set(BufferBinding::Array); |
| 3404 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3405 | if (mState.mExtensions.pixelBufferObject || getClientVersion() >= ES_3_0) |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3406 | { |
| 3407 | mValidBufferBindings.set(BufferBinding::PixelPack); |
| 3408 | mValidBufferBindings.set(BufferBinding::PixelUnpack); |
| 3409 | } |
| 3410 | |
| 3411 | if (getClientVersion() >= ES_3_0) |
| 3412 | { |
| 3413 | mValidBufferBindings.set(BufferBinding::CopyRead); |
| 3414 | mValidBufferBindings.set(BufferBinding::CopyWrite); |
| 3415 | mValidBufferBindings.set(BufferBinding::TransformFeedback); |
| 3416 | mValidBufferBindings.set(BufferBinding::Uniform); |
| 3417 | } |
| 3418 | |
| 3419 | if (getClientVersion() >= ES_3_1) |
| 3420 | { |
| 3421 | mValidBufferBindings.set(BufferBinding::AtomicCounter); |
| 3422 | mValidBufferBindings.set(BufferBinding::ShaderStorage); |
| 3423 | mValidBufferBindings.set(BufferBinding::DrawIndirect); |
| 3424 | mValidBufferBindings.set(BufferBinding::DispatchIndirect); |
| 3425 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 3426 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3427 | mThreadPool = angle::WorkerThreadPool::Create(mState.mExtensions.parallelShaderCompile); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3428 | |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3429 | // Reinitialize some dirty bits that depend on extensions. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3430 | bool robustInit = mState.isRobustResourceInitEnabled(); |
Jamie Madill | 132d15c | 2018-11-30 15:25:38 -0500 | [diff] [blame] | 3431 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, robustInit); |
| 3432 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES_INIT, robustInit); |
| 3433 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_IMAGES_INIT, robustInit); |
| 3434 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, robustInit); |
| 3435 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES_INIT, robustInit); |
| 3436 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_IMAGES_INIT, robustInit); |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3437 | |
Jamie Madill | d51fbe3 | 2019-01-25 15:03:39 -0500 | [diff] [blame^] | 3438 | // We need to validate buffer bounds if we are in a WebGL or robust access context and the |
| 3439 | // back-end does not support robust buffer access behaviour. |
| 3440 | if (!mSupportedExtensions.robustBufferAccessBehavior && (mState.isWebGL() || mRobustAccess)) |
| 3441 | { |
| 3442 | mBufferAccessValidationEnabled = true; |
| 3443 | } |
| 3444 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3445 | // Reinitialize state cache after extension changes. |
| 3446 | mStateCache.initialize(this); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3447 | } |
| 3448 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3449 | void Context::initWorkarounds() |
| 3450 | { |
Jamie Madill | 761b02c | 2017-06-23 16:27:06 -0400 | [diff] [blame] | 3451 | // Apply back-end workarounds. |
| 3452 | mImplementation->applyNativeWorkarounds(&mWorkarounds); |
| 3453 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3454 | // Lose the context upon out of memory error if the application is |
| 3455 | // expecting to watch for those events. |
| 3456 | mWorkarounds.loseContextOnOutOfMemory = (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
Jamie Madill | d4f0776 | 2018-10-19 19:24:07 -0400 | [diff] [blame] | 3457 | |
| 3458 | if (mWorkarounds.syncFramebufferBindingsOnTexImage) |
| 3459 | { |
| 3460 | // Update the Framebuffer bindings on TexImage to work around an Intel bug. |
| 3461 | mTexImageDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 3462 | mTexImageDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
| 3463 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3464 | } |
| 3465 | |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 3466 | bool Context::noopDrawInstanced(PrimitiveMode mode, GLsizei count, GLsizei instanceCount) |
| 3467 | { |
| 3468 | return (instanceCount == 0) || noopDraw(mode, count); |
| 3469 | } |
| 3470 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3471 | angle::Result Context::prepareForClear(GLbitfield mask) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3472 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3473 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3474 | ANGLE_TRY(mState.getDrawFramebuffer()->ensureClearAttachmentsInitialized(this, mask)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3475 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3476 | return angle::Result::Continue; |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3477 | } |
| 3478 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3479 | angle::Result Context::prepareForClearBuffer(GLenum buffer, GLint drawbuffer) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3480 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3481 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3482 | ANGLE_TRY(mState.getDrawFramebuffer()->ensureClearBufferAttachmentsInitialized(this, buffer, |
| 3483 | drawbuffer)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3484 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3485 | return angle::Result::Continue; |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3486 | } |
| 3487 | |
Jamie Madill | 132d15c | 2018-11-30 15:25:38 -0500 | [diff] [blame] | 3488 | ANGLE_INLINE angle::Result Context::prepareForDispatch() |
| 3489 | { |
| 3490 | ANGLE_TRY(syncDirtyObjects(mComputeDirtyObjects)); |
| 3491 | return syncDirtyBits(mComputeDirtyBits); |
| 3492 | } |
| 3493 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3494 | angle::Result Context::syncState(const State::DirtyBits &bitMask, |
| 3495 | const State::DirtyObjects &objectMask) |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 3496 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3497 | ANGLE_TRY(syncDirtyObjects(objectMask)); |
| 3498 | ANGLE_TRY(syncDirtyBits(bitMask)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3499 | return angle::Result::Continue; |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3500 | } |
| 3501 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3502 | void Context::blitFramebuffer(GLint srcX0, |
| 3503 | GLint srcY0, |
| 3504 | GLint srcX1, |
| 3505 | GLint srcY1, |
| 3506 | GLint dstX0, |
| 3507 | GLint dstY0, |
| 3508 | GLint dstX1, |
| 3509 | GLint dstY1, |
| 3510 | GLbitfield mask, |
| 3511 | GLenum filter) |
| 3512 | { |
Qin Jiajia | aef9216 | 2018-02-27 13:51:44 +0800 | [diff] [blame] | 3513 | if (mask == 0) |
| 3514 | { |
| 3515 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 3516 | // buffers are copied. |
| 3517 | return; |
| 3518 | } |
| 3519 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3520 | Framebuffer *drawFramebuffer = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3521 | ASSERT(drawFramebuffer); |
| 3522 | |
| 3523 | Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0); |
| 3524 | Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0); |
| 3525 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3526 | ANGLE_CONTEXT_TRY(syncStateForBlit()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3527 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3528 | ANGLE_CONTEXT_TRY(drawFramebuffer->blit(this, srcArea, dstArea, mask, filter)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3529 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3530 | |
| 3531 | void Context::clear(GLbitfield mask) |
| 3532 | { |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3533 | ANGLE_CONTEXT_TRY(prepareForClear(mask)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3534 | ANGLE_CONTEXT_TRY(mState.getDrawFramebuffer()->clear(this, mask)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3535 | } |
| 3536 | |
| 3537 | void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values) |
| 3538 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3539 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3540 | const FramebufferAttachment *attachment = nullptr; |
| 3541 | if (buffer == GL_DEPTH) |
| 3542 | { |
| 3543 | attachment = framebufferObject->getDepthbuffer(); |
| 3544 | } |
| 3545 | if (buffer == GL_COLOR && |
| 3546 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3547 | { |
| 3548 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3549 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3550 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3551 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3552 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3553 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3554 | return; |
| 3555 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3556 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3557 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3558 | } |
| 3559 | |
| 3560 | void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values) |
| 3561 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3562 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3563 | const FramebufferAttachment *attachment = nullptr; |
| 3564 | if (buffer == GL_COLOR && |
| 3565 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3566 | { |
| 3567 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3568 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3569 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3570 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3571 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3572 | { |
| 3573 | return; |
| 3574 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3575 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3576 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferuiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3577 | } |
| 3578 | |
| 3579 | void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values) |
| 3580 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3581 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3582 | const FramebufferAttachment *attachment = nullptr; |
| 3583 | if (buffer == GL_STENCIL) |
| 3584 | { |
| 3585 | attachment = framebufferObject->getStencilbuffer(); |
| 3586 | } |
| 3587 | if (buffer == GL_COLOR && |
| 3588 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3589 | { |
| 3590 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3591 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3592 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3593 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3594 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3595 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3596 | return; |
| 3597 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3598 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3599 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3600 | } |
| 3601 | |
| 3602 | void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 3603 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3604 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3605 | ASSERT(framebufferObject); |
| 3606 | |
| 3607 | // If a buffer is not present, the clear has no effect |
| 3608 | if (framebufferObject->getDepthbuffer() == nullptr && |
| 3609 | framebufferObject->getStencilbuffer() == nullptr) |
| 3610 | { |
| 3611 | return; |
| 3612 | } |
| 3613 | |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3614 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
| 3615 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfi(this, buffer, drawbuffer, depth, stencil)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3616 | } |
| 3617 | |
| 3618 | void Context::readPixels(GLint x, |
| 3619 | GLint y, |
| 3620 | GLsizei width, |
| 3621 | GLsizei height, |
| 3622 | GLenum format, |
| 3623 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3624 | void *pixels) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3625 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3626 | if (width == 0 || height == 0) |
| 3627 | { |
| 3628 | return; |
| 3629 | } |
| 3630 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3631 | ANGLE_CONTEXT_TRY(syncStateForReadPixels()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3632 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3633 | Framebuffer *readFBO = mState.getReadFramebuffer(); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 3634 | ASSERT(readFBO); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3635 | |
| 3636 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3637 | ANGLE_CONTEXT_TRY(readFBO->readPixels(this, area, format, type, pixels)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3638 | } |
| 3639 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3640 | void Context::readPixelsRobust(GLint x, |
| 3641 | GLint y, |
| 3642 | GLsizei width, |
| 3643 | GLsizei height, |
| 3644 | GLenum format, |
| 3645 | GLenum type, |
| 3646 | GLsizei bufSize, |
| 3647 | GLsizei *length, |
| 3648 | GLsizei *columns, |
| 3649 | GLsizei *rows, |
| 3650 | void *pixels) |
| 3651 | { |
| 3652 | readPixels(x, y, width, height, format, type, pixels); |
| 3653 | } |
| 3654 | |
| 3655 | void Context::readnPixelsRobust(GLint x, |
| 3656 | GLint y, |
| 3657 | GLsizei width, |
| 3658 | GLsizei height, |
| 3659 | GLenum format, |
| 3660 | GLenum type, |
| 3661 | GLsizei bufSize, |
| 3662 | GLsizei *length, |
| 3663 | GLsizei *columns, |
| 3664 | GLsizei *rows, |
| 3665 | void *data) |
| 3666 | { |
| 3667 | readPixels(x, y, width, height, format, type, data); |
| 3668 | } |
| 3669 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3670 | void Context::copyTexImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3671 | GLint level, |
| 3672 | GLenum internalformat, |
| 3673 | GLint x, |
| 3674 | GLint y, |
| 3675 | GLsizei width, |
| 3676 | GLsizei height, |
| 3677 | GLint border) |
| 3678 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3679 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3680 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3681 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3682 | Rectangle sourceArea(x, y, width, height); |
| 3683 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3684 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3685 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3686 | ANGLE_CONTEXT_TRY( |
| 3687 | texture->copyImage(this, target, level, sourceArea, internalformat, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3688 | } |
| 3689 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3690 | void Context::copyTexSubImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3691 | GLint level, |
| 3692 | GLint xoffset, |
| 3693 | GLint yoffset, |
| 3694 | GLint x, |
| 3695 | GLint y, |
| 3696 | GLsizei width, |
| 3697 | GLsizei height) |
| 3698 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3699 | if (width == 0 || height == 0) |
| 3700 | { |
| 3701 | return; |
| 3702 | } |
| 3703 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3704 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3705 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3706 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3707 | Offset destOffset(xoffset, yoffset, 0); |
| 3708 | Rectangle sourceArea(x, y, width, height); |
| 3709 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3710 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3711 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3712 | ANGLE_CONTEXT_TRY( |
| 3713 | texture->copySubImage(this, target, level, destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3714 | } |
| 3715 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3716 | void Context::copyTexSubImage3D(TextureType target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3717 | GLint level, |
| 3718 | GLint xoffset, |
| 3719 | GLint yoffset, |
| 3720 | GLint zoffset, |
| 3721 | GLint x, |
| 3722 | GLint y, |
| 3723 | GLsizei width, |
| 3724 | GLsizei height) |
| 3725 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3726 | if (width == 0 || height == 0) |
| 3727 | { |
| 3728 | return; |
| 3729 | } |
| 3730 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3731 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3732 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3733 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3734 | Offset destOffset(xoffset, yoffset, zoffset); |
| 3735 | Rectangle sourceArea(x, y, width, height); |
| 3736 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3737 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3738 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3739 | ANGLE_CONTEXT_TRY(texture->copySubImage(this, NonCubeTextureTypeToTarget(target), level, |
| 3740 | destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3741 | } |
| 3742 | |
| 3743 | void Context::framebufferTexture2D(GLenum target, |
| 3744 | GLenum attachment, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3745 | TextureTarget textarget, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3746 | GLuint texture, |
| 3747 | GLint level) |
| 3748 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3749 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3750 | ASSERT(framebuffer); |
| 3751 | |
| 3752 | if (texture != 0) |
| 3753 | { |
| 3754 | Texture *textureObj = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3755 | ImageIndex index = ImageIndex::MakeFromTarget(textarget, level); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3756 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3757 | } |
| 3758 | else |
| 3759 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3760 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3761 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3762 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3763 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3764 | } |
| 3765 | |
| 3766 | void Context::framebufferRenderbuffer(GLenum target, |
| 3767 | GLenum attachment, |
| 3768 | GLenum renderbuffertarget, |
| 3769 | GLuint renderbuffer) |
| 3770 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3771 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3772 | ASSERT(framebuffer); |
| 3773 | |
| 3774 | if (renderbuffer != 0) |
| 3775 | { |
| 3776 | Renderbuffer *renderbufferObject = getRenderbuffer(renderbuffer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3777 | |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3778 | framebuffer->setAttachment(this, GL_RENDERBUFFER, attachment, gl::ImageIndex(), |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3779 | renderbufferObject); |
| 3780 | } |
| 3781 | else |
| 3782 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3783 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3784 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3785 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3786 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3787 | } |
| 3788 | |
| 3789 | void Context::framebufferTextureLayer(GLenum target, |
| 3790 | GLenum attachment, |
| 3791 | GLuint texture, |
| 3792 | GLint level, |
| 3793 | GLint layer) |
| 3794 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3795 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3796 | ASSERT(framebuffer); |
| 3797 | |
| 3798 | if (texture != 0) |
| 3799 | { |
| 3800 | Texture *textureObject = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3801 | ImageIndex index = ImageIndex::MakeFromType(textureObject->getType(), level, layer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3802 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObject); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3803 | } |
| 3804 | else |
| 3805 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3806 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3807 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3808 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3809 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3810 | } |
| 3811 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3812 | void Context::framebufferTextureMultiviewLayered(GLenum target, |
| 3813 | GLenum attachment, |
| 3814 | GLuint texture, |
| 3815 | GLint level, |
| 3816 | GLint baseViewIndex, |
| 3817 | GLsizei numViews) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3818 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3819 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3820 | ASSERT(framebuffer); |
| 3821 | |
| 3822 | if (texture != 0) |
| 3823 | { |
| 3824 | Texture *textureObj = getTexture(texture); |
| 3825 | |
Olli Etuaho | 2c8f084 | 2018-09-12 14:44:55 +0300 | [diff] [blame] | 3826 | ImageIndex index; |
| 3827 | if (textureObj->getType() == TextureType::_2DArray) |
| 3828 | { |
| 3829 | index = ImageIndex::Make2DArrayRange(level, baseViewIndex, numViews); |
| 3830 | } |
| 3831 | else |
| 3832 | { |
| 3833 | ASSERT(textureObj->getType() == TextureType::_2DMultisampleArray); |
| 3834 | ASSERT(level == 0); |
| 3835 | index = ImageIndex::Make2DMultisampleArrayRange(baseViewIndex, numViews); |
| 3836 | } |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3837 | framebuffer->setAttachmentMultiviewLayered(this, GL_TEXTURE, attachment, index, textureObj, |
| 3838 | numViews, baseViewIndex); |
| 3839 | } |
| 3840 | else |
| 3841 | { |
| 3842 | framebuffer->resetAttachment(this, attachment); |
| 3843 | } |
| 3844 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3845 | mState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3846 | } |
| 3847 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3848 | void Context::framebufferTextureMultiviewSideBySide(GLenum target, |
| 3849 | GLenum attachment, |
| 3850 | GLuint texture, |
| 3851 | GLint level, |
| 3852 | GLsizei numViews, |
| 3853 | const GLint *viewportOffsets) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3854 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3855 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 3856 | ASSERT(framebuffer); |
| 3857 | |
| 3858 | if (texture != 0) |
| 3859 | { |
| 3860 | Texture *textureObj = getTexture(texture); |
| 3861 | |
| 3862 | ImageIndex index = ImageIndex::Make2D(level); |
| 3863 | framebuffer->setAttachmentMultiviewSideBySide(this, GL_TEXTURE, attachment, index, |
| 3864 | textureObj, numViews, viewportOffsets); |
| 3865 | } |
| 3866 | else |
| 3867 | { |
| 3868 | framebuffer->resetAttachment(this, attachment); |
| 3869 | } |
| 3870 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3871 | mState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3872 | } |
| 3873 | |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3874 | void Context::framebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level) |
| 3875 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3876 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jiawei Shao | a880247 | 2018-05-28 11:17:47 +0800 | [diff] [blame] | 3877 | ASSERT(framebuffer); |
| 3878 | |
| 3879 | if (texture != 0) |
| 3880 | { |
| 3881 | Texture *textureObj = getTexture(texture); |
| 3882 | |
| 3883 | ImageIndex index = ImageIndex::MakeFromType( |
| 3884 | textureObj->getType(), level, ImageIndex::kEntireLevel, ImageIndex::kEntireLevel); |
| 3885 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
| 3886 | } |
| 3887 | else |
| 3888 | { |
| 3889 | framebuffer->resetAttachment(this, attachment); |
| 3890 | } |
| 3891 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3892 | mState.setObjectDirty(target); |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3893 | } |
| 3894 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3895 | void Context::drawBuffers(GLsizei n, const GLenum *bufs) |
| 3896 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3897 | Framebuffer *framebuffer = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3898 | ASSERT(framebuffer); |
| 3899 | framebuffer->setDrawBuffers(n, bufs); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3900 | mState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 3901 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3902 | } |
| 3903 | |
| 3904 | void Context::readBuffer(GLenum mode) |
| 3905 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3906 | Framebuffer *readFBO = mState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3907 | readFBO->setReadBuffer(mode); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3908 | mState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3909 | } |
| 3910 | |
| 3911 | void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) |
| 3912 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3913 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3914 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3915 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3916 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3917 | ASSERT(framebuffer); |
| 3918 | |
| 3919 | // The specification isn't clear what should be done when the framebuffer isn't complete. |
| 3920 | // 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] | 3921 | ANGLE_CONTEXT_TRY(framebuffer->discard(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3922 | } |
| 3923 | |
| 3924 | void Context::invalidateFramebuffer(GLenum target, |
| 3925 | GLsizei numAttachments, |
| 3926 | const GLenum *attachments) |
| 3927 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3928 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3929 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3930 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3931 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3932 | ASSERT(framebuffer); |
| 3933 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 3934 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3935 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3936 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3937 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3938 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3939 | ANGLE_CONTEXT_TRY(framebuffer->invalidate(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3940 | } |
| 3941 | |
| 3942 | void Context::invalidateSubFramebuffer(GLenum target, |
| 3943 | GLsizei numAttachments, |
| 3944 | const GLenum *attachments, |
| 3945 | GLint x, |
| 3946 | GLint y, |
| 3947 | GLsizei width, |
| 3948 | GLsizei height) |
| 3949 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3950 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3951 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3952 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3953 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3954 | ASSERT(framebuffer); |
| 3955 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 3956 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3957 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3958 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3959 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3960 | |
| 3961 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3962 | ANGLE_CONTEXT_TRY(framebuffer->invalidateSub(this, numAttachments, attachments, area)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3963 | } |
| 3964 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3965 | void Context::texImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3966 | GLint level, |
| 3967 | GLint internalformat, |
| 3968 | GLsizei width, |
| 3969 | GLsizei height, |
| 3970 | GLint border, |
| 3971 | GLenum format, |
| 3972 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3973 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3974 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3975 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3976 | |
| 3977 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3978 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3979 | ANGLE_CONTEXT_TRY(texture->setImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3980 | internalformat, size, format, type, |
| 3981 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3982 | } |
| 3983 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3984 | void Context::texImage2DRobust(TextureTarget target, |
| 3985 | GLint level, |
| 3986 | GLint internalformat, |
| 3987 | GLsizei width, |
| 3988 | GLsizei height, |
| 3989 | GLint border, |
| 3990 | GLenum format, |
| 3991 | GLenum type, |
| 3992 | GLsizei bufSize, |
| 3993 | const void *pixels) |
| 3994 | { |
| 3995 | texImage2D(target, level, internalformat, width, height, border, format, type, pixels); |
| 3996 | } |
| 3997 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3998 | void Context::texImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3999 | GLint level, |
| 4000 | GLint internalformat, |
| 4001 | GLsizei width, |
| 4002 | GLsizei height, |
| 4003 | GLsizei depth, |
| 4004 | GLint border, |
| 4005 | GLenum format, |
| 4006 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4007 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4008 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4009 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4010 | |
| 4011 | Extents size(width, height, depth); |
| 4012 | Texture *texture = getTargetTexture(target); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4013 | ANGLE_CONTEXT_TRY(texture->setImage(this, mState.getUnpackState(), |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4014 | NonCubeTextureTypeToTarget(target), level, internalformat, |
| 4015 | size, format, type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4016 | } |
| 4017 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4018 | void Context::texImage3DRobust(TextureType target, |
| 4019 | GLint level, |
| 4020 | GLint internalformat, |
| 4021 | GLsizei width, |
| 4022 | GLsizei height, |
| 4023 | GLsizei depth, |
| 4024 | GLint border, |
| 4025 | GLenum format, |
| 4026 | GLenum type, |
| 4027 | GLsizei bufSize, |
| 4028 | const void *pixels) |
| 4029 | { |
| 4030 | texImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 4031 | } |
| 4032 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4033 | void Context::texSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4034 | GLint level, |
| 4035 | GLint xoffset, |
| 4036 | GLint yoffset, |
| 4037 | GLsizei width, |
| 4038 | GLsizei height, |
| 4039 | GLenum format, |
| 4040 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4041 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4042 | { |
| 4043 | // Zero sized uploads are valid but no-ops |
| 4044 | if (width == 0 || height == 0) |
| 4045 | { |
| 4046 | return; |
| 4047 | } |
| 4048 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4049 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4050 | |
| 4051 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4052 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4053 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4054 | gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4055 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4056 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mState.getUnpackState(), unpackBuffer, target, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4057 | level, area, format, type, |
| 4058 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4059 | } |
| 4060 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4061 | void Context::texSubImage2DRobust(TextureTarget target, |
| 4062 | GLint level, |
| 4063 | GLint xoffset, |
| 4064 | GLint yoffset, |
| 4065 | GLsizei width, |
| 4066 | GLsizei height, |
| 4067 | GLenum format, |
| 4068 | GLenum type, |
| 4069 | GLsizei bufSize, |
| 4070 | const void *pixels) |
| 4071 | { |
| 4072 | texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 4073 | } |
| 4074 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4075 | void Context::texSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4076 | GLint level, |
| 4077 | GLint xoffset, |
| 4078 | GLint yoffset, |
| 4079 | GLint zoffset, |
| 4080 | GLsizei width, |
| 4081 | GLsizei height, |
| 4082 | GLsizei depth, |
| 4083 | GLenum format, |
| 4084 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4085 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4086 | { |
| 4087 | // Zero sized uploads are valid but no-ops |
| 4088 | if (width == 0 || height == 0 || depth == 0) |
| 4089 | { |
| 4090 | return; |
| 4091 | } |
| 4092 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4093 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4094 | |
| 4095 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4096 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4097 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4098 | gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4099 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4100 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mState.getUnpackState(), unpackBuffer, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4101 | NonCubeTextureTypeToTarget(target), level, area, format, |
| 4102 | type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4103 | } |
| 4104 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4105 | void Context::texSubImage3DRobust(TextureType target, |
| 4106 | GLint level, |
| 4107 | GLint xoffset, |
| 4108 | GLint yoffset, |
| 4109 | GLint zoffset, |
| 4110 | GLsizei width, |
| 4111 | GLsizei height, |
| 4112 | GLsizei depth, |
| 4113 | GLenum format, |
| 4114 | GLenum type, |
| 4115 | GLsizei bufSize, |
| 4116 | const void *pixels) |
| 4117 | { |
| 4118 | texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, |
| 4119 | pixels); |
| 4120 | } |
| 4121 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4122 | void Context::compressedTexImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4123 | GLint level, |
| 4124 | GLenum internalformat, |
| 4125 | GLsizei width, |
| 4126 | GLsizei height, |
| 4127 | GLint border, |
| 4128 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4129 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4130 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4131 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4132 | |
| 4133 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4134 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4135 | ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4136 | internalformat, size, imageSize, |
| 4137 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4138 | } |
| 4139 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4140 | void Context::compressedTexImage2DRobust(TextureTarget target, |
| 4141 | GLint level, |
| 4142 | GLenum internalformat, |
| 4143 | GLsizei width, |
| 4144 | GLsizei height, |
| 4145 | GLint border, |
| 4146 | GLsizei imageSize, |
| 4147 | GLsizei dataSize, |
| 4148 | const GLvoid *data) |
| 4149 | { |
| 4150 | compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); |
| 4151 | } |
| 4152 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4153 | void Context::compressedTexImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4154 | GLint level, |
| 4155 | GLenum internalformat, |
| 4156 | GLsizei width, |
| 4157 | GLsizei height, |
| 4158 | GLsizei depth, |
| 4159 | GLint border, |
| 4160 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4161 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4162 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4163 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4164 | |
| 4165 | Extents size(width, height, depth); |
| 4166 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4167 | ANGLE_CONTEXT_TRY(texture->setCompressedImage( |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4168 | this, mState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, internalformat, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4169 | size, imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4170 | } |
| 4171 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4172 | void Context::compressedTexImage3DRobust(TextureType target, |
| 4173 | GLint level, |
| 4174 | GLenum internalformat, |
| 4175 | GLsizei width, |
| 4176 | GLsizei height, |
| 4177 | GLsizei depth, |
| 4178 | GLint border, |
| 4179 | GLsizei imageSize, |
| 4180 | GLsizei dataSize, |
| 4181 | const GLvoid *data) |
| 4182 | { |
| 4183 | compressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, |
| 4184 | data); |
| 4185 | } |
| 4186 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4187 | void Context::compressedTexSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4188 | GLint level, |
| 4189 | GLint xoffset, |
| 4190 | GLint yoffset, |
| 4191 | GLsizei width, |
| 4192 | GLsizei height, |
| 4193 | GLenum format, |
| 4194 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4195 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4196 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4197 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4198 | |
| 4199 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4200 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4201 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4202 | area, format, imageSize, |
| 4203 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4204 | } |
| 4205 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4206 | void Context::compressedTexSubImage2DRobust(TextureTarget target, |
| 4207 | GLint level, |
| 4208 | GLint xoffset, |
| 4209 | GLint yoffset, |
| 4210 | GLsizei width, |
| 4211 | GLsizei height, |
| 4212 | GLenum format, |
| 4213 | GLsizei imageSize, |
| 4214 | GLsizei dataSize, |
| 4215 | const GLvoid *data) |
| 4216 | { |
| 4217 | compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, |
| 4218 | data); |
| 4219 | } |
| 4220 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4221 | void Context::compressedTexSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4222 | GLint level, |
| 4223 | GLint xoffset, |
| 4224 | GLint yoffset, |
| 4225 | GLint zoffset, |
| 4226 | GLsizei width, |
| 4227 | GLsizei height, |
| 4228 | GLsizei depth, |
| 4229 | GLenum format, |
| 4230 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4231 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4232 | { |
| 4233 | // Zero sized uploads are valid but no-ops |
| 4234 | if (width == 0 || height == 0) |
| 4235 | { |
| 4236 | return; |
| 4237 | } |
| 4238 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4239 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4240 | |
| 4241 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4242 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4243 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage( |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4244 | this, mState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, area, format, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4245 | imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4246 | } |
| 4247 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4248 | void Context::compressedTexSubImage3DRobust(TextureType target, |
| 4249 | GLint level, |
| 4250 | GLint xoffset, |
| 4251 | GLint yoffset, |
| 4252 | GLint zoffset, |
| 4253 | GLsizei width, |
| 4254 | GLsizei height, |
| 4255 | GLsizei depth, |
| 4256 | GLenum format, |
| 4257 | GLsizei imageSize, |
| 4258 | GLsizei dataSize, |
| 4259 | const GLvoid *data) |
| 4260 | { |
| 4261 | compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, |
| 4262 | imageSize, data); |
| 4263 | } |
| 4264 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4265 | void Context::generateMipmap(TextureType target) |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4266 | { |
| 4267 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4268 | ANGLE_CONTEXT_TRY(texture->generateMipmap(this)); |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4269 | } |
| 4270 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4271 | void Context::copyTexture(GLuint sourceId, |
| 4272 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4273 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4274 | GLuint destId, |
| 4275 | GLint destLevel, |
| 4276 | GLint internalFormat, |
| 4277 | GLenum destType, |
| 4278 | GLboolean unpackFlipY, |
| 4279 | GLboolean unpackPremultiplyAlpha, |
| 4280 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4281 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4282 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4283 | |
| 4284 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4285 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4286 | ANGLE_CONTEXT_TRY( |
| 4287 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4288 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4289 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4290 | } |
| 4291 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4292 | void Context::copySubTexture(GLuint sourceId, |
| 4293 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4294 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4295 | GLuint destId, |
| 4296 | GLint destLevel, |
| 4297 | GLint xoffset, |
| 4298 | GLint yoffset, |
| 4299 | GLint x, |
| 4300 | GLint y, |
| 4301 | GLsizei width, |
| 4302 | GLsizei height, |
| 4303 | GLboolean unpackFlipY, |
| 4304 | GLboolean unpackPremultiplyAlpha, |
| 4305 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4306 | { |
| 4307 | // Zero sized copies are valid but no-ops |
| 4308 | if (width == 0 || height == 0) |
| 4309 | { |
| 4310 | return; |
| 4311 | } |
| 4312 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4313 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4314 | |
| 4315 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4316 | gl::Texture *destTexture = getTexture(destId); |
| 4317 | Offset offset(xoffset, yoffset, 0); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4318 | Box box(x, y, 0, width, height, 1); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4319 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4320 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4321 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4322 | sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4323 | } |
| 4324 | |
| 4325 | void Context::copyTexture3D(GLuint sourceId, |
| 4326 | GLint sourceLevel, |
| 4327 | TextureTarget destTarget, |
| 4328 | GLuint destId, |
| 4329 | GLint destLevel, |
| 4330 | GLint internalFormat, |
| 4331 | GLenum destType, |
| 4332 | GLboolean unpackFlipY, |
| 4333 | GLboolean unpackPremultiplyAlpha, |
| 4334 | GLboolean unpackUnmultiplyAlpha) |
| 4335 | { |
| 4336 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4337 | |
| 4338 | Texture *sourceTexture = getTexture(sourceId); |
| 4339 | Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4340 | ANGLE_CONTEXT_TRY( |
| 4341 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4342 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4343 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4344 | } |
| 4345 | |
| 4346 | void Context::copySubTexture3D(GLuint sourceId, |
| 4347 | GLint sourceLevel, |
| 4348 | TextureTarget destTarget, |
| 4349 | GLuint destId, |
| 4350 | GLint destLevel, |
| 4351 | GLint xoffset, |
| 4352 | GLint yoffset, |
| 4353 | GLint zoffset, |
| 4354 | GLint x, |
| 4355 | GLint y, |
| 4356 | GLint z, |
| 4357 | GLsizei width, |
| 4358 | GLsizei height, |
| 4359 | GLsizei depth, |
| 4360 | GLboolean unpackFlipY, |
| 4361 | GLboolean unpackPremultiplyAlpha, |
| 4362 | GLboolean unpackUnmultiplyAlpha) |
| 4363 | { |
| 4364 | // Zero sized copies are valid but no-ops |
| 4365 | if (width == 0 || height == 0 || depth == 0) |
| 4366 | { |
| 4367 | return; |
| 4368 | } |
| 4369 | |
| 4370 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4371 | |
| 4372 | Texture *sourceTexture = getTexture(sourceId); |
| 4373 | Texture *destTexture = getTexture(destId); |
| 4374 | Offset offset(xoffset, yoffset, zoffset); |
| 4375 | Box box(x, y, z, width, height, depth); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4376 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4377 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4378 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4379 | sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4380 | } |
| 4381 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4382 | void Context::compressedCopyTexture(GLuint sourceId, GLuint destId) |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4383 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4384 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4385 | |
| 4386 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4387 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4388 | ANGLE_CONTEXT_TRY(destTexture->copyCompressedTexture(this, sourceTexture)); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4389 | } |
| 4390 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4391 | void Context::getBufferPointerv(BufferBinding target, GLenum pname, void **params) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4392 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4393 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4394 | ASSERT(buffer); |
| 4395 | |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 4396 | QueryBufferPointerv(buffer, pname, params); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4397 | } |
| 4398 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4399 | void Context::getBufferPointervRobust(BufferBinding target, |
| 4400 | GLenum pname, |
| 4401 | GLsizei bufSize, |
| 4402 | GLsizei *length, |
| 4403 | void **params) |
| 4404 | { |
| 4405 | getBufferPointerv(target, pname, params); |
| 4406 | } |
| 4407 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4408 | void *Context::mapBuffer(BufferBinding target, GLenum access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4409 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4410 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4411 | ASSERT(buffer); |
| 4412 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4413 | if (buffer->map(this, access) == 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 nullptr; |
| 4416 | } |
| 4417 | |
| 4418 | return buffer->getMapPointer(); |
| 4419 | } |
| 4420 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4421 | GLboolean Context::unmapBuffer(BufferBinding target) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4422 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4423 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4424 | ASSERT(buffer); |
| 4425 | |
| 4426 | GLboolean result; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4427 | if (buffer->unmap(this, &result) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4428 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4429 | return GL_FALSE; |
| 4430 | } |
| 4431 | |
| 4432 | return result; |
| 4433 | } |
| 4434 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4435 | void *Context::mapBufferRange(BufferBinding target, |
| 4436 | GLintptr offset, |
| 4437 | GLsizeiptr length, |
| 4438 | GLbitfield access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4439 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4440 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4441 | ASSERT(buffer); |
| 4442 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4443 | if (buffer->mapRange(this, offset, length, access) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4444 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4445 | return nullptr; |
| 4446 | } |
| 4447 | |
| 4448 | return buffer->getMapPointer(); |
| 4449 | } |
| 4450 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4451 | void Context::flushMappedBufferRange(BufferBinding /*target*/, |
| 4452 | GLintptr /*offset*/, |
| 4453 | GLsizeiptr /*length*/) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4454 | { |
| 4455 | // We do not currently support a non-trivial implementation of FlushMappedBufferRange |
| 4456 | } |
| 4457 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4458 | angle::Result Context::syncStateForReadPixels() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4459 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4460 | return syncState(mReadPixelsDirtyBits, mReadPixelsDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4461 | } |
| 4462 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4463 | angle::Result Context::syncStateForTexImage() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4464 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4465 | return syncState(mTexImageDirtyBits, mTexImageDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4466 | } |
| 4467 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4468 | angle::Result Context::syncStateForBlit() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4469 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4470 | return syncState(mBlitDirtyBits, mBlitDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4471 | } |
| 4472 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4473 | angle::Result Context::syncStateForPathOperation() |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4474 | { |
| 4475 | ANGLE_TRY(syncDirtyObjects(mPathOperationDirtyObjects)); |
| 4476 | |
| 4477 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 4478 | ANGLE_TRY(syncDirtyBits()); |
| 4479 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4480 | return angle::Result::Continue; |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4481 | } |
| 4482 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4483 | void Context::activeShaderProgram(GLuint pipeline, GLuint program) |
| 4484 | { |
| 4485 | UNIMPLEMENTED(); |
| 4486 | } |
| 4487 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4488 | void Context::activeTexture(GLenum texture) |
| 4489 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4490 | mState.setActiveSampler(texture - GL_TEXTURE0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4491 | } |
| 4492 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4493 | void Context::blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4494 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4495 | mState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4496 | } |
| 4497 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4498 | void Context::blendEquation(GLenum mode) |
| 4499 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4500 | mState.setBlendEquation(mode, mode); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4501 | } |
| 4502 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4503 | void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 4504 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4505 | mState.setBlendEquation(modeRGB, modeAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4506 | } |
| 4507 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4508 | void Context::blendFunc(GLenum sfactor, GLenum dfactor) |
| 4509 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4510 | mState.setBlendFactors(sfactor, dfactor, sfactor, dfactor); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4511 | } |
| 4512 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4513 | void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 4514 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4515 | mState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4516 | } |
| 4517 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4518 | void Context::clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4519 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4520 | mState.setColorClearValue(red, green, blue, alpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4521 | } |
| 4522 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4523 | void Context::clearDepthf(GLfloat depth) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4524 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4525 | mState.setDepthClearValue(clamp01(depth)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4526 | } |
| 4527 | |
| 4528 | void Context::clearStencil(GLint s) |
| 4529 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4530 | mState.setStencilClearValue(s); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4531 | } |
| 4532 | |
| 4533 | void Context::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 4534 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4535 | mState.setColorMask(ConvertToBool(red), ConvertToBool(green), ConvertToBool(blue), |
| 4536 | ConvertToBool(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4537 | } |
| 4538 | |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 4539 | void Context::cullFace(CullFaceMode mode) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4540 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4541 | mState.setCullMode(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4542 | } |
| 4543 | |
| 4544 | void Context::depthFunc(GLenum func) |
| 4545 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4546 | mState.setDepthFunc(func); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4547 | } |
| 4548 | |
| 4549 | void Context::depthMask(GLboolean flag) |
| 4550 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4551 | mState.setDepthMask(ConvertToBool(flag)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4552 | } |
| 4553 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4554 | void Context::depthRangef(GLfloat zNear, GLfloat zFar) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4555 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4556 | mState.setDepthRange(clamp01(zNear), clamp01(zFar)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4557 | } |
| 4558 | |
| 4559 | void Context::disable(GLenum cap) |
| 4560 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4561 | mState.setEnableFeature(cap, false); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4562 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4563 | } |
| 4564 | |
| 4565 | void Context::disableVertexAttribArray(GLuint index) |
| 4566 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4567 | mState.setEnableVertexAttribArray(index, false); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4568 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4569 | } |
| 4570 | |
| 4571 | void Context::enable(GLenum cap) |
| 4572 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4573 | mState.setEnableFeature(cap, true); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4574 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4575 | } |
| 4576 | |
| 4577 | void Context::enableVertexAttribArray(GLuint index) |
| 4578 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4579 | mState.setEnableVertexAttribArray(index, true); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4580 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4581 | } |
| 4582 | |
| 4583 | void Context::frontFace(GLenum mode) |
| 4584 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4585 | mState.setFrontFace(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4586 | } |
| 4587 | |
| 4588 | void Context::hint(GLenum target, GLenum mode) |
| 4589 | { |
| 4590 | switch (target) |
| 4591 | { |
| 4592 | case GL_GENERATE_MIPMAP_HINT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4593 | mState.setGenerateMipmapHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4594 | break; |
| 4595 | |
| 4596 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4597 | mState.setFragmentShaderDerivativeHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4598 | break; |
| 4599 | |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 4600 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 4601 | case GL_POINT_SMOOTH_HINT: |
| 4602 | case GL_LINE_SMOOTH_HINT: |
| 4603 | case GL_FOG_HINT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4604 | mState.gles1().setHint(target, mode); |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 4605 | break; |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4606 | default: |
| 4607 | UNREACHABLE(); |
| 4608 | return; |
| 4609 | } |
| 4610 | } |
| 4611 | |
| 4612 | void Context::lineWidth(GLfloat width) |
| 4613 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4614 | mState.setLineWidth(width); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4615 | } |
| 4616 | |
| 4617 | void Context::pixelStorei(GLenum pname, GLint param) |
| 4618 | { |
| 4619 | switch (pname) |
| 4620 | { |
| 4621 | case GL_UNPACK_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4622 | mState.setUnpackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4623 | break; |
| 4624 | |
| 4625 | case GL_PACK_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4626 | mState.setPackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4627 | break; |
| 4628 | |
| 4629 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4630 | mState.setPackReverseRowOrder(param != 0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4631 | break; |
| 4632 | |
| 4633 | case GL_UNPACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4634 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4635 | mState.setUnpackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4636 | break; |
| 4637 | |
| 4638 | case GL_UNPACK_IMAGE_HEIGHT: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4639 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4640 | mState.setUnpackImageHeight(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4641 | break; |
| 4642 | |
| 4643 | case GL_UNPACK_SKIP_IMAGES: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4644 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4645 | mState.setUnpackSkipImages(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4646 | break; |
| 4647 | |
| 4648 | case GL_UNPACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4649 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4650 | mState.setUnpackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4651 | break; |
| 4652 | |
| 4653 | case GL_UNPACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4654 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4655 | mState.setUnpackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4656 | break; |
| 4657 | |
| 4658 | case GL_PACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4659 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4660 | mState.setPackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4661 | break; |
| 4662 | |
| 4663 | case GL_PACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4664 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4665 | mState.setPackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4666 | break; |
| 4667 | |
| 4668 | case GL_PACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4669 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4670 | mState.setPackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4671 | break; |
| 4672 | |
| 4673 | default: |
| 4674 | UNREACHABLE(); |
| 4675 | return; |
| 4676 | } |
| 4677 | } |
| 4678 | |
| 4679 | void Context::polygonOffset(GLfloat factor, GLfloat units) |
| 4680 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4681 | mState.setPolygonOffsetParams(factor, units); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4682 | } |
| 4683 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4684 | void Context::sampleCoverage(GLfloat value, GLboolean invert) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4685 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4686 | mState.setSampleCoverageParams(clamp01(value), ConvertToBool(invert)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4687 | } |
| 4688 | |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 4689 | void Context::sampleMaski(GLuint maskNumber, GLbitfield mask) |
| 4690 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4691 | mState.setSampleMaskParams(maskNumber, mask); |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 4692 | } |
| 4693 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4694 | void Context::scissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4695 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4696 | mState.setScissorParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4697 | } |
| 4698 | |
| 4699 | void Context::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 4700 | { |
| 4701 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4702 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4703 | mState.setStencilParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4704 | } |
| 4705 | |
| 4706 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4707 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4708 | mState.setStencilBackParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4709 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4710 | |
| 4711 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4712 | } |
| 4713 | |
| 4714 | void Context::stencilMaskSeparate(GLenum face, GLuint mask) |
| 4715 | { |
| 4716 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4717 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4718 | mState.setStencilWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4719 | } |
| 4720 | |
| 4721 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4722 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4723 | mState.setStencilBackWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4724 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4725 | |
| 4726 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4727 | } |
| 4728 | |
| 4729 | void Context::stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 4730 | { |
| 4731 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4732 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4733 | mState.setStencilOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4734 | } |
| 4735 | |
| 4736 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4737 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4738 | mState.setStencilBackOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4739 | } |
| 4740 | } |
| 4741 | |
| 4742 | void Context::vertexAttrib1f(GLuint index, GLfloat x) |
| 4743 | { |
| 4744 | GLfloat vals[4] = {x, 0, 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::vertexAttrib1fv(GLuint index, const GLfloat *values) |
| 4750 | { |
| 4751 | GLfloat vals[4] = {values[0], 0, 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::vertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 4757 | { |
| 4758 | GLfloat vals[4] = {x, y, 0, 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::vertexAttrib2fv(GLuint index, const GLfloat *values) |
| 4764 | { |
| 4765 | GLfloat vals[4] = {values[0], values[1], 0, 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::vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 4771 | { |
| 4772 | GLfloat vals[4] = {x, y, z, 1}; |
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::vertexAttrib3fv(GLuint index, const GLfloat *values) |
| 4778 | { |
| 4779 | GLfloat vals[4] = {values[0], values[1], values[2], 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4780 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4781 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4782 | } |
| 4783 | |
| 4784 | void Context::vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4785 | { |
| 4786 | GLfloat vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4787 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4788 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4789 | } |
| 4790 | |
| 4791 | void Context::vertexAttrib4fv(GLuint index, const GLfloat *values) |
| 4792 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4793 | mState.setVertexAttribf(index, values); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4794 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4795 | } |
| 4796 | |
| 4797 | void Context::vertexAttribPointer(GLuint index, |
| 4798 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4799 | VertexAttribType type, |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4800 | GLboolean normalized, |
| 4801 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4802 | const void *ptr) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4803 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4804 | mState.setVertexAttribPointer(this, index, mState.getTargetBuffer(BufferBinding::Array), size, |
Jamie Madill | 6e18a23 | 2019-01-16 13:27:14 -0500 | [diff] [blame] | 4805 | type, ConvertToBool(normalized), stride, ptr); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4806 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4807 | } |
| 4808 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4809 | void Context::vertexAttribFormat(GLuint attribIndex, |
| 4810 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4811 | VertexAttribType type, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4812 | GLboolean normalized, |
| 4813 | GLuint relativeOffset) |
| 4814 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4815 | mState.setVertexAttribFormat(attribIndex, size, type, ConvertToBool(normalized), false, |
| 4816 | relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4817 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4818 | } |
| 4819 | |
| 4820 | void Context::vertexAttribIFormat(GLuint attribIndex, |
| 4821 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4822 | VertexAttribType type, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4823 | GLuint relativeOffset) |
| 4824 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4825 | mState.setVertexAttribFormat(attribIndex, size, type, false, true, relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4826 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4827 | } |
| 4828 | |
| 4829 | void Context::vertexAttribBinding(GLuint attribIndex, GLuint bindingIndex) |
| 4830 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4831 | mState.setVertexAttribBinding(this, attribIndex, bindingIndex); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4832 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4833 | } |
| 4834 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4835 | void Context::vertexBindingDivisor(GLuint bindingIndex, GLuint divisor) |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4836 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4837 | mState.setVertexBindingDivisor(bindingIndex, divisor); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4838 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4839 | } |
| 4840 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4841 | void Context::viewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4842 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4843 | mState.setViewportParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4844 | } |
| 4845 | |
| 4846 | void Context::vertexAttribIPointer(GLuint index, |
| 4847 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4848 | VertexAttribType type, |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4849 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4850 | const void *pointer) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4851 | { |
Jamie Madill | 6e18a23 | 2019-01-16 13:27:14 -0500 | [diff] [blame] | 4852 | mState.setVertexAttribIPointer(this, index, mState.getTargetBuffer(BufferBinding::Array), size, |
| 4853 | type, stride, pointer); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4854 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4855 | } |
| 4856 | |
| 4857 | void Context::vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 4858 | { |
| 4859 | GLint vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4860 | mState.setVertexAttribi(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4861 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4862 | } |
| 4863 | |
| 4864 | void Context::vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 4865 | { |
| 4866 | GLuint vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4867 | mState.setVertexAttribu(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4868 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4869 | } |
| 4870 | |
| 4871 | void Context::vertexAttribI4iv(GLuint index, const GLint *v) |
| 4872 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4873 | mState.setVertexAttribi(index, v); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4874 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4875 | } |
| 4876 | |
| 4877 | void Context::vertexAttribI4uiv(GLuint index, const GLuint *v) |
| 4878 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4879 | mState.setVertexAttribu(index, v); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4880 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4881 | } |
| 4882 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4883 | void Context::getVertexAttribiv(GLuint index, GLenum pname, GLint *params) |
| 4884 | { |
| 4885 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4886 | getState().getVertexAttribCurrentValue(index); |
| 4887 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4888 | QueryVertexAttribiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4889 | currentValues, pname, params); |
| 4890 | } |
| 4891 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4892 | void Context::getVertexAttribivRobust(GLuint index, |
| 4893 | GLenum pname, |
| 4894 | GLsizei bufSize, |
| 4895 | GLsizei *length, |
| 4896 | GLint *params) |
| 4897 | { |
| 4898 | getVertexAttribiv(index, pname, params); |
| 4899 | } |
| 4900 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4901 | void Context::getVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) |
| 4902 | { |
| 4903 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4904 | getState().getVertexAttribCurrentValue(index); |
| 4905 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4906 | QueryVertexAttribfv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4907 | currentValues, pname, params); |
| 4908 | } |
| 4909 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4910 | void Context::getVertexAttribfvRobust(GLuint index, |
| 4911 | GLenum pname, |
| 4912 | GLsizei bufSize, |
| 4913 | GLsizei *length, |
| 4914 | GLfloat *params) |
| 4915 | { |
| 4916 | getVertexAttribfv(index, pname, params); |
| 4917 | } |
| 4918 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4919 | void Context::getVertexAttribIiv(GLuint index, GLenum pname, GLint *params) |
| 4920 | { |
| 4921 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4922 | getState().getVertexAttribCurrentValue(index); |
| 4923 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4924 | QueryVertexAttribIiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4925 | currentValues, pname, params); |
| 4926 | } |
| 4927 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4928 | void Context::getVertexAttribIivRobust(GLuint index, |
| 4929 | GLenum pname, |
| 4930 | GLsizei bufSize, |
| 4931 | GLsizei *length, |
| 4932 | GLint *params) |
| 4933 | { |
| 4934 | getVertexAttribIiv(index, pname, params); |
| 4935 | } |
| 4936 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4937 | void Context::getVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) |
| 4938 | { |
| 4939 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4940 | getState().getVertexAttribCurrentValue(index); |
| 4941 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4942 | QueryVertexAttribIuiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4943 | currentValues, pname, params); |
| 4944 | } |
| 4945 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4946 | void Context::getVertexAttribIuivRobust(GLuint index, |
| 4947 | GLenum pname, |
| 4948 | GLsizei bufSize, |
| 4949 | GLsizei *length, |
| 4950 | GLuint *params) |
| 4951 | { |
| 4952 | getVertexAttribIuiv(index, pname, params); |
| 4953 | } |
| 4954 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4955 | void Context::getVertexAttribPointerv(GLuint index, GLenum pname, void **pointer) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4956 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4957 | const VertexAttribute &attrib = getState().getVertexArray()->getVertexAttribute(index); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4958 | QueryVertexAttribPointerv(attrib, pname, pointer); |
| 4959 | } |
| 4960 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4961 | void Context::getVertexAttribPointervRobust(GLuint index, |
| 4962 | GLenum pname, |
| 4963 | GLsizei bufSize, |
| 4964 | GLsizei *length, |
| 4965 | void **pointer) |
| 4966 | { |
| 4967 | getVertexAttribPointerv(index, pname, pointer); |
| 4968 | } |
| 4969 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4970 | void Context::debugMessageControl(GLenum source, |
| 4971 | GLenum type, |
| 4972 | GLenum severity, |
| 4973 | GLsizei count, |
| 4974 | const GLuint *ids, |
| 4975 | GLboolean enabled) |
| 4976 | { |
| 4977 | std::vector<GLuint> idVector(ids, ids + count); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4978 | mState.getDebug().setMessageControl(source, type, severity, std::move(idVector), |
| 4979 | ConvertToBool(enabled)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4980 | } |
| 4981 | |
| 4982 | void Context::debugMessageInsert(GLenum source, |
| 4983 | GLenum type, |
| 4984 | GLuint id, |
| 4985 | GLenum severity, |
| 4986 | GLsizei length, |
| 4987 | const GLchar *buf) |
| 4988 | { |
| 4989 | 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] | 4990 | mState.getDebug().insertMessage(source, type, id, severity, std::move(msg)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4991 | } |
| 4992 | |
| 4993 | void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam) |
| 4994 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4995 | mState.getDebug().setCallback(callback, userParam); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4996 | } |
| 4997 | |
| 4998 | GLuint Context::getDebugMessageLog(GLuint count, |
| 4999 | GLsizei bufSize, |
| 5000 | GLenum *sources, |
| 5001 | GLenum *types, |
| 5002 | GLuint *ids, |
| 5003 | GLenum *severities, |
| 5004 | GLsizei *lengths, |
| 5005 | GLchar *messageLog) |
| 5006 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5007 | return static_cast<GLuint>(mState.getDebug().getMessages(count, bufSize, sources, types, ids, |
| 5008 | severities, lengths, messageLog)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5009 | } |
| 5010 | |
| 5011 | void Context::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) |
| 5012 | { |
| 5013 | 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] | 5014 | mState.getDebug().pushGroup(source, id, std::move(msg)); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5015 | mImplementation->pushDebugGroup(source, id, length, message); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5016 | } |
| 5017 | |
| 5018 | void Context::popDebugGroup() |
| 5019 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5020 | mState.getDebug().popGroup(); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5021 | mImplementation->popDebugGroup(); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5022 | } |
| 5023 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5024 | void Context::bufferData(BufferBinding target, GLsizeiptr size, const void *data, BufferUsage usage) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5025 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5026 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5027 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5028 | ANGLE_CONTEXT_TRY(buffer->bufferData(this, target, data, size, usage)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5029 | } |
| 5030 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5031 | void Context::bufferSubData(BufferBinding target, |
| 5032 | GLintptr offset, |
| 5033 | GLsizeiptr size, |
| 5034 | const void *data) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5035 | { |
Courtney Goeltzenleuchter | 62114aa | 2018-08-28 09:36:46 -0600 | [diff] [blame] | 5036 | if (data == nullptr || size == 0) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5037 | { |
| 5038 | return; |
| 5039 | } |
| 5040 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5041 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5042 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5043 | ANGLE_CONTEXT_TRY(buffer->bufferSubData(this, target, data, size, offset)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5044 | } |
| 5045 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5046 | void Context::attachShader(GLuint program, GLuint shader) |
| 5047 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5048 | Program *programObject = mState.mShaderProgramManager->getProgram(program); |
| 5049 | Shader *shaderObject = mState.mShaderProgramManager->getShader(shader); |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5050 | ASSERT(programObject && shaderObject); |
| 5051 | programObject->attachShader(shaderObject); |
| 5052 | } |
| 5053 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 5054 | const Workarounds &Context::getWorkarounds() const |
| 5055 | { |
| 5056 | return mWorkarounds; |
| 5057 | } |
| 5058 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5059 | void Context::copyBufferSubData(BufferBinding readTarget, |
| 5060 | BufferBinding writeTarget, |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5061 | GLintptr readOffset, |
| 5062 | GLintptr writeOffset, |
| 5063 | GLsizeiptr size) |
| 5064 | { |
| 5065 | // if size is zero, the copy is a successful no-op |
| 5066 | if (size == 0) |
| 5067 | { |
| 5068 | return; |
| 5069 | } |
| 5070 | |
| 5071 | // TODO(jmadill): cache these. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5072 | Buffer *readBuffer = mState.getTargetBuffer(readTarget); |
| 5073 | Buffer *writeBuffer = mState.getTargetBuffer(writeTarget); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5074 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5075 | ANGLE_CONTEXT_TRY( |
| 5076 | writeBuffer->copyBufferSubData(this, readBuffer, readOffset, writeOffset, size)); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5077 | } |
| 5078 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5079 | void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *name) |
| 5080 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5081 | // Ideally we could share the program query with the validation layer if possible. |
| 5082 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5083 | ASSERT(programObject); |
| 5084 | programObject->bindAttributeLocation(index, name); |
| 5085 | } |
| 5086 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5087 | void Context::bindBufferBase(BufferBinding target, GLuint index, GLuint buffer) |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5088 | { |
| 5089 | bindBufferRange(target, index, buffer, 0, 0); |
| 5090 | } |
| 5091 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5092 | void Context::bindBufferRange(BufferBinding target, |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5093 | GLuint index, |
| 5094 | GLuint buffer, |
| 5095 | GLintptr offset, |
| 5096 | GLsizeiptr size) |
| 5097 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5098 | Buffer *object = mState.mBufferManager->checkBufferAllocation(mImplementation.get(), buffer); |
| 5099 | ANGLE_CONTEXT_TRY(mState.setIndexedBufferBinding(this, target, index, object, offset, size)); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5100 | if (target == BufferBinding::Uniform) |
| 5101 | { |
Jamie Madill | 472ddc8 | 2018-10-18 18:41:56 -0400 | [diff] [blame] | 5102 | mUniformBufferObserverBindings[index].bind(object); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 5103 | mStateCache.onUniformBufferStateChange(this); |
| 5104 | } |
| 5105 | else |
| 5106 | { |
| 5107 | mStateCache.onBufferBindingChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5108 | } |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5109 | } |
| 5110 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5111 | void Context::bindFramebuffer(GLenum target, GLuint framebuffer) |
| 5112 | { |
| 5113 | if (target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5114 | { |
| 5115 | bindReadFramebuffer(framebuffer); |
| 5116 | } |
| 5117 | |
| 5118 | if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5119 | { |
| 5120 | bindDrawFramebuffer(framebuffer); |
| 5121 | } |
| 5122 | } |
| 5123 | |
| 5124 | void Context::bindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 5125 | { |
| 5126 | ASSERT(target == GL_RENDERBUFFER); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5127 | Renderbuffer *object = mState.mRenderbufferManager->checkRenderbufferAllocation( |
| 5128 | mImplementation.get(), renderbuffer); |
| 5129 | mState.setRenderbufferBinding(this, object); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5130 | } |
| 5131 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5132 | void Context::texStorage2DMultisample(TextureType target, |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5133 | GLsizei samples, |
| 5134 | GLenum internalformat, |
| 5135 | GLsizei width, |
| 5136 | GLsizei height, |
| 5137 | GLboolean fixedsamplelocations) |
| 5138 | { |
| 5139 | Extents size(width, height, 1); |
| 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))); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5143 | } |
| 5144 | |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5145 | void Context::texStorage3DMultisample(TextureType target, |
| 5146 | GLsizei samples, |
| 5147 | GLenum internalformat, |
| 5148 | GLsizei width, |
| 5149 | GLsizei height, |
| 5150 | GLsizei depth, |
| 5151 | GLboolean fixedsamplelocations) |
| 5152 | { |
Olli Etuaho | 0c5a9e2 | 2018-08-27 14:36:23 +0300 | [diff] [blame] | 5153 | Extents size(width, height, depth); |
| 5154 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5155 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5156 | ConvertToBool(fixedsamplelocations))); |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5157 | } |
| 5158 | |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5159 | void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val) |
| 5160 | { |
JiangYizhou | 5b03f47 | 2017-01-09 10:22:53 +0800 | [diff] [blame] | 5161 | // According to spec 3.1 Table 20.49: Framebuffer Dependent Values, |
| 5162 | // the sample position should be queried by DRAW_FRAMEBUFFER. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5163 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_DRAW_FRAMEBUFFER)); |
| 5164 | const Framebuffer *framebuffer = mState.getDrawFramebuffer(); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5165 | |
| 5166 | switch (pname) |
| 5167 | { |
| 5168 | case GL_SAMPLE_POSITION: |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5169 | ANGLE_CONTEXT_TRY(framebuffer->getSamplePosition(this, index, val)); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5170 | break; |
| 5171 | default: |
| 5172 | UNREACHABLE(); |
| 5173 | } |
| 5174 | } |
| 5175 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5176 | void Context::getMultisamplefvRobust(GLenum pname, |
| 5177 | GLuint index, |
| 5178 | GLsizei bufSize, |
| 5179 | GLsizei *length, |
| 5180 | GLfloat *val) |
| 5181 | { |
| 5182 | UNIMPLEMENTED(); |
| 5183 | } |
| 5184 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5185 | void Context::renderbufferStorage(GLenum target, |
| 5186 | GLenum internalformat, |
| 5187 | GLsizei width, |
| 5188 | GLsizei height) |
| 5189 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5190 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5191 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
| 5192 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5193 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5194 | ANGLE_CONTEXT_TRY(renderbuffer->setStorage(this, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5195 | } |
| 5196 | |
| 5197 | void Context::renderbufferStorageMultisample(GLenum target, |
| 5198 | GLsizei samples, |
| 5199 | GLenum internalformat, |
| 5200 | GLsizei width, |
| 5201 | GLsizei height) |
| 5202 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5203 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5204 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5205 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5206 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5207 | ANGLE_CONTEXT_TRY( |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5208 | renderbuffer->setStorageMultisample(this, samples, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5209 | } |
| 5210 | |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5211 | void Context::getSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) |
| 5212 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 5213 | const Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5214 | ANGLE_CONTEXT_TRY(QuerySynciv(this, syncObject, pname, bufSize, length, values)); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5215 | } |
| 5216 | |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5217 | void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 5218 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5219 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5220 | QueryFramebufferParameteriv(framebuffer, pname, params); |
| 5221 | } |
| 5222 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5223 | void Context::getFramebufferParameterivRobust(GLenum target, |
| 5224 | GLenum pname, |
| 5225 | GLsizei bufSize, |
| 5226 | GLsizei *length, |
| 5227 | GLint *params) |
| 5228 | { |
| 5229 | UNIMPLEMENTED(); |
| 5230 | } |
| 5231 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5232 | void Context::framebufferParameteri(GLenum target, GLenum pname, GLint param) |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5233 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5234 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | b983a4b | 2018-08-01 11:34:51 -0400 | [diff] [blame] | 5235 | SetFramebufferParameteri(this, framebuffer, pname, param); |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5236 | } |
| 5237 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5238 | bool Context::getScratchBuffer(size_t requstedSizeBytes, |
| 5239 | angle::MemoryBuffer **scratchBufferOut) const |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5240 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5241 | return mScratchBuffer.get(requstedSizeBytes, scratchBufferOut); |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5242 | } |
| 5243 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5244 | bool Context::getZeroFilledBuffer(size_t requstedSizeBytes, |
| 5245 | angle::MemoryBuffer **zeroBufferOut) const |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5246 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5247 | return mZeroFilledBuffer.getInitialized(requstedSizeBytes, zeroBufferOut, 0); |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5248 | } |
| 5249 | |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5250 | void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) |
| 5251 | { |
| 5252 | if (numGroupsX == 0u || numGroupsY == 0u || numGroupsZ == 0u) |
| 5253 | { |
| 5254 | return; |
| 5255 | } |
| 5256 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 5257 | ANGLE_CONTEXT_TRY(prepareForDispatch()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5258 | ANGLE_CONTEXT_TRY(mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ)); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5259 | } |
| 5260 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5261 | void Context::dispatchComputeIndirect(GLintptr indirect) |
| 5262 | { |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 5263 | ANGLE_CONTEXT_TRY(prepareForDispatch()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5264 | ANGLE_CONTEXT_TRY(mImplementation->dispatchComputeIndirect(this, indirect)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5265 | } |
| 5266 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5267 | void Context::texStorage2D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5268 | GLsizei levels, |
| 5269 | GLenum internalFormat, |
| 5270 | GLsizei width, |
| 5271 | GLsizei height) |
| 5272 | { |
| 5273 | Extents size(width, height, 1); |
| 5274 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5275 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5276 | } |
| 5277 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5278 | void Context::texStorage3D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5279 | GLsizei levels, |
| 5280 | GLenum internalFormat, |
| 5281 | GLsizei width, |
| 5282 | GLsizei height, |
| 5283 | GLsizei depth) |
| 5284 | { |
| 5285 | Extents size(width, height, depth); |
| 5286 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5287 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5288 | } |
| 5289 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5290 | void Context::memoryBarrier(GLbitfield barriers) |
| 5291 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5292 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrier(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5293 | } |
| 5294 | |
| 5295 | void Context::memoryBarrierByRegion(GLbitfield barriers) |
| 5296 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5297 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrierByRegion(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5298 | } |
| 5299 | |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5300 | void Context::multiDrawArrays(PrimitiveMode mode, |
| 5301 | const GLint *firsts, |
| 5302 | const GLsizei *counts, |
| 5303 | GLsizei drawcount) |
| 5304 | { |
| 5305 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5306 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5307 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5308 | if (hasDrawID) |
| 5309 | { |
| 5310 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5311 | { |
| 5312 | if (noopDraw(mode, counts[drawID])) |
| 5313 | { |
| 5314 | continue; |
| 5315 | } |
| 5316 | programObject->setDrawIDUniform(drawID); |
| 5317 | ANGLE_CONTEXT_TRY( |
| 5318 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5319 | MarkTransformFeedbackBufferUsage(this, counts[drawID], 1); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5320 | } |
| 5321 | } |
| 5322 | else |
| 5323 | { |
| 5324 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5325 | { |
| 5326 | if (noopDraw(mode, counts[drawID])) |
| 5327 | { |
| 5328 | continue; |
| 5329 | } |
| 5330 | ANGLE_CONTEXT_TRY( |
| 5331 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5332 | MarkTransformFeedbackBufferUsage(this, counts[drawID], 1); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5333 | } |
| 5334 | } |
| 5335 | } |
| 5336 | |
| 5337 | void Context::multiDrawArraysInstanced(PrimitiveMode mode, |
| 5338 | const GLint *firsts, |
| 5339 | const GLsizei *counts, |
| 5340 | const GLsizei *instanceCounts, |
| 5341 | GLsizei drawcount) |
| 5342 | { |
| 5343 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5344 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5345 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5346 | if (hasDrawID) |
| 5347 | { |
| 5348 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5349 | { |
| 5350 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5351 | { |
| 5352 | continue; |
| 5353 | } |
| 5354 | programObject->setDrawIDUniform(drawID); |
| 5355 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5356 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5357 | MarkTransformFeedbackBufferUsage(this, counts[drawID], instanceCounts[drawID]); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5358 | } |
| 5359 | } |
| 5360 | else |
| 5361 | { |
| 5362 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5363 | { |
| 5364 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5365 | { |
| 5366 | continue; |
| 5367 | } |
| 5368 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5369 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5370 | MarkTransformFeedbackBufferUsage(this, counts[drawID], instanceCounts[drawID]); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5371 | } |
| 5372 | } |
| 5373 | } |
| 5374 | |
| 5375 | void Context::multiDrawElements(PrimitiveMode mode, |
| 5376 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5377 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5378 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5379 | GLsizei drawcount) |
| 5380 | { |
| 5381 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5382 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5383 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5384 | if (hasDrawID) |
| 5385 | { |
| 5386 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5387 | { |
| 5388 | if (noopDraw(mode, counts[drawID])) |
| 5389 | { |
| 5390 | continue; |
| 5391 | } |
| 5392 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5393 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5394 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5395 | } |
| 5396 | } |
| 5397 | else |
| 5398 | { |
| 5399 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5400 | { |
| 5401 | if (noopDraw(mode, counts[drawID])) |
| 5402 | { |
| 5403 | continue; |
| 5404 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5405 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5406 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5407 | } |
| 5408 | } |
| 5409 | } |
| 5410 | |
| 5411 | void Context::multiDrawElementsInstanced(PrimitiveMode mode, |
| 5412 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5413 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5414 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5415 | const GLsizei *instanceCounts, |
| 5416 | GLsizei drawcount) |
| 5417 | { |
| 5418 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5419 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5420 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5421 | if (hasDrawID) |
| 5422 | { |
| 5423 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5424 | { |
| 5425 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5426 | { |
| 5427 | continue; |
| 5428 | } |
| 5429 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5430 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5431 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5432 | } |
| 5433 | } |
| 5434 | else |
| 5435 | { |
| 5436 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5437 | { |
| 5438 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5439 | { |
| 5440 | continue; |
| 5441 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5442 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5443 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5444 | } |
| 5445 | } |
| 5446 | } |
| 5447 | |
Jeff Gilbert | 465d609 | 2019-01-02 16:21:18 -0800 | [diff] [blame] | 5448 | void Context::provokingVertex(ProvokingVertex provokeMode) |
| 5449 | { |
| 5450 | mState.setProvokingVertex(provokeMode); |
| 5451 | } |
| 5452 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5453 | GLenum Context::checkFramebufferStatus(GLenum target) |
| 5454 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5455 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5456 | ASSERT(framebuffer); |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 5457 | return framebuffer->checkStatus(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5458 | } |
| 5459 | |
| 5460 | void Context::compileShader(GLuint shader) |
| 5461 | { |
| 5462 | Shader *shaderObject = GetValidShader(this, shader); |
| 5463 | if (!shaderObject) |
| 5464 | { |
| 5465 | return; |
| 5466 | } |
| 5467 | shaderObject->compile(this); |
| 5468 | } |
| 5469 | |
| 5470 | void Context::deleteBuffers(GLsizei n, const GLuint *buffers) |
| 5471 | { |
| 5472 | for (int i = 0; i < n; i++) |
| 5473 | { |
| 5474 | deleteBuffer(buffers[i]); |
| 5475 | } |
| 5476 | } |
| 5477 | |
| 5478 | void Context::deleteFramebuffers(GLsizei n, const GLuint *framebuffers) |
| 5479 | { |
| 5480 | for (int i = 0; i < n; i++) |
| 5481 | { |
| 5482 | if (framebuffers[i] != 0) |
| 5483 | { |
| 5484 | deleteFramebuffer(framebuffers[i]); |
| 5485 | } |
| 5486 | } |
| 5487 | } |
| 5488 | |
| 5489 | void Context::deleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) |
| 5490 | { |
| 5491 | for (int i = 0; i < n; i++) |
| 5492 | { |
| 5493 | deleteRenderbuffer(renderbuffers[i]); |
| 5494 | } |
| 5495 | } |
| 5496 | |
| 5497 | void Context::deleteTextures(GLsizei n, const GLuint *textures) |
| 5498 | { |
| 5499 | for (int i = 0; i < n; i++) |
| 5500 | { |
| 5501 | if (textures[i] != 0) |
| 5502 | { |
| 5503 | deleteTexture(textures[i]); |
| 5504 | } |
| 5505 | } |
| 5506 | } |
| 5507 | |
| 5508 | void Context::detachShader(GLuint program, GLuint shader) |
| 5509 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5510 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5511 | ASSERT(programObject); |
| 5512 | |
| 5513 | Shader *shaderObject = getShader(shader); |
| 5514 | ASSERT(shaderObject); |
| 5515 | |
| 5516 | programObject->detachShader(this, shaderObject); |
| 5517 | } |
| 5518 | |
| 5519 | void Context::genBuffers(GLsizei n, GLuint *buffers) |
| 5520 | { |
| 5521 | for (int i = 0; i < n; i++) |
| 5522 | { |
| 5523 | buffers[i] = createBuffer(); |
| 5524 | } |
| 5525 | } |
| 5526 | |
| 5527 | void Context::genFramebuffers(GLsizei n, GLuint *framebuffers) |
| 5528 | { |
| 5529 | for (int i = 0; i < n; i++) |
| 5530 | { |
| 5531 | framebuffers[i] = createFramebuffer(); |
| 5532 | } |
| 5533 | } |
| 5534 | |
| 5535 | void Context::genRenderbuffers(GLsizei n, GLuint *renderbuffers) |
| 5536 | { |
| 5537 | for (int i = 0; i < n; i++) |
| 5538 | { |
| 5539 | renderbuffers[i] = createRenderbuffer(); |
| 5540 | } |
| 5541 | } |
| 5542 | |
| 5543 | void Context::genTextures(GLsizei n, GLuint *textures) |
| 5544 | { |
| 5545 | for (int i = 0; i < n; i++) |
| 5546 | { |
| 5547 | textures[i] = createTexture(); |
| 5548 | } |
| 5549 | } |
| 5550 | |
| 5551 | void Context::getActiveAttrib(GLuint program, |
| 5552 | GLuint index, |
| 5553 | GLsizei bufsize, |
| 5554 | GLsizei *length, |
| 5555 | GLint *size, |
| 5556 | GLenum *type, |
| 5557 | GLchar *name) |
| 5558 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5559 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5560 | ASSERT(programObject); |
| 5561 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 5562 | } |
| 5563 | |
| 5564 | void Context::getActiveUniform(GLuint program, |
| 5565 | GLuint index, |
| 5566 | GLsizei bufsize, |
| 5567 | GLsizei *length, |
| 5568 | GLint *size, |
| 5569 | GLenum *type, |
| 5570 | 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 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 5575 | } |
| 5576 | |
| 5577 | void Context::getAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) |
| 5578 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5579 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5580 | ASSERT(programObject); |
| 5581 | programObject->getAttachedShaders(maxcount, count, shaders); |
| 5582 | } |
| 5583 | |
| 5584 | GLint Context::getAttribLocation(GLuint program, const GLchar *name) |
| 5585 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5586 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5587 | ASSERT(programObject); |
| 5588 | return programObject->getAttributeLocation(name); |
| 5589 | } |
| 5590 | |
| 5591 | void Context::getBooleanv(GLenum pname, GLboolean *params) |
| 5592 | { |
| 5593 | GLenum nativeType; |
| 5594 | unsigned int numParams = 0; |
| 5595 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5596 | |
| 5597 | if (nativeType == GL_BOOL) |
| 5598 | { |
| 5599 | getBooleanvImpl(pname, params); |
| 5600 | } |
| 5601 | else |
| 5602 | { |
| 5603 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5604 | } |
| 5605 | } |
| 5606 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5607 | void Context::getBooleanvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLboolean *params) |
| 5608 | { |
| 5609 | getBooleanv(pname, params); |
| 5610 | } |
| 5611 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5612 | void Context::getFloatv(GLenum pname, GLfloat *params) |
| 5613 | { |
| 5614 | GLenum nativeType; |
| 5615 | unsigned int numParams = 0; |
| 5616 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5617 | |
| 5618 | if (nativeType == GL_FLOAT) |
| 5619 | { |
| 5620 | getFloatvImpl(pname, params); |
| 5621 | } |
| 5622 | else |
| 5623 | { |
| 5624 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5625 | } |
| 5626 | } |
| 5627 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5628 | void Context::getFloatvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLfloat *params) |
| 5629 | { |
| 5630 | getFloatv(pname, params); |
| 5631 | } |
| 5632 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5633 | void Context::getIntegerv(GLenum pname, GLint *params) |
| 5634 | { |
| 5635 | GLenum nativeType; |
| 5636 | unsigned int numParams = 0; |
| 5637 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5638 | |
| 5639 | if (nativeType == GL_INT) |
| 5640 | { |
| 5641 | getIntegervImpl(pname, params); |
| 5642 | } |
| 5643 | else |
| 5644 | { |
| 5645 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5646 | } |
| 5647 | } |
| 5648 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5649 | void Context::getIntegervRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint *data) |
| 5650 | { |
| 5651 | getIntegerv(pname, data); |
| 5652 | } |
| 5653 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5654 | void Context::getProgramiv(GLuint program, GLenum pname, GLint *params) |
| 5655 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5656 | // Don't resolve link if checking the link completion status. |
| 5657 | Program *programObject = (pname == GL_COMPLETION_STATUS_KHR ? getProgramNoResolveLink(program) |
| 5658 | : getProgramResolveLink(program)); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5659 | ASSERT(programObject); |
Jamie Madill | ffe00c0 | 2017-06-27 16:26:55 -0400 | [diff] [blame] | 5660 | QueryProgramiv(this, programObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5661 | } |
| 5662 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5663 | void Context::getProgramivRobust(GLuint program, |
| 5664 | GLenum pname, |
| 5665 | GLsizei bufSize, |
| 5666 | GLsizei *length, |
| 5667 | GLint *params) |
| 5668 | { |
| 5669 | getProgramiv(program, pname, params); |
| 5670 | } |
| 5671 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5672 | void Context::getProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params) |
| 5673 | { |
| 5674 | UNIMPLEMENTED(); |
| 5675 | } |
| 5676 | |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 5677 | void Context::getProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5678 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5679 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5680 | ASSERT(programObject); |
| 5681 | programObject->getInfoLog(bufsize, length, infolog); |
| 5682 | } |
| 5683 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5684 | void Context::getProgramPipelineInfoLog(GLuint pipeline, |
| 5685 | GLsizei bufSize, |
| 5686 | GLsizei *length, |
| 5687 | GLchar *infoLog) |
| 5688 | { |
| 5689 | UNIMPLEMENTED(); |
| 5690 | } |
| 5691 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5692 | void Context::getShaderiv(GLuint shader, GLenum pname, GLint *params) |
| 5693 | { |
| 5694 | Shader *shaderObject = getShader(shader); |
| 5695 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5696 | QueryShaderiv(shaderObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5697 | } |
| 5698 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5699 | void Context::getShaderivRobust(GLuint shader, |
| 5700 | GLenum pname, |
| 5701 | GLsizei bufSize, |
| 5702 | GLsizei *length, |
| 5703 | GLint *params) |
| 5704 | { |
| 5705 | getShaderiv(shader, pname, params); |
| 5706 | } |
| 5707 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5708 | void Context::getShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
| 5709 | { |
| 5710 | Shader *shaderObject = getShader(shader); |
| 5711 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5712 | shaderObject->getInfoLog(bufsize, length, infolog); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5713 | } |
| 5714 | |
| 5715 | void Context::getShaderPrecisionFormat(GLenum shadertype, |
| 5716 | GLenum precisiontype, |
| 5717 | GLint *range, |
| 5718 | GLint *precision) |
| 5719 | { |
| 5720 | // TODO(jmadill): Compute shaders. |
| 5721 | |
| 5722 | switch (shadertype) |
| 5723 | { |
| 5724 | case GL_VERTEX_SHADER: |
| 5725 | switch (precisiontype) |
| 5726 | { |
| 5727 | case GL_LOW_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5728 | mState.mCaps.vertexLowpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5729 | break; |
| 5730 | case GL_MEDIUM_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5731 | mState.mCaps.vertexMediumpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5732 | break; |
| 5733 | case GL_HIGH_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5734 | mState.mCaps.vertexHighpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5735 | break; |
| 5736 | |
| 5737 | case GL_LOW_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5738 | mState.mCaps.vertexLowpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5739 | break; |
| 5740 | case GL_MEDIUM_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5741 | mState.mCaps.vertexMediumpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5742 | break; |
| 5743 | case GL_HIGH_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5744 | mState.mCaps.vertexHighpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5745 | break; |
| 5746 | |
| 5747 | default: |
| 5748 | UNREACHABLE(); |
| 5749 | return; |
| 5750 | } |
| 5751 | break; |
| 5752 | |
| 5753 | case GL_FRAGMENT_SHADER: |
| 5754 | switch (precisiontype) |
| 5755 | { |
| 5756 | case GL_LOW_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5757 | mState.mCaps.fragmentLowpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5758 | break; |
| 5759 | case GL_MEDIUM_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5760 | mState.mCaps.fragmentMediumpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5761 | break; |
| 5762 | case GL_HIGH_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5763 | mState.mCaps.fragmentHighpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5764 | break; |
| 5765 | |
| 5766 | case GL_LOW_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5767 | mState.mCaps.fragmentLowpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5768 | break; |
| 5769 | case GL_MEDIUM_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5770 | mState.mCaps.fragmentMediumpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5771 | break; |
| 5772 | case GL_HIGH_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5773 | mState.mCaps.fragmentHighpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5774 | break; |
| 5775 | |
| 5776 | default: |
| 5777 | UNREACHABLE(); |
| 5778 | return; |
| 5779 | } |
| 5780 | break; |
| 5781 | |
| 5782 | default: |
| 5783 | UNREACHABLE(); |
| 5784 | return; |
| 5785 | } |
| 5786 | } |
| 5787 | |
| 5788 | void Context::getShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source) |
| 5789 | { |
| 5790 | Shader *shaderObject = getShader(shader); |
| 5791 | ASSERT(shaderObject); |
| 5792 | shaderObject->getSource(bufsize, length, source); |
| 5793 | } |
| 5794 | |
| 5795 | void Context::getUniformfv(GLuint program, GLint location, GLfloat *params) |
| 5796 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5797 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5798 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5799 | programObject->getUniformfv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5800 | } |
| 5801 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5802 | void Context::getUniformfvRobust(GLuint program, |
| 5803 | GLint location, |
| 5804 | GLsizei bufSize, |
| 5805 | GLsizei *length, |
| 5806 | GLfloat *params) |
| 5807 | { |
| 5808 | getUniformfv(program, location, params); |
| 5809 | } |
| 5810 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5811 | void Context::getUniformiv(GLuint program, GLint location, GLint *params) |
| 5812 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5813 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5814 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5815 | programObject->getUniformiv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5816 | } |
| 5817 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5818 | void Context::getUniformivRobust(GLuint program, |
| 5819 | GLint location, |
| 5820 | GLsizei bufSize, |
| 5821 | GLsizei *length, |
| 5822 | GLint *params) |
| 5823 | { |
| 5824 | getUniformiv(program, location, params); |
| 5825 | } |
| 5826 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5827 | GLint Context::getUniformLocation(GLuint program, const GLchar *name) |
| 5828 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5829 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5830 | ASSERT(programObject); |
| 5831 | return programObject->getUniformLocation(name); |
| 5832 | } |
| 5833 | |
| 5834 | GLboolean Context::isBuffer(GLuint buffer) |
| 5835 | { |
| 5836 | if (buffer == 0) |
| 5837 | { |
| 5838 | return GL_FALSE; |
| 5839 | } |
| 5840 | |
| 5841 | return (getBuffer(buffer) ? GL_TRUE : GL_FALSE); |
| 5842 | } |
| 5843 | |
| 5844 | GLboolean Context::isEnabled(GLenum cap) |
| 5845 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5846 | return mState.getEnableFeature(cap); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5847 | } |
| 5848 | |
| 5849 | GLboolean Context::isFramebuffer(GLuint framebuffer) |
| 5850 | { |
| 5851 | if (framebuffer == 0) |
| 5852 | { |
| 5853 | return GL_FALSE; |
| 5854 | } |
| 5855 | |
| 5856 | return (getFramebuffer(framebuffer) ? GL_TRUE : GL_FALSE); |
| 5857 | } |
| 5858 | |
| 5859 | GLboolean Context::isProgram(GLuint program) |
| 5860 | { |
| 5861 | if (program == 0) |
| 5862 | { |
| 5863 | return GL_FALSE; |
| 5864 | } |
| 5865 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5866 | return (getProgramNoResolveLink(program) ? GL_TRUE : GL_FALSE); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5867 | } |
| 5868 | |
| 5869 | GLboolean Context::isRenderbuffer(GLuint renderbuffer) |
| 5870 | { |
| 5871 | if (renderbuffer == 0) |
| 5872 | { |
| 5873 | return GL_FALSE; |
| 5874 | } |
| 5875 | |
| 5876 | return (getRenderbuffer(renderbuffer) ? GL_TRUE : GL_FALSE); |
| 5877 | } |
| 5878 | |
| 5879 | GLboolean Context::isShader(GLuint shader) |
| 5880 | { |
| 5881 | if (shader == 0) |
| 5882 | { |
| 5883 | return GL_FALSE; |
| 5884 | } |
| 5885 | |
| 5886 | return (getShader(shader) ? GL_TRUE : GL_FALSE); |
| 5887 | } |
| 5888 | |
| 5889 | GLboolean Context::isTexture(GLuint texture) |
| 5890 | { |
| 5891 | if (texture == 0) |
| 5892 | { |
| 5893 | return GL_FALSE; |
| 5894 | } |
| 5895 | |
| 5896 | return (getTexture(texture) ? GL_TRUE : GL_FALSE); |
| 5897 | } |
| 5898 | |
| 5899 | void Context::linkProgram(GLuint program) |
| 5900 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5901 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5902 | ASSERT(programObject); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5903 | ANGLE_CONTEXT_TRY(programObject->link(this)); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5904 | |
| 5905 | // Don't parallel link a program which is active in any GL contexts. With this assumption, we |
| 5906 | // don't need to worry that: |
| 5907 | // 1. Draw calls after link use the new executable code or the old one depending on the link |
| 5908 | // result. |
| 5909 | // 2. When a backend program, e.g., ProgramD3D is linking, other backend classes like |
| 5910 | // StateManager11, Renderer11, etc., may have a chance to make unexpected calls to |
| 5911 | // ProgramD3D. |
| 5912 | if (programObject->isInUse()) |
| 5913 | { |
Jamie Madill | 785e8a0 | 2018-10-04 17:42:00 -0400 | [diff] [blame] | 5914 | programObject->resolveLink(this); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 5915 | if (programObject->isLinked()) |
| 5916 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5917 | ANGLE_CONTEXT_TRY(mState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 5918 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5919 | mStateCache.onProgramExecutableChange(this); |
| 5920 | } |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5921 | } |
| 5922 | |
| 5923 | void Context::releaseShaderCompiler() |
| 5924 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5925 | mCompiler.set(this, nullptr); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5926 | } |
| 5927 | |
| 5928 | void Context::shaderBinary(GLsizei n, |
| 5929 | const GLuint *shaders, |
| 5930 | GLenum binaryformat, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 5931 | const void *binary, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5932 | GLsizei length) |
| 5933 | { |
| 5934 | // No binary shader formats are supported. |
| 5935 | UNIMPLEMENTED(); |
| 5936 | } |
| 5937 | |
Olli Etuaho | 0ca0975 | 2018-09-24 11:00:50 +0300 | [diff] [blame] | 5938 | void Context::bindFragDataLocationIndexed(GLuint program, |
| 5939 | GLuint colorNumber, |
| 5940 | GLuint index, |
| 5941 | const char *name) |
| 5942 | { |
| 5943 | Program *programObject = getProgramNoResolveLink(program); |
| 5944 | programObject->bindFragmentOutputLocation(colorNumber, name); |
| 5945 | programObject->bindFragmentOutputIndex(index, name); |
| 5946 | } |
| 5947 | |
| 5948 | void Context::bindFragDataLocation(GLuint program, GLuint colorNumber, const char *name) |
| 5949 | { |
| 5950 | bindFragDataLocationIndexed(program, colorNumber, 0u, name); |
| 5951 | } |
| 5952 | |
| 5953 | int Context::getFragDataIndex(GLuint program, const char *name) |
| 5954 | { |
| 5955 | Program *programObject = getProgramResolveLink(program); |
| 5956 | return programObject->getFragDataIndex(name); |
| 5957 | } |
| 5958 | |
| 5959 | int Context::getProgramResourceLocationIndex(GLuint program, |
| 5960 | GLenum programInterface, |
| 5961 | const char *name) |
| 5962 | { |
| 5963 | Program *programObject = getProgramResolveLink(program); |
| 5964 | ASSERT(programInterface == GL_PROGRAM_OUTPUT); |
| 5965 | return programObject->getFragDataIndex(name); |
| 5966 | } |
| 5967 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5968 | void Context::shaderSource(GLuint shader, |
| 5969 | GLsizei count, |
| 5970 | const GLchar *const *string, |
| 5971 | const GLint *length) |
| 5972 | { |
| 5973 | Shader *shaderObject = getShader(shader); |
| 5974 | ASSERT(shaderObject); |
| 5975 | shaderObject->setSource(count, string, length); |
| 5976 | } |
| 5977 | |
| 5978 | void Context::stencilFunc(GLenum func, GLint ref, GLuint mask) |
| 5979 | { |
| 5980 | stencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
| 5981 | } |
| 5982 | |
| 5983 | void Context::stencilMask(GLuint mask) |
| 5984 | { |
| 5985 | stencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 5986 | } |
| 5987 | |
| 5988 | void Context::stencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 5989 | { |
| 5990 | stencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 5991 | } |
| 5992 | |
| 5993 | void Context::uniform1f(GLint location, GLfloat x) |
| 5994 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5995 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5996 | program->setUniform1fv(location, 1, &x); |
| 5997 | } |
| 5998 | |
| 5999 | void Context::uniform1fv(GLint location, GLsizei count, const GLfloat *v) |
| 6000 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6001 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6002 | program->setUniform1fv(location, count, v); |
| 6003 | } |
| 6004 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6005 | void Context::setUniform1iImpl(Program *program, GLint location, GLsizei count, const GLint *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6006 | { |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 6007 | program->setUniform1iv(this, location, count, v); |
| 6008 | } |
| 6009 | |
| 6010 | void Context::onSamplerUniformChange(size_t textureUnitIndex) |
| 6011 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6012 | mState.onActiveTextureChange(this, textureUnitIndex); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 6013 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6014 | } |
| 6015 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6016 | void Context::uniform1i(GLint location, GLint x) |
| 6017 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6018 | setUniform1iImpl(mState.getProgram(), location, 1, &x); |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6019 | } |
| 6020 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6021 | void Context::uniform1iv(GLint location, GLsizei count, const GLint *v) |
| 6022 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6023 | setUniform1iImpl(mState.getProgram(), location, count, v); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6024 | } |
| 6025 | |
| 6026 | void Context::uniform2f(GLint location, GLfloat x, GLfloat y) |
| 6027 | { |
| 6028 | GLfloat xy[2] = {x, y}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6029 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6030 | program->setUniform2fv(location, 1, xy); |
| 6031 | } |
| 6032 | |
| 6033 | void Context::uniform2fv(GLint location, GLsizei count, const GLfloat *v) |
| 6034 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6035 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6036 | program->setUniform2fv(location, count, v); |
| 6037 | } |
| 6038 | |
| 6039 | void Context::uniform2i(GLint location, GLint x, GLint y) |
| 6040 | { |
| 6041 | GLint xy[2] = {x, y}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6042 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6043 | program->setUniform2iv(location, 1, xy); |
| 6044 | } |
| 6045 | |
| 6046 | void Context::uniform2iv(GLint location, GLsizei count, const GLint *v) |
| 6047 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6048 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6049 | program->setUniform2iv(location, count, v); |
| 6050 | } |
| 6051 | |
| 6052 | void Context::uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 6053 | { |
| 6054 | GLfloat xyz[3] = {x, y, z}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6055 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6056 | program->setUniform3fv(location, 1, xyz); |
| 6057 | } |
| 6058 | |
| 6059 | void Context::uniform3fv(GLint location, GLsizei count, const GLfloat *v) |
| 6060 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6061 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6062 | program->setUniform3fv(location, count, v); |
| 6063 | } |
| 6064 | |
| 6065 | void Context::uniform3i(GLint location, GLint x, GLint y, GLint z) |
| 6066 | { |
| 6067 | GLint xyz[3] = {x, y, z}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6068 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6069 | program->setUniform3iv(location, 1, xyz); |
| 6070 | } |
| 6071 | |
| 6072 | void Context::uniform3iv(GLint location, GLsizei count, const GLint *v) |
| 6073 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6074 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6075 | program->setUniform3iv(location, count, v); |
| 6076 | } |
| 6077 | |
| 6078 | void Context::uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 6079 | { |
| 6080 | GLfloat xyzw[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6081 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6082 | program->setUniform4fv(location, 1, xyzw); |
| 6083 | } |
| 6084 | |
| 6085 | void Context::uniform4fv(GLint location, GLsizei count, const GLfloat *v) |
| 6086 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6087 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6088 | program->setUniform4fv(location, count, v); |
| 6089 | } |
| 6090 | |
| 6091 | void Context::uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 6092 | { |
| 6093 | GLint xyzw[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6094 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6095 | program->setUniform4iv(location, 1, xyzw); |
| 6096 | } |
| 6097 | |
| 6098 | void Context::uniform4iv(GLint location, GLsizei count, const GLint *v) |
| 6099 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6100 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6101 | program->setUniform4iv(location, count, v); |
| 6102 | } |
| 6103 | |
| 6104 | void Context::uniformMatrix2fv(GLint location, |
| 6105 | GLsizei count, |
| 6106 | GLboolean transpose, |
| 6107 | const GLfloat *value) |
| 6108 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6109 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6110 | program->setUniformMatrix2fv(location, count, transpose, value); |
| 6111 | } |
| 6112 | |
| 6113 | void Context::uniformMatrix3fv(GLint location, |
| 6114 | GLsizei count, |
| 6115 | GLboolean transpose, |
| 6116 | const GLfloat *value) |
| 6117 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6118 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6119 | program->setUniformMatrix3fv(location, count, transpose, value); |
| 6120 | } |
| 6121 | |
| 6122 | void Context::uniformMatrix4fv(GLint location, |
| 6123 | GLsizei count, |
| 6124 | GLboolean transpose, |
| 6125 | const GLfloat *value) |
| 6126 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6127 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6128 | program->setUniformMatrix4fv(location, count, transpose, value); |
| 6129 | } |
| 6130 | |
| 6131 | void Context::validateProgram(GLuint program) |
| 6132 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6133 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6134 | ASSERT(programObject); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6135 | programObject->validate(mState.mCaps); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6136 | } |
| 6137 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6138 | void Context::validateProgramPipeline(GLuint pipeline) |
| 6139 | { |
| 6140 | UNIMPLEMENTED(); |
| 6141 | } |
| 6142 | |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6143 | void Context::getProgramBinary(GLuint program, |
| 6144 | GLsizei bufSize, |
| 6145 | GLsizei *length, |
| 6146 | GLenum *binaryFormat, |
| 6147 | void *binary) |
| 6148 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6149 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6150 | ASSERT(programObject != nullptr); |
| 6151 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6152 | ANGLE_CONTEXT_TRY(programObject->saveBinary(this, binaryFormat, binary, bufSize, length)); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6153 | } |
| 6154 | |
| 6155 | void Context::programBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length) |
| 6156 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6157 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6158 | ASSERT(programObject != nullptr); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 6159 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6160 | ANGLE_CONTEXT_TRY(programObject->loadBinary(this, binaryFormat, binary, length)); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6161 | if (programObject->isInUse()) |
| 6162 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6163 | ANGLE_CONTEXT_TRY(mState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 6164 | mStateCache.onProgramExecutableChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6165 | } |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6166 | } |
| 6167 | |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6168 | void Context::uniform1ui(GLint location, GLuint v0) |
| 6169 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6170 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6171 | program->setUniform1uiv(location, 1, &v0); |
| 6172 | } |
| 6173 | |
| 6174 | void Context::uniform2ui(GLint location, GLuint v0, GLuint v1) |
| 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 xy[] = {v0, v1}; |
| 6178 | program->setUniform2uiv(location, 1, xy); |
| 6179 | } |
| 6180 | |
| 6181 | void Context::uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 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 | const GLuint xyz[] = {v0, v1, v2}; |
| 6185 | program->setUniform3uiv(location, 1, xyz); |
| 6186 | } |
| 6187 | |
| 6188 | void Context::uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 6189 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6190 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6191 | const GLuint xyzw[] = {v0, v1, v2, v3}; |
| 6192 | program->setUniform4uiv(location, 1, xyzw); |
| 6193 | } |
| 6194 | |
| 6195 | void Context::uniform1uiv(GLint location, GLsizei count, const GLuint *value) |
| 6196 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6197 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6198 | program->setUniform1uiv(location, count, value); |
| 6199 | } |
| 6200 | void Context::uniform2uiv(GLint location, GLsizei count, const GLuint *value) |
| 6201 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6202 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6203 | program->setUniform2uiv(location, count, value); |
| 6204 | } |
| 6205 | |
| 6206 | void Context::uniform3uiv(GLint location, GLsizei count, const GLuint *value) |
| 6207 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6208 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6209 | program->setUniform3uiv(location, count, value); |
| 6210 | } |
| 6211 | |
| 6212 | void Context::uniform4uiv(GLint location, GLsizei count, const GLuint *value) |
| 6213 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6214 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6215 | program->setUniform4uiv(location, count, value); |
| 6216 | } |
| 6217 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6218 | void Context::genQueries(GLsizei n, GLuint *ids) |
| 6219 | { |
| 6220 | for (GLsizei i = 0; i < n; i++) |
| 6221 | { |
| 6222 | GLuint handle = mQueryHandleAllocator.allocate(); |
| 6223 | mQueryMap.assign(handle, nullptr); |
| 6224 | ids[i] = handle; |
| 6225 | } |
| 6226 | } |
| 6227 | |
| 6228 | void Context::deleteQueries(GLsizei n, const GLuint *ids) |
| 6229 | { |
| 6230 | for (int i = 0; i < n; i++) |
| 6231 | { |
| 6232 | GLuint query = ids[i]; |
| 6233 | |
| 6234 | Query *queryObject = nullptr; |
| 6235 | if (mQueryMap.erase(query, &queryObject)) |
| 6236 | { |
| 6237 | mQueryHandleAllocator.release(query); |
| 6238 | if (queryObject) |
| 6239 | { |
| 6240 | queryObject->release(this); |
| 6241 | } |
| 6242 | } |
| 6243 | } |
| 6244 | } |
| 6245 | |
| 6246 | GLboolean Context::isQuery(GLuint id) |
| 6247 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 6248 | return (getQuery(id, false, QueryType::InvalidEnum) != nullptr) ? GL_TRUE : GL_FALSE; |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6249 | } |
| 6250 | |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6251 | void Context::uniformMatrix2x3fv(GLint location, |
| 6252 | GLsizei count, |
| 6253 | GLboolean transpose, |
| 6254 | const GLfloat *value) |
| 6255 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6256 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6257 | program->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6258 | } |
| 6259 | |
| 6260 | void Context::uniformMatrix3x2fv(GLint location, |
| 6261 | GLsizei count, |
| 6262 | GLboolean transpose, |
| 6263 | const GLfloat *value) |
| 6264 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6265 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6266 | program->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6267 | } |
| 6268 | |
| 6269 | void Context::uniformMatrix2x4fv(GLint location, |
| 6270 | GLsizei count, |
| 6271 | GLboolean transpose, |
| 6272 | const GLfloat *value) |
| 6273 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6274 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6275 | program->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6276 | } |
| 6277 | |
| 6278 | void Context::uniformMatrix4x2fv(GLint location, |
| 6279 | GLsizei count, |
| 6280 | GLboolean transpose, |
| 6281 | const GLfloat *value) |
| 6282 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6283 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6284 | program->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6285 | } |
| 6286 | |
| 6287 | void Context::uniformMatrix3x4fv(GLint location, |
| 6288 | GLsizei count, |
| 6289 | GLboolean transpose, |
| 6290 | const GLfloat *value) |
| 6291 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6292 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6293 | program->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6294 | } |
| 6295 | |
| 6296 | void Context::uniformMatrix4x3fv(GLint location, |
| 6297 | GLsizei count, |
| 6298 | GLboolean transpose, |
| 6299 | const GLfloat *value) |
| 6300 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6301 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6302 | program->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6303 | } |
| 6304 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 6305 | void Context::deleteVertexArrays(GLsizei n, const GLuint *arrays) |
| 6306 | { |
| 6307 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6308 | { |
| 6309 | GLuint vertexArray = arrays[arrayIndex]; |
| 6310 | |
| 6311 | if (arrays[arrayIndex] != 0) |
| 6312 | { |
| 6313 | VertexArray *vertexArrayObject = nullptr; |
| 6314 | if (mVertexArrayMap.erase(vertexArray, &vertexArrayObject)) |
| 6315 | { |
| 6316 | if (vertexArrayObject != nullptr) |
| 6317 | { |
| 6318 | detachVertexArray(vertexArray); |
| 6319 | vertexArrayObject->onDestroy(this); |
| 6320 | } |
| 6321 | |
| 6322 | mVertexArrayHandleAllocator.release(vertexArray); |
| 6323 | } |
| 6324 | } |
| 6325 | } |
| 6326 | } |
| 6327 | |
| 6328 | void Context::genVertexArrays(GLsizei n, GLuint *arrays) |
| 6329 | { |
| 6330 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6331 | { |
| 6332 | GLuint vertexArray = mVertexArrayHandleAllocator.allocate(); |
| 6333 | mVertexArrayMap.assign(vertexArray, nullptr); |
| 6334 | arrays[arrayIndex] = vertexArray; |
| 6335 | } |
| 6336 | } |
| 6337 | |
| 6338 | bool Context::isVertexArray(GLuint array) |
| 6339 | { |
| 6340 | if (array == 0) |
| 6341 | { |
| 6342 | return GL_FALSE; |
| 6343 | } |
| 6344 | |
| 6345 | VertexArray *vao = getVertexArray(array); |
| 6346 | return (vao != nullptr ? GL_TRUE : GL_FALSE); |
| 6347 | } |
| 6348 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6349 | void Context::endTransformFeedback() |
| 6350 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6351 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6352 | ANGLE_CONTEXT_TRY(transformFeedback->end(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6353 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6354 | } |
| 6355 | |
| 6356 | void Context::transformFeedbackVaryings(GLuint program, |
| 6357 | GLsizei count, |
| 6358 | const GLchar *const *varyings, |
| 6359 | GLenum bufferMode) |
| 6360 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6361 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6362 | ASSERT(programObject); |
| 6363 | programObject->setTransformFeedbackVaryings(count, varyings, bufferMode); |
| 6364 | } |
| 6365 | |
| 6366 | void Context::getTransformFeedbackVarying(GLuint program, |
| 6367 | GLuint index, |
| 6368 | GLsizei bufSize, |
| 6369 | GLsizei *length, |
| 6370 | GLsizei *size, |
| 6371 | GLenum *type, |
| 6372 | GLchar *name) |
| 6373 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6374 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6375 | ASSERT(programObject); |
| 6376 | programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name); |
| 6377 | } |
| 6378 | |
| 6379 | void Context::deleteTransformFeedbacks(GLsizei n, const GLuint *ids) |
| 6380 | { |
| 6381 | for (int i = 0; i < n; i++) |
| 6382 | { |
| 6383 | GLuint transformFeedback = ids[i]; |
| 6384 | if (transformFeedback == 0) |
| 6385 | { |
| 6386 | continue; |
| 6387 | } |
| 6388 | |
| 6389 | TransformFeedback *transformFeedbackObject = nullptr; |
| 6390 | if (mTransformFeedbackMap.erase(transformFeedback, &transformFeedbackObject)) |
| 6391 | { |
| 6392 | if (transformFeedbackObject != nullptr) |
| 6393 | { |
| 6394 | detachTransformFeedback(transformFeedback); |
| 6395 | transformFeedbackObject->release(this); |
| 6396 | } |
| 6397 | |
| 6398 | mTransformFeedbackHandleAllocator.release(transformFeedback); |
| 6399 | } |
| 6400 | } |
| 6401 | } |
| 6402 | |
| 6403 | void Context::genTransformFeedbacks(GLsizei n, GLuint *ids) |
| 6404 | { |
| 6405 | for (int i = 0; i < n; i++) |
| 6406 | { |
| 6407 | GLuint transformFeedback = mTransformFeedbackHandleAllocator.allocate(); |
| 6408 | mTransformFeedbackMap.assign(transformFeedback, nullptr); |
| 6409 | ids[i] = transformFeedback; |
| 6410 | } |
| 6411 | } |
| 6412 | |
| 6413 | bool Context::isTransformFeedback(GLuint id) |
| 6414 | { |
| 6415 | if (id == 0) |
| 6416 | { |
| 6417 | // The 3.0.4 spec [section 6.1.11] states that if ID is zero, IsTransformFeedback |
| 6418 | // returns FALSE |
| 6419 | return GL_FALSE; |
| 6420 | } |
| 6421 | |
| 6422 | const TransformFeedback *transformFeedback = getTransformFeedback(id); |
| 6423 | return ((transformFeedback != nullptr) ? GL_TRUE : GL_FALSE); |
| 6424 | } |
| 6425 | |
| 6426 | void Context::pauseTransformFeedback() |
| 6427 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6428 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6429 | ANGLE_CONTEXT_TRY(transformFeedback->pause(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6430 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6431 | } |
| 6432 | |
| 6433 | void Context::resumeTransformFeedback() |
| 6434 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6435 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6436 | ANGLE_CONTEXT_TRY(transformFeedback->resume(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6437 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6438 | } |
| 6439 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6440 | void Context::getUniformuiv(GLuint program, GLint location, GLuint *params) |
| 6441 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6442 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 6443 | programObject->getUniformuiv(this, location, params); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6444 | } |
| 6445 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6446 | void Context::getUniformuivRobust(GLuint program, |
| 6447 | GLint location, |
| 6448 | GLsizei bufSize, |
| 6449 | GLsizei *length, |
| 6450 | GLuint *params) |
| 6451 | { |
| 6452 | getUniformuiv(program, location, params); |
| 6453 | } |
| 6454 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6455 | GLint Context::getFragDataLocation(GLuint program, const GLchar *name) |
| 6456 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6457 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6458 | return programObject->getFragDataLocation(name); |
| 6459 | } |
| 6460 | |
| 6461 | void Context::getUniformIndices(GLuint program, |
| 6462 | GLsizei uniformCount, |
| 6463 | const GLchar *const *uniformNames, |
| 6464 | GLuint *uniformIndices) |
| 6465 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6466 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6467 | if (!programObject->isLinked()) |
| 6468 | { |
| 6469 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6470 | { |
| 6471 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 6472 | } |
| 6473 | } |
| 6474 | else |
| 6475 | { |
| 6476 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6477 | { |
| 6478 | uniformIndices[uniformId] = programObject->getUniformIndex(uniformNames[uniformId]); |
| 6479 | } |
| 6480 | } |
| 6481 | } |
| 6482 | |
| 6483 | void Context::getActiveUniformsiv(GLuint program, |
| 6484 | GLsizei uniformCount, |
| 6485 | const GLuint *uniformIndices, |
| 6486 | GLenum pname, |
| 6487 | GLint *params) |
| 6488 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6489 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6490 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6491 | { |
| 6492 | const GLuint index = uniformIndices[uniformId]; |
jchen10 | baf5d94 | 2017-08-28 20:45:48 +0800 | [diff] [blame] | 6493 | params[uniformId] = GetUniformResourceProperty(programObject, index, pname); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6494 | } |
| 6495 | } |
| 6496 | |
| 6497 | GLuint Context::getUniformBlockIndex(GLuint program, const GLchar *uniformBlockName) |
| 6498 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6499 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6500 | return programObject->getUniformBlockIndex(uniformBlockName); |
| 6501 | } |
| 6502 | |
| 6503 | void Context::getActiveUniformBlockiv(GLuint program, |
| 6504 | GLuint uniformBlockIndex, |
| 6505 | GLenum pname, |
| 6506 | GLint *params) |
| 6507 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6508 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6509 | QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params); |
| 6510 | } |
| 6511 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6512 | void Context::getActiveUniformBlockivRobust(GLuint program, |
| 6513 | GLuint uniformBlockIndex, |
| 6514 | GLenum pname, |
| 6515 | GLsizei bufSize, |
| 6516 | GLsizei *length, |
| 6517 | GLint *params) |
| 6518 | { |
| 6519 | getActiveUniformBlockiv(program, uniformBlockIndex, pname, params); |
| 6520 | } |
| 6521 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6522 | void Context::getActiveUniformBlockName(GLuint program, |
| 6523 | GLuint uniformBlockIndex, |
| 6524 | GLsizei bufSize, |
| 6525 | GLsizei *length, |
| 6526 | GLchar *uniformBlockName) |
| 6527 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6528 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6529 | programObject->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 6530 | } |
| 6531 | |
| 6532 | void Context::uniformBlockBinding(GLuint program, |
| 6533 | GLuint uniformBlockIndex, |
| 6534 | GLuint uniformBlockBinding) |
| 6535 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6536 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6537 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6538 | |
Jamie Madill | 956ab4d | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 6539 | // 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] | 6540 | if (programObject->isInUse()) |
| 6541 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6542 | mState.setObjectDirty(GL_PROGRAM); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 6543 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6544 | } |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6545 | } |
| 6546 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6547 | GLsync Context::fenceSync(GLenum condition, GLbitfield flags) |
| 6548 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6549 | GLuint handle = mState.mSyncManager->createSync(mImplementation.get()); |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6550 | GLsync syncHandle = reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6551 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6552 | Sync *syncObject = getSync(syncHandle); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 6553 | if (syncObject->set(this, condition, flags) == angle::Result::Stop) |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6554 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6555 | deleteSync(syncHandle); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6556 | return nullptr; |
| 6557 | } |
| 6558 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6559 | return syncHandle; |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6560 | } |
| 6561 | |
| 6562 | GLboolean Context::isSync(GLsync sync) |
| 6563 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6564 | return (getSync(sync) != nullptr); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6565 | } |
| 6566 | |
| 6567 | GLenum Context::clientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6568 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6569 | Sync *syncObject = getSync(sync); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6570 | |
| 6571 | GLenum result = GL_WAIT_FAILED; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 6572 | if (syncObject->clientWait(this, flags, timeout, &result) == angle::Result::Stop) |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6573 | { |
| 6574 | return GL_WAIT_FAILED; |
| 6575 | } |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6576 | return result; |
| 6577 | } |
| 6578 | |
| 6579 | void Context::waitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6580 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6581 | Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6582 | ANGLE_CONTEXT_TRY(syncObject->serverWait(this, flags, timeout)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6583 | } |
| 6584 | |
| 6585 | void Context::getInteger64v(GLenum pname, GLint64 *params) |
| 6586 | { |
| 6587 | GLenum nativeType = GL_NONE; |
| 6588 | unsigned int numParams = 0; |
| 6589 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 6590 | |
| 6591 | if (nativeType == GL_INT_64_ANGLEX) |
| 6592 | { |
| 6593 | getInteger64vImpl(pname, params); |
| 6594 | } |
| 6595 | else |
| 6596 | { |
| 6597 | CastStateValues(this, nativeType, pname, numParams, params); |
| 6598 | } |
| 6599 | } |
| 6600 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6601 | void Context::getInteger64vRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint64 *data) |
| 6602 | { |
| 6603 | getInteger64v(pname, data); |
| 6604 | } |
| 6605 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 6606 | void Context::getBufferParameteri64v(BufferBinding target, GLenum pname, GLint64 *params) |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6607 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6608 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6609 | QueryBufferParameteri64v(buffer, pname, params); |
| 6610 | } |
| 6611 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6612 | void Context::getBufferParameteri64vRobust(BufferBinding target, |
| 6613 | GLenum pname, |
| 6614 | GLsizei bufSize, |
| 6615 | GLsizei *length, |
| 6616 | GLint64 *params) |
| 6617 | { |
| 6618 | getBufferParameteri64v(target, pname, params); |
| 6619 | } |
| 6620 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6621 | void Context::genSamplers(GLsizei count, GLuint *samplers) |
| 6622 | { |
| 6623 | for (int i = 0; i < count; i++) |
| 6624 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6625 | samplers[i] = mState.mSamplerManager->createSampler(); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6626 | } |
| 6627 | } |
| 6628 | |
| 6629 | void Context::deleteSamplers(GLsizei count, const GLuint *samplers) |
| 6630 | { |
| 6631 | for (int i = 0; i < count; i++) |
| 6632 | { |
| 6633 | GLuint sampler = samplers[i]; |
| 6634 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6635 | if (mState.mSamplerManager->getSampler(sampler)) |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6636 | { |
| 6637 | detachSampler(sampler); |
| 6638 | } |
| 6639 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6640 | mState.mSamplerManager->deleteObject(this, sampler); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6641 | } |
| 6642 | } |
| 6643 | |
| 6644 | void Context::getInternalformativ(GLenum target, |
| 6645 | GLenum internalformat, |
| 6646 | GLenum pname, |
| 6647 | GLsizei bufSize, |
| 6648 | GLint *params) |
| 6649 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6650 | const TextureCaps &formatCaps = mState.mTextureCaps.get(internalformat); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6651 | QueryInternalFormativ(formatCaps, pname, bufSize, params); |
| 6652 | } |
| 6653 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6654 | void Context::getInternalformativRobust(GLenum target, |
| 6655 | GLenum internalformat, |
| 6656 | GLenum pname, |
| 6657 | GLsizei bufSize, |
| 6658 | GLsizei *length, |
| 6659 | GLint *params) |
| 6660 | { |
| 6661 | getInternalformativ(target, internalformat, pname, bufSize, params); |
| 6662 | } |
| 6663 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6664 | void Context::programUniform1i(GLuint program, GLint location, GLint v0) |
| 6665 | { |
| 6666 | programUniform1iv(program, location, 1, &v0); |
| 6667 | } |
| 6668 | |
| 6669 | void Context::programUniform2i(GLuint program, GLint location, GLint v0, GLint v1) |
| 6670 | { |
| 6671 | GLint xy[2] = {v0, v1}; |
| 6672 | programUniform2iv(program, location, 1, xy); |
| 6673 | } |
| 6674 | |
| 6675 | void Context::programUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2) |
| 6676 | { |
| 6677 | GLint xyz[3] = {v0, v1, v2}; |
| 6678 | programUniform3iv(program, location, 1, xyz); |
| 6679 | } |
| 6680 | |
| 6681 | void Context::programUniform4i(GLuint program, |
| 6682 | GLint location, |
| 6683 | GLint v0, |
| 6684 | GLint v1, |
| 6685 | GLint v2, |
| 6686 | GLint v3) |
| 6687 | { |
| 6688 | GLint xyzw[4] = {v0, v1, v2, v3}; |
| 6689 | programUniform4iv(program, location, 1, xyzw); |
| 6690 | } |
| 6691 | |
| 6692 | void Context::programUniform1ui(GLuint program, GLint location, GLuint v0) |
| 6693 | { |
| 6694 | programUniform1uiv(program, location, 1, &v0); |
| 6695 | } |
| 6696 | |
| 6697 | void Context::programUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1) |
| 6698 | { |
| 6699 | GLuint xy[2] = {v0, v1}; |
| 6700 | programUniform2uiv(program, location, 1, xy); |
| 6701 | } |
| 6702 | |
| 6703 | void Context::programUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6704 | { |
| 6705 | GLuint xyz[3] = {v0, v1, v2}; |
| 6706 | programUniform3uiv(program, location, 1, xyz); |
| 6707 | } |
| 6708 | |
| 6709 | void Context::programUniform4ui(GLuint program, |
| 6710 | GLint location, |
| 6711 | GLuint v0, |
| 6712 | GLuint v1, |
| 6713 | GLuint v2, |
| 6714 | GLuint v3) |
| 6715 | { |
| 6716 | GLuint xyzw[4] = {v0, v1, v2, v3}; |
| 6717 | programUniform4uiv(program, location, 1, xyzw); |
| 6718 | } |
| 6719 | |
| 6720 | void Context::programUniform1f(GLuint program, GLint location, GLfloat v0) |
| 6721 | { |
| 6722 | programUniform1fv(program, location, 1, &v0); |
| 6723 | } |
| 6724 | |
| 6725 | void Context::programUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1) |
| 6726 | { |
| 6727 | GLfloat xy[2] = {v0, v1}; |
| 6728 | programUniform2fv(program, location, 1, xy); |
| 6729 | } |
| 6730 | |
| 6731 | void Context::programUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) |
| 6732 | { |
| 6733 | GLfloat xyz[3] = {v0, v1, v2}; |
| 6734 | programUniform3fv(program, location, 1, xyz); |
| 6735 | } |
| 6736 | |
| 6737 | void Context::programUniform4f(GLuint program, |
| 6738 | GLint location, |
| 6739 | GLfloat v0, |
| 6740 | GLfloat v1, |
| 6741 | GLfloat v2, |
| 6742 | GLfloat v3) |
| 6743 | { |
| 6744 | GLfloat xyzw[4] = {v0, v1, v2, v3}; |
| 6745 | programUniform4fv(program, location, 1, xyzw); |
| 6746 | } |
| 6747 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6748 | void Context::programUniform1iv(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); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6751 | ASSERT(programObject); |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6752 | setUniform1iImpl(programObject, location, count, value); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6753 | } |
| 6754 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6755 | void Context::programUniform2iv(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->setUniform2iv(location, count, value); |
| 6760 | } |
| 6761 | |
| 6762 | void Context::programUniform3iv(GLuint program, GLint location, GLsizei count, const GLint *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->setUniform3iv(location, count, value); |
| 6767 | } |
| 6768 | |
| 6769 | void Context::programUniform4iv(GLuint program, GLint location, GLsizei count, const GLint *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->setUniform4iv(location, count, value); |
| 6774 | } |
| 6775 | |
| 6776 | void Context::programUniform1uiv(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->setUniform1uiv(location, count, value); |
| 6781 | } |
| 6782 | |
| 6783 | void Context::programUniform2uiv(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->setUniform2uiv(location, count, value); |
| 6788 | } |
| 6789 | |
| 6790 | void Context::programUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint *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->setUniform3uiv(location, count, value); |
| 6795 | } |
| 6796 | |
| 6797 | void Context::programUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint *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->setUniform4uiv(location, count, value); |
| 6802 | } |
| 6803 | |
| 6804 | void Context::programUniform1fv(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->setUniform1fv(location, count, value); |
| 6809 | } |
| 6810 | |
| 6811 | void Context::programUniform2fv(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->setUniform2fv(location, count, value); |
| 6816 | } |
| 6817 | |
| 6818 | void Context::programUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6819 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6820 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6821 | ASSERT(programObject); |
| 6822 | programObject->setUniform3fv(location, count, value); |
| 6823 | } |
| 6824 | |
| 6825 | void Context::programUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6826 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6827 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6828 | ASSERT(programObject); |
| 6829 | programObject->setUniform4fv(location, count, value); |
| 6830 | } |
| 6831 | |
| 6832 | void Context::programUniformMatrix2fv(GLuint program, |
| 6833 | GLint location, |
| 6834 | GLsizei count, |
| 6835 | GLboolean transpose, |
| 6836 | const GLfloat *value) |
| 6837 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6838 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6839 | ASSERT(programObject); |
| 6840 | programObject->setUniformMatrix2fv(location, count, transpose, value); |
| 6841 | } |
| 6842 | |
| 6843 | void Context::programUniformMatrix3fv(GLuint program, |
| 6844 | GLint location, |
| 6845 | GLsizei count, |
| 6846 | GLboolean transpose, |
| 6847 | const GLfloat *value) |
| 6848 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6849 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6850 | ASSERT(programObject); |
| 6851 | programObject->setUniformMatrix3fv(location, count, transpose, value); |
| 6852 | } |
| 6853 | |
| 6854 | void Context::programUniformMatrix4fv(GLuint program, |
| 6855 | GLint location, |
| 6856 | GLsizei count, |
| 6857 | GLboolean transpose, |
| 6858 | const GLfloat *value) |
| 6859 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6860 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6861 | ASSERT(programObject); |
| 6862 | programObject->setUniformMatrix4fv(location, count, transpose, value); |
| 6863 | } |
| 6864 | |
| 6865 | void Context::programUniformMatrix2x3fv(GLuint program, |
| 6866 | GLint location, |
| 6867 | GLsizei count, |
| 6868 | GLboolean transpose, |
| 6869 | const GLfloat *value) |
| 6870 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6871 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6872 | ASSERT(programObject); |
| 6873 | programObject->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6874 | } |
| 6875 | |
| 6876 | void Context::programUniformMatrix3x2fv(GLuint program, |
| 6877 | GLint location, |
| 6878 | GLsizei count, |
| 6879 | GLboolean transpose, |
| 6880 | const GLfloat *value) |
| 6881 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6882 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6883 | ASSERT(programObject); |
| 6884 | programObject->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6885 | } |
| 6886 | |
| 6887 | void Context::programUniformMatrix2x4fv(GLuint program, |
| 6888 | GLint location, |
| 6889 | GLsizei count, |
| 6890 | GLboolean transpose, |
| 6891 | const GLfloat *value) |
| 6892 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6893 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6894 | ASSERT(programObject); |
| 6895 | programObject->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6896 | } |
| 6897 | |
| 6898 | void Context::programUniformMatrix4x2fv(GLuint program, |
| 6899 | GLint location, |
| 6900 | GLsizei count, |
| 6901 | GLboolean transpose, |
| 6902 | const GLfloat *value) |
| 6903 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6904 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6905 | ASSERT(programObject); |
| 6906 | programObject->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6907 | } |
| 6908 | |
| 6909 | void Context::programUniformMatrix3x4fv(GLuint program, |
| 6910 | GLint location, |
| 6911 | GLsizei count, |
| 6912 | GLboolean transpose, |
| 6913 | const GLfloat *value) |
| 6914 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6915 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6916 | ASSERT(programObject); |
| 6917 | programObject->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6918 | } |
| 6919 | |
| 6920 | void Context::programUniformMatrix4x3fv(GLuint program, |
| 6921 | GLint location, |
| 6922 | GLsizei count, |
| 6923 | GLboolean transpose, |
| 6924 | const GLfloat *value) |
| 6925 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6926 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6927 | ASSERT(programObject); |
| 6928 | programObject->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6929 | } |
| 6930 | |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6931 | bool Context::isCurrentTransformFeedback(const TransformFeedback *tf) const |
| 6932 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6933 | return mState.isCurrentTransformFeedback(tf); |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6934 | } |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6935 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 6936 | void Context::genProgramPipelines(GLsizei count, GLuint *pipelines) |
| 6937 | { |
| 6938 | for (int i = 0; i < count; i++) |
| 6939 | { |
| 6940 | pipelines[i] = createProgramPipeline(); |
| 6941 | } |
| 6942 | } |
| 6943 | |
| 6944 | void Context::deleteProgramPipelines(GLsizei count, const GLuint *pipelines) |
| 6945 | { |
| 6946 | for (int i = 0; i < count; i++) |
| 6947 | { |
| 6948 | if (pipelines[i] != 0) |
| 6949 | { |
| 6950 | deleteProgramPipeline(pipelines[i]); |
| 6951 | } |
| 6952 | } |
| 6953 | } |
| 6954 | |
| 6955 | GLboolean Context::isProgramPipeline(GLuint pipeline) |
| 6956 | { |
| 6957 | if (pipeline == 0) |
| 6958 | { |
| 6959 | return GL_FALSE; |
| 6960 | } |
| 6961 | |
| 6962 | return (getProgramPipeline(pipeline) ? GL_TRUE : GL_FALSE); |
| 6963 | } |
| 6964 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6965 | void Context::finishFenceNV(GLuint fence) |
| 6966 | { |
| 6967 | FenceNV *fenceObject = getFenceNV(fence); |
| 6968 | |
| 6969 | ASSERT(fenceObject && fenceObject->isSet()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6970 | ANGLE_CONTEXT_TRY(fenceObject->finish(this)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6971 | } |
| 6972 | |
| 6973 | void Context::getFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 6974 | { |
| 6975 | FenceNV *fenceObject = getFenceNV(fence); |
| 6976 | |
| 6977 | ASSERT(fenceObject && fenceObject->isSet()); |
| 6978 | |
| 6979 | switch (pname) |
| 6980 | { |
| 6981 | case GL_FENCE_STATUS_NV: |
| 6982 | { |
| 6983 | // GL_NV_fence spec: |
| 6984 | // Once the status of a fence has been finished (via FinishFenceNV) or tested and |
| 6985 | // the returned status is TRUE (via either TestFenceNV or GetFenceivNV querying the |
| 6986 | // FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence. |
| 6987 | GLboolean status = GL_TRUE; |
| 6988 | if (fenceObject->getStatus() != GL_TRUE) |
| 6989 | { |
Jamie Madill | a0691b7 | 2018-07-25 10:41:22 -0400 | [diff] [blame] | 6990 | ANGLE_CONTEXT_TRY(fenceObject->test(this, &status)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6991 | } |
| 6992 | *params = status; |
| 6993 | break; |
| 6994 | } |
| 6995 | |
| 6996 | case GL_FENCE_CONDITION_NV: |
| 6997 | { |
| 6998 | *params = static_cast<GLint>(fenceObject->getCondition()); |
| 6999 | break; |
| 7000 | } |
| 7001 | |
| 7002 | default: |
| 7003 | UNREACHABLE(); |
| 7004 | } |
| 7005 | } |
| 7006 | |
| 7007 | void Context::getTranslatedShaderSource(GLuint shader, |
| 7008 | GLsizei bufsize, |
| 7009 | GLsizei *length, |
| 7010 | GLchar *source) |
| 7011 | { |
| 7012 | Shader *shaderObject = getShader(shader); |
| 7013 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 7014 | shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7015 | } |
| 7016 | |
| 7017 | void Context::getnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params) |
| 7018 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7019 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7020 | ASSERT(programObject); |
| 7021 | |
| 7022 | programObject->getUniformfv(this, location, params); |
| 7023 | } |
| 7024 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7025 | void Context::getnUniformfvRobust(GLuint program, |
| 7026 | GLint location, |
| 7027 | GLsizei bufSize, |
| 7028 | GLsizei *length, |
| 7029 | GLfloat *params) |
| 7030 | { |
| 7031 | UNIMPLEMENTED(); |
| 7032 | } |
| 7033 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7034 | void Context::getnUniformiv(GLuint program, GLint location, GLsizei bufSize, GLint *params) |
| 7035 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7036 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7037 | ASSERT(programObject); |
| 7038 | |
| 7039 | programObject->getUniformiv(this, location, params); |
| 7040 | } |
| 7041 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7042 | void Context::getnUniformivRobust(GLuint program, |
| 7043 | GLint location, |
| 7044 | GLsizei bufSize, |
| 7045 | GLsizei *length, |
| 7046 | GLint *params) |
| 7047 | { |
| 7048 | UNIMPLEMENTED(); |
| 7049 | } |
| 7050 | |
| 7051 | void Context::getnUniformuivRobust(GLuint program, |
| 7052 | GLint location, |
| 7053 | GLsizei bufSize, |
| 7054 | GLsizei *length, |
| 7055 | GLuint *params) |
| 7056 | { |
| 7057 | UNIMPLEMENTED(); |
| 7058 | } |
| 7059 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7060 | GLboolean Context::isFenceNV(GLuint fence) |
| 7061 | { |
| 7062 | FenceNV *fenceObject = getFenceNV(fence); |
| 7063 | |
| 7064 | if (fenceObject == nullptr) |
| 7065 | { |
| 7066 | return GL_FALSE; |
| 7067 | } |
| 7068 | |
| 7069 | // GL_NV_fence spec: |
| 7070 | // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an |
| 7071 | // existing fence. |
| 7072 | return fenceObject->isSet(); |
| 7073 | } |
| 7074 | |
| 7075 | void Context::readnPixels(GLint x, |
| 7076 | GLint y, |
| 7077 | GLsizei width, |
| 7078 | GLsizei height, |
| 7079 | GLenum format, |
| 7080 | GLenum type, |
| 7081 | GLsizei bufSize, |
| 7082 | void *data) |
| 7083 | { |
| 7084 | return readPixels(x, y, width, height, format, type, data); |
| 7085 | } |
| 7086 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7087 | void Context::setFenceNV(GLuint fence, GLenum condition) |
| 7088 | { |
| 7089 | ASSERT(condition == GL_ALL_COMPLETED_NV); |
| 7090 | |
| 7091 | FenceNV *fenceObject = getFenceNV(fence); |
| 7092 | ASSERT(fenceObject != nullptr); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7093 | ANGLE_CONTEXT_TRY(fenceObject->set(this, condition)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7094 | } |
| 7095 | |
| 7096 | GLboolean Context::testFenceNV(GLuint fence) |
| 7097 | { |
| 7098 | FenceNV *fenceObject = getFenceNV(fence); |
| 7099 | |
| 7100 | ASSERT(fenceObject != nullptr); |
| 7101 | ASSERT(fenceObject->isSet() == GL_TRUE); |
| 7102 | |
| 7103 | GLboolean result = GL_TRUE; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 7104 | if (fenceObject->test(this, &result) == angle::Result::Stop) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7105 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7106 | return GL_TRUE; |
| 7107 | } |
| 7108 | |
| 7109 | return result; |
| 7110 | } |
| 7111 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 7112 | void Context::eGLImageTargetTexture2D(TextureType target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7113 | { |
| 7114 | Texture *texture = getTargetTexture(target); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7115 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7116 | ANGLE_CONTEXT_TRY(texture->setEGLImageTarget(this, target, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7117 | } |
| 7118 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7119 | void Context::eGLImageTargetRenderbufferStorage(GLenum target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7120 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7121 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7122 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7123 | ANGLE_CONTEXT_TRY(renderbuffer->setStorageEGLImageTarget(this, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7124 | } |
| 7125 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7126 | void Context::texStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width) |
| 7127 | { |
| 7128 | UNIMPLEMENTED(); |
| 7129 | } |
| 7130 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7131 | bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) |
| 7132 | { |
| 7133 | // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation |
| 7134 | // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due |
| 7135 | // to the fact that it is stored internally as a float, and so would require conversion |
| 7136 | // if returned from Context::getIntegerv. Since this conversion is already implemented |
| 7137 | // in the case that one calls glGetIntegerv to retrieve a float-typed state variable, we |
| 7138 | // place DEPTH_CLEAR_VALUE with the floats. This should make no difference to the calling |
| 7139 | // application. |
| 7140 | switch (pname) |
| 7141 | { |
| 7142 | case GL_COMPRESSED_TEXTURE_FORMATS: |
| 7143 | { |
| 7144 | *type = GL_INT; |
| 7145 | *numParams = static_cast<unsigned int>(getCaps().compressedTextureFormats.size()); |
| 7146 | return true; |
| 7147 | } |
| 7148 | case GL_SHADER_BINARY_FORMATS: |
| 7149 | { |
| 7150 | *type = GL_INT; |
| 7151 | *numParams = static_cast<unsigned int>(getCaps().shaderBinaryFormats.size()); |
| 7152 | return true; |
| 7153 | } |
| 7154 | |
| 7155 | case GL_MAX_VERTEX_ATTRIBS: |
| 7156 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 7157 | case GL_MAX_VARYING_VECTORS: |
| 7158 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 7159 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 7160 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
| 7161 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 7162 | case GL_MAX_RENDERBUFFER_SIZE: |
| 7163 | case GL_NUM_SHADER_BINARY_FORMATS: |
| 7164 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 7165 | case GL_ARRAY_BUFFER_BINDING: |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7166 | case GL_FRAMEBUFFER_BINDING: // GL_FRAMEBUFFER_BINDING now equivalent to |
| 7167 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7168 | case GL_RENDERBUFFER_BINDING: |
| 7169 | case GL_CURRENT_PROGRAM: |
| 7170 | case GL_PACK_ALIGNMENT: |
| 7171 | case GL_UNPACK_ALIGNMENT: |
| 7172 | case GL_GENERATE_MIPMAP_HINT: |
| 7173 | case GL_RED_BITS: |
| 7174 | case GL_GREEN_BITS: |
| 7175 | case GL_BLUE_BITS: |
| 7176 | case GL_ALPHA_BITS: |
| 7177 | case GL_DEPTH_BITS: |
| 7178 | case GL_STENCIL_BITS: |
| 7179 | case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 7180 | case GL_CULL_FACE_MODE: |
| 7181 | case GL_FRONT_FACE: |
| 7182 | case GL_ACTIVE_TEXTURE: |
| 7183 | case GL_STENCIL_FUNC: |
| 7184 | case GL_STENCIL_VALUE_MASK: |
| 7185 | case GL_STENCIL_REF: |
| 7186 | case GL_STENCIL_FAIL: |
| 7187 | case GL_STENCIL_PASS_DEPTH_FAIL: |
| 7188 | case GL_STENCIL_PASS_DEPTH_PASS: |
| 7189 | case GL_STENCIL_BACK_FUNC: |
| 7190 | case GL_STENCIL_BACK_VALUE_MASK: |
| 7191 | case GL_STENCIL_BACK_REF: |
| 7192 | case GL_STENCIL_BACK_FAIL: |
| 7193 | case GL_STENCIL_BACK_PASS_DEPTH_FAIL: |
| 7194 | case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
| 7195 | case GL_DEPTH_FUNC: |
| 7196 | case GL_BLEND_SRC_RGB: |
| 7197 | case GL_BLEND_SRC_ALPHA: |
| 7198 | case GL_BLEND_DST_RGB: |
| 7199 | case GL_BLEND_DST_ALPHA: |
| 7200 | case GL_BLEND_EQUATION_RGB: |
| 7201 | case GL_BLEND_EQUATION_ALPHA: |
| 7202 | case GL_STENCIL_WRITEMASK: |
| 7203 | case GL_STENCIL_BACK_WRITEMASK: |
| 7204 | case GL_STENCIL_CLEAR_VALUE: |
| 7205 | case GL_SUBPIXEL_BITS: |
| 7206 | case GL_MAX_TEXTURE_SIZE: |
| 7207 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 7208 | case GL_SAMPLE_BUFFERS: |
| 7209 | case GL_SAMPLES: |
| 7210 | case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 7211 | case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 7212 | case GL_TEXTURE_BINDING_2D: |
| 7213 | case GL_TEXTURE_BINDING_CUBE_MAP: |
| 7214 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 7215 | { |
| 7216 | *type = GL_INT; |
| 7217 | *numParams = 1; |
| 7218 | return true; |
| 7219 | } |
| 7220 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 7221 | { |
| 7222 | if (!getExtensions().packReverseRowOrder) |
| 7223 | { |
| 7224 | return false; |
| 7225 | } |
| 7226 | *type = GL_INT; |
| 7227 | *numParams = 1; |
| 7228 | return true; |
| 7229 | } |
| 7230 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
| 7231 | case GL_TEXTURE_BINDING_RECTANGLE_ANGLE: |
| 7232 | { |
| 7233 | if (!getExtensions().textureRectangle) |
| 7234 | { |
| 7235 | return false; |
| 7236 | } |
| 7237 | *type = GL_INT; |
| 7238 | *numParams = 1; |
| 7239 | return true; |
| 7240 | } |
| 7241 | case GL_MAX_DRAW_BUFFERS_EXT: |
| 7242 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
| 7243 | { |
| 7244 | if ((getClientMajorVersion() < 3) && !getExtensions().drawBuffers) |
| 7245 | { |
| 7246 | return false; |
| 7247 | } |
| 7248 | *type = GL_INT; |
| 7249 | *numParams = 1; |
| 7250 | return true; |
| 7251 | } |
| 7252 | case GL_MAX_VIEWPORT_DIMS: |
| 7253 | { |
| 7254 | *type = GL_INT; |
| 7255 | *numParams = 2; |
| 7256 | return true; |
| 7257 | } |
| 7258 | case GL_VIEWPORT: |
| 7259 | case GL_SCISSOR_BOX: |
| 7260 | { |
| 7261 | *type = GL_INT; |
| 7262 | *numParams = 4; |
| 7263 | return true; |
| 7264 | } |
| 7265 | case GL_SHADER_COMPILER: |
| 7266 | case GL_SAMPLE_COVERAGE_INVERT: |
| 7267 | case GL_DEPTH_WRITEMASK: |
| 7268 | case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled, |
| 7269 | case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries. |
| 7270 | case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as |
| 7271 | // bool-natural |
| 7272 | case GL_SAMPLE_COVERAGE: |
| 7273 | case GL_SCISSOR_TEST: |
| 7274 | case GL_STENCIL_TEST: |
| 7275 | case GL_DEPTH_TEST: |
| 7276 | case GL_BLEND: |
| 7277 | case GL_DITHER: |
| 7278 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 7279 | { |
| 7280 | *type = GL_BOOL; |
| 7281 | *numParams = 1; |
| 7282 | return true; |
| 7283 | } |
| 7284 | case GL_COLOR_WRITEMASK: |
| 7285 | { |
| 7286 | *type = GL_BOOL; |
| 7287 | *numParams = 4; |
| 7288 | return true; |
| 7289 | } |
| 7290 | case GL_POLYGON_OFFSET_FACTOR: |
| 7291 | case GL_POLYGON_OFFSET_UNITS: |
| 7292 | case GL_SAMPLE_COVERAGE_VALUE: |
| 7293 | case GL_DEPTH_CLEAR_VALUE: |
| 7294 | case GL_LINE_WIDTH: |
| 7295 | { |
| 7296 | *type = GL_FLOAT; |
| 7297 | *numParams = 1; |
| 7298 | return true; |
| 7299 | } |
| 7300 | case GL_ALIASED_LINE_WIDTH_RANGE: |
| 7301 | case GL_ALIASED_POINT_SIZE_RANGE: |
| 7302 | case GL_DEPTH_RANGE: |
| 7303 | { |
| 7304 | *type = GL_FLOAT; |
| 7305 | *numParams = 2; |
| 7306 | return true; |
| 7307 | } |
| 7308 | case GL_COLOR_CLEAR_VALUE: |
| 7309 | case GL_BLEND_COLOR: |
| 7310 | { |
| 7311 | *type = GL_FLOAT; |
| 7312 | *numParams = 4; |
| 7313 | return true; |
| 7314 | } |
| 7315 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7316 | if (!getExtensions().textureFilterAnisotropic) |
| 7317 | { |
| 7318 | return false; |
| 7319 | } |
| 7320 | *type = GL_FLOAT; |
| 7321 | *numParams = 1; |
| 7322 | return true; |
| 7323 | case GL_TIMESTAMP_EXT: |
| 7324 | if (!getExtensions().disjointTimerQuery) |
| 7325 | { |
| 7326 | return false; |
| 7327 | } |
| 7328 | *type = GL_INT_64_ANGLEX; |
| 7329 | *numParams = 1; |
| 7330 | return true; |
| 7331 | case GL_GPU_DISJOINT_EXT: |
| 7332 | if (!getExtensions().disjointTimerQuery) |
| 7333 | { |
| 7334 | return false; |
| 7335 | } |
| 7336 | *type = GL_INT; |
| 7337 | *numParams = 1; |
| 7338 | return true; |
| 7339 | case GL_COVERAGE_MODULATION_CHROMIUM: |
| 7340 | if (!getExtensions().framebufferMixedSamples) |
| 7341 | { |
| 7342 | return false; |
| 7343 | } |
| 7344 | *type = GL_INT; |
| 7345 | *numParams = 1; |
| 7346 | return true; |
| 7347 | case GL_TEXTURE_BINDING_EXTERNAL_OES: |
| 7348 | if (!getExtensions().eglStreamConsumerExternal && !getExtensions().eglImageExternal) |
| 7349 | { |
| 7350 | return false; |
| 7351 | } |
| 7352 | *type = GL_INT; |
| 7353 | *numParams = 1; |
| 7354 | return true; |
| 7355 | } |
| 7356 | |
| 7357 | if (getExtensions().debug) |
| 7358 | { |
| 7359 | switch (pname) |
| 7360 | { |
| 7361 | case GL_DEBUG_LOGGED_MESSAGES: |
| 7362 | case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: |
| 7363 | case GL_DEBUG_GROUP_STACK_DEPTH: |
| 7364 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 7365 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 7366 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 7367 | case GL_MAX_LABEL_LENGTH: |
| 7368 | *type = GL_INT; |
| 7369 | *numParams = 1; |
| 7370 | return true; |
| 7371 | |
| 7372 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 7373 | case GL_DEBUG_OUTPUT: |
| 7374 | *type = GL_BOOL; |
| 7375 | *numParams = 1; |
| 7376 | return true; |
| 7377 | } |
| 7378 | } |
| 7379 | |
| 7380 | if (getExtensions().multisampleCompatibility) |
| 7381 | { |
| 7382 | switch (pname) |
| 7383 | { |
| 7384 | case GL_MULTISAMPLE_EXT: |
| 7385 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 7386 | *type = GL_BOOL; |
| 7387 | *numParams = 1; |
| 7388 | return true; |
| 7389 | } |
| 7390 | } |
| 7391 | |
| 7392 | if (getExtensions().pathRendering) |
| 7393 | { |
| 7394 | switch (pname) |
| 7395 | { |
| 7396 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 7397 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 7398 | *type = GL_FLOAT; |
| 7399 | *numParams = 16; |
| 7400 | return true; |
| 7401 | } |
| 7402 | } |
| 7403 | |
| 7404 | if (getExtensions().bindGeneratesResource) |
| 7405 | { |
| 7406 | switch (pname) |
| 7407 | { |
| 7408 | case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 7409 | *type = GL_BOOL; |
| 7410 | *numParams = 1; |
| 7411 | return true; |
| 7412 | } |
| 7413 | } |
| 7414 | |
| 7415 | if (getExtensions().clientArrays) |
| 7416 | { |
| 7417 | switch (pname) |
| 7418 | { |
| 7419 | case GL_CLIENT_ARRAYS_ANGLE: |
| 7420 | *type = GL_BOOL; |
| 7421 | *numParams = 1; |
| 7422 | return true; |
| 7423 | } |
| 7424 | } |
| 7425 | |
| 7426 | if (getExtensions().sRGBWriteControl) |
| 7427 | { |
| 7428 | switch (pname) |
| 7429 | { |
| 7430 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 7431 | *type = GL_BOOL; |
| 7432 | *numParams = 1; |
| 7433 | return true; |
| 7434 | } |
| 7435 | } |
| 7436 | |
| 7437 | if (getExtensions().robustResourceInitialization && |
| 7438 | pname == GL_ROBUST_RESOURCE_INITIALIZATION_ANGLE) |
| 7439 | { |
| 7440 | *type = GL_BOOL; |
| 7441 | *numParams = 1; |
| 7442 | return true; |
| 7443 | } |
| 7444 | |
| 7445 | if (getExtensions().programCacheControl && pname == GL_PROGRAM_CACHE_ENABLED_ANGLE) |
| 7446 | { |
| 7447 | *type = GL_BOOL; |
| 7448 | *numParams = 1; |
| 7449 | return true; |
| 7450 | } |
| 7451 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7452 | if (getExtensions().parallelShaderCompile && pname == GL_MAX_SHADER_COMPILER_THREADS_KHR) |
| 7453 | { |
| 7454 | *type = GL_INT; |
| 7455 | *numParams = 1; |
| 7456 | return true; |
| 7457 | } |
| 7458 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 7459 | if (getExtensions().blendFuncExtended && pname == GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT) |
| 7460 | { |
| 7461 | *type = GL_INT; |
| 7462 | *numParams = 1; |
| 7463 | return true; |
| 7464 | } |
| 7465 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7466 | // Check for ES3.0+ parameter names which are also exposed as ES2 extensions |
| 7467 | switch (pname) |
| 7468 | { |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7469 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE equivalent to FRAMEBUFFER_BINDING |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7470 | case GL_READ_FRAMEBUFFER_BINDING_ANGLE: |
| 7471 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferBlit) |
| 7472 | { |
| 7473 | return false; |
| 7474 | } |
| 7475 | *type = GL_INT; |
| 7476 | *numParams = 1; |
| 7477 | return true; |
| 7478 | |
| 7479 | case GL_NUM_PROGRAM_BINARY_FORMATS_OES: |
| 7480 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7481 | { |
| 7482 | return false; |
| 7483 | } |
| 7484 | *type = GL_INT; |
| 7485 | *numParams = 1; |
| 7486 | return true; |
| 7487 | |
| 7488 | case GL_PROGRAM_BINARY_FORMATS_OES: |
| 7489 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7490 | { |
| 7491 | return false; |
| 7492 | } |
| 7493 | *type = GL_INT; |
| 7494 | *numParams = static_cast<unsigned int>(getCaps().programBinaryFormats.size()); |
| 7495 | return true; |
| 7496 | |
| 7497 | case GL_PACK_ROW_LENGTH: |
| 7498 | case GL_PACK_SKIP_ROWS: |
| 7499 | case GL_PACK_SKIP_PIXELS: |
| 7500 | if ((getClientMajorVersion() < 3) && !getExtensions().packSubimage) |
| 7501 | { |
| 7502 | return false; |
| 7503 | } |
| 7504 | *type = GL_INT; |
| 7505 | *numParams = 1; |
| 7506 | return true; |
| 7507 | case GL_UNPACK_ROW_LENGTH: |
| 7508 | case GL_UNPACK_SKIP_ROWS: |
| 7509 | case GL_UNPACK_SKIP_PIXELS: |
| 7510 | if ((getClientMajorVersion() < 3) && !getExtensions().unpackSubimage) |
| 7511 | { |
| 7512 | return false; |
| 7513 | } |
| 7514 | *type = GL_INT; |
| 7515 | *numParams = 1; |
| 7516 | return true; |
| 7517 | case GL_VERTEX_ARRAY_BINDING: |
| 7518 | if ((getClientMajorVersion() < 3) && !getExtensions().vertexArrayObject) |
| 7519 | { |
| 7520 | return false; |
| 7521 | } |
| 7522 | *type = GL_INT; |
| 7523 | *numParams = 1; |
| 7524 | return true; |
| 7525 | case GL_PIXEL_PACK_BUFFER_BINDING: |
| 7526 | case GL_PIXEL_UNPACK_BUFFER_BINDING: |
| 7527 | if ((getClientMajorVersion() < 3) && !getExtensions().pixelBufferObject) |
| 7528 | { |
| 7529 | return false; |
| 7530 | } |
| 7531 | *type = GL_INT; |
| 7532 | *numParams = 1; |
| 7533 | return true; |
| 7534 | case GL_MAX_SAMPLES: |
| 7535 | { |
| 7536 | static_assert(GL_MAX_SAMPLES_ANGLE == GL_MAX_SAMPLES, |
| 7537 | "GL_MAX_SAMPLES_ANGLE not equal to GL_MAX_SAMPLES"); |
| 7538 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferMultisample) |
| 7539 | { |
| 7540 | return false; |
| 7541 | } |
| 7542 | *type = GL_INT; |
| 7543 | *numParams = 1; |
| 7544 | return true; |
| 7545 | |
| 7546 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: |
| 7547 | if ((getClientMajorVersion() < 3) && !getExtensions().standardDerivatives) |
| 7548 | { |
| 7549 | return false; |
| 7550 | } |
| 7551 | *type = GL_INT; |
| 7552 | *numParams = 1; |
| 7553 | return true; |
| 7554 | } |
| 7555 | } |
| 7556 | |
| 7557 | if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT) |
| 7558 | { |
| 7559 | if ((getClientVersion() < Version(3, 0)) && !getExtensions().drawBuffers) |
| 7560 | { |
| 7561 | return false; |
| 7562 | } |
| 7563 | *type = GL_INT; |
| 7564 | *numParams = 1; |
| 7565 | return true; |
| 7566 | } |
| 7567 | |
| 7568 | if (getExtensions().multiview && pname == GL_MAX_VIEWS_ANGLE) |
| 7569 | { |
| 7570 | *type = GL_INT; |
| 7571 | *numParams = 1; |
| 7572 | return true; |
| 7573 | } |
| 7574 | |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7575 | if (getClientVersion() < Version(2, 0)) |
| 7576 | { |
| 7577 | switch (pname) |
| 7578 | { |
| 7579 | case GL_ALPHA_TEST_FUNC: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7580 | case GL_CLIENT_ACTIVE_TEXTURE: |
| 7581 | case GL_MATRIX_MODE: |
| 7582 | case GL_MAX_TEXTURE_UNITS: |
| 7583 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
| 7584 | case GL_MAX_PROJECTION_STACK_DEPTH: |
| 7585 | case GL_MAX_TEXTURE_STACK_DEPTH: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7586 | case GL_MAX_LIGHTS: |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 7587 | case GL_MAX_CLIP_PLANES: |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 7588 | case GL_VERTEX_ARRAY_STRIDE: |
| 7589 | case GL_NORMAL_ARRAY_STRIDE: |
| 7590 | case GL_COLOR_ARRAY_STRIDE: |
| 7591 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 7592 | case GL_VERTEX_ARRAY_SIZE: |
| 7593 | case GL_COLOR_ARRAY_SIZE: |
| 7594 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 7595 | case GL_VERTEX_ARRAY_TYPE: |
| 7596 | case GL_NORMAL_ARRAY_TYPE: |
| 7597 | case GL_COLOR_ARRAY_TYPE: |
| 7598 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 7599 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 7600 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 7601 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 7602 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 7603 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 7604 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 7605 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
Lingfeng Yang | a0cfa87 | 2018-05-30 21:12:17 -0700 | [diff] [blame] | 7606 | case GL_SHADE_MODEL: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7607 | case GL_MODELVIEW_STACK_DEPTH: |
| 7608 | case GL_PROJECTION_STACK_DEPTH: |
| 7609 | case GL_TEXTURE_STACK_DEPTH: |
| 7610 | case GL_LOGIC_OP_MODE: |
| 7611 | case GL_BLEND_SRC: |
| 7612 | case GL_BLEND_DST: |
| 7613 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 7614 | case GL_POINT_SMOOTH_HINT: |
| 7615 | case GL_LINE_SMOOTH_HINT: |
| 7616 | case GL_FOG_HINT: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7617 | *type = GL_INT; |
| 7618 | *numParams = 1; |
| 7619 | return true; |
| 7620 | case GL_ALPHA_TEST_REF: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7621 | case GL_FOG_DENSITY: |
| 7622 | case GL_FOG_START: |
| 7623 | case GL_FOG_END: |
| 7624 | case GL_FOG_MODE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7625 | case GL_POINT_SIZE: |
| 7626 | case GL_POINT_SIZE_MIN: |
| 7627 | case GL_POINT_SIZE_MAX: |
| 7628 | case GL_POINT_FADE_THRESHOLD_SIZE: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7629 | *type = GL_FLOAT; |
| 7630 | *numParams = 1; |
| 7631 | return true; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7632 | case GL_SMOOTH_POINT_SIZE_RANGE: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7633 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7634 | *type = GL_FLOAT; |
| 7635 | *numParams = 2; |
| 7636 | return true; |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7637 | case GL_CURRENT_COLOR: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7638 | case GL_CURRENT_TEXTURE_COORDS: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7639 | case GL_LIGHT_MODEL_AMBIENT: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7640 | case GL_FOG_COLOR: |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7641 | *type = GL_FLOAT; |
| 7642 | *numParams = 4; |
| 7643 | return true; |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7644 | case GL_CURRENT_NORMAL: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7645 | case GL_POINT_DISTANCE_ATTENUATION: |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7646 | *type = GL_FLOAT; |
| 7647 | *numParams = 3; |
| 7648 | return true; |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 7649 | case GL_MODELVIEW_MATRIX: |
| 7650 | case GL_PROJECTION_MATRIX: |
| 7651 | case GL_TEXTURE_MATRIX: |
| 7652 | *type = GL_FLOAT; |
| 7653 | *numParams = 16; |
| 7654 | return true; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7655 | case GL_LIGHT_MODEL_TWO_SIDE: |
| 7656 | *type = GL_BOOL; |
| 7657 | *numParams = 1; |
| 7658 | return true; |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7659 | } |
| 7660 | } |
| 7661 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7662 | if (getClientVersion() < Version(3, 0)) |
| 7663 | { |
| 7664 | return false; |
| 7665 | } |
| 7666 | |
| 7667 | // Check for ES3.0+ parameter names |
| 7668 | switch (pname) |
| 7669 | { |
| 7670 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 7671 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 7672 | case GL_UNIFORM_BUFFER_BINDING: |
| 7673 | case GL_TRANSFORM_FEEDBACK_BINDING: |
| 7674 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7675 | case GL_COPY_READ_BUFFER_BINDING: |
| 7676 | case GL_COPY_WRITE_BUFFER_BINDING: |
| 7677 | case GL_SAMPLER_BINDING: |
| 7678 | case GL_READ_BUFFER: |
| 7679 | case GL_TEXTURE_BINDING_3D: |
| 7680 | case GL_TEXTURE_BINDING_2D_ARRAY: |
| 7681 | case GL_MAX_3D_TEXTURE_SIZE: |
| 7682 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 7683 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
| 7684 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
| 7685 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 7686 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 7687 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 7688 | case GL_MAX_VARYING_COMPONENTS: |
| 7689 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
| 7690 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
| 7691 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 7692 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 7693 | case GL_NUM_EXTENSIONS: |
| 7694 | case GL_MAJOR_VERSION: |
| 7695 | case GL_MINOR_VERSION: |
| 7696 | case GL_MAX_ELEMENTS_INDICES: |
| 7697 | case GL_MAX_ELEMENTS_VERTICES: |
| 7698 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 7699 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 7700 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 7701 | case GL_UNPACK_IMAGE_HEIGHT: |
| 7702 | case GL_UNPACK_SKIP_IMAGES: |
| 7703 | { |
| 7704 | *type = GL_INT; |
| 7705 | *numParams = 1; |
| 7706 | return true; |
| 7707 | } |
| 7708 | |
| 7709 | case GL_MAX_ELEMENT_INDEX: |
| 7710 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 7711 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
| 7712 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
| 7713 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 7714 | { |
| 7715 | *type = GL_INT_64_ANGLEX; |
| 7716 | *numParams = 1; |
| 7717 | return true; |
| 7718 | } |
| 7719 | |
| 7720 | case GL_TRANSFORM_FEEDBACK_ACTIVE: |
| 7721 | case GL_TRANSFORM_FEEDBACK_PAUSED: |
| 7722 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 7723 | case GL_RASTERIZER_DISCARD: |
| 7724 | { |
| 7725 | *type = GL_BOOL; |
| 7726 | *numParams = 1; |
| 7727 | return true; |
| 7728 | } |
| 7729 | |
| 7730 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 7731 | { |
| 7732 | *type = GL_FLOAT; |
| 7733 | *numParams = 1; |
| 7734 | return true; |
| 7735 | } |
| 7736 | } |
| 7737 | |
| 7738 | if (getExtensions().requestExtension) |
| 7739 | { |
| 7740 | switch (pname) |
| 7741 | { |
| 7742 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 7743 | *type = GL_INT; |
| 7744 | *numParams = 1; |
| 7745 | return true; |
| 7746 | } |
| 7747 | } |
| 7748 | |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7749 | if (getExtensions().textureMultisample) |
| 7750 | { |
| 7751 | switch (pname) |
| 7752 | { |
| 7753 | case GL_MAX_COLOR_TEXTURE_SAMPLES_ANGLE: |
| 7754 | case GL_MAX_INTEGER_SAMPLES_ANGLE: |
| 7755 | case GL_MAX_DEPTH_TEXTURE_SAMPLES_ANGLE: |
| 7756 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ANGLE: |
Yizhou Jiang | 7310da3 | 2018-11-05 14:40:01 +0800 | [diff] [blame] | 7757 | case GL_MAX_SAMPLE_MASK_WORDS: |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7758 | *type = GL_INT; |
| 7759 | *numParams = 1; |
| 7760 | return true; |
| 7761 | } |
| 7762 | } |
| 7763 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7764 | if (getClientVersion() < Version(3, 1)) |
| 7765 | { |
| 7766 | return false; |
| 7767 | } |
| 7768 | |
| 7769 | switch (pname) |
| 7770 | { |
| 7771 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7772 | case GL_DRAW_INDIRECT_BUFFER_BINDING: |
| 7773 | case GL_DISPATCH_INDIRECT_BUFFER_BINDING: |
| 7774 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 7775 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 7776 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 7777 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 7778 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 7779 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 7780 | case GL_MAX_INTEGER_SAMPLES: |
| 7781 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 7782 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 7783 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 7784 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
| 7785 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
| 7786 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
| 7787 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
| 7788 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
| 7789 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
| 7790 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
| 7791 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
| 7792 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7793 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7794 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 7795 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
| 7796 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
| 7797 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 7798 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
| 7799 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
| 7800 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
| 7801 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
| 7802 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
| 7803 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
| 7804 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 7805 | case GL_MAX_UNIFORM_LOCATIONS: |
| 7806 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 7807 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7808 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 7809 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 7810 | case GL_MAX_IMAGE_UNITS: |
| 7811 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 7812 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 7813 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 7814 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7815 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 7816 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE: |
Olli Etuaho | dff32a0 | 2018-08-28 14:35:50 +0300 | [diff] [blame] | 7817 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7818 | *type = GL_INT; |
| 7819 | *numParams = 1; |
| 7820 | return true; |
| 7821 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 7822 | *type = GL_INT_64_ANGLEX; |
| 7823 | *numParams = 1; |
| 7824 | return true; |
| 7825 | case GL_SAMPLE_MASK: |
| 7826 | *type = GL_BOOL; |
| 7827 | *numParams = 1; |
| 7828 | return true; |
| 7829 | } |
| 7830 | |
| 7831 | if (getExtensions().geometryShader) |
| 7832 | { |
| 7833 | switch (pname) |
| 7834 | { |
| 7835 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
| 7836 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
| 7837 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7838 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
| 7839 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7840 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
| 7841 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
| 7842 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
| 7843 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
| 7844 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
| 7845 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
| 7846 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
| 7847 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
| 7848 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
| 7849 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
| 7850 | *type = GL_INT; |
| 7851 | *numParams = 1; |
| 7852 | return true; |
| 7853 | } |
| 7854 | } |
| 7855 | |
| 7856 | return false; |
| 7857 | } |
| 7858 | |
| 7859 | bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams) |
| 7860 | { |
| 7861 | if (getClientVersion() < Version(3, 0)) |
| 7862 | { |
| 7863 | return false; |
| 7864 | } |
| 7865 | |
| 7866 | switch (target) |
| 7867 | { |
| 7868 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7869 | case GL_UNIFORM_BUFFER_BINDING: |
| 7870 | { |
| 7871 | *type = GL_INT; |
| 7872 | *numParams = 1; |
| 7873 | return true; |
| 7874 | } |
| 7875 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 7876 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 7877 | case GL_UNIFORM_BUFFER_START: |
| 7878 | case GL_UNIFORM_BUFFER_SIZE: |
| 7879 | { |
| 7880 | *type = GL_INT_64_ANGLEX; |
| 7881 | *numParams = 1; |
| 7882 | return true; |
| 7883 | } |
| 7884 | } |
| 7885 | |
| 7886 | if (getClientVersion() < Version(3, 1)) |
| 7887 | { |
| 7888 | return false; |
| 7889 | } |
| 7890 | |
| 7891 | switch (target) |
| 7892 | { |
| 7893 | case GL_IMAGE_BINDING_LAYERED: |
| 7894 | { |
| 7895 | *type = GL_BOOL; |
| 7896 | *numParams = 1; |
| 7897 | return true; |
| 7898 | } |
| 7899 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 7900 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 7901 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7902 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7903 | case GL_VERTEX_BINDING_BUFFER: |
| 7904 | case GL_VERTEX_BINDING_DIVISOR: |
| 7905 | case GL_VERTEX_BINDING_OFFSET: |
| 7906 | case GL_VERTEX_BINDING_STRIDE: |
| 7907 | case GL_SAMPLE_MASK_VALUE: |
| 7908 | case GL_IMAGE_BINDING_NAME: |
| 7909 | case GL_IMAGE_BINDING_LEVEL: |
| 7910 | case GL_IMAGE_BINDING_LAYER: |
| 7911 | case GL_IMAGE_BINDING_ACCESS: |
| 7912 | case GL_IMAGE_BINDING_FORMAT: |
| 7913 | { |
| 7914 | *type = GL_INT; |
| 7915 | *numParams = 1; |
| 7916 | return true; |
| 7917 | } |
| 7918 | case GL_ATOMIC_COUNTER_BUFFER_START: |
| 7919 | case GL_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7920 | case GL_SHADER_STORAGE_BUFFER_START: |
| 7921 | case GL_SHADER_STORAGE_BUFFER_SIZE: |
| 7922 | { |
| 7923 | *type = GL_INT_64_ANGLEX; |
| 7924 | *numParams = 1; |
| 7925 | return true; |
| 7926 | } |
| 7927 | } |
| 7928 | |
| 7929 | return false; |
| 7930 | } |
| 7931 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7932 | Program *Context::getProgramNoResolveLink(GLuint handle) const |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7933 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7934 | return mState.mShaderProgramManager->getProgram(handle); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7935 | } |
| 7936 | |
| 7937 | Shader *Context::getShader(GLuint handle) const |
| 7938 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7939 | return mState.mShaderProgramManager->getShader(handle); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7940 | } |
| 7941 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7942 | bool Context::isRenderbufferGenerated(GLuint renderbuffer) const |
| 7943 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7944 | return mState.mRenderbufferManager->isHandleGenerated(renderbuffer); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7945 | } |
| 7946 | |
| 7947 | bool Context::isFramebufferGenerated(GLuint framebuffer) const |
| 7948 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7949 | return mState.mFramebufferManager->isHandleGenerated(framebuffer); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7950 | } |
| 7951 | |
| 7952 | bool Context::isProgramPipelineGenerated(GLuint pipeline) const |
| 7953 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7954 | return mState.mProgramPipelineManager->isHandleGenerated(pipeline); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7955 | } |
| 7956 | |
| 7957 | bool Context::usingDisplayTextureShareGroup() const |
| 7958 | { |
| 7959 | return mDisplayTextureShareGroup; |
| 7960 | } |
| 7961 | |
| 7962 | GLenum Context::getConvertedRenderbufferFormat(GLenum internalformat) const |
| 7963 | { |
| 7964 | return mState.mExtensions.webglCompatibility && mState.mClientVersion.major == 2 && |
| 7965 | internalformat == GL_DEPTH_STENCIL |
| 7966 | ? GL_DEPTH24_STENCIL8 |
| 7967 | : internalformat; |
| 7968 | } |
| 7969 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7970 | void Context::maxShaderCompilerThreads(GLuint count) |
| 7971 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7972 | GLuint oldCount = mState.getMaxShaderCompilerThreads(); |
| 7973 | mState.setMaxShaderCompilerThreads(count); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 7974 | // A count of zero specifies a request for no parallel compiling or linking. |
| 7975 | if ((oldCount == 0 || count == 0) && (oldCount != 0 || count != 0)) |
| 7976 | { |
| 7977 | mThreadPool = angle::WorkerThreadPool::Create(count > 0); |
| 7978 | } |
| 7979 | mThreadPool->setMaxThreads(count); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7980 | } |
| 7981 | |
Jamie Madill | 2eb6503 | 2018-07-30 10:25:57 -0400 | [diff] [blame] | 7982 | bool Context::isGLES1() const |
| 7983 | { |
| 7984 | return mState.getClientVersion() < Version(2, 0); |
| 7985 | } |
| 7986 | |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 7987 | void Context::onSubjectStateChange(const Context *context, |
| 7988 | angle::SubjectIndex index, |
| 7989 | angle::SubjectMessage message) |
| 7990 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 7991 | switch (index) |
| 7992 | { |
| 7993 | case kVertexArraySubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 7994 | switch (message) |
| 7995 | { |
| 7996 | case angle::SubjectMessage::CONTENTS_CHANGED: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7997 | mState.setObjectDirty(GL_VERTEX_ARRAY); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 7998 | mStateCache.onVertexArrayBufferContentsChange(this); |
| 7999 | break; |
| 8000 | case angle::SubjectMessage::RESOURCE_MAPPED: |
| 8001 | case angle::SubjectMessage::RESOURCE_UNMAPPED: |
| 8002 | case angle::SubjectMessage::BINDING_CHANGED: |
| 8003 | mStateCache.onVertexArrayBufferStateChange(this); |
| 8004 | break; |
| 8005 | default: |
| 8006 | break; |
| 8007 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8008 | break; |
| 8009 | |
| 8010 | case kReadFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8011 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8012 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8013 | mState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8014 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8015 | break; |
| 8016 | |
| 8017 | case kDrawFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8018 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8019 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8020 | mState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8021 | } |
| 8022 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8023 | break; |
| 8024 | |
| 8025 | default: |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8026 | if (index < kTextureMaxSubjectIndex) |
| 8027 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8028 | mState.onActiveTextureStateChange(this, index); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8029 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8030 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8031 | else if (index < kUniformBufferMaxSubjectIndex) |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8032 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8033 | mState.onUniformBufferStateChange(index - kUniformBuffer0SubjectIndex); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8034 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8035 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8036 | else |
| 8037 | { |
| 8038 | ASSERT(index < kSamplerMaxSubjectIndex); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8039 | mState.setSamplerDirty(index - kSampler0SubjectIndex); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8040 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8041 | break; |
| 8042 | } |
| 8043 | } |
| 8044 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8045 | // ErrorSet implementation. |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8046 | ErrorSet::ErrorSet(Context *context) : mContext(context) {} |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8047 | |
| 8048 | ErrorSet::~ErrorSet() = default; |
| 8049 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8050 | void ErrorSet::handleError(GLenum errorCode, |
| 8051 | const char *message, |
| 8052 | const char *file, |
| 8053 | const char *function, |
| 8054 | unsigned int line) |
| 8055 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8056 | if (errorCode == GL_OUT_OF_MEMORY && mContext->getWorkarounds().loseContextOnOutOfMemory) |
| 8057 | { |
| 8058 | mContext->markContextLost(); |
| 8059 | } |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8060 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8061 | std::stringstream errorStream; |
| 8062 | errorStream << "Error: " << gl::FmtHex(errorCode) << ", in " << file << ", " << function << ":" |
| 8063 | << line << ". " << message; |
| 8064 | |
Geoff Lang | 7139b43 | 2018-12-14 16:57:28 -0500 | [diff] [blame] | 8065 | std::string formattedMessage = errorStream.str(); |
| 8066 | |
| 8067 | // Always log a warning, this function is only called on unexpected internal errors. |
| 8068 | WARN() << formattedMessage; |
| 8069 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8070 | // validationError does the necessary work to process the error. |
Geoff Lang | 7139b43 | 2018-12-14 16:57:28 -0500 | [diff] [blame] | 8071 | validationError(errorCode, formattedMessage.c_str()); |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8072 | } |
| 8073 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8074 | void ErrorSet::validationError(GLenum errorCode, const char *message) |
| 8075 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8076 | ASSERT(errorCode != GL_NO_ERROR); |
| 8077 | mErrors.insert(errorCode); |
| 8078 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8079 | mContext->getState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, |
| 8080 | errorCode, GL_DEBUG_SEVERITY_HIGH, message); |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8081 | } |
| 8082 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8083 | bool ErrorSet::empty() const |
| 8084 | { |
| 8085 | return mErrors.empty(); |
| 8086 | } |
| 8087 | |
| 8088 | GLenum ErrorSet::popError() |
| 8089 | { |
| 8090 | ASSERT(!empty()); |
| 8091 | GLenum error = *mErrors.begin(); |
| 8092 | mErrors.erase(mErrors.begin()); |
| 8093 | return error; |
| 8094 | } |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8095 | |
| 8096 | // StateCache implementation. |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8097 | StateCache::StateCache() |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8098 | : mCachedHasAnyEnabledClientAttrib(false), |
| 8099 | mCachedNonInstancedVertexElementLimit(0), |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8100 | mCachedInstancedVertexElementLimit(0), |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8101 | mCachedBasicDrawStatesError(kInvalidPointer), |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8102 | mCachedBasicDrawElementsError(kInvalidPointer), |
| 8103 | mCachedTransformFeedbackActiveUnpaused(false) |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8104 | {} |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8105 | |
| 8106 | StateCache::~StateCache() = default; |
| 8107 | |
Jamie Madill | d51fbe3 | 2019-01-25 15:03:39 -0500 | [diff] [blame^] | 8108 | ANGLE_INLINE void StateCache::updateVertexElementLimits(Context *context) |
| 8109 | { |
| 8110 | if (context->isBufferAccessValidationEnabled()) |
| 8111 | { |
| 8112 | updateVertexElementLimitsImpl(context); |
| 8113 | } |
| 8114 | } |
| 8115 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8116 | void StateCache::initialize(Context *context) |
| 8117 | { |
| 8118 | updateValidDrawModes(context); |
| 8119 | updateValidBindTextureTypes(context); |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8120 | updateValidDrawElementsTypes(context); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8121 | updateBasicDrawStatesError(); |
| 8122 | updateBasicDrawElementsError(); |
Jamie Madill | c8c7d40 | 2019-01-16 13:27:15 -0500 | [diff] [blame] | 8123 | updateVertexAttribTypesValidation(context); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8124 | } |
| 8125 | |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8126 | void StateCache::updateActiveAttribsMask(Context *context) |
| 8127 | { |
| 8128 | bool isGLES1 = context->isGLES1(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8129 | const State &glState = context->getState(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8130 | |
| 8131 | if (!isGLES1 && !glState.getProgram()) |
| 8132 | { |
| 8133 | mCachedActiveBufferedAttribsMask = AttributesMask(); |
| 8134 | mCachedActiveClientAttribsMask = AttributesMask(); |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8135 | mCachedActiveDefaultAttribsMask = AttributesMask(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8136 | return; |
| 8137 | } |
| 8138 | |
| 8139 | AttributesMask activeAttribs = isGLES1 ? glState.gles1().getVertexArraysAttributeMask() |
| 8140 | : glState.getProgram()->getActiveAttribLocationsMask(); |
| 8141 | |
| 8142 | const VertexArray *vao = glState.getVertexArray(); |
| 8143 | ASSERT(vao); |
| 8144 | |
| 8145 | const AttributesMask &clientAttribs = vao->getClientAttribsMask(); |
| 8146 | const AttributesMask &enabledAttribs = vao->getEnabledAttributesMask(); |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8147 | const AttributesMask &activeEnabled = activeAttribs & enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8148 | |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8149 | mCachedActiveClientAttribsMask = activeEnabled & clientAttribs; |
| 8150 | mCachedActiveBufferedAttribsMask = activeEnabled & ~clientAttribs; |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8151 | mCachedActiveDefaultAttribsMask = activeAttribs & ~enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8152 | mCachedHasAnyEnabledClientAttrib = (clientAttribs & enabledAttribs).any(); |
| 8153 | } |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8154 | |
Jamie Madill | d51fbe3 | 2019-01-25 15:03:39 -0500 | [diff] [blame^] | 8155 | void StateCache::updateVertexElementLimitsImpl(Context *context) |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8156 | { |
Jamie Madill | d51fbe3 | 2019-01-25 15:03:39 -0500 | [diff] [blame^] | 8157 | ASSERT(context->isBufferAccessValidationEnabled()); |
| 8158 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8159 | const VertexArray *vao = context->getState().getVertexArray(); |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8160 | |
| 8161 | mCachedNonInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8162 | mCachedInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8163 | |
| 8164 | // VAO can be null on Context startup. If we make this computation lazier we could ASSERT. |
| 8165 | // If there are no buffered attributes then we should not limit the draw call count. |
| 8166 | if (!vao || !mCachedActiveBufferedAttribsMask.any()) |
| 8167 | { |
| 8168 | return; |
| 8169 | } |
| 8170 | |
| 8171 | const auto &vertexAttribs = vao->getVertexAttributes(); |
| 8172 | const auto &vertexBindings = vao->getVertexBindings(); |
| 8173 | |
| 8174 | for (size_t attributeIndex : mCachedActiveBufferedAttribsMask) |
| 8175 | { |
| 8176 | const VertexAttribute &attrib = vertexAttribs[attributeIndex]; |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8177 | |
| 8178 | const VertexBinding &binding = vertexBindings[attrib.bindingIndex]; |
| 8179 | ASSERT(context->isGLES1() || |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8180 | context->getState().getProgram()->isAttribLocationActive(attributeIndex)); |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8181 | |
| 8182 | GLint64 limit = attrib.getCachedElementLimit(); |
| 8183 | if (binding.getDivisor() > 0) |
| 8184 | { |
| 8185 | mCachedInstancedVertexElementLimit = |
| 8186 | std::min(mCachedInstancedVertexElementLimit, limit); |
| 8187 | } |
| 8188 | else |
| 8189 | { |
| 8190 | mCachedNonInstancedVertexElementLimit = |
| 8191 | std::min(mCachedNonInstancedVertexElementLimit, limit); |
| 8192 | } |
| 8193 | } |
| 8194 | } |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8195 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8196 | void StateCache::updateBasicDrawStatesError() |
| 8197 | { |
| 8198 | mCachedBasicDrawStatesError = kInvalidPointer; |
| 8199 | } |
| 8200 | |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8201 | void StateCache::updateBasicDrawElementsError() |
| 8202 | { |
| 8203 | mCachedBasicDrawElementsError = kInvalidPointer; |
| 8204 | } |
| 8205 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8206 | intptr_t StateCache::getBasicDrawStatesErrorImpl(Context *context) const |
| 8207 | { |
| 8208 | ASSERT(mCachedBasicDrawStatesError == kInvalidPointer); |
| 8209 | mCachedBasicDrawStatesError = reinterpret_cast<intptr_t>(ValidateDrawStates(context)); |
| 8210 | return mCachedBasicDrawStatesError; |
| 8211 | } |
| 8212 | |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8213 | intptr_t StateCache::getBasicDrawElementsErrorImpl(Context *context) const |
| 8214 | { |
| 8215 | ASSERT(mCachedBasicDrawElementsError == kInvalidPointer); |
| 8216 | mCachedBasicDrawElementsError = reinterpret_cast<intptr_t>(ValidateDrawElementsStates(context)); |
| 8217 | return mCachedBasicDrawElementsError; |
| 8218 | } |
| 8219 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8220 | void StateCache::onVertexArrayBindingChange(Context *context) |
| 8221 | { |
| 8222 | updateActiveAttribsMask(context); |
| 8223 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8224 | updateBasicDrawStatesError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8225 | } |
| 8226 | |
| 8227 | void StateCache::onProgramExecutableChange(Context *context) |
| 8228 | { |
| 8229 | updateActiveAttribsMask(context); |
| 8230 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8231 | updateBasicDrawStatesError(); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8232 | updateValidDrawModes(context); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8233 | } |
| 8234 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8235 | void StateCache::onVertexArrayFormatChange(Context *context) |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8236 | { |
| 8237 | updateVertexElementLimits(context); |
| 8238 | } |
| 8239 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8240 | void StateCache::onVertexArrayBufferContentsChange(Context *context) |
| 8241 | { |
| 8242 | updateVertexElementLimits(context); |
| 8243 | updateBasicDrawStatesError(); |
| 8244 | } |
| 8245 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8246 | void StateCache::onVertexArrayStateChange(Context *context) |
| 8247 | { |
| 8248 | updateActiveAttribsMask(context); |
| 8249 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8250 | updateBasicDrawStatesError(); |
| 8251 | } |
| 8252 | |
| 8253 | void StateCache::onVertexArrayBufferStateChange(Context *context) |
| 8254 | { |
| 8255 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8256 | updateBasicDrawElementsError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8257 | } |
| 8258 | |
| 8259 | void StateCache::onGLES1ClientStateChange(Context *context) |
| 8260 | { |
| 8261 | updateActiveAttribsMask(context); |
| 8262 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8263 | |
| 8264 | void StateCache::onDrawFramebufferChange(Context *context) |
| 8265 | { |
| 8266 | updateBasicDrawStatesError(); |
| 8267 | } |
| 8268 | |
| 8269 | void StateCache::onContextCapChange(Context *context) |
| 8270 | { |
| 8271 | updateBasicDrawStatesError(); |
| 8272 | } |
| 8273 | |
| 8274 | void StateCache::onStencilStateChange(Context *context) |
| 8275 | { |
| 8276 | updateBasicDrawStatesError(); |
| 8277 | } |
| 8278 | |
| 8279 | void StateCache::onDefaultVertexAttributeChange(Context *context) |
| 8280 | { |
| 8281 | updateBasicDrawStatesError(); |
| 8282 | } |
| 8283 | |
| 8284 | void StateCache::onActiveTextureChange(Context *context) |
| 8285 | { |
| 8286 | updateBasicDrawStatesError(); |
| 8287 | } |
| 8288 | |
| 8289 | void StateCache::onQueryChange(Context *context) |
| 8290 | { |
| 8291 | updateBasicDrawStatesError(); |
| 8292 | } |
| 8293 | |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 8294 | void StateCache::onActiveTransformFeedbackChange(Context *context) |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8295 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8296 | updateTransformFeedbackActiveUnpaused(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8297 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8298 | updateBasicDrawElementsError(); |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8299 | updateValidDrawModes(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8300 | } |
| 8301 | |
| 8302 | void StateCache::onUniformBufferStateChange(Context *context) |
| 8303 | { |
| 8304 | updateBasicDrawStatesError(); |
| 8305 | } |
| 8306 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8307 | void StateCache::setValidDrawModes(bool pointsOK, |
| 8308 | bool linesOK, |
| 8309 | bool trisOK, |
| 8310 | bool lineAdjOK, |
| 8311 | bool triAdjOK) |
| 8312 | { |
| 8313 | mCachedValidDrawModes[PrimitiveMode::Points] = pointsOK; |
| 8314 | mCachedValidDrawModes[PrimitiveMode::Lines] = linesOK; |
| 8315 | mCachedValidDrawModes[PrimitiveMode::LineStrip] = linesOK; |
| 8316 | mCachedValidDrawModes[PrimitiveMode::LineLoop] = linesOK; |
| 8317 | mCachedValidDrawModes[PrimitiveMode::Triangles] = trisOK; |
| 8318 | mCachedValidDrawModes[PrimitiveMode::TriangleFan] = trisOK; |
| 8319 | mCachedValidDrawModes[PrimitiveMode::TriangleStrip] = trisOK; |
| 8320 | mCachedValidDrawModes[PrimitiveMode::LinesAdjacency] = lineAdjOK; |
| 8321 | mCachedValidDrawModes[PrimitiveMode::LineStripAdjacency] = lineAdjOK; |
| 8322 | mCachedValidDrawModes[PrimitiveMode::TrianglesAdjacency] = triAdjOK; |
| 8323 | mCachedValidDrawModes[PrimitiveMode::TriangleStripAdjacency] = triAdjOK; |
| 8324 | } |
| 8325 | |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8326 | void StateCache::updateValidDrawModes(Context *context) |
| 8327 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8328 | const State &state = context->getState(); |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8329 | Program *program = state.getProgram(); |
| 8330 | |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8331 | if (mCachedTransformFeedbackActiveUnpaused) |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8332 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8333 | TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback(); |
| 8334 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8335 | // ES Spec 3.0 validation text: |
| 8336 | // When transform feedback is active and not paused, all geometric primitives generated must |
| 8337 | // match the value of primitiveMode passed to BeginTransformFeedback. The error |
| 8338 | // INVALID_OPERATION is generated by DrawArrays and DrawArraysInstanced if mode is not |
| 8339 | // identical to primitiveMode. The error INVALID_OPERATION is also generated by |
| 8340 | // DrawElements, DrawElementsInstanced, and DrawRangeElements while transform feedback is |
| 8341 | // active and not paused, regardless of mode. Any primitive type may be used while transform |
| 8342 | // feedback is paused. |
| 8343 | if (!context->getExtensions().geometryShader) |
| 8344 | { |
| 8345 | mCachedValidDrawModes.fill(false); |
| 8346 | mCachedValidDrawModes[curTransformFeedback->getPrimitiveMode()] = true; |
| 8347 | return; |
| 8348 | } |
| 8349 | |
| 8350 | // EXT_geometry_shader validation text: |
| 8351 | // When transform feedback is active and not paused, all geometric primitives generated must |
| 8352 | // be compatible with the value of <primitiveMode> passed to BeginTransformFeedback. If a |
| 8353 | // geometry shader is active, the type of primitive emitted by that shader is used instead |
| 8354 | // of the <mode> parameter passed to drawing commands for the purposes of this error check. |
| 8355 | // Any primitive type may be used while transform feedback is paused. |
| 8356 | bool pointsOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Points; |
| 8357 | bool linesOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Lines; |
| 8358 | bool trisOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Triangles; |
| 8359 | |
| 8360 | setValidDrawModes(pointsOK, linesOK, trisOK, false, false); |
| 8361 | return; |
| 8362 | } |
| 8363 | |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8364 | if (!program || !program->hasLinkedShaderStage(ShaderType::Geometry)) |
| 8365 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8366 | mCachedValidDrawModes = kValidBasicDrawModes; |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8367 | return; |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8368 | } |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8369 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8370 | ASSERT(program && program->hasLinkedShaderStage(ShaderType::Geometry)); |
| 8371 | PrimitiveMode gsMode = program->getGeometryShaderInputPrimitiveType(); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8372 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8373 | bool pointsOK = gsMode == PrimitiveMode::Points; |
| 8374 | bool linesOK = gsMode == PrimitiveMode::Lines; |
| 8375 | bool trisOK = gsMode == PrimitiveMode::Triangles; |
| 8376 | bool lineAdjOK = gsMode == PrimitiveMode::LinesAdjacency; |
| 8377 | bool triAdjOK = gsMode == PrimitiveMode::TrianglesAdjacency; |
| 8378 | |
| 8379 | setValidDrawModes(pointsOK, linesOK, trisOK, lineAdjOK, triAdjOK); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8380 | } |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8381 | |
| 8382 | void StateCache::updateValidBindTextureTypes(Context *context) |
| 8383 | { |
| 8384 | const Extensions &exts = context->getExtensions(); |
| 8385 | bool isGLES3 = context->getClientMajorVersion() >= 3; |
| 8386 | bool isGLES31 = context->getClientVersion() >= Version(3, 1); |
| 8387 | |
| 8388 | mCachedValidBindTextureTypes = {{ |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8389 | {TextureType::_2D, true}, |
| 8390 | {TextureType::_2DArray, isGLES3}, |
| 8391 | {TextureType::_2DMultisample, isGLES31 || exts.textureMultisample}, |
| 8392 | {TextureType::_2DMultisampleArray, exts.textureStorageMultisample2DArray}, |
| 8393 | {TextureType::_3D, isGLES3}, |
| 8394 | {TextureType::External, exts.eglImageExternal || exts.eglStreamConsumerExternal}, |
| 8395 | {TextureType::Rectangle, exts.textureRectangle}, |
| 8396 | {TextureType::CubeMap, true}, |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8397 | }}; |
| 8398 | } |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8399 | |
| 8400 | void StateCache::updateValidDrawElementsTypes(Context *context) |
| 8401 | { |
| 8402 | bool supportsUint = |
| 8403 | (context->getClientMajorVersion() >= 3 || context->getExtensions().elementIndexUint); |
| 8404 | |
| 8405 | mCachedValidDrawElementsTypes = {{ |
| 8406 | {DrawElementsType::UnsignedByte, true}, |
| 8407 | {DrawElementsType::UnsignedShort, true}, |
| 8408 | {DrawElementsType::UnsignedInt, supportsUint}, |
| 8409 | }}; |
| 8410 | } |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8411 | |
| 8412 | void StateCache::updateTransformFeedbackActiveUnpaused(Context *context) |
| 8413 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8414 | TransformFeedback *xfb = context->getState().getCurrentTransformFeedback(); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8415 | mCachedTransformFeedbackActiveUnpaused = xfb && xfb->isActive() && !xfb->isPaused(); |
| 8416 | } |
Jamie Madill | c8c7d40 | 2019-01-16 13:27:15 -0500 | [diff] [blame] | 8417 | |
| 8418 | void StateCache::updateVertexAttribTypesValidation(Context *context) |
| 8419 | { |
| 8420 | if (context->getClientMajorVersion() <= 2) |
| 8421 | { |
| 8422 | mCachedVertexAttribTypesValidation = {{ |
| 8423 | {VertexAttribType::Byte, VertexAttribTypeCase::Valid}, |
| 8424 | {VertexAttribType::Short, VertexAttribTypeCase::Valid}, |
| 8425 | {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid}, |
| 8426 | {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid}, |
| 8427 | {VertexAttribType::Float, VertexAttribTypeCase::Valid}, |
| 8428 | {VertexAttribType::Fixed, VertexAttribTypeCase::Valid}, |
| 8429 | }}; |
| 8430 | } |
| 8431 | else |
| 8432 | { |
| 8433 | mCachedVertexAttribTypesValidation = {{ |
| 8434 | {VertexAttribType::Byte, VertexAttribTypeCase::Valid}, |
| 8435 | {VertexAttribType::Short, VertexAttribTypeCase::Valid}, |
| 8436 | {VertexAttribType::Int, VertexAttribTypeCase::Valid}, |
| 8437 | {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid}, |
| 8438 | {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid}, |
| 8439 | {VertexAttribType::UnsignedInt, VertexAttribTypeCase::Valid}, |
| 8440 | {VertexAttribType::Float, VertexAttribTypeCase::Valid}, |
| 8441 | {VertexAttribType::HalfFloat, VertexAttribTypeCase::Valid}, |
| 8442 | {VertexAttribType::Fixed, VertexAttribTypeCase::Valid}, |
| 8443 | {VertexAttribType::Int2101010, VertexAttribTypeCase::ValidSize4Only}, |
| 8444 | {VertexAttribType::UnsignedInt2101010, VertexAttribTypeCase::ValidSize4Only}, |
| 8445 | }}; |
| 8446 | |
| 8447 | mCachedIntegerVertexAttribTypesValidation = {{ |
| 8448 | {VertexAttribType::Byte, VertexAttribTypeCase::Valid}, |
| 8449 | {VertexAttribType::Short, VertexAttribTypeCase::Valid}, |
| 8450 | {VertexAttribType::Int, VertexAttribTypeCase::Valid}, |
| 8451 | {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid}, |
| 8452 | {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid}, |
| 8453 | {VertexAttribType::UnsignedInt, VertexAttribTypeCase::Valid}, |
| 8454 | }}; |
| 8455 | } |
| 8456 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 8457 | } // namespace gl |